]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: merge blocking_writers branches in btrfs_tree_read_lock
authorDavid Sterba <dsterba@suse.com>
Thu, 10 Oct 2019 21:29:21 +0000 (23:29 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 18 Nov 2019 16:51:50 +0000 (17:51 +0100)
commit60cb53c74fc0079a4e57f305fd6b3062f4cd1928
treeafab71dc2a492eee2af86e6512baf0e3c5d99edd
parentb7ebae2ab6f40ad501f8ded05f145c68d4eaf6f0
btrfs: merge blocking_writers branches in btrfs_tree_read_lock

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: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/locking.c