locks: reinstate locks_delete_block optimization
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 18 Mar 2020 11:52:21 +0000 (07:52 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Mar 2020 07:26:53 +0000 (08:26 +0100)
commit6a42cea67491cedecaed7bfdf4e76ddce581f1fb
tree0d7f65f832316c2b6387e63ba6c682e0420828c2
parent5e62fb2c5d44e82ee7fae8c7fe946c7116489281
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>
fs/cifs/file.c
fs/locks.c