[Drbd-dev] [PATCH drbd-9.0] compat: __vmalloc() pgprot argument was removed in v5.8

Lukas Wunner lukas at wunner.de
Sun Oct 11 18:07:36 CEST 2020


Commit torvalds/linux at 88dca4ca5a93 removed the pgprot argument from
__vmalloc().  There's a single invocation in drbd_bitmap.c.  Drop the
argument to stay as close as possible to upstream and apply a cocci
patch for older kernels which reinstates the additional argument.

Reported-by: Michael Hierweck <michael.hierweck at hostsharing.net>
Signed-off-by: Lukas Wunner <lukas at wunner.de>
---
 drbd/drbd-kernel-compat/cocci/__vmalloc__no_has_2_params.cocci | 3 +++
 drbd/drbd-kernel-compat/gen_patch_names.c                      | 3 +++
 drbd/drbd-kernel-compat/tests/__vmalloc_has_2_params.c         | 8 ++++++++
 drbd/drbd_bitmap.c                                             | 3 +--
 4 files changed, 15 insertions(+), 2 deletions(-)
 create mode 100644 drbd/drbd-kernel-compat/cocci/__vmalloc__no_has_2_params.cocci
 create mode 100644 drbd/drbd-kernel-compat/tests/__vmalloc_has_2_params.c

diff --git a/drbd/drbd-kernel-compat/cocci/__vmalloc__no_has_2_params.cocci b/drbd/drbd-kernel-compat/cocci/__vmalloc__no_has_2_params.cocci
new file mode 100644
index 0000000..335581d
--- /dev/null
+++ b/drbd/drbd-kernel-compat/cocci/__vmalloc__no_has_2_params.cocci
@@ -0,0 +1,3 @@
+@@ expression S, G; @@
+- __vmalloc(S, G)
++ __vmalloc(S, G, PAGE_KERNEL)
diff --git a/drbd/drbd-kernel-compat/gen_patch_names.c b/drbd/drbd-kernel-compat/gen_patch_names.c
index 8d5af81..86e9d02 100644
--- a/drbd/drbd-kernel-compat/gen_patch_names.c
+++ b/drbd/drbd-kernel-compat/gen_patch_names.c
@@ -323,6 +323,9 @@ int main(int argc, char **argv)
 	patch(1, "part_stat_h", true, false,
 	      COMPAT_HAVE_PART_STAT_H, "present");
 
+	patch(1, "__vmalloc", true, false,
+	      COMPAT___VMALLOC_HAS_2_PARAMS, "has_2_params");
+
 /* #define BLKDEV_ISSUE_ZEROOUT_EXPORTED */
 /* #define BLKDEV_ZERO_NOUNMAP */
 
diff --git a/drbd/drbd-kernel-compat/tests/__vmalloc_has_2_params.c b/drbd/drbd-kernel-compat/tests/__vmalloc_has_2_params.c
new file mode 100644
index 0000000..00e2c28
--- /dev/null
+++ b/drbd/drbd-kernel-compat/tests/__vmalloc_has_2_params.c
@@ -0,0 +1,8 @@
+/* { "version": "v5.8-rc1", "commit": "88dca4ca5a93d2c09e5bbc6a62fbfc3af83c4fca", "comment": "pgprot argument to __vmalloc was removed", "author": "Christoph Hellwig <hch at lst.de>", "date": "Mon Jun 1 21:51:40 2020 -0700" } */
+
+#include <linux/vmalloc.h>
+
+void foo(void)
+{
+	__vmalloc(0, 0);
+}
diff --git a/drbd/drbd_bitmap.c b/drbd/drbd_bitmap.c
index 4dbed26..e23ed5a 100644
--- a/drbd/drbd_bitmap.c
+++ b/drbd/drbd_bitmap.c
@@ -366,9 +366,7 @@ static struct page **bm_realloc_pages(struct drbd_bitmap *b, unsigned long want)
 	new_pages = kzalloc(bytes, GFP_NOIO | __GFP_NOWARN);
 	if (!new_pages) {
 		new_pages = __vmalloc(bytes,
-				GFP_NOIO | __GFP_HIGHMEM | __GFP_ZERO,
-				PAGE_KERNEL);
+				      GFP_NOIO | __GFP_HIGHMEM | __GFP_ZERO);
 		if (!new_pages)
 			return NULL;
 	}
-- 
2.27.0



More information about the drbd-dev mailing list