File 0022-LU-13783-libcfs-support-__vmalloc-with-only-2-args.patch of Package lustre_2_12

From 467f633061d7e1e40a4e62189474d4537420c89a Mon Sep 17 00:00:00 2001
From: Mr NeilBrown <neilb@suse.de>
Date: Wed, 21 Oct 2020 15:26:35 +1100
Subject: [PATCH 22/35] LU-13783 libcfs: support __vmalloc with only 2 args.

Since v5.8-rc1~201^2~19 Commit 88dca4ca5a93 ("mm: remove the pgprot
argument to __vmalloc") __vmalloc only takes 2 arguments.

So introduce __ll_vmalloc which takes 2 args, and calls
__vmalloc with correct number of args.

Test-Parameters: trivial
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I2c89512a12e28b27544a891620e448a9b752b089
Reviewed-on: https://review.whamcloud.com/40328
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Aurelien Degremont <degremoa@amazon.com>
Reviewed-by: Chris Horn <chris.horn@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
---
 libcfs/autoconf/lustre-libcfs.m4        | 18 ++++++++++++++++++
 libcfs/include/libcfs/linux/linux-mem.h |  6 ++++++
 lnet/klnds/gnilnd/gnilnd.h              |  8 +++-----
 lustre/include/obd_support.h            |  4 ++--
 4 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/libcfs/autoconf/lustre-libcfs.m4 b/libcfs/autoconf/lustre-libcfs.m4
index 069488b2eaa2..a7eae74218ef 100644
--- a/libcfs/autoconf/lustre-libcfs.m4
+++ b/libcfs/autoconf/lustre-libcfs.m4
@@ -1255,6 +1255,23 @@ cache_detail_writers_atomic, [
 EXTRA_KCFLAGS="$tmp_flags"
 ]) # LIBCFS_CACHE_DETAIL_WRITERS
 
+#
+# LIBCFS_VMALLOC_2ARGS
+#
+# kernel v5.8-rc1~201^2~19
+# mm: remove the pgprot argument to __vmalloc
+AC_DEFUN([LIBCFS_VMALLOC_2ARGS], [
+LB_CHECK_COMPILE([if __vmalloc has 2 args],
+vmalloc_2args, [
+	#include <linux/vmalloc.h>
+],[
+	__vmalloc(0, 0);
+],[
+	AC_DEFINE(HAVE_VMALLOC_2ARGS, 1,
+		[__vmalloc only takes 2 args.])
+])
+]) # LIBCFS_VMALLOC_2ARGS
+
 #
 # LIBCFS_HAVE_NR_UNSTABLE_NFS
 #
@@ -1452,6 +1469,7 @@ LIBCFS_HAVE_NR_UNSTABLE_NFS
 # 5.8
 LIBCFS_HAVE_MMAP_LOCK
 LIBCFS_KERNEL_SETSOCKOPT
+LIBCFS_VMALLOC_2ARGS
 # 5.15
 LIBCFS_PARAM_SET_UINT_MINMAX
 ]) # LIBCFS_PROG_LINUX
diff --git a/libcfs/include/libcfs/linux/linux-mem.h b/libcfs/include/libcfs/linux/linux-mem.h
index 1ae22859ce67..81e79dbf2485 100644
--- a/libcfs/include/libcfs/linux/linux-mem.h
+++ b/libcfs/include/libcfs/linux/linux-mem.h
@@ -153,4 +153,10 @@ static inline void mmap_read_unlock(struct mm_struct *mm)
 }
 #endif
 
+#ifdef HAVE_VMALLOC_2ARGS
+#define __ll_vmalloc(size, flags) __vmalloc(size, flags)
+#else
+#define __ll_vmalloc(size, flags) __vmalloc(size, flags, PAGE_KERNEL)
+#endif
+
 #endif /* __LINUX_CFS_MEM_H__ */
diff --git a/lnet/klnds/gnilnd/gnilnd.h b/lnet/klnds/gnilnd/gnilnd.h
index 2c4968a8e8b0..fa88a08b6992 100644
--- a/lnet/klnds/gnilnd/gnilnd.h
+++ b/lnet/klnds/gnilnd/gnilnd.h
@@ -1001,12 +1001,10 @@ static inline void *kgnilnd_vzalloc(int size)
 {
 	void *ret;
 	if (*kgnilnd_tunables.kgn_vzalloc_noretry)
-		ret = __vmalloc(size, __GFP_HIGHMEM | GFP_NOIO | __GFP_NORETRY |
-				      __GFP_ZERO,
-				PAGE_KERNEL);
+		ret = __ll_vmalloc(size, __GFP_HIGHMEM | GFP_NOIO | __GFP_ZERO |
+				   __GFP_NORETRY);
 	else
-		ret = __vmalloc(size, __GFP_HIGHMEM | GFP_NOIO | __GFP_ZERO,
-				PAGE_KERNEL);
+		ret = __ll_vmalloc(size, __GFP_HIGHMEM | GFP_NOIO | __GFP_ZERO);
 
 	LIBCFS_ALLOC_POST(ret, size);
 	return ret;
diff --git a/lustre/include/obd_support.h b/lustre/include/obd_support.h
index b6a6cce334d8..30aef099d816 100644
--- a/lustre/include/obd_support.h
+++ b/lustre/include/obd_support.h
@@ -42,6 +42,7 @@
 #include <libcfs/libcfs.h>
 #include <lprocfs_status.h>
 #include <lustre_handles.h>
+#include <libcfs/linux/linux-mem.h>
 
 /* global variables */
 extern struct lprocfs_stats *obd_memory;
@@ -818,8 +819,7 @@ do {									      \
 #define __OBD_VMALLOC_VERBOSE(ptr, cptab, cpt, size)			      \
 do {									      \
 	(ptr) = cptab == NULL ?						      \
-		__vmalloc(size, GFP_NOFS | __GFP_HIGHMEM | __GFP_ZERO,	      \
-			  PAGE_KERNEL) :				      \
+		__ll_vmalloc(size, GFP_NOFS | __GFP_HIGHMEM | __GFP_ZERO) :   \
 		cfs_cpt_vzalloc(cptab, cpt, size);			      \
 	if (unlikely((ptr) == NULL)) {                                        \
 		CERROR("vmalloc of '" #ptr "' (%d bytes) failed\n",           \
-- 
2.41.0

openSUSE Build Service is sponsored by