LINUX: hold vcache while dropping dcache refs 06/12206/3
authorMichael Meffie <mmeffie@sinenomine.net>
Thu, 25 Feb 2016 23:49:20 +0000 (18:49 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Wed, 13 Apr 2016 02:16:51 +0000 (22:16 -0400)
Hold a reference on a vcache while attempting to evict the inode from
the dcache. Since the afs_xvcache lock is dropped, it could be possible
for the vcache to be flushed during this time, making it unsafe to use
the vcache after the eviction attempt.

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

src/afs/LINUX/osi_vcache.c

index e64265f..8a0c578 100644 (file)
@@ -28,6 +28,7 @@ osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
     /* First, see if we can evict the inode from the dcache */
     if (defersleep && avc != afs_globalVp && VREFCOUNT(avc) > 1 && avc->opens == 0) {
        *slept = 1;
+       AFS_FAST_HOLD(avc);
        ReleaseWriteLock(&afs_xvcache);
         AFS_GUNLOCK();
 
@@ -87,6 +88,7 @@ restart:
 inuse:
        AFS_GLOCK();
        ObtainWriteLock(&afs_xvcache, 733);
+       AFS_FAST_RELE(avc);
     }
 
     /* See if we can evict it from the VLRUQ */