LINUX: add afs_d_alias_lock & _unlock compat wrappers 90/12790/5
authorMark Vitale <mvitale@sinenomine.net>
Thu, 30 Nov 2017 21:46:16 +0000 (16:46 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Mon, 1 Jan 2018 23:39:54 +0000 (18:39 -0500)
Simplify some #ifdefs for HAVE_DCACHE_LOCK by pushing them down into
new helpers in osi_compat.h.

No functional change should be incurred by this commit.

Change-Id: Ia0dc560bc84c8db4b84ddcc77a17bab5fbf93af9
Reviewed-on: https://gerrit.openafs.org/12790
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/afs/LINUX/osi_compat.h
src/afs/LINUX/osi_vcache.c
src/afs/LINUX/osi_vnodeops.c

index 7ed4d05..abe6b71 100644 (file)
@@ -471,6 +471,18 @@ afs_linux_unlock_inode(struct inode *ip) {
 #endif
 }
 
+/* Use these to lock or unlock an inode for processing
+ * its dentry aliases en masse.
+ */
+#if defined(HAVE_DCACHE_LOCK)
+#define afs_d_alias_lock(ip)       spin_lock(&dcache_lock)
+#define afs_d_alias_unlock(ip)     spin_unlock(&dcache_lock)
+#else
+#define afs_d_alias_lock(ip)       spin_lock(&(ip)->i_lock)
+#define afs_d_alias_unlock(ip)     spin_unlock(&(ip)->i_lock)
+#endif
+
+
 /* Use this instead of dget for dentry operations
  * that occur under a higher lock (e.g. alias processing).
  * Requires that the higher lock (e.g. dcache_lock or
index e463971..e7c8620 100644 (file)
@@ -25,7 +25,7 @@ TryEvictDentries(struct vcache *avc)
 #endif
 
 #if defined(HAVE_DCACHE_LOCK)
-    spin_lock(&dcache_lock);
+    afs_d_alias_lock(inode);
 
 restart:
     list_for_each_entry(dentry, &inode->i_dentry, d_alias) {
@@ -33,19 +33,19 @@ restart:
            continue;
        afs_linux_dget(dentry);
 
-       spin_unlock(&dcache_lock);
+       afs_d_alias_unlock(inode);
        if (d_invalidate(dentry) == -EBUSY) {
            dput(dentry);
            /* perhaps lock and try to continue? (use cur as head?) */
            goto inuse;
        }
        dput(dentry);
-       spin_lock(&dcache_lock);
+       afs_d_alias_lock(inode);
        goto restart;
     }
-    spin_unlock(&dcache_lock);
+    afs_d_alias_unlock(inode);
 #else /* HAVE_DCACHE_LOCK */
-    spin_lock(&inode->i_lock);
+    afs_d_alias_lock(inode);
 
 restart:
 #if defined(D_ALIAS_IS_HLIST)
@@ -65,17 +65,17 @@ restart:
        spin_unlock(&dentry->d_lock);
        afs_linux_dget(dentry);
 
-       spin_unlock(&inode->i_lock);
+       afs_d_alias_unlock(inode);
        if (afs_d_invalidate(dentry) == -EBUSY) {
            dput(dentry);
            /* perhaps lock and try to continue? (use cur as head?) */
            goto inuse;
        }
        dput(dentry);
-       spin_lock(&inode->i_lock);
+       afs_d_alias_lock(inode);
        goto restart;
     }
-    spin_unlock(&inode->i_lock);
+    afs_d_alias_unlock(inode);
 #endif /* HAVE_DCACHE_LOCK */
 inuse:
     return;
@@ -197,11 +197,8 @@ osi_ResetRootVCache(afs_uint32 volid)
 
     dp = d_find_alias(root);
 
-#if defined(HAVE_DCACHE_LOCK)
-    spin_lock(&dcache_lock);
-#else
-    spin_lock(&AFSTOV(vcp)->i_lock);
-#endif
+    afs_d_alias_lock(AFSTOV(vcp));
+
     spin_lock(&dp->d_lock);
 #if defined(D_ALIAS_IS_HLIST)
     hlist_del_init(&dp->d_alias);
@@ -212,11 +209,9 @@ osi_ResetRootVCache(afs_uint32 volid)
 #endif
     dp->d_inode = AFSTOV(vcp);
     spin_unlock(&dp->d_lock);
-#if defined(HAVE_DCACHE_LOCK)
-    spin_unlock(&dcache_lock);
-#else
-    spin_unlock(&AFSTOV(vcp)->i_lock);
-#endif
+
+    afs_d_alias_unlock(AFSTOV(vcp));
+
     dput(dp);
 
     AFS_RELE(root);
index 3bb2f76..a9394ee 100644 (file)
@@ -890,11 +890,7 @@ canonical_dentry(struct inode *ip)
 
     d_prune_aliases(ip);
 
-# ifdef HAVE_DCACHE_LOCK
-    spin_lock(&dcache_lock);
-# else
-    spin_lock(&ip->i_lock);
-# endif
+    afs_d_alias_lock(ip);
 
 #if defined(D_ALIAS_IS_HLIST)
 # if defined(HLIST_ITERATOR_NO_NODE)
@@ -925,12 +921,12 @@ canonical_dentry(struct inode *ip)
     if (ret) {
        afs_linux_dget(ret);
     }
-    spin_unlock(&dcache_lock);
+    afs_d_alias_unlock(ip);
 # else
     if (ret) {
        afs_linux_dget(ret);
     }
-    spin_unlock(&ip->i_lock);
+    afs_d_alias_unlock(ip);
 # endif
 
     return ret;