Whamcloud - gitweb
LU-3974 client: use standard dentry locking function 41/7741/3
authorJames Simmons <uja.ornl@gmail.com>
Mon, 2 Dec 2013 16:44:19 +0000 (11:44 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 11 Dec 2013 14:00:33 +0000 (14:00 +0000)
Over time the struct dentry reference count have change
its data structure. In the 3.11 kernel it was changed
to a struct lockref. To handle these cases in the past
Lustre implemented a d_refcount wrapper to handle all
these changes. At the same time for 3.11 a d_count()
wrapper was introduced. So this patch moved use to use
this d_count wrapper and if not present we emulate it.

Signed-off-by: James Simmons <uja.ornl@gmail.com>
Change-Id: I4c175e789298841f9d599e5195dbd94ccea6216a
Reviewed-on: http://review.whamcloud.com/7741
Reviewed-by: Peng Tao <bergwolf@gmail.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/autoconf/lustre-core.m4
lustre/include/linux/lustre_patchless_compat.h
lustre/include/linux/lvfs.h
lustre/llite/dcache.c
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/namei.c
lustre/ptlrpc/sec_ctx.c

index 0732b9b..8124d2c 100644 (file)
@@ -1288,6 +1288,25 @@ LB_LINUX_TRY_COMPILE([
 ])
 
 #
+# 3.11 need to access d_count to get dentry reference count
+#
+AC_DEFUN([LC_HAVE_DCOUNT],
+[AC_MSG_CHECKING([if d_count exist])
+LB_LINUX_TRY_COMPILE([
+       #include <linux/dcache.h>
+],[
+       struct dentry de;
+
+       d_count(&de);
+],[
+       AC_DEFINE(HAVE_D_COUNT, 1, [d_count exist])
+       AC_MSG_RESULT([yes])
+],[
+       AC_MSG_RESULT([no])
+])
+])
+
+#
 # LC_PROG_LINUX
 #
 # Lustre linux kernel checks
@@ -1386,6 +1405,9 @@ AC_DEFUN([LC_PROG_LINUX],
         LC_HAVE_ONLY_PROCFS_SEQ
         LC_BLKDEV_RELEASE_RETURN_INT
 
+        # 3.11
+        LC_HAVE_DCOUNT
+
         #
         if test x$enable_server != xno ; then
                LC_FUNC_DEV_SET_RDONLY
index c948cda..747bd4d 100644 (file)
@@ -91,10 +91,10 @@ truncate_complete_page(struct address_space *mapping, struct page *page)
 #endif /* !HAVE_TRUNCATE_COMPLETE_PAGE */
 
 #ifdef HAVE_DCACHE_LOCK
-#  define dget_dlock(d)                 dget_locked(d)
-#  define d_refcount(d)                 atomic_read(&(d)->d_count)
-#else
-#  define d_refcount(d)                 ((d)->d_count)
+#  define dget_dlock(d)                        dget_locked(d)
+#  define d_count(d)                   atomic_read(&(d)->d_count)
+#elif !defined(HAVE_D_COUNT)
+#  define d_count(d)                   ((d)->d_count)
 #endif /* HAVE_DCACHE_LOCK */
 
 #ifdef ATTR_OPEN
index 64445b7..68b4317 100644 (file)
@@ -99,7 +99,7 @@ static inline void l_dput(struct dentry *de)
         if (!de || IS_ERR(de))
                 return;
         //shrink_dcache_parent(de);
-       LASSERT(d_refcount(de) > 0);
+       LASSERT(d_count(de) > 0);
         dput(de);
 }
 
index 7097833..6fca4cb 100644 (file)
@@ -117,7 +117,7 @@ int ll_dcompare(struct dentry *parent, struct qstr *d_name, struct qstr *name)
 
        CDEBUG(D_DENTRY, "found name %.*s(%p) flags %#x refc %d\n",
               name->len, name->name, dentry, dentry->d_flags,
-              d_refcount(dentry));
+              d_count(dentry));
 
        /* mountpoint is always valid */
        if (d_mountpoint((struct dentry *)dentry))
@@ -181,10 +181,10 @@ static int ll_ddelete(HAVE_D_DELETE_CONST struct dentry *de)
               list_empty(&de->d_subdirs) ? "" : "subdirs");
 
 #ifdef HAVE_DCACHE_LOCK
-       LASSERT(d_refcount(de) == 0);
+       LASSERT(d_count(de) == 0);
 #else
        /* kernel >= 2.6.38 last refcount is decreased after this function. */
-       LASSERT(d_refcount(de) == 1);
+       LASSERT(d_count(de) == 1);
 #endif
 
        /* Disable this piece of code temproarily because this is called
@@ -210,7 +210,7 @@ int ll_d_init(struct dentry *de)
 
        CDEBUG(D_DENTRY, "ldd on dentry %.*s (%p) parent %p inode %p refc %d\n",
                de->d_name.len, de->d_name.name, de, de->d_parent, de->d_inode,
-               d_refcount(de));
+               d_count(de));
 
        if (de->d_fsdata == NULL) {
                struct ll_dentry_data *lld;
index 92c1de3..daeac51 100644 (file)
@@ -1617,12 +1617,12 @@ static inline void d_lustre_invalidate(struct dentry *dentry, int nested)
 {
        CDEBUG(D_DENTRY, "invalidate dentry %.*s (%p) parent %p inode %p "
               "refc %d\n", dentry->d_name.len, dentry->d_name.name, dentry,
-              dentry->d_parent, dentry->d_inode, d_refcount(dentry));
+              dentry->d_parent, dentry->d_inode, d_count(dentry));
 
        spin_lock_nested(&dentry->d_lock,
                         nested ? DENTRY_D_LOCK_NESTED : DENTRY_D_LOCK_NORMAL);
        __d_lustre_invalidate(dentry);
-       if (d_refcount(dentry) == 0)
+       if (d_count(dentry) == 0)
                __d_drop(dentry);
        spin_unlock(&dentry->d_lock);
 }
index a69d01d..9d9e432 100644 (file)
@@ -676,7 +676,7 @@ void lustre_dump_dentry(struct dentry *dentry, int recur)
                " flags=0x%x, fsdata=%p, %d subdirs\n", dentry,
                dentry->d_name.len, dentry->d_name.name,
                dentry->d_parent->d_name.len, dentry->d_parent->d_name.name,
-              dentry->d_parent, dentry->d_inode, d_refcount(dentry),
+              dentry->d_parent, dentry->d_inode, d_count(dentry),
                dentry->d_flags, dentry->d_fsdata, subdirs);
         if (dentry->d_inode != NULL)
                 ll_dump_inode(dentry->d_inode);
index 8876711..5051c5e 100644 (file)
@@ -420,7 +420,7 @@ struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de)
                        iput(inode);
                        CDEBUG(D_DENTRY,
                               "Reuse dentry %p inode %p refc %d flags %#x\n",
-                             new, new->d_inode, d_refcount(new), new->d_flags);
+                             new, new->d_inode, d_count(new), new->d_flags);
                        return new;
                }
        }
@@ -429,7 +429,7 @@ struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de)
                return ERR_PTR(rc);
        d_add(de, inode);
        CDEBUG(D_DENTRY, "Add dentry %p inode %p refc %d flags %#x\n",
-              de, de->d_inode, d_refcount(de), de->d_flags);
+              de, de->d_inode, d_count(de), de->d_flags);
         return de;
 }
 
index 8f4deb3..3da4c25 100644 (file)
@@ -101,8 +101,8 @@ void push_ctxt(struct lvfs_run_ctxt *save, struct lvfs_run_ctxt *new_ctx,
        OBD_SET_CTXT_MAGIC(save);
 
        save->fs = get_fs();
-       LASSERT(d_refcount(current->fs->pwd.dentry));
-       LASSERT(d_refcount(new_ctx->pwd));
+       LASSERT(d_count(current->fs->pwd.dentry));
+       LASSERT(d_count(new_ctx->pwd));
        save->pwd = dget(current->fs->pwd.dentry);
        save->pwdmnt = mntget(current->fs->pwd.mnt);
        save->luc.luc_umask = current_umask();