From: @jackie_wu123
Reviewed-by: @small_leek
Signed-off-by: @small_leek
This commit is contained in:
openeuler-ci-bot 2020-11-11 10:56:00 +08:00 committed by Gitee
commit 0bc0f1bbe5
8 changed files with 454 additions and 4 deletions

Binary file not shown.

BIN
6.2.3.114.tar.gz Normal file

Binary file not shown.

View File

@ -0,0 +1,94 @@
From 4f133fd8e48ad7a35d0f36a491fb771ff688a7be Mon Sep 17 00:00:00 2001
From: Andrew Walsh <awalsh@redhat.com>
Date: Thu, 3 Sep 2020 18:11:14 -0400
Subject: [PATCH] Replace generic_make_request with submit_bio_noacct.
<Author: jwiele@redhat.com>
In kernel 5.9, generic_make_request has been renamed to
submit_bio_noacct to more accurately describe its
function. There is a comment in vdo/kernel/kernelLayer.c
referencing generic_make_request which is not touched by this
change because the whole lengthy comment will have to be
massively revised or even removed for upstreaming.
The doxygen comments in dmvdo.c and dmDory.c that reference
generic_make_request cannot easily be made conditional because
doxygen does not process preprocessor directives within
comments. The comments can be rephrased to simply refer to bio
submission because the exact name of the function used to do
the submission is not critical to the meaning of the comments.
Pair: sweettea
.../dmvdo.c
.../ioSubmitter.c
.../kvdoFlush.c
Replace generic_make_request with submit_bio_noacct for kernels > 5.9.
---
vdo/kernel/dmvdo.c | 8 ++++----
vdo/kernel/ioSubmitter.c | 4 ++++
vdo/kernel/kvdoFlush.c | 4 ++++
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/vdo/kernel/dmvdo.c b/vdo/kernel/dmvdo.c
index a6c7b98..f5bed6d 100644
--- a/vdo/kernel/dmvdo.c
+++ b/vdo/kernel/dmvdo.c
@@ -80,8 +80,8 @@ static KernelLayer *getKernelLayerForTarget(struct dm_target *ti)
/**
* Begin VDO processing of a bio. This is called by the device mapper
- * through the "map" function, and has resulted from a call to either
- * submit_bio or generic_make_request.
+ * through the "map" function, and has resulted from a bio being
+ * submitted.
*
* @param ti The dm_target. We only need the "private" member to give
* us the KernelLayer.
@@ -95,11 +95,11 @@ static KernelLayer *getKernelLayerForTarget(struct dm_target *ti)
* DM_MAPIO_SUBMITTED VDO will take care of this I/O, either
* processing it completely and calling
* bio_endio, or forwarding it onward by
- * calling generic_make_request.
+ * submitting it to the next layer.
*
* DM_MAPIO_REMAPPED VDO has modified the bio and the device
* mapper will immediately forward the bio
- * onward using generic_make_request.
+ * onward by submitting it to the next layer.
*
* DM_MAPIO_REQUEUE We do not use this. It is used by device
* mapper devices to defer an I/O request
diff --git a/vdo/kernel/ioSubmitter.c b/vdo/kernel/ioSubmitter.c
index 036bf25..0e28c3f 100644
--- a/vdo/kernel/ioSubmitter.c
+++ b/vdo/kernel/ioSubmitter.c
@@ -291,7 +291,11 @@ static void sendBioToDevice(KVIO *kvio, BIO *bio, TraceLocation location)
countAllBios(kvio, bio);
kvioAddTraceRecord(kvio, location);
bio->bi_next = NULL;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,9,0)
generic_make_request(bio);
+#else
+ submit_bio_noacct(bio);
+#endif
}
/**
diff --git a/vdo/kernel/kvdoFlush.c b/vdo/kernel/kvdoFlush.c
index 7b38af1..ddc3958 100644
--- a/vdo/kernel/kvdoFlush.c
+++ b/vdo/kernel/kvdoFlush.c
@@ -198,7 +198,11 @@ static void kvdoCompleteFlushWork(KvdoWorkItem *item)
prepareFlushBIO(bio, bio->bi_private, getKernelLayerBdev(layer),
bio->bi_end_io);
atomic64_inc(&layer->flushOut);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5,9,0)
generic_make_request(bio);
+#else
+ submit_bio_noacct(bio);
+#endif
}

View File

@ -0,0 +1,41 @@
From efdcec17c8c1548d062010cc7ed7e163e7c25e3c Mon Sep 17 00:00:00 2001
From: Andrew Walsh <awalsh@redhat.com>
Date: Thu, 3 Sep 2020 17:52:49 -0400
Subject: [PATCH] Eliminated obsolete function smp_read_barrier_depends.
<Author: jwiele@redhat.com>
In Kernels newer than 5.9 or so, smp_read_barrier_depends has
been removed because its functionality is provided by
READ_ONCE. See: https://lkml.org/lkml/2019/11/8/1021
We provide a user space implementation that is empty for the
four primary platforms we test on. That can be deleted. Some
additional barriers can be added if we find that some platform
requires them.
Pair: sweeettea
.../funnelQueue.c
Replaced the call to smp_read_barrier_depends with a comment
noting that an additional barrier may be needed in the
future for some platforms such as Alpha.
---
uds/util/funnelQueue.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/uds/util/funnelQueue.c b/uds/util/funnelQueue.c
index 922c74e..2464716 100644
--- a/uds/util/funnelQueue.c
+++ b/uds/util/funnelQueue.c
@@ -74,7 +74,9 @@ static FunnelQueueEntry *getOldest(FunnelQueue *queue)
// without breaking the queue invariants.
oldest = next;
queue->oldest = oldest;
- smp_read_barrier_depends();
+ // XXX Some platforms such as Alpha may require an
+ // additional barrier here. See
+ // https://lkml.org/lkml/2019/11/8/1021
next = oldest->next;
}

46
fix-vcmalloc.patch Normal file
View File

@ -0,0 +1,46 @@
From ae1667c59561a77864b227b8c939f28e079d901c Mon Sep 17 00:00:00 2001
From: Andrew Walsh <awalsh@redhat.com>
Date: Fri, 19 Jun 2020 12:49:03 -0400
Subject: [PATCH] Update __vmalloc() signature for 5.8+ kernels.
<Author: sweettea@redhat.com>
Pair: sclafani
.../memoryLinuxKernel.c
Updated to have __vmalloc() with two arguments for 5.8+ kernels.
For now, it is ifdef'd for 5.8+ kernels; we will remove the
ifdef at some point after the lab has been updated to have
no Fedora machines with an earlier kernel.
---
uds/memoryLinuxKernel.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/uds/memoryLinuxKernel.c b/uds/memoryLinuxKernel.c
index b2f3714..a4f0dc1 100644
--- a/uds/memoryLinuxKernel.c
+++ b/uds/memoryLinuxKernel.c
@@ -279,7 +279,11 @@ int allocateMemory(size_t size, size_t align, const char *what, void *ptr)
* retries will succeed.
*/
for (;;) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
+ p = __vmalloc(size, gfpFlags | __GFP_NOWARN);
+#else
p = __vmalloc(size, gfpFlags | __GFP_NOWARN, PAGE_KERNEL);
+#endif
// Try again unless we succeeded or more than 1 second has elapsed.
if ((p != NULL) || (jiffies_to_msecs(jiffies - startTime) > 1000)) {
break;
@@ -288,7 +292,11 @@ int allocateMemory(size_t size, size_t align, const char *what, void *ptr)
}
if (p == NULL) {
// Try one more time, logging a failure for this call.
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
+ p = __vmalloc(size, gfpFlags);
+#else
p = __vmalloc(size, gfpFlags, PAGE_KERNEL);
+#endif
}
if (p == NULL) {
FREE(block);

View File

@ -1,7 +1,7 @@
#This spec is obtained from source code(kvdo-6.2.2.24.tar.gz)
%define spec_release 6
%define spec_release 1
%define kmod_name kmod-kvdo
%define kmod_driver_version 6.2.2.24
%define kmod_driver_version 6.2.3.114
%define kmod_rpm_release %{spec_release}
%define kmod_kernel_version 3.10.0-693.el7
@ -14,7 +14,7 @@ Release: %{kmod_rpm_release}
Summary: Kernel Modules for Virtual Data Optimizer
License: GPLv2+
URL: http://github.com/dm-vdo/kvdo
Source0: https://github.com/dm-vdo/kvdo/archive/6.2.2.24.tar.gz
Source0: https://github.com/dm-vdo/kvdo/archive/6.2.3.114.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
Requires: dkms
Requires: kernel-devel >= %{kmod_kernel_version}
@ -27,6 +27,11 @@ ExcludeArch: ppc
ExcludeArch: ppc64
ExcludeArch: ppc64le
ExcludeArch: i686
Patch0001: fix-generic_make_request.patch
Patch0002: fix-smp_read_barrier_depends.patch
Patch0003: fix-vcmalloc.patch
Patch0004: update_procfs_args.patch
Patch0005: update_times_type.patch
%description
Virtual Data Optimizer (VDO) is a device mapper target that delivers
@ -52,7 +57,7 @@ done
/usr/sbin/dkms --rpm_safe_upgrade remove -m %{kmod_name} -v %{version}-%{kmod_rpm_release} --all || :
%prep
%setup -n kvdo-%{kmod_driver_version}
%autosetup -n kvdo-%{kmod_driver_version} -p1
%build
# Nothing doing here, as we're going to build on whatever kernel we end up
@ -85,6 +90,9 @@ rm -rf $RPM_BUILD_ROOT
%{_usr}/src/%{kmod_name}-%{version}-%{kmod_rpm_release}/*
%changelog
* Wed Nov 11 2020 wutao <wutao61@huawei.com> - 6.2.3.114-1
- Update to 6.2.3.114 and adapt to kernel 5.10
* Fri Aug 28 2020 sunguoshuai <sunguoshuai@huawei.com> - 6.2.2.24-6
- Modify the install dir.

58
update_procfs_args.patch Normal file
View File

@ -0,0 +1,58 @@
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] 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()

203
update_times_type.patch Normal file
View File

@ -0,0 +1,203 @@
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] 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