From 12b6c0b993bca79091d035cbe4cf1805d8adcc47 Mon Sep 17 00:00:00 2001 From: Lai Siyao Date: Thu, 21 Jun 2012 15:40:50 +0800 Subject: [PATCH] LU-506 kernel: 2.6.38 kernel macro check cleanup * HAVE_DCACHE_LOCK is used to mark kernel >= 2.6.38, instead of other kernel macros, this makes it easier to maintain kernel support in the future. * minor cleanups. Signed-off-by: Lai Siyao Change-Id: Ic9a6a8c339a10b34e2b1b06b47fd9e252cd3ec2c Reviewed-on: http://review.whamcloud.com/3159 Reviewed-by: Yang Sheng Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Fan Yong --- lnet/lnet/lib-msg.c | 2 +- lustre/llite/dcache.c | 16 +++++++++------- lustre/llite/file.c | 4 ++-- lustre/llite/llite_lib.c | 7 ++++--- lustre/osc/osc_io.c | 2 -- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lnet/lnet/lib-msg.c b/lnet/lnet/lib-msg.c index 3c16bf7..c3cb58b 100644 --- a/lnet/lnet/lib-msg.c +++ b/lnet/lnet/lib-msg.c @@ -544,5 +544,5 @@ lnet_msg_container_setup(struct lnet_msg_container *container) return -ENOMEM; } - return 0; + return rc; } diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c index 88db91b..c15e3e7 100644 --- a/lustre/llite/dcache.c +++ b/lustre/llite/dcache.c @@ -171,11 +171,11 @@ static int ll_ddelete(HAVE_D_DELETE_CONST struct dentry *de) d_unhashed((struct dentry *)de) ? "" : "hashed,", list_empty(&de->d_subdirs) ? "" : "subdirs"); +#ifdef HAVE_DCACHE_LOCK + LASSERT(d_refcount(de) == 0); +#else /* kernel >= 2.6.38 last refcount is decreased after this function. */ -#ifdef DCACHE_OP_DELETE LASSERT(d_refcount(de) == 1); -#else - LASSERT(d_refcount(de) == 0); #endif /* if not ldlm lock for this inode, set i_nlink to 0 so that @@ -233,10 +233,11 @@ int ll_dops_init(struct dentry *de, int block, int init_sa) if (lld != NULL && init_sa != 0) lld->lld_sa_generation = 0; -#ifdef DCACHE_OP_HASH - LASSERT(de->d_op == &ll_d_ops); -#else +#ifdef HAVE_DCACHE_LOCK de->d_op = &ll_d_ops; +#else + /* kernel >= 2.6.38 d_op is set in d_alloc() */ + LASSERT(de->d_op == &ll_d_ops); #endif return rc; } @@ -613,7 +614,8 @@ int ll_revalidate_nd(struct dentry *dentry, struct nameidata *nd) int rc; ENTRY; -#ifdef LOOKUP_RCU +#ifndef HAVE_DCACHE_LOCK + /* kernel >= 2.6.38 supports rcu-walk, but lustre doesn't. */ if (nd->flags & LOOKUP_RCU) return -ECHILD; #endif diff --git a/lustre/llite/file.c b/lustre/llite/file.c index cc6214c..1893082 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -2532,7 +2532,7 @@ lustre_check_acl(struct inode *inode, int mask) int rc; ENTRY; -#ifdef IPERM_FLAG_RCU +#ifdef HAVE_GENERIC_PERMISSION_4ARGS if (flags & IPERM_FLAG_RCU) return -ECHILD; #endif @@ -2565,7 +2565,7 @@ int ll_inode_permission(struct inode *inode, int mask, struct nameidata *nd) int rc = 0; ENTRY; -#ifdef IPERM_FLAG_RCU +#ifdef HAVE_GENERIC_PERMISSION_4ARGS if (flags & IPERM_FLAG_RCU) return -ECHILD; #endif diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 050a9a3..1ce9807 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -535,11 +535,12 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, cl_sb_init(sb); sb->s_root = d_alloc_root(root); -#ifdef DCACHE_OP_HASH +#ifdef HAVE_DCACHE_LOCK + sb->s_root->d_op = &ll_d_root_ops; +#else + /* kernel >= 2.6.38 store dentry operations in sb->s_d_op. */ d_set_d_op(sb->s_root, &ll_d_root_ops); sb->s_d_op = &ll_d_ops; -#else - sb->s_root->d_op = &ll_d_root_ops; #endif sbi->ll_sdev_orig = sb->s_dev; diff --git a/lustre/osc/osc_io.c b/lustre/osc/osc_io.c index a94ac61..cc14b5a 100644 --- a/lustre/osc/osc_io.c +++ b/lustre/osc/osc_io.c @@ -99,7 +99,6 @@ static int osc_io_submit(const struct lu_env *env, const struct cl_io_slice *ios, enum cl_req_type crt, struct cl_2queue *queue) { - struct obd_export *exp; struct cl_page *page; struct cl_page *tmp; struct client_obd *cli = NULL; @@ -121,7 +120,6 @@ static int osc_io_submit(const struct lu_env *env, CDEBUG(D_CACHE, "%d %d\n", qin->pl_nr, crt); osc = cl2osc(ios->cis_obj); - exp = osc_export(osc); cli = osc_cli(osc); max_pages = cli->cl_max_pages_per_rpc; -- 1.8.3.1