Btrfs: make btrfs_search_forward return with nodes unlocked
None of the uses of btrfs_search_forward() need to have the path nodes (level >= 1) read locked, only the leaf needs to be locked while the caller processes it. Therefore make it return a path with all nodes unlocked, except for the leaf. This change is motivated by the observation that during a file fsync we repeatdly call btrfs_search_forward() and process the returned leaf while upper nodes of the returned path (level >= 1) are read locked, which unnecessarily blocks other tasks that want to write to the same fs/subvol btree. Therefore instead of modifying the fsync code to unlock all nodes with level >= 1 immediately after calling btrfs_search_forward(), change btrfs_search_forward() to do it, so that it benefits all callers. Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: Chris Mason <clm@fb.com>
This commit is contained in:

committed by
Chris Mason

parent
79aec2b80d
commit
f98de9b9c0
@@ -936,12 +936,9 @@ static int find_new_extents(struct btrfs_root *root,
|
||||
min_key.offset = *off;
|
||||
|
||||
while (1) {
|
||||
path->keep_locks = 1;
|
||||
ret = btrfs_search_forward(root, &min_key, path, newer_than);
|
||||
if (ret != 0)
|
||||
goto none;
|
||||
path->keep_locks = 0;
|
||||
btrfs_unlock_up_safe(path, 1);
|
||||
process_slot:
|
||||
if (min_key.objectid != ino)
|
||||
goto none;
|
||||
@@ -2088,8 +2085,6 @@ static noinline int search_ioctl(struct inode *inode,
|
||||
key.type = sk->min_type;
|
||||
key.offset = sk->min_offset;
|
||||
|
||||
path->keep_locks = 1;
|
||||
|
||||
while (1) {
|
||||
ret = btrfs_search_forward(root, &key, path, sk->min_transid);
|
||||
if (ret != 0) {
|
||||
|
Reference in New Issue
Block a user