locks: reinstate locks_delete_block optimization
Subsystems (4)
Jeff Layton
maintainerPATCH 1/1 locks: reinstate locks_delete_block optimization
From: Linus Torvalds <[email protected]>
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 <[email protected]>
Reviewed-by NeilBrown <[email protected]>
Fixes 6d390e4b5d48 (locks: fix a potential use-after-free problem when wakeup a waiter)
Signed-off-by Jeff Layton <[email protected]>
--- fs/cifs/file.c | 3 ++- fs/locks.c | 54 ++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 50 insertions(+), 7 deletions(-)
Hi Linus,
Sending this individually since it's just a single patch. If you'd prefer a pull request, let me know.
-- Jeff
fs/cifs/file.c +2 -1
@@ -1169,7 +1169,8 @@ cifs_posix_lock_set(struct file *file, struct file_lock *flock) 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);
fs/locks.c +48 -6
107 lines not on this page · raw message
Signature · 1 line
2.24.1