From 5792e0211be275cf79d10e8c5f6ab2a14493e07a Mon Sep 17 00:00:00 2001 From: Yadavendra Yadav Date: Fri, 26 Jul 2019 19:59:25 +0530 Subject: [PATCH] LINUX: Avoid re-taking global lock in afs_dentry_iput MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit “dput” function internally can call dentry_iput which results in calling afs_dentry_iput. So in case before calling “dput” if global lock was held then when afs_dentry_iput is called it will again try to lock global lock and will result in deadlock scenario. So to avoid this deadlock make sure if global lock is already taken before calling afs_dentry_iput, don’t try to lock it again. This issue was partially fixed in commit 0dac4de8 (Linux: drop GLOCK before calling dput) Change-Id: I71f18c58d5254f0cf0c68ef04c22268ed70dd50f Reviewed-on: https://gerrit.openafs.org/13725 Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Benjamin Kaduk --- src/afs/LINUX/osi_vnodeops.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index fad928baf3..0ca2646afb 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -1453,12 +1453,20 @@ static void afs_dentry_iput(struct dentry *dp, struct inode *ip) { struct vcache *vcp = VTOAFS(ip); + int haveGlock = ISAFS_GLOCK(); + + if (!haveGlock) { + AFS_GLOCK(); + } - AFS_GLOCK(); if (!AFS_IS_DISCONNECTED || (vcp->f.states & CUnlinked)) { (void) afs_InactiveVCache(vcp, NULL); } - AFS_GUNLOCK(); + + if (!haveGlock) { + AFS_GUNLOCK(); + } + afs_linux_clear_nfsfs_renamed(dp); iput(ip);