Commit 8ef385bb authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba
Browse files

btrfs: use btrfs_read_node_slot in walk_down_reloc_tree



We do not need to call read_tree_block() here, simply use the
btrfs_read_node_slot helper.

Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 206983b7
Loading
Loading
Loading
Loading
+2 −13
Original line number Diff line number Diff line
@@ -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;