Skip to content

Commit 17515f1

Browse files
adam900710kdave
authored andcommitted
btrfs: Fix wrong first_key parameter in replace_path
Commit 581c176 ("btrfs: Validate child tree block's level and first key") introduced new @first_key parameter for read_tree_block(), however caller in replace_path() is parasing wrong key to read_tree_block(). It should use parameter @first_key other than @key. Normally it won't expose problem as @key is normally initialzied to the same value of @first_key we expect. However in relocation recovery case, @key can be set to (0, 0, 0), and since no valid key in relocation tree can be (0, 0, 0), it will cause read_tree_block() to return -EUCLEAN and interrupt relocation recovery. Fix it by setting @first_key correctly. Fixes: 581c176 ("btrfs: Validate child tree block's level and first key") Signed-off-by: Qu Wenruo <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent c087232 commit 17515f1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

fs/btrfs/relocation.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1841,7 +1841,7 @@ int replace_path(struct btrfs_trans_handle *trans,
18411841
old_bytenr = btrfs_node_blockptr(parent, slot);
18421842
blocksize = fs_info->nodesize;
18431843
old_ptr_gen = btrfs_node_ptr_generation(parent, slot);
1844-
btrfs_node_key_to_cpu(parent, &key, slot);
1844+
btrfs_node_key_to_cpu(parent, &first_key, slot);
18451845

18461846
if (level <= max_level) {
18471847
eb = path->nodes[level];

0 commit comments

Comments
 (0)