• David Sterba's avatar
    btrfs: merge blocking_writers branches in btrfs_tree_read_lock · f5c2a525
    David Sterba authored
    There are two ifs that use eb::blocking_writers. As this is a variable
    modified inside and outside of locks, we could minimize number of
    accesses to avoid problems with getting different results at different
    times.
    
    The access here is locked so this can only race with btrfs_tree_unlock
    that sets blocking_writers to 0 without lock and unsets the lock owner.
    
    The first branch is taken only if the same thread already holds the
    lock, the second if checks for blocking writers. Here we'd either unlock
    and wait, or proceed. Both are valid states of the locking protocol.
    Reviewed-by: default avatarJohannes Thumshirn <jthumshirn@suse.de>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    f5c2a525
locking.c 9.71 KB