Skip to content

Commit 8434ec4

Browse files
fdmananakdave
authored andcommitted
Btrfs: fix copy_items() return value when logging an inode
When logging an inode, at tree-log.c:copy_items(), if we call btrfs_next_leaf() at the loop which checks for the need to log holes, we need to make sure copy_items() returns the value 1 to its caller and not 0 (on success). This is because the path the caller passed was released and is now different from what is was before, and the caller expects a return value of 0 to mean both success and that the path has not changed, while a return value of 1 means both success and signals the caller that it can not reuse the path, it has to perform another tree search. Even though this is a case that should not be triggered on normal circumstances or very rare at least, its consequences can be very unpredictable (especially when replaying a log tree). Fixes: 16e7549 ("Btrfs: incompatible format change to remove hole extents") Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 4ee3fad commit 8434ec4

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fs/btrfs/tree-log.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3968,6 +3968,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
39683968
ASSERT(ret == 0);
39693969
src = src_path->nodes[0];
39703970
i = 0;
3971+
need_find_last_extent = true;
39713972
}
39723973

39733974
btrfs_item_key_to_cpu(src, &key, i);

0 commit comments

Comments
 (0)