From 961875cbedc2c91cdba6dc34a43c6136ea9797fb Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Thu, 25 Feb 2016 18:49:20 -0500 Subject: [PATCH] LINUX: hold vcache while dropping dcache refs 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 Reviewed-by: Andrew Deason Reviewed-by: Benjamin Kaduk --- src/afs/LINUX/osi_vcache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/afs/LINUX/osi_vcache.c b/src/afs/LINUX/osi_vcache.c index e64265f76d..8a0c578998 100644 --- a/src/afs/LINUX/osi_vcache.c +++ b/src/afs/LINUX/osi_vcache.c @@ -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 */