btrfs: use btrfs_read_node_slot in walk_down_reloc_tree
authorJosef Bacik <josef@toxicpanda.com>
Thu, 5 Nov 2020 15:45:11 +0000 (10:45 -0500)
committerDavid Sterba <dsterba@suse.com>
Tue, 8 Dec 2020 14:54:06 +0000 (15:54 +0100)
We do not need to call read_tree_block() here, simply use the
btrfs_read_node_slot helper.

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/relocation.c

index 415332a303ec37d172b1a2f13d72044217859f38..91ed88ef0931fb4c9289023580a804c898bdb5ef 100644 (file)
@@ -1415,10 +1415,8 @@ static noinline_for_stack
 int walk_down_reloc_tree(struct btrfs_root *root, struct btrfs_path *path,
                         int *level)
 {
-       struct btrfs_fs_info *fs_info = root->fs_info;
        struct extent_buffer *eb = NULL;
        int i;
-       u64 bytenr;
        u64 ptr_gen = 0;
        u64 last_snapshot;
        u32 nritems;
@@ -1426,8 +1424,6 @@ int walk_down_reloc_tree(struct btrfs_root *root, struct btrfs_path *path,
        last_snapshot = btrfs_root_last_snapshot(&root->root_item);
 
        for (i = *level; i > 0; i--) {
-               struct btrfs_key first_key;
-
                eb = path->nodes[i];
                nritems = btrfs_header_nritems(eb);
                while (path->slots[i] < nritems) {
@@ -1447,16 +1443,9 @@ int walk_down_reloc_tree(struct btrfs_root *root, struct btrfs_path *path,
                        return 0;
                }
 
-               bytenr = btrfs_node_blockptr(eb, path->slots[i]);
-               btrfs_node_key_to_cpu(eb, &first_key, path->slots[i]);
-               eb = read_tree_block(fs_info, bytenr, ptr_gen, i - 1,
-                                    &first_key);
-               if (IS_ERR(eb)) {
+               eb = btrfs_read_node_slot(eb, path->slots[i]);
+               if (IS_ERR(eb))
                        return PTR_ERR(eb);
-               } else if (!extent_buffer_uptodate(eb)) {
-                       free_extent_buffer(eb);
-                       return -EIO;
-               }
                BUG_ON(btrfs_header_level(eb) != i - 1);
                path->nodes[i - 1] = eb;
                path->slots[i - 1] = 0;