]> www.infradead.org Git - users/dwmw2/linux.git/commit
btrfs: avoid pointless wake ups of drew lock readers
authorFilipe Manana <fdmanana@suse.com>
Mon, 18 Mar 2024 11:08:30 +0000 (11:08 +0000)
committerDavid Sterba <dsterba@suse.com>
Tue, 7 May 2024 19:31:00 +0000 (21:31 +0200)
commitc79f57eafc5e01190fa05f2de8cbd5f579d68acd
treef8dc60260d1a8c40530c87df5ddae1a40f028a2b
parentc66f2afc714867cf7e685680d848748e0d636bef
btrfs: avoid pointless wake ups of drew lock readers

When unlocking a write lock on a drew lock, at btrfs_drew_write_unlock(),
it's pointless to wake up tasks waiting to acquire a read lock if we
didn't decrement the 'writers' counter down to 0, since a read lock can
only be acquired when the counter reaches a value of 0. Doing so is
harmless from a functional point of view, but it's not efficient due to
unnecessarily waking up tasks just for them to sleep again on the
waitqueue.

So change this to wake up readers only if we decremented the 'writers'
counter to 0.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/locking.c