Commit 4345f7b6 authored by Filipe Manana's avatar Filipe Manana Committed by Khalid Elmously

Btrfs: fix copy_items() return value when logging an inode

BugLink: https://bugs.launchpad.net/bugs/1775771

[ Upstream commit 8434ec46 ]

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: 16e7549f ("Btrfs: incompatible format change to remove hole extents")
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
parent cf115188
...@@ -3835,6 +3835,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans, ...@@ -3835,6 +3835,7 @@ static noinline int copy_items(struct btrfs_trans_handle *trans,
ASSERT(ret == 0); ASSERT(ret == 0);
src = src_path->nodes[0]; src = src_path->nodes[0];
i = 0; i = 0;
need_find_last_extent = true;
} }
btrfs_item_key_to_cpu(src, &key, i); btrfs_item_key_to_cpu(src, &key, i);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment