diff --git a/include/linux/mm_compat.h b/include/linux/mm_compat.h index 173acd434..b375f9b39 100644 --- a/include/linux/mm_compat.h +++ b/include/linux/mm_compat.h @@ -93,16 +93,37 @@ extern shrink_dcache_memory_t shrink_dcache_memory_fn; # define shrink_dcache_memory(nr, gfp) \ ({ \ struct shrink_control sc = { .nr_to_scan = nr, .gfp_mask = gfp }; \ - shrink_dcache_memory_fn(NULL, &sc); \ + int __ret__ = 0; \ + \ + if (shrink_dcache_memory_fn) \ + __ret__ = shrink_dcache_memory_fn(NULL, &sc); \ + \ + __ret__; \ }) # elif defined(HAVE_3ARGS_SHRINKER_CALLBACK) typedef int (*shrink_dcache_memory_t)(struct shrinker *, int, gfp_t); extern shrink_dcache_memory_t shrink_dcache_memory_fn; -# define shrink_dcache_memory(nr, gfp) shrink_dcache_memory_fn(NULL, nr, gfp) +# define shrink_dcache_memory(nr, gfp) \ +({ \ + int __ret__ = 0; \ + \ + if (shrink_dcache_memory_fn) \ + __ret__ = shrink_dcache_memory_fn(NULL, nr, gfp); \ + \ + __ret__; \ +}) # else typedef int (*shrink_dcache_memory_t)(int, gfp_t); extern shrink_dcache_memory_t shrink_dcache_memory_fn; -# define shrink_dcache_memory(nr, gfp) shrink_dcache_memory_fn(nr, gfp) +# define shrink_dcache_memory(nr, gfp) \ +({ \ + int __ret__ = 0; \ + \ + if (shrink_dcache_memory_fn) \ + __ret__ = shrink_dcache_memory_fn(nr, gfp); \ + \ + __ret__; \ +}) # endif /* HAVE_3ARGS_SHRINKER_CALLBACK */ #endif /* HAVE_SHRINK_DCACHE_MEMORY */ @@ -120,16 +141,37 @@ extern shrink_icache_memory_t shrink_icache_memory_fn; # define shrink_icache_memory(nr, gfp) \ ({ \ struct shrink_control sc = { .nr_to_scan = nr, .gfp_mask = gfp }; \ - shrink_icache_memory_fn(NULL, &sc); \ + int __ret__ = 0; \ + \ + if (shrink_icache_memory_fn) \ + __ret__ = shrink_icache_memory_fn(NULL, &sc); \ + \ + __ret__; \ }) # elif defined(HAVE_3ARGS_SHRINKER_CALLBACK) typedef int (*shrink_icache_memory_t)(struct shrinker *, int, gfp_t); extern shrink_icache_memory_t shrink_icache_memory_fn; -# define shrink_icache_memory(nr, gfp) shrink_icache_memory_fn(NULL, nr, gfp) +# define shrink_icache_memory(nr, gfp) \ +({ \ + int __ret__ = 0; \ + \ + if (shrink_icache_memory_fn) \ + __ret__ = shrink_icache_memory_fn(NULL, nr, gfp); \ + \ + __ret__; \ +}) # else typedef int (*shrink_icache_memory_t)(int, gfp_t); extern shrink_icache_memory_t shrink_icache_memory_fn; -# define shrink_icache_memory(nr, gfp) shrink_icache_memory_fn(nr, gfp) +# define shrink_icache_memory(nr, gfp) \ +({ \ + int __ret__ = 0; \ + \ + if (shrink_icache_memory_fn) \ + __ret__ = shrink_icache_memory_fn(nr, gfp); \ + \ + __ret__; \ +}) # endif /* HAVE_3ARGS_SHRINKER_CALLBACK */ #endif /* HAVE_SHRINK_ICACHE_MEMORY */ diff --git a/module/spl/spl-kmem.c b/module/spl/spl-kmem.c index b3c054a95..1d2fa9053 100644 --- a/module/spl/spl-kmem.c +++ b/module/spl/spl-kmem.c @@ -2123,21 +2123,15 @@ spl_kmem_init_kallsyms_lookup(void) #endif /* HAVE_INVALIDATE_INODES */ #ifndef HAVE_SHRINK_DCACHE_MEMORY + /* When shrink_dcache_memory_fn == NULL support is disabled */ shrink_dcache_memory_fn = (shrink_dcache_memory_t) - spl_kallsyms_lookup_name("shrink_dcache_memory"); - if (!shrink_dcache_memory_fn) { - printk(KERN_ERR "Error: Unknown symbol shrink_dcache_memory\n"); - return -EFAULT; - } + spl_kallsyms_lookup_name("shrink_dcache_memory"); #endif /* HAVE_SHRINK_DCACHE_MEMORY */ #ifndef HAVE_SHRINK_ICACHE_MEMORY + /* When shrink_icache_memory_fn == NULL support is disabled */ shrink_icache_memory_fn = (shrink_icache_memory_t) - spl_kallsyms_lookup_name("shrink_icache_memory"); - if (!shrink_icache_memory_fn) { - printk(KERN_ERR "Error: Unknown symbol shrink_icache_memory\n"); - return -EFAULT; - } + spl_kallsyms_lookup_name("shrink_icache_memory"); #endif /* HAVE_SHRINK_ICACHE_MEMORY */ return 0;