From aaf5a7adcc310aa09f0b0265d3dc64742099633b Mon Sep 17 00:00:00 2001 From: Bobi Jam Date: Thu, 31 Mar 2011 12:06:14 +0800 Subject: [PATCH] LU-73 Make register_shrinker argument more visible. Change-Id: I0e1e9331b250bb31ae1e545e5705243e3a26c75a Signed-off-by: Bobi Jam Reviewed-on: http://review.whamcloud.com/377 Tested-by: Hudson Reviewed-by: Oleg Drokin Reviewed-by: wangdi --- lustre/autoconf/lustre-core.m4 | 40 +++++++++++++++++++--------------- lustre/include/linux/lustre_compat25.h | 12 ++-------- lustre/ldlm/ldlm_pool.c | 6 +++-- lustre/llite/llite_internal.h | 1 - lustre/obdclass/lu_object.c | 3 ++- lustre/ptlrpc/sec_bulk.c | 3 ++- 6 files changed, 32 insertions(+), 33 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index f4e0e1f..5f020d5 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -1598,7 +1598,29 @@ AC_DEFUN([LC_REGISTER_SHRINKER], [mm/vmscan.c],[ AC_DEFINE(HAVE_REGISTER_SHRINKER, 1, [kernel exports register_shrinker]) +# 2.6.32 added another argument to struct shrinker->shrink + AC_MSG_CHECKING([if passing shrinker as first argument]) + tmp_flags="$EXTRA_KCFLAGS" + EXTRA_KCFLAGS="-Werror" + LB_LINUX_TRY_COMPILE([ + #include + int test_shrink(struct shrinker *, int, gfp_t); + ],[ + struct shrinker *shr = NULL; + shr->shrink = test_shrink; + ],[ + AC_MSG_RESULT([yes]) + AC_DEFINE(SHRINKER_FIRST_ARG, [struct shrinker *shrinker,], + [kernel is passing shrinker as first argument]) + ],[ + AC_DEFINE(SHRINKER_FIRST_ARG, , + [kernel is not passing shrinker as first argument]) + ]) + EXTRA_KCFLAGS="$tmp_flags" ],[ + AC_DEFINE(SHRINKER_FIRST_ARG, , + [kernel does not exports register_shrinker, + so SHRINKER_FIRST_ARG is empty]) ]) ]) @@ -2083,23 +2105,6 @@ LB_LINUX_TRY_COMPILE([ ]) ]) -# 2.6.32-71 adds an argument to shrink callback -AC_DEFUN([LC_SHRINK_3ARGS], -[AC_MSG_CHECKING([if shrink has 3 arguments]) -LB_LINUX_TRY_COMPILE([ - #include -],[ - struct shrinker s; - return s.shrink(NULL, 0, 0); -],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_SHRINK_3ARGS, 1, - [shrink has 3 arguments]) -],[ - AC_MSG_RESULT(no) -]) -]) - # # LC_EXT4_SINGLEDATA_TRANS_BLOCKS_SB # @@ -2346,7 +2351,6 @@ AC_DEFUN([LC_PROG_LINUX], LC_SB_BDI LC_BLK_QUEUE_MAX_SECTORS LC_BLK_QUEUE_MAX_SEGMENTS - LC_SHRINK_3ARGS LC_EXT4_SINGLEDATA_TRANS_BLOCKS_SB # diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index cc504e5..f651958 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -690,16 +690,8 @@ static inline int ll_crypto_hmac(struct crypto_tfm *tfm, #define cpu_to_node(cpu) 0 #endif -#ifndef HAVE_REGISTER_SHRINKER -#define KERN_SHRINKER(name) name(int nr_to_scan, gfp_t gfp_mask) -#else -#ifdef HAVE_SHRINK_3ARGS -typedef int (*cfs_shrinker_t)(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask); -#define KERN_SHRINKER(name) name(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask) -#else -typedef int (*cfs_shrinker_t)(int nr_to_scan, gfp_t gfp_mask); -#define KERN_SHRINKER(name) name(int nr_to_scan, gfp_t gfp_mask) -#endif +#ifdef HAVE_REGISTER_SHRINKER +typedef int (*cfs_shrinker_t)(SHRINKER_FIRST_ARG int nr_to_scan, gfp_t gfp_mask); static inline struct shrinker *cfs_set_shrinker(int seek, cfs_shrinker_t func) diff --git a/lustre/ldlm/ldlm_pool.c b/lustre/ldlm/ldlm_pool.c index fa55e4205..6d3cf0d 100644 --- a/lustre/ldlm/ldlm_pool.c +++ b/lustre/ldlm/ldlm_pool.c @@ -1151,12 +1151,14 @@ static int ldlm_pools_shrink(ldlm_side_t client, int nr, return cached; } -static int KERN_SHRINKER(ldlm_pools_srv_shrink) +static int ldlm_pools_srv_shrink(SHRINKER_FIRST_ARG int nr_to_scan, + unsigned int gfp_mask) { return ldlm_pools_shrink(LDLM_NAMESPACE_SERVER, nr_to_scan, gfp_mask); } -static int KERN_SHRINKER(ldlm_pools_cli_shrink) +static int ldlm_pools_cli_shrink(SHRINKER_FIRST_ARG int nr_to_scan, + unsigned int gfp_mask) { return ldlm_pools_shrink(LDLM_NAMESPACE_CLIENT, nr_to_scan, gfp_mask); } diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 3299464..43186e9 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -701,7 +701,6 @@ void ll_lli_init(struct ll_inode_info *lli); int ll_fill_super(struct super_block *sb); void ll_put_super(struct super_block *sb); void ll_kill_super(struct super_block *sb); -int ll_shrink_cache(int nr_to_scan, gfp_t gfp_mask); struct inode *ll_inode_from_lock(struct ldlm_lock *lock); void ll_clear_inode(struct inode *inode); int ll_setattr_raw(struct inode *inode, struct iattr *attr); diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index 69aa691..3023736 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -1626,7 +1626,8 @@ static void lu_site_stats_get(cfs_hash_t *hs, } #ifdef __KERNEL__ -static int KERN_SHRINKER(lu_cache_shrink) +static int lu_cache_shrink(SHRINKER_FIRST_ARG int nr_to_scan, + unsigned int gfp_mask) { lu_site_stats_t stats; struct lu_site *s; diff --git a/lustre/ptlrpc/sec_bulk.c b/lustre/ptlrpc/sec_bulk.c index a42dacb..7243e8f 100644 --- a/lustre/ptlrpc/sec_bulk.c +++ b/lustre/ptlrpc/sec_bulk.c @@ -239,7 +239,8 @@ static void enc_pools_release_free_pages(long npages) * could be called frequently for query (@nr_to_scan == 0). * we try to keep at least PTLRPC_MAX_BRW_PAGES pages in the pool. */ -static int KERN_SHRINKER(enc_pools_shrink) +static int enc_pools_shrink(SHRINKER_FIRST_ARG int nr_to_scan, + unsigned int gfp_mask) { if (unlikely(nr_to_scan != 0)) { cfs_spin_lock(&page_pools.epp_lock); -- 1.8.3.1