summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2024-05-07 21:12:04 +0300
committerDavid Sterba <dsterba@suse.com>2024-07-11 16:33:24 +0300
commit3fdf5798fa379c36d068090d026d18dd6dfc5b6c (patch)
tree001b38e4ea1803a1ce594c5d6eba53b43eb269c0
parent133b3da83539bd04e97e24cbc8693a1cdca4b5ec (diff)
downloadlinux-3fdf5798fa379c36d068090d026d18dd6dfc5b6c.tar.xz
btrfs: use btrfs_read_extent_buffer() in do_walk_down()
Currently if our extent buffer isn't uptodate we will drop the lock, free it, and then call read_tree_block() for the bytenr. This is inefficient, we already have the extent buffer, we can simply call btrfs_read_extent_buffer(). Merge these two cases down into one if statement, if we are not uptodate we can drop the lock, trigger readahead, and do the read using btrfs_read_extent_buffer(), and carry on. Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/extent-tree.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 3e31dc753877..cff46f04b32d 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -5507,22 +5507,15 @@ static noinline int do_walk_down(struct btrfs_trans_handle *trans,
if (!btrfs_buffer_uptodate(next, generation, 0)) {
btrfs_tree_unlock(next);
- free_extent_buffer(next);
- next = NULL;
- *lookup_info = 1;
- }
-
- if (!next) {
if (level == 1)
reada_walk_down(trans, root, wc, path);
- next = read_tree_block(fs_info, bytenr, &check);
- if (IS_ERR(next)) {
- return PTR_ERR(next);
- } else if (!extent_buffer_uptodate(next)) {
+ ret = btrfs_read_extent_buffer(next, &check);
+ if (ret) {
free_extent_buffer(next);
- return -EIO;
+ return ret;
}
btrfs_tree_lock(next);
+ *lookup_info = 1;
}
level--;