aboutsummaryrefslogtreecommitdiffstats
path: root/module/spl/spl-kmem.c
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2011-03-23 15:45:55 -0700
committerBrian Behlendorf <[email protected]>2011-04-06 20:06:03 -0700
commit495bd532ab4aaef46b57094d59707bad91e6ec25 (patch)
tree16bd9d692bfe445673dd52c01c7b34ae665682cd /module/spl/spl-kmem.c
parent91cb1d91a4cf0dfa360f09747915699d0bef3d6f (diff)
Linux shrinker compat
The Linux shrinker has gone through three API changes since 2.6.22. Rather than force every caller to understand all three APIs this change consolidates the compatibility code in to the mm-compat.h header. The caller then can then use a single spl provided shrinker API which does the right thing for your kernel. SPL_SHRINKER_CALLBACK_PROTO(shrinker_callback, cb, nr_to_scan, gfp_mask); SPL_SHRINKER_DECLARE(shrinker_struct, shrinker_callback, seeks); spl_register_shrinker(&shrinker_struct); spl_unregister_shrinker(&&shrinker_struct); spl_exec_shrinker(&shrinker_struct, nr_to_scan, gfp_mask);
Diffstat (limited to 'module/spl/spl-kmem.c')
-rw-r--r--module/spl/spl-kmem.c50
1 files changed, 9 insertions, 41 deletions
diff --git a/module/spl/spl-kmem.c b/module/spl/spl-kmem.c
index 2f533bdf6..87594bde9 100644
--- a/module/spl/spl-kmem.c
+++ b/module/spl/spl-kmem.c
@@ -819,21 +819,10 @@ struct rw_semaphore spl_kmem_cache_sem; /* Cache list lock */
static int spl_cache_flush(spl_kmem_cache_t *skc,
spl_kmem_magazine_t *skm, int flush);
-#ifdef HAVE_SET_SHRINKER
-static struct shrinker *spl_kmem_cache_shrinker;
-#else
-# 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 /* HAVE_SET_SHRINKER */
+SPL_SHRINKER_CALLBACK_PROTO(spl_kmem_cache_generic_shrinker,
+ shrinker_cb, nr_to_scan, gfp_mask);
+SPL_SHRINKER_DECLARE(spl_kmem_cache_shrinker,
+ spl_kmem_cache_generic_shrinker, KMC_DEFAULT_SEEKS);
static void *
kv_alloc(spl_kmem_cache_t *skc, int size, int flags)
@@ -1859,14 +1848,8 @@ 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_SHRINKER_CALLBACK_PROTO(spl_kmem_cache_generic_shrinker,
+ shrinker_cb, nr_to_scan, gfp_mask)
{
spl_kmem_cache_t *skc;
int unused = 0;
@@ -1930,11 +1913,7 @@ 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 */
+ spl_exec_shrinker(&spl_kmem_cache_shrinker, KMC_REAP_CHUNK, GFP_KERNEL);
}
EXPORT_SYMBOL(spl_kmem_reap);
@@ -2135,14 +2114,7 @@ spl_kmem_init(void)
init_rwsem(&spl_kmem_cache_sem);
INIT_LIST_HEAD(&spl_kmem_cache_list);
-#ifdef HAVE_SET_SHRINKER
- spl_kmem_cache_shrinker = set_shrinker(KMC_DEFAULT_SEEKS,
- spl_kmem_cache_generic_shrinker);
- if (spl_kmem_cache_shrinker == NULL)
- SRETURN(rc = -ENOMEM);
-#else
- register_shrinker(&spl_kmem_cache_shrinker);
-#endif
+ spl_register_shrinker(&spl_kmem_cache_shrinker);
#ifdef DEBUG_KMEM
kmem_alloc_used_set(0);
@@ -2178,11 +2150,7 @@ spl_kmem_fini(void)
#endif /* DEBUG_KMEM */
SENTRY;
-#ifdef HAVE_SET_SHRINKER
- remove_shrinker(spl_kmem_cache_shrinker);
-#else
- unregister_shrinker(&spl_kmem_cache_shrinker);
-#endif
+ spl_unregister_shrinker(&spl_kmem_cache_shrinker);
SEXIT;
}