From 4275f6e6e56437d41d021833437add74ec22db87 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Mon, 1 Aug 2022 09:25:17 -0700 Subject: [PATCH] Use memalloc_nofs_save memalloc_nofs_save() was introduced as preferential to trying to use GFP flags to indicate that a task should not recurse during reclaim. We use it instead of the _noio_ we were using before. Signed-off-by: Zach Brown --- kmod/src/Makefile.kernelcompat | 9 +++++++++ kmod/src/block.c | 7 ++++--- kmod/src/kernelcompat.h | 5 +++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/kmod/src/Makefile.kernelcompat b/kmod/src/Makefile.kernelcompat index 3e129eed..fb802bf2 100644 --- a/kmod/src/Makefile.kernelcompat +++ b/kmod/src/Makefile.kernelcompat @@ -101,3 +101,12 @@ endif ifneq (,$(shell grep 'percpu_counter_add_batch' include/linux/percpu_counter.h)) ccflags-y += -DKC_PERCPU_COUNTER_ADD_BATCH endif + +# +# v4.11-4550-g7dea19f9ee63 +# +# Introduced memalloc_nofs_{save,restore} preferred instead of _noio_. +# +ifneq (,$(shell grep 'memalloc_nofs_save' include/linux/sched/mm.h)) +ccflags-y += -DKC_MEMALLOC_NOFS_SAVE +endif diff --git a/kmod/src/block.c b/kmod/src/block.c index 89cda9c0..14686f15 100644 --- a/kmod/src/block.c +++ b/kmod/src/block.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "format.h" #include "super.h" @@ -128,7 +129,7 @@ static __le32 block_calc_crc(struct scoutfs_block_header *hdr, u32 size) static struct block_private *block_alloc(struct super_block *sb, u64 blkno) { struct block_private *bp; - unsigned int noio_flags; + unsigned int nofs_flags; /* * If we had multiple blocks per page we'd need to be a little @@ -156,9 +157,9 @@ static struct block_private *block_alloc(struct super_block *sb, u64 blkno) * spurious reclaim-on dependencies and warnings. */ lockdep_off(); - noio_flags = memalloc_noio_save(); + nofs_flags = memalloc_nofs_save(); bp->virt = __vmalloc(SCOUTFS_BLOCK_LG_SIZE, GFP_NOFS | __GFP_HIGHMEM, PAGE_KERNEL); - memalloc_noio_restore(noio_flags); + memalloc_nofs_restore(nofs_flags); lockdep_on(); if (!bp->virt) { diff --git a/kmod/src/kernelcompat.h b/kmod/src/kernelcompat.h index b22b265f..4923730e 100644 --- a/kmod/src/kernelcompat.h +++ b/kmod/src/kernelcompat.h @@ -117,4 +117,9 @@ static inline int dir_emit_dots(struct file *file, void *dirent, #define percpu_counter_add_batch __percpu_counter_add #endif +#ifndef KC_MEMALLOC_NOFS_SAVE +#define memalloc_nofs_save memalloc_noio_save +#define memalloc_nofs_restore memalloc_noio_restore +#endif + #endif