LINUX: do not use d_invalidate to evict dentries 63/12363/4
authorMark Vitale <mvitale@sinenomine.net>
Thu, 4 Aug 2016 22:42:27 +0000 (18:42 -0400)
committerBenjamin Kaduk <kaduk@mit.edu>
Mon, 14 Nov 2016 07:25:51 +0000 (02:25 -0500)
When working within the AFS filespace, commands which access large
numbers of OpenAFS files (e.g., git operations and builds) may result in
active files (e.g., the current working directory) being evicted from the
dentry cache.  One symptom of this is the following message upon return
to the shell prompt:

"fatal: unable to get current working directory: No such file or
directory"

Starting with Linux 3.18, d_invalidate returns void because it always
succeeds.  Commit a42f01d5ebb13da575b3123800ee6990743155ab adapted
OpenAFS to cope with the new return type, but not with the changed
semantics of d_invalidate.  Because d_invalidate can no longer fail with
-EBUSY when invoked on an in-use dentry. OpenAFS must no longer trust it
to preserve in-use dentries.

Modify the dentry eviction code to use a method (d_prune_aliases) that
does not evict in-use dentries.

Change-Id: I1826ae2a89ef4cf6b631da532521bb17bb8da513
Reviewed-on: https://gerrit.openafs.org/12363
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

src/afs/LINUX/osi_vcache.c

index bc74b67..23040b1 100644 (file)
@@ -24,6 +24,13 @@ TryEvictDentries(struct vcache *avc)
     struct hlist_node *p;
 #endif
 
+#if defined(D_INVALIDATE_IS_VOID)
+    /* At this kernel level, d_invalidate always succeeds;
+     * that is, it will now invalidate even an active directory,
+     * Therefore we must use a different method to evict dentries.
+     */
+    d_prune_aliases(inode);
+#else
 #if defined(HAVE_DCACHE_LOCK)
     spin_lock(&dcache_lock);
 
@@ -78,6 +85,7 @@ restart:
     spin_unlock(&inode->i_lock);
 #endif /* HAVE_DCACHE_LOCK */
 inuse:
+#endif /* D_INVALIDATE_IS_VOID */
     return;
 }