Skip to contentSkip to conversation

: flock: drop cross-node lock when failed locally

PATCH New Wengang Wang 1 participant 1 message Feb 28, 2014 OCFS2

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : flock: drop cross-node lock when failed locally

ocfs2_do_flock() calls ocfs2_file_lock() to get the cross-node clock and then call flock_lock_file_wait() to compete with local processes. In case flock_lock_file_wait() failed, say -ENOMEM, clean up work is not done. This patch adds the cleanup --drop the cross-node lock which was just granted.

---
 fs/ocfs2/locks.c | 3 +++
 1 file changed, 3 insertions(+)
fs/ocfs2/locks.c +3 -0
index e57c804..4dc89ab 100644
@@ -82,6 +82,9 @@ static int ocfs2_do_flock(struct file *file, struct inode *inode,
 	}
 
 	ret = flock_lock_file_wait(file, fl);
+	if (ret) {
+		ocfs2_file_unlock(file);
+	}
 
 out:
 	mutex_unlock(&fp->fp_mutex);
Signature · 1 line
1.8.3.1