diff options
author | Brian Behlendorf <[email protected]> | 2010-10-22 14:16:43 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2010-10-22 14:51:26 -0700 |
commit | 23aa63cbf5e712493d9439f888e426f89bb97857 (patch) | |
tree | 9a0a4c3a679c2f6fe1ae1696f32d78aedd7329ba /module/spl/spl-kmem.c | |
parent | a68d91d770c0d4b8b72d9d07e65a79f3f99f03c6 (diff) |
Fix 2.6.35 shrinker callback API change
As of linux-2.6.35 the shrinker callback API now takes an additional
argument. The shrinker struct is passed to the callback so that users
can embed the shrinker structure in private data and use container_of()
to access it. This removes the need to always use global state for the
shrinker.
To handle this we add the SPL_AC_3ARGS_SHRINKER_CALLBACK autoconf
check to properly detect the API. Then we simply setup a callback
function with the correct number of arguments. For now we do not make
use of the new 3rd argument.
Diffstat (limited to 'module/spl/spl-kmem.c')
-rw-r--r-- | module/spl/spl-kmem.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/module/spl/spl-kmem.c b/module/spl/spl-kmem.c index aefa00fa6..1a9c1fe96 100644 --- a/module/spl/spl-kmem.c +++ b/module/spl/spl-kmem.c @@ -817,13 +817,18 @@ static int spl_cache_flush(spl_kmem_cache_t *skc, #ifdef HAVE_SET_SHRINKER static struct shrinker *spl_kmem_cache_shrinker; #else -static int spl_kmem_cache_generic_shrinker(int nr_to_scan, - unsigned int gfp_mask); +# ifdef HAVE_3ARGS_SHRINKER_CALLBACK +static int spl_kmem_cache_generic_shrinker(struct shrinker *shrinker_cb, + int nr_to_scan, unsigned int gfp_mask); +# else +static int spl_kmem_cache_generic_shrinker( + int nr_to_scan, unsigned int gfp_mask); +# endif /* HAVE_3ARGS_SHRINKER_CALLBACK */ static struct shrinker spl_kmem_cache_shrinker = { .shrink = spl_kmem_cache_generic_shrinker, .seeks = KMC_DEFAULT_SEEKS, }; -#endif +#endif /* HAVE_SET_SHRINKER */ static void * kv_alloc(spl_kmem_cache_t *skc, int size, int flags) @@ -1829,8 +1834,14 @@ EXPORT_SYMBOL(spl_kmem_cache_free); * objects should be freed, because Solaris semantics are to free * all available objects we may free more objects than requested. */ +#ifdef HAVE_3ARGS_SHRINKER_CALLBACK +static int +spl_kmem_cache_generic_shrinker(struct shrinker *shrinker_cb, + int nr_to_scan, unsigned int gfp_mask) +#else static int spl_kmem_cache_generic_shrinker(int nr_to_scan, unsigned int gfp_mask) +#endif /* HAVE_3ARGS_SHRINKER_CALLBACK */ { spl_kmem_cache_t *skc; int unused = 0; @@ -1894,7 +1905,11 @@ EXPORT_SYMBOL(spl_kmem_cache_reap_now); void spl_kmem_reap(void) { +#ifdef HAVE_3ARGS_SHRINKER_CALLBACK + spl_kmem_cache_generic_shrinker(NULL, KMC_REAP_CHUNK, GFP_KERNEL); +#else spl_kmem_cache_generic_shrinker(KMC_REAP_CHUNK, GFP_KERNEL); +#endif /* HAVE_3ARGS_SHRINKER_CALLBACK */ } EXPORT_SYMBOL(spl_kmem_reap); |