From 2e0c077c8faebc261e73cb03a1e37007c161bf0e Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Wed, 24 Aug 2011 16:23:37 -0400 Subject: [PATCH] LINUX vcache lock ordering in afs_linux_readdir Normalize shared and exclusive lock operations. Take the lock exclusive immediately, since the code assumes a write lock if the vcache state is in flux or the entry is being fetched, releasing -write- rather than shared, since we do not hold a shared lock. Reviewed-on: http://gerrit.openafs.org/5309 Tested-by: BuildBot Reviewed-by: Simon Wilkinson Reviewed-by: Derrick Brashear (cherry picked from commit fa97579a08cdf23fcff3c50a5845d72a785feeaf) Change-Id: I282913fead10791751ebaf3c7c6b33e3fbd9a1f7 Reviewed-on: http://gerrit.openafs.org/6305 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- src/afs/LINUX/osi_vnodeops.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index dd133d46c..2cbf2b14b 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -220,8 +220,7 @@ afs_linux_readdir(struct file *fp, void *dirbuf, filldir_t filldir) code = -ENOENT; goto out; } - ObtainSharedLock(&avc->lock, 810); - UpgradeSToWLock(&avc->lock, 811); + ObtainWriteLock(&avc->lock, 811); ObtainReadLock(&tdc->lock); /* * Make sure that the data in the cache is current. There are two @@ -233,15 +232,15 @@ afs_linux_readdir(struct file *fp, void *dirbuf, filldir_t filldir) && (tdc->dflags & DFFetching) && hsame(avc->f.m.DataVersion, tdc->f.versionNo)) { ReleaseReadLock(&tdc->lock); - ReleaseSharedLock(&avc->lock); + ReleaseWriteLock(&avc->lock); afs_osi_Sleep(&tdc->validPos); - ObtainSharedLock(&avc->lock, 812); + ObtainWriteLock(&avc->lock, 812); ObtainReadLock(&tdc->lock); } if (!(avc->f.states & CStatd) || !hsame(avc->f.m.DataVersion, tdc->f.versionNo)) { ReleaseReadLock(&tdc->lock); - ReleaseSharedLock(&avc->lock); + ReleaseWriteLock(&avc->lock); afs_PutDCache(tdc); goto tagain; } -- 2.39.5