summaryrefslogtreecommitdiffstats
path: root/fs/locks.c
diff options
context:
space:
mode:
authorJeff Layton <jeff.layton@primarydata.com>2016-01-08 07:30:43 -0500
committerJeff Layton <jeff.layton@primarydata.com>2016-01-08 11:38:07 -0500
commit0752ba807b04ccd69cb4bc8bbf829a80ee208a3c (patch)
treee74312e3335b7241a2c373bb2c076b73c1f9cda0 /fs/locks.c
parent7f3697e24dc3820b10f445a4a7d914fc356012d1 (diff)
downloadlinux-stable-0752ba807b04ccd69cb4bc8bbf829a80ee208a3c.tar.gz
linux-stable-0752ba807b04ccd69cb4bc8bbf829a80ee208a3c.tar.bz2
linux-stable-0752ba807b04ccd69cb4bc8bbf829a80ee208a3c.zip
locks: don't check for race with close when setting OFD lock
We don't clean out OFD locks on close(), so there's no need to check for a race with them here. They'll get cleaned out at the same time that flock locks are. Signed-off-by: Jeff Layton <jeff.layton@primarydata.com> Acked-by: "J. Bruce Fields" <bfields@fieldses.org>
Diffstat (limited to 'fs/locks.c')
-rw-r--r--fs/locks.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/fs/locks.c b/fs/locks.c
index c263aff793bc..e72077d5a664 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -2219,10 +2219,12 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
error = do_lock_file_wait(filp, cmd, file_lock);
/*
- * Attempt to detect a close/fcntl race and recover by
- * releasing the lock that was just acquired.
+ * Attempt to detect a close/fcntl race and recover by releasing the
+ * lock that was just acquired. There is no need to do that when we're
+ * unlocking though, or for OFD locks.
*/
- if (!error && file_lock->fl_type != F_UNLCK) {
+ if (!error && file_lock->fl_type != F_UNLCK &&
+ !(file_lock->fl_flags & FL_OFDLCK)) {
/*
* We need that spin_lock here - it prevents reordering between
* update of i_flctx->flc_posix and check for it done in
@@ -2361,10 +2363,12 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
error = do_lock_file_wait(filp, cmd, file_lock);
/*
- * Attempt to detect a close/fcntl race and recover by
- * releasing the lock that was just acquired.
+ * Attempt to detect a close/fcntl race and recover by releasing the
+ * lock that was just acquired. There is no need to do that when we're
+ * unlocking though, or for OFD locks.
*/
- if (!error && file_lock->fl_type != F_UNLCK) {
+ if (!error && file_lock->fl_type != F_UNLCK &&
+ !(file_lock->fl_flags & FL_OFDLCK)) {
/*
* We need that spin_lock here - it prevents reordering between
* update of i_flctx->flc_posix and check for it done in