From: Josef Bacik Date: Fri, 6 Nov 2020 21:27:29 +0000 (-0500) Subject: btrfs: cleanup the locking in btrfs_next_old_leaf X-Git-Tag: io_uring-5.11-2020-12-23~54^2~93 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=ffeb03cfe2b49b73da7b325a31714003761fc6d5;p=linux-block.git btrfs: cleanup the locking in btrfs_next_old_leaf We are carrying around this next_rw_lock from when we would do spinning vs blocking read locks. Now that we have the rwsem locking we can simply use the read lock flag unconditionally and the read lock helpers. Reviewed-by: Filipe Manana Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index e2673c29e733..ec904db041e6 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c @@ -5272,7 +5272,6 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct btrfs_path *path, struct btrfs_key key; u32 nritems; int ret; - int next_rw_lock = 0; nritems = btrfs_header_nritems(path->nodes[0]); if (nritems == 0) @@ -5282,7 +5281,6 @@ int btrfs_next_old_leaf(struct btrfs_root *root, struct btrfs_path *path, again: level = 1; next = NULL; - next_rw_lock = 0; btrfs_release_path(path); path->keep_locks = 1; @@ -5346,12 +5344,11 @@ again: } if (next) { - btrfs_tree_unlock_rw(next, next_rw_lock); + btrfs_tree_read_unlock(next); free_extent_buffer(next); } next = c; - next_rw_lock = path->locks[level]; ret = read_block_for_search(root, path, &next, level, slot, &key); if (ret == -EAGAIN) @@ -5382,7 +5379,6 @@ again: BTRFS_NESTING_RIGHT, path->recurse); } - next_rw_lock = BTRFS_READ_LOCK; } break; } @@ -5391,13 +5387,13 @@ again: level--; c = path->nodes[level]; if (path->locks[level]) - btrfs_tree_unlock_rw(c, path->locks[level]); + btrfs_tree_read_unlock(c); free_extent_buffer(c); path->nodes[level] = next; path->slots[level] = 0; if (!path->skip_locking) - path->locks[level] = next_rw_lock; + path->locks[level] = BTRFS_READ_LOCK; if (!level) break; @@ -5411,11 +5407,9 @@ again: goto done; } - if (!path->skip_locking) { + if (!path->skip_locking) __btrfs_tree_read_lock(next, BTRFS_NESTING_RIGHT, path->recurse); - next_rw_lock = BTRFS_READ_LOCK; - } } ret = 0; done: