mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-26 16:41:25 +00:00
btrfs: handle failure of add_pending_csums
add_pending_csums was added as part of the new data=ordered
implementation in e6dcd2dc9c
("Btrfs: New data=ordered
implementation"). Even back then it called the btrfs_csum_file_blocks
which can fail but it never bothered handling the failure. In ENOMEM
situation this could lead to the filesystem failing to write the
checksums for a particular extent and not detect this. On read this
could lead to the filesystem erroring out due to crc mismatch. Fix it by
propagating failure from add_pending_csums and handling them.
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
a8fd1f7174
commit
ac01f26a27
1 changed files with 9 additions and 2 deletions
|
@ -2042,12 +2042,15 @@ static noinline int add_pending_csums(struct btrfs_trans_handle *trans,
|
||||||
struct inode *inode, struct list_head *list)
|
struct inode *inode, struct list_head *list)
|
||||||
{
|
{
|
||||||
struct btrfs_ordered_sum *sum;
|
struct btrfs_ordered_sum *sum;
|
||||||
|
int ret;
|
||||||
|
|
||||||
list_for_each_entry(sum, list, list) {
|
list_for_each_entry(sum, list, list) {
|
||||||
trans->adding_csums = true;
|
trans->adding_csums = true;
|
||||||
btrfs_csum_file_blocks(trans,
|
ret = btrfs_csum_file_blocks(trans,
|
||||||
BTRFS_I(inode)->root->fs_info->csum_root, sum);
|
BTRFS_I(inode)->root->fs_info->csum_root, sum);
|
||||||
trans->adding_csums = false;
|
trans->adding_csums = false;
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -3061,7 +3064,11 @@ static int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_pending_csums(trans, inode, &ordered_extent->list);
|
ret = add_pending_csums(trans, inode, &ordered_extent->list);
|
||||||
|
if (ret) {
|
||||||
|
btrfs_abort_transaction(trans, ret);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
btrfs_ordered_update_i_size(inode, 0, ordered_extent);
|
btrfs_ordered_update_i_size(inode, 0, ordered_extent);
|
||||||
ret = btrfs_update_inode_fallback(trans, root, inode);
|
ret = btrfs_update_inode_fallback(trans, root, inode);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue