aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Machek <[email protected]>2020-08-06 23:18:09 -0700
committerLinus Torvalds <[email protected]>2020-08-07 11:33:22 -0700
commit57c720d4144a9c2b88105c3e8f7b0e97e4b5cc93 (patch)
tree755a18fa721d7f2b0cf3b931c427b7ef84632ec2
parent4510a5a98aff2d395e67890c480c0665f953ea00 (diff)
ocfs2: fix unbalanced locking
Based on what fails, function can return with nfs_sync_rwlock either locked or unlocked. That can not be right. Always return with lock unlocked on error. Fixes: 4cd9973f9ff6 ("ocfs2: avoid inode removal while nfsd is accessing it") Signed-off-by: Pavel Machek (CIP) <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Reviewed-by: Joseph Qi <[email protected]> Reviewed-by: Andrew Morton <[email protected]> Cc: Mark Fasheh <[email protected]> Cc: Joel Becker <[email protected]> Cc: Junxiao Bi <[email protected]> Cc: Changwei Ge <[email protected]> Cc: Gang He <[email protected]> Cc: Jun Piao <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
-rw-r--r--fs/ocfs2/dlmglue.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/ocfs2/dlmglue.c b/fs/ocfs2/dlmglue.c
index 751bc4dc7466..8e3a369086db 100644
--- a/fs/ocfs2/dlmglue.c
+++ b/fs/ocfs2/dlmglue.c
@@ -2871,9 +2871,15 @@ int ocfs2_nfs_sync_lock(struct ocfs2_super *osb, int ex)
status = ocfs2_cluster_lock(osb, lockres, ex ? LKM_EXMODE : LKM_PRMODE,
0, 0);
- if (status < 0)
+ if (status < 0) {
mlog(ML_ERROR, "lock on nfs sync lock failed %d\n", status);
+ if (ex)
+ up_write(&osb->nfs_sync_rwlock);
+ else
+ up_read(&osb->nfs_sync_rwlock);
+ }
+
return status;
}