]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
ocfs2: flock: drop cross-node lock when failed locally
authorWengang Wang <wen.gang.wang@oracle.com>
Thu, 3 Apr 2014 21:47:09 +0000 (14:47 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 3 Apr 2014 23:20:56 +0000 (16:20 -0700)
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.

[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Wengang Wang <wen.gang.wang@oracle.com>
Cc: Joel Becker <jlbec@evilplan.org>
Reviewed-by: Mark Fasheh <mfasheh@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/ocfs2/locks.c

index e57c804069ea6487c0a8eba6d203f88ccd8dd39a..6b6d092b09985941f856671722d6db52e1fd035d 100644 (file)
@@ -82,6 +82,8 @@ 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);