diff mbox series

[v3,46/54] btrfs: handle __add_reloc_root failure in btrfs_reloc_post_snapshot

Message ID b6828b73e6b324c40908877fcf4b9930986a3766.1606938211.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series Cleanup error handling in relocation | expand

Commit Message

Josef Bacik Dec. 2, 2020, 7:51 p.m. UTC
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(-)

Comments

Qu Wenruo Dec. 3, 2020, 5:34 a.m. UTC | #1
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 mbox series

Patch

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)