]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: fix abort logic in btrfs_replace_file_extents
authorJosef Bacik <josef@toxicpanda.com>
Tue, 5 Oct 2021 20:35:27 +0000 (16:35 -0400)
committerDavid Sterba <dsterba@suse.com>
Thu, 7 Oct 2021 20:08:06 +0000 (22:08 +0200)
commitc96512d9000c5161a130c0daa64bc9991176ae67
tree27662cc5d275b92ba51f7cfcbd3e868368b0eed6
parent0c3da800cb5d95a9e9aa70f948c1bbb9b2c2822d
btrfs: fix abort logic in btrfs_replace_file_extents

Error injection testing uncovered a case where we'd end up with a
corrupt file system with a missing extent in the middle of a file.  This
occurs because the if statement to decide if we should abort is wrong.

The only way we would abort in this case is if we got a ret !=
-EOPNOTSUPP and we called from the file clone code.  However the
prealloc code uses this path too.  Instead we need to abort if there is
an error, and the only error we _don't_ abort on is -EOPNOTSUPP and only
if we came from the clone file code.

CC: stable@vger.kernel.org # 5.10+
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
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.c