Whamcloud - gitweb
LU-506 kernel: 2.6.38 kernel macro check cleanup
authorLai Siyao <laisiyao@whamcloud.com>
Thu, 21 Jun 2012 07:40:50 +0000 (15:40 +0800)
committerOleg Drokin <green@whamcloud.com>
Tue, 26 Jun 2012 15:33:05 +0000 (11:33 -0400)
* 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 <laisiyao@whamcloud.com>
Change-Id: Ic9a6a8c339a10b34e2b1b06b47fd9e252cd3ec2c
Reviewed-on: http://review.whamcloud.com/3159
Reviewed-by: Yang Sheng <ys@whamcloud.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Fan Yong <yong.fan@whamcloud.com>
lnet/lnet/lib-msg.c
lustre/llite/dcache.c
lustre/llite/file.c
lustre/llite/llite_lib.c
lustre/osc/osc_io.c

index 3c16bf7..c3cb58b 100644 (file)
@@ -544,5 +544,5 @@ lnet_msg_container_setup(struct lnet_msg_container *container)
                return -ENOMEM;
        }
 
-       return 0;
+       return rc;
 }
index 88db91b..c15e3e7 100644 (file)
@@ -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
index cc6214c..1893082 100644 (file)
@@ -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
index 050a9a3..1ce9807 100644 (file)
@@ -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;
index a94ac61..cc14b5a 100644 (file)
@@ -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;