Re: [PATCH 6/6] btrfs: Remove BUG_ON from run_delalloc_nocow
From: Filipe Manana <hidden>
Date: 2019-08-06 10:34:57
On Mon, Aug 5, 2019 at 3:47 PM Nikolay Borisov [off-list ref] wrote:
Correctly handle failure cases when adding an ordered extents in case of REGULAR or PREALLOC extents. Signed-off-by: Nikolay Borisov <redacted>
Reviewed-by: Filipe Manana <redacted> It's correct, but:
quoted hunk ↗ jump to hunk
--- fs/btrfs/inode.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 6c3f9f3a7ed1..b935c301ca72 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c@@ -1569,16 +1569,26 @@ static noinline int run_delalloc_nocow(struct inode *inode, disk_bytenr, num_bytes, num_bytes, BTRFS_ORDERED_PREALLOC); + if (nocow) + btrfs_dec_nocow_writers(fs_info, disk_bytenr); + if (ret) { + btrfs_drop_extent_cache(BTRFS_I(inode), + cur_offset, + cur_offset + num_bytes - 1, + 0); + goto error; + } } else { ret = btrfs_add_ordered_extent(inode, cur_offset, disk_bytenr, num_bytes, num_bytes, BTRFS_ORDERED_NOCOW); + if (nocow) + btrfs_dec_nocow_writers(fs_info, disk_bytenr); + if (ret) + goto error;
We are now duplicating some error handling. Could be done like before, outside the if branches.
} - if (nocow) - btrfs_dec_nocow_writers(fs_info, disk_bytenr); - BUG_ON(ret); /* -ENOMEM */
Just replacing the BUG_ON(ret) with "if (ret) goto error;".
if (root->root_key.objectid ==
BTRFS_DATA_RELOC_TREE_OBJECTID)
--
2.17.1-- Filipe David Manana, “Whether you think you can, or you think you can't — you're right.”