LINUX: Avoid re-taking global lock in afs_dentry_iput

“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 <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
This commit is contained in:
Yadavendra Yadav 2019-07-26 19:59:25 +05:30 committed by Benjamin Kaduk
parent 104a9d357d
commit 5792e0211b

View File

@ -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);