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:25:41 +0000 (08:25 +0100)
commitf9f635c04769bae7014e2ff3f86f9c4f1d4d184c
tree2931d7930c8c9a7e07e81404cc5966ad620bd8e3
parent384e15fc4226551a45b54226dc57bca7e23db9d8
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