Message ID | b6828b73e6b324c40908877fcf4b9930986a3766.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:51, Josef Bacik wrote: > If we fail to add the reloc root, drop it and return the error. All > callers of this function already handle errors appropriately. > > Signed-off-by: Josef Bacik <josef@toxicpanda.com> Better to fold into previous patch. Despite that, Reviewed-by: Qu Wenruo <wqu@suse.com> Thanks, Qu > --- > fs/btrfs/relocation.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c > index 6315e74c1da0..695a52cd07b0 100644 > --- a/fs/btrfs/relocation.c > +++ b/fs/btrfs/relocation.c > @@ -4204,7 +4204,10 @@ int btrfs_reloc_post_snapshot(struct btrfs_trans_handle *trans, > return PTR_ERR(reloc_root); > > ret = __add_reloc_root(reloc_root); > - BUG_ON(ret < 0); > + if (ret) { > + btrfs_put_root(reloc_root); > + return ret; > + } > new_root->reloc_root = btrfs_grab_root(reloc_root); > > if (rc->create_reloc_tree) >
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 6315e74c1da0..695a52cd07b0 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -4204,7 +4204,10 @@ int btrfs_reloc_post_snapshot(struct btrfs_trans_handle *trans, return PTR_ERR(reloc_root); ret = __add_reloc_root(reloc_root); - BUG_ON(ret < 0); + if (ret) { + btrfs_put_root(reloc_root); + return ret; + } new_root->reloc_root = btrfs_grab_root(reloc_root); if (rc->create_reloc_tree)
If we fail to add the reloc root, drop it and return the error. All callers of this function already handle errors appropriately. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- fs/btrfs/relocation.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)