From 7ddb6b599426e2f59787ce924c9a5d1801ca0ba7 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=utf8 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) Reviewed-on: https://gerrit.openafs.org/13725 Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Benjamin Kaduk (cherry picked from commit 5792e0211be275cf79d10e8c5f6ab2a14493e07a) Change-Id: I4a17700adb18956fc61462663fdb690b267cc928 Reviewed-on: https://gerrit.openafs.org/13748 Reviewed-by: Andrew Deason Reviewed-by: Cheyenne Wills Reviewed-by: Michael Meffie Tested-by: BuildBot Reviewed-by: Stephan Wiesand --- 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 e3422ca80..f45f54f42 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); -- 2.39.5