diff mbox series

[v3,15/54] btrfs: check record_root_in_trans related failures in select_reloc_root

Message ID b17d60d0e20d5898344b299d7018418d4c082fcb.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:50 p.m. UTC
We will record the fs root or the reloc root in the trans in
select_reloc_root.  These will actually return errors in the following
patches, so check their return value here and return it up the stack.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 fs/btrfs/relocation.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Qu Wenruo Dec. 3, 2020, 2:33 a.m. UTC | #1
On 2020/12/3 上午3:50, Josef Bacik wrote:
> We will record the fs root or the reloc root in the trans in
> select_reloc_root.  These will actually return errors in the following
> patches, so check their return value here and return it up the stack.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> ---
>  fs/btrfs/relocation.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index bf4e1018356a..d663d8fc085d 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -1990,6 +1990,7 @@ struct btrfs_root *select_reloc_root(struct btrfs_trans_handle *trans,
>  	struct btrfs_backref_node *next;
>  	struct btrfs_root *root;
>  	int index = 0;
> +	int ret;
>  
>  	next = node;
>  	while (1) {
> @@ -2027,11 +2028,15 @@ struct btrfs_root *select_reloc_root(struct btrfs_trans_handle *trans,
>  		}
>  
>  		if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
> -			record_reloc_root_in_trans(trans, root);
> +			ret = record_reloc_root_in_trans(trans, root);
> +			if (ret)
> +				return ERR_PTR(ret);
>  			break;
>  		}
>  
> -		btrfs_record_root_in_trans(trans, root);
> +		ret = btrfs_record_root_in_trans(trans, root);
> +		if (ret)
> +			return ERR_PTR(ret);
>  		root = root->reloc_root;
>  
>  		if (next->new_bytenr != root->node->start) {
>
diff mbox series

Patch

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index bf4e1018356a..d663d8fc085d 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -1990,6 +1990,7 @@  struct btrfs_root *select_reloc_root(struct btrfs_trans_handle *trans,
 	struct btrfs_backref_node *next;
 	struct btrfs_root *root;
 	int index = 0;
+	int ret;
 
 	next = node;
 	while (1) {
@@ -2027,11 +2028,15 @@  struct btrfs_root *select_reloc_root(struct btrfs_trans_handle *trans,
 		}
 
 		if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
-			record_reloc_root_in_trans(trans, root);
+			ret = record_reloc_root_in_trans(trans, root);
+			if (ret)
+				return ERR_PTR(ret);
 			break;
 		}
 
-		btrfs_record_root_in_trans(trans, root);
+		ret = btrfs_record_root_in_trans(trans, root);
+		if (ret)
+			return ERR_PTR(ret);
 		root = root->reloc_root;
 
 		if (next->new_bytenr != root->node->start) {