]> git.ipfire.org Git - people/ms/linux.git/commit
btrfs: use a bit to track the existence of tree mod log users
authorFilipe Manana <fdmanana@suse.com>
Thu, 11 Mar 2021 14:31:09 +0000 (14:31 +0000)
committerDavid Sterba <dsterba@suse.com>
Mon, 19 Apr 2021 15:25:16 +0000 (17:25 +0200)
commitbc03f39ec3c18454b624cd753b536fdb790f18f0
tree844442e6d938354c14285521ed079825f1c44246
parent406808ab2f0ba3dfb01ca591f55173af8f8d2c66
btrfs: use a bit to track the existence of tree mod log users

The tree modification log functions are called very frequently, basically
they are called every time a btree is modified (a pointer added or removed
to a node, a new root for a btree is set, etc). Because of that, to avoid
heavy lock contention on the lock that protects the list of tree mod log
users, we have checks that test the emptiness of the list with a full
memory barrier before the checks, so that when there are no tree mod log
users we avoid taking the lock.

Replace the memory barrier and list emptiness check with a test for a new
bit set at fs_info->flags. This bit is used to indicate when there are
tree mod log users, set whenever a user is added to the list and cleared
when the last user is removed from the list. This makes the intention a
bit more obvious and possibly more efficient (assuming test_bit() may be
cheaper than a full memory barrier on some architectures).

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/ctree.h
fs/btrfs/tree-mod-log.c