summaryrefslogtreecommitdiff
path: root/fs/cifs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2020-03-18 07:52:21 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-03-25 08:26:53 +0100
commit6a42cea67491cedecaed7bfdf4e76ddce581f1fb (patch)
tree0d7f65f832316c2b6387e63ba6c682e0420828c2 /fs/cifs
parent5e62fb2c5d44e82ee7fae8c7fe946c7116489281 (diff)
locks: reinstate locks_delete_block optimization
[ Upstream commit dcf23ac3e846ca0cf626c155a0e3fcbbcf4fae8a ] There is measurable performance impact in some synthetic tests due to commit 6d390e4b5d48 (locks: fix a potential use-after-free problem when wakeup a waiter). Fix the race condition instead by clearing the fl_blocker pointer after the wake_up, using explicit acquire/release semantics. This does mean that we can no longer use the clearing of fl_blocker as the wait condition, so switch the waiters over to checking whether the fl_blocked_member list_head is empty. Reviewed-by: yangerkun <yangerkun@huawei.com> Reviewed-by: NeilBrown <neilb@suse.de> Fixes: 6d390e4b5d48 (locks: fix a potential use-after-free problem when wakeup a waiter) Signed-off-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/cifs')
-rw-r--r--fs/cifs/file.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 5b1460486535..dc195435519b 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -1175,7 +1175,8 @@ try_again:
rc = posix_lock_file(file, flock, NULL);
up_write(&cinode->lock_sem);
if (rc == FILE_LOCK_DEFERRED) {
- rc = wait_event_interruptible(flock->fl_wait, !flock->fl_blocker);
+ rc = wait_event_interruptible(flock->fl_wait,
+ list_empty(&flock->fl_blocked_member));
if (!rc)
goto try_again;
locks_delete_block(flock);