Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

btrfs: abort transaction in do_remap_reloc_trans() on failure

If one of the calls made by do_remap_reloc_trans() fails, we can leave
the remap tree in an inconsistent state. Abort the transaction if this
happens, to prevent the corrupt state from reaching the disk.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Mark Harmstone <mark@harmstone.com>
Signed-off-by: David Sterba <dsterba@suse.com>

authored by

Mark Harmstone and committed by
David Sterba
73db0fad 9b882453

+10 -4
+10 -4
fs/btrfs/relocation.c
··· 5035 5035 5036 5036 if (bg_needs_free_space) { 5037 5037 ret = btrfs_add_block_group_free_space(trans, dest_bg); 5038 - if (ret) 5038 + if (ret) { 5039 + btrfs_abort_transaction(trans, ret); 5039 5040 goto fail; 5041 + } 5040 5042 } 5041 5043 5042 5044 ret = copy_remapped_data(fs_info, start, new_addr, length); 5043 - if (ret) 5045 + if (ret) { 5046 + btrfs_abort_transaction(trans, ret); 5044 5047 goto fail; 5048 + } 5045 5049 5046 5050 ret = btrfs_remove_from_free_space_tree(trans, new_addr, length); 5047 - if (ret) 5051 + if (ret) { 5052 + btrfs_abort_transaction(trans, ret); 5048 5053 goto fail; 5054 + } 5049 5055 5050 5056 ret = add_remap_entry(trans, path, src_bg, start, new_addr, length); 5051 5057 if (ret) { 5052 - btrfs_add_to_free_space_tree(trans, new_addr, length); 5058 + btrfs_abort_transaction(trans, ret); 5053 5059 goto fail; 5054 5060 } 5055 5061