]> www.infradead.org Git - users/jedix/linux-maple.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>
Tue, 6 Apr 2021 13:35:55 +0000 (15:35 +0200)
commit200a9f469e0188701955e8ce2a9def7eed9839ac
tree1c68e8fcbb07aad5058ad26453b4f47d921ea205
parentb6491e402032b30b22c4d71766383715557c3d3c
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