]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Linux 3.11: Adapt to d_count changes
authorMarc Dionne <marc.dionne@your-file-system.com>
Tue, 3 Sep 2013 11:55:14 +0000 (07:55 -0400)
committerStephan Wiesand <stephan.wiesand@desy.de>
Tue, 24 Sep 2013 18:32:46 +0000 (11:32 -0700)
In preparation for upcoming changes in the 3.12 cycle, d_lockref
was introduced late in the 3.11 cycle.  The dentry's d_lock and
d_count are moved to this new structure.  A new d_lock macro makes
the change transparent for locking, but direct users of d_count
must adapt.  A new d_count() helper function is provided and
should now be used.

Use the new d_count() helper function if available, and move
some of the ifdef logic into a helper compatibility function.

Reviewed-on: http://gerrit.openafs.org/10219
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
Reviewed-by: Simon Wilkinson <simonxwilkinson@gmail.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
(cherry picked from commit 1f577e41b65e9bd213a915a296ecf5bedd17fcc1)

Change-Id: I43db7b00f966a214259b6814d0308b7164e31295
Reviewed-on: http://gerrit.openafs.org/10241
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
acinclude.m4
src/afs/LINUX/osi_compat.h
src/afs/LINUX/osi_vnodeops.c

index a2209043f7dacf8165ea3500074f01a13ee2bc7c..c1d3f4bea5214520b753571ff0ad6f95038889da 100644 (file)
@@ -881,6 +881,9 @@ case $AFS_SYSNAME in *_linux* | *_umlinux*)
                 AC_CHECK_LINUX_FUNC([d_alloc_anon],
                                     [#include <linux/fs.h>],
                                     [d_alloc_anon(NULL);])
+                AC_CHECK_LINUX_FUNC([d_count],
+                                    [#include <linux/dcache.h>],
+                                    [d_count(NULL);])
                 AC_CHECK_LINUX_FUNC([d_make_root],
                                     [#include <linux/fs.h>],
                                     [d_make_root(NULL);])
index b933560baba28eae06dc58e52b42a36501448f2f..90bcd9a3a89495cb7296db2b6f7a98b879223843 100644 (file)
@@ -565,4 +565,32 @@ afs_proc_create(char *name, umode_t mode, struct proc_dir_entry *parent, struct
 #endif
 }
 
+static inline int
+afs_dentry_count(struct dentry *dp)
+{
+#if defined(HAVE_LINUX_D_COUNT)
+    return d_count(dp);
+#elif defined(D_COUNT_INT)
+    return dp->d_count;
+#else
+    return atomic_read(&dp->d_count);
+#endif
+}
+
+static inline void
+afs_maybe_shrink_dcache(struct dentry *dp)
+{
+#if defined(HAVE_LINUX_D_COUNT) || defined(D_COUNT_INT)
+    spin_lock(&dp->d_lock);
+    if (afs_dentry_count(dp) > 1) {
+       spin_unlock(&dp->d_lock);
+       shrink_dcache_parent(dp);
+    } else
+       spin_unlock(&dp->d_lock);
+#else
+    if (afs_dentry_count(dp) > 1)
+       shrink_dcache_parent(dp);
+#endif
+}
+
 #endif /* AFS_LINUX_OSI_COMPAT_H */
index e067386fea73564e86260d38159ce5a63f714ac7..64b5fdfd5ef69856a41580d4967ccfd6771271a8 100644 (file)
@@ -1656,17 +1656,7 @@ afs_linux_rename(struct inode *oldip, struct dentry *olddp,
        rehash = newdp;
     }
 
-#if defined(D_COUNT_INT)
-    spin_lock(&olddp->d_lock);
-    if (olddp->d_count > 1) {
-       spin_unlock(&olddp->d_lock);
-       shrink_dcache_parent(olddp);
-    } else
-       spin_unlock(&olddp->d_lock);
-#else
-    if (atomic_read(&olddp->d_count) > 1)
-       shrink_dcache_parent(olddp);
-#endif
+    afs_maybe_shrink_dcache(olddp);
 
     AFS_GLOCK();
     code = afs_rename(VTOAFS(oldip), (char *)oldname, VTOAFS(newip), (char *)newname, credp);