LINUX: consolidate duplicate code in osi_TryEvictDentries 92/12792/5
authorMark Vitale <mvitale@sinenomine.net>
Thu, 30 Nov 2017 22:56:13 +0000 (17:56 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Tue, 2 Jan 2018 03:05:09 +0000 (22:05 -0500)
The two stanzas for HAVE_DCACHE_LOCK are now functionally identical;
remove the preprocessor conditionals and duplicate code.

Minor functional change is incurrred for very old (before 2.6.38) Linux
versions that have dcache_lock; we are now obtaining the d_lock as well.

This is safe because d_lock is also quite old (pre-git, 2.6.12), and it
is a spinlock that's only held for checking d_unhashed.  Therefore, it
should have negligible performance impact.  It cannot cause deadlocks or
violate locking order, because spinlocks can't be held across sleeps.

Change-Id: I08faf204e6bd82c4401cdf6048d12cd551dd18fc
Reviewed-on: https://gerrit.openafs.org/12792
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Andrew Deason <adeason@dson.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/afs/LINUX/osi_vcache.c

index e7c8620..1a5012c 100644 (file)
@@ -24,27 +24,6 @@ TryEvictDentries(struct vcache *avc)
     struct hlist_node *p;
 #endif
 
-#if defined(HAVE_DCACHE_LOCK)
-    afs_d_alias_lock(inode);
-
-restart:
-    list_for_each_entry(dentry, &inode->i_dentry, d_alias) {
-       if (d_unhashed(dentry))
-           continue;
-       afs_linux_dget(dentry);
-
-       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);
-       afs_d_alias_lock(inode);
-       goto restart;
-    }
-    afs_d_alias_unlock(inode);
-#else /* HAVE_DCACHE_LOCK */
     afs_d_alias_lock(inode);
 
 restart:
@@ -76,7 +55,7 @@ restart:
        goto restart;
     }
     afs_d_alias_unlock(inode);
-#endif /* HAVE_DCACHE_LOCK */
+
 inuse:
     return;
 }