]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: fix error handling in btrfs_del_csums
authorJosef Bacik <josef@toxicpanda.com>
Wed, 19 May 2021 14:52:45 +0000 (10:52 -0400)
committerDavid Sterba <dsterba@suse.com>
Thu, 27 May 2021 21:30:49 +0000 (23:30 +0200)
commitd90c165d2ee51c17a2e17dcb4b52bd538993a656
treea9b2a386d63c91761f4aecff6239b196f7c58f57
parenta98b683459e4c3da0c02c42607e6953d39ccacda
btrfs: fix error handling in btrfs_del_csums

Error injection stress would sometimes fail with checksums on disk that
did not have a corresponding extent.  This occurred because the pattern
in btrfs_del_csums was

while (1) {
ret = btrfs_search_slot();
if (ret < 0)
break;
}
ret = 0;
out:
btrfs_free_path(path);
return ret;

If we got an error from btrfs_search_slot we'd clear the error because
we were breaking instead of goto out.  Instead of using goto out, simply
handle the cases where we may leave a random value in ret, and get rid
of the

ret = 0;
out:

pattern and simply allow break to have the proper error reporting.  With
this fix we properly abort the transaction and do not commit thinking we
successfully deleted the csum.

Reviewed-by: Qu Wenruo <wqu@suse.com>
CC: stable@vger.kernel.org # 4.4+
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/file-item.c