• Filipe Manana's avatar
    btrfs: use a bit to track the existence of tree mod log users · bc03f39e
    Filipe Manana authored
    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: default avatarFilipe Manana <fdmanana@suse.com>
    Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    bc03f39e
tree-mod-log.c 22.2 KB