Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Update the PKGBUILD to handle new kernels
From 3b8b8deb5c2a4dece730c912ee127b5a6853ed04 Mon Sep 17 00:00:00 2001
From: Seamus Connor <sconnor@tinfoilwizard.net>
Date: Mon, 11 May 2020 19:36:24 -0700
Subject: [PATCH] building on Linux 5.6.11-arch1
---
PKGBUILD | 15 +-
...procfs-args-for-kernel-5.6-and-above.patch | 61 ++++++
Update-time-types-for-newer-kernels.patch | 206 ++++++++++++++++++
config_hz.patch | 4 +-
4 files changed, 276 insertions(+), 10 deletions(-)
create mode 100644 Update-procfs-args-for-kernel-5.6-and-above.patch
create mode 100644 Update-time-types-for-newer-kernels.patch
diff --git a/PKGBUILD b/PKGBUILD
index 0bea400..79a142d 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -13,22 +13,21 @@ provides=('kvdo')
source=("$_pkgname-$pkgver.tar.gz::https://github.com/dm-vdo/kvdo/archive/$pkgver.tar.gz"
"dkms.conf"
"vla-warning.patch"
- "config_hz.patch")
+ "config_hz.patch"
+ "Update-time-types-for-newer-kernels.patch"
+ "Update-procfs-args-for-kernel-5.6-and-above.patch")
sha256sums=('95cc869efc057acc1a99bc723e66b5522c571a643193be733baa20793d7ccd35'
'516f60bdb28f7a0cb6c8f1f84c656ee7c6aec8feb393538f227ed515372ac88a'
'a6b9a42ef6c0933ff02fe304f9ab627f045f83abc8ed33cf0b91522096cade0f'
- '2f8633e1d4df849bcccc0562f3678af33d9d88fda899d8ac7046e963fd984efd')
+ '9858964de72226b77461fda31201e7195691956276cafd33f2facf6a5cb0c802'
+ '989be415f6b43e53064ef07fd621b99bd42aab6b9463bde24a6679ea723bc0fa'
+ 'aca22afe84a4fdb0c9b5add54c04f106f7c424c30c8ae6074cfd60e7c5648969')
package() {
mkdir -p "$pkgdir"/usr/src
cp -r "$_pkgname-$pkgver" "$pkgdir"/usr/src/"$_pkgname-$pkgver"
cd "$pkgdir"/usr/src/kvdo-"$pkgver"
- patch --forward --strip=1 -i "$srcdir"/vla-warning.patch
- if [ $(zgrep "^CONFIG_HZ=" /proc/config.gz|awk -F '=' '{print$2}') -eq 300 ]
- then
- echo -e "\n\nYour kernel is compiled with 'CONFIG_HZ=300'; see https://aur.archlinux.org/packages/kvdo-dkms#comment-733306 for more information\n\n"
- patch --forward --strip=0 -i "$srcdir"/config_hz.patch
- fi
+ cat "$srcdir"/*.patch | patch -p1
cd "$srcdir"
sed -e "s/@PKGVER@/${pkgver}/" dkms.conf > "$pkgdir"/usr/src/"$_pkgname-$pkgver"/dkms.conf
}
diff --git a/Update-procfs-args-for-kernel-5.6-and-above.patch b/Update-procfs-args-for-kernel-5.6-and-above.patch
new file mode 100644
index 0000000..eba1a25
--- /dev/null
+++ b/Update-procfs-args-for-kernel-5.6-and-above.patch
@@ -0,0 +1,61 @@
+From ff4c6a2861600e9737aa2b14000af7ec9b7618e1 Mon Sep 17 00:00:00 2001
+From: Andrew Walsh <awalsh@redhat.com>
+Date: Wed, 26 Feb 2020 20:44:57 -0500
+Subject: [PATCH 3/3] Update procfs args for kernel 5.6 and above.
+
+With commit d56c0d45f0e27f814e87a1676b6bdccccbc252e9 in the kernel, proc calls need to use 'struct proc_ops' instead of 'struct file_operations'. This commit applies that requirement for kernels 5.6 and newer.
+---
+ vdo/kernel/statusProcfs.c | 18 ++++++++++++++++++
+ 1 file changed, 18 insertions(+)
+
+diff --git a/vdo/kernel/statusProcfs.c b/vdo/kernel/statusProcfs.c
+index 70e8c9b..26b67f9 100644
+--- a/vdo/kernel/statusProcfs.c
++++ b/vdo/kernel/statusProcfs.c
+@@ -82,12 +82,21 @@ static int statusDedupeOpen(struct inode *inode, struct file *file)
+ #endif
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)
++static const struct proc_ops vdoProcfsDedupeOps = {
++ .proc_open = statusDedupeOpen,
++ .proc_read = seq_read,
++ .proc_lseek = seq_lseek,
++ .proc_release = single_release,
++};
++#else
+ static const struct file_operations vdoProcfsDedupeOps = {
+ .open = statusDedupeOpen,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ };
++#endif
+
+ /**********************************************************************/
+ static void copyBioStat(BioStats *b, const AtomicBioStats *a)
+@@ -175,12 +184,21 @@ static int statusKernelOpen(struct inode *inode, struct file *file)
+ #endif
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0)
++static const struct proc_ops vdoProcfsKernelOps = {
++ .proc_open = statusKernelOpen,
++ .proc_read = seq_read,
++ .proc_lseek = seq_lseek,
++ .proc_release = single_release,
++};
++#else
+ static const struct file_operations vdoProcfsKernelOps = {
+ .open = statusKernelOpen,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+ };
++#endif
+
+ /**********************************************************************/
+ int vdoInitProcfs()
+--
+2.26.2
+
diff --git a/Update-time-types-for-newer-kernels.patch b/Update-time-types-for-newer-kernels.patch
new file mode 100644
index 0000000..0c0b56c
--- /dev/null
+++ b/Update-time-types-for-newer-kernels.patch
@@ -0,0 +1,206 @@
+From 3823b2bb1ff983bcfc17d4be718b3d471d7047db Mon Sep 17 00:00:00 2001
+From: Andrew Walsh <awalsh@redhat.com>
+Date: Wed, 26 Feb 2020 19:50:25 -0500
+Subject: [PATCH 2/3] Update time types for newer kernels
+
+<Author: jwiele@redhat.com>
+
+Newer kernels have removed time types and functions that are
+specific to user space APIs as part of the effort to use
+ktime_t for all kernel timekeeping. Luckily, UDS only uses
+timespec and timeval in user space. UDS uses time_t in stats,
+but time_t is just a number of seconds, and in modern systems
+should be a 64 bit integer, even on 32 bit systems, so it can
+be compatibly replaced with int64_t. A static assertion will
+check that assumption.
+
+Pair: sweettea
+
+.../timeUtils.h
+Add a function to convert absolute nanosecond time to
+ milliseconds.
+Wrap user space specific functions with "#ifndef __KERNEL__".
+Correct the comments on the user space specific functions.
+
+.../timeUtils.c
+Add a static assertion that time_t is the same as int64_t.
+
+.../indexLayout.c
+Use the new absolute time to milliseconds function in lieu of
+ the old getTimeMS function which was needed when user space
+ time had a different representation from kernel space time,
+ but can now be replaced with a simpler function.
+
+.../uds.h
+.../indexSession.c
+Represent time in stats as int64_t instead of time_t.
+---
+ uds/indexLayout.c | 10 +---------
+ uds/indexSession.c | 2 +-
+ uds/timeUtils.c | 1 +
+ uds/timeUtils.h | 41 +++++++++++++++++++++++++++++++++--------
+ uds/uds.h | 2 +-
+ 5 files changed, 37 insertions(+), 19 deletions(-)
+
+diff --git a/uds/indexLayout.c b/uds/indexLayout.c
+index 606111d..4aab553 100644
+--- a/uds/indexLayout.c
++++ b/uds/indexLayout.c
+@@ -1859,14 +1859,6 @@ static int selectLatestIndexSaveLayout(SubIndexLayout *sil,
+ return UDS_SUCCESS;
+ }
+
+-/*****************************************************************************/
+-static uint64_t getTimeMS(AbsTime time)
+-{
+- time_t t = asTimeT(time);
+- RelTime r = timeDifference(time, fromTimeT(t));
+- return (uint64_t) t * 1000 + relTimeToMilliseconds(r);
+-}
+-
+ /*****************************************************************************/
+ __attribute__((warn_unused_result))
+ static int instantiateIndexSaveLayout(IndexSaveLayout *isl,
+@@ -1908,7 +1900,7 @@ static int instantiateIndexSaveLayout(IndexSaveLayout *isl,
+ isl->read = isl->written = false;
+ isl->saveType = saveType;
+ memset(&isl->saveData, 0, sizeof(isl->saveData));
+- isl->saveData.timestamp = getTimeMS(currentTime(CLOCK_REALTIME));
++ isl->saveData.timestamp = absTimeToMilliseconds(currentTime(CLOCK_REALTIME));
+ isl->saveData.version = 1;
+
+ isl->saveData.nonce = generateIndexSaveNonce(volumeNonce, isl);
+diff --git a/uds/indexSession.c b/uds/indexSession.c
+index 13d55ed..f16b051 100644
+--- a/uds/indexSession.c
++++ b/uds/indexSession.c
+@@ -33,7 +33,7 @@ static void collectStats(const struct uds_index_session *indexSession,
+ {
+ const SessionStats *sessionStats = &indexSession->stats;
+
+- stats->currentTime = asTimeT(currentTime(CLOCK_REALTIME));
++ stats->currentTime = absTimeToSeconds(currentTime(CLOCK_REALTIME));
+
+ stats->postsFound = READ_ONCE(sessionStats->postsFound);
+ stats->inMemoryPostsFound = READ_ONCE(sessionStats->postsFoundOpenChapter);
+diff --git a/uds/timeUtils.c b/uds/timeUtils.c
+index ddf3b2b..7cf872c 100644
+--- a/uds/timeUtils.c
++++ b/uds/timeUtils.c
+@@ -19,6 +19,7 @@
+ * $Id: //eng/uds-releases/jasper/src/uds/timeUtils.c#4 $
+ */
+
++#include "permassert.h"
+ #include "stringUtils.h"
+ #include "timeUtils.h"
+
+diff --git a/uds/timeUtils.h b/uds/timeUtils.h
+index 8d159f4..b08d63b 100644
+--- a/uds/timeUtils.h
++++ b/uds/timeUtils.h
+@@ -110,6 +110,19 @@ RelTime timeDifference(AbsTime a, AbsTime b);
+
+
+ /**
++ * Convert an AbsTime value to milliseconds
++ *
++ * @param abstime The absolute time
++ *
++ * @return the equivalent number of millseconds since the epoch
++ **/
++static INLINE int64_t absTimeToMilliseconds(AbsTime abstime)
++{
++ return abstime / NSEC_PER_MSEC;
++}
++
++/**
++ *
+ * Convert seconds to a RelTime value
+ *
+ * @param seconds A number of seconds
+@@ -216,13 +229,13 @@ static INLINE int64_t relTimeToNanoseconds(RelTime reltime)
+ uint64_t nowUsec(void) __attribute__((warn_unused_result));
+
+ /**
+- * Convert from an AbsTime to a time_t
++ * Convert from an AbsTime to seconds truncating
+ *
+ * @param time an AbsTime time
+ *
+- * @return a time_t time
++ * @return a 64 bit signed number of seconds
+ **/
+-static INLINE time_t asTimeT(AbsTime time)
++static INLINE int64_t absTimeToSeconds(AbsTime time)
+ {
+ #ifdef __KERNEL__
+ return time / 1000000000;
+@@ -232,13 +245,13 @@ static INLINE time_t asTimeT(AbsTime time)
+ }
+
+ /**
+- * Convert from a time_t to an AbsTime,
++ * Convert from seconds to an AbsTime,
+ *
+- * @param time a time_t time
++ * @param time a 64 bit signed number of seconds
+ *
+ * @return an AbsTime time
+ **/
+-static INLINE AbsTime fromTimeT(time_t time)
++static INLINE AbsTime fromSeconds(int64_t time)
+ {
+ #ifdef __KERNEL__
+ return time * 1000000000;
+@@ -252,12 +265,24 @@ static INLINE AbsTime fromTimeT(time_t time)
+
+ #ifndef __KERNEL__
+ /**
+- * Convert from an AbsTime to a struct timespec
++ * Convert from an AbsTime to a time_t
+ *
+ * @param time an AbsTime time
+ *
+ * @return a time_t time
+ **/
++static INLINE time_t asTimeT(AbsTime time)
++{
++ return time / NSEC_PER_SEC;
++}
++
++/**
++ * Convert from an AbsTime to a struct timespec
++ *
++ * @param time an AbsTime time
++ *
++ * @return a timespec time
++ **/
+ static INLINE struct timespec asTimeSpec(AbsTime time)
+ {
+ return time;
+@@ -270,7 +295,7 @@ static INLINE struct timespec asTimeSpec(AbsTime time)
+ *
+ * @param time an AbsTime time
+ *
+- * @return a time_t time
++ * @return a struct timeval time
+ **/
+ static INLINE struct timeval asTimeVal(AbsTime time)
+ {
+diff --git a/uds/uds.h b/uds/uds.h
+index 42e2863..dd4260d 100644
+--- a/uds/uds.h
++++ b/uds/uds.h
+@@ -179,7 +179,7 @@ typedef struct udsIndexStats {
+ **/
+ typedef struct udsContextStats {
+ /** The time at which context statistics were last fetched */
+- time_t currentTime;
++ int64_t currentTime;
+ /**
+ * The number of post calls since context statistics were last reset that
+ * found an existing entry
+--
+2.26.2
+
diff --git a/config_hz.patch b/config_hz.patch
index 7f88b68..08af35f 100644
--- a/config_hz.patch
+++ b/config_hz.patch
@@ -1,5 +1,5 @@
---- vdo/kernel/histogram.c 2020-01-21 02:56:37.000000000 +0100
-+++ vdo/kernel/histogram_arch.c 2020-03-12 10:59:26.296614253 +0100
+--- a/vdo/kernel/histogram.c 2020-01-21 02:56:37.000000000 +0100
++++ b/vdo/kernel/histogram_arch.c 2020-03-12 10:59:26.296614253 +0100
@@ -597,7 +597,10 @@
* milliseconds, and the unit conversion code needs updating.
*/
--
2.26.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment