Message ID | dc884af858abedd5596d31fbf365a830ec6b26d2.1606938211.git.josef@toxicpanda.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Cleanup error handling in relocation | expand |
On 2020/12/3 上午3:50, Josef Bacik wrote: > We call btrfs_update_root in btrfs_update_reloc_root, which can fail for > all sorts of reasons, including IO errors. Instead of panicing the box > lets return the error, now that all callers properly handle those > errors. > > Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: Qu Wenruo <wqu@suse.com> But a little surprised that, btrfs_update_reloc_root() has int return value but we still uses BUG_ON() for error handling. Thanks, Qu > --- > fs/btrfs/relocation.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c > index e41d14958b8b..2fcb07bc8450 100644 > --- a/fs/btrfs/relocation.c > +++ b/fs/btrfs/relocation.c > @@ -894,7 +894,7 @@ int btrfs_update_reloc_root(struct btrfs_trans_handle *trans, > int ret; > > if (!have_reloc_root(root)) > - goto out; > + return 0; > > reloc_root = root->reloc_root; > root_item = &reloc_root->root_item; > @@ -927,10 +927,8 @@ int btrfs_update_reloc_root(struct btrfs_trans_handle *trans, > > ret = btrfs_update_root(trans, fs_info->tree_root, > &reloc_root->root_key, root_item); > - BUG_ON(ret); > btrfs_put_root(reloc_root); > -out: > - return 0; > + return ret; > } > > /* >
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index e41d14958b8b..2fcb07bc8450 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -894,7 +894,7 @@ int btrfs_update_reloc_root(struct btrfs_trans_handle *trans, int ret; if (!have_reloc_root(root)) - goto out; + return 0; reloc_root = root->reloc_root; root_item = &reloc_root->root_item; @@ -927,10 +927,8 @@ int btrfs_update_reloc_root(struct btrfs_trans_handle *trans, ret = btrfs_update_root(trans, fs_info->tree_root, &reloc_root->root_key, root_item); - BUG_ON(ret); btrfs_put_root(reloc_root); -out: - return 0; + return ret; } /*
We call btrfs_update_root in btrfs_update_reloc_root, which can fail for all sorts of reasons, including IO errors. Instead of panicing the box lets return the error, now that all callers properly handle those errors. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- fs/btrfs/relocation.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)