[v2] btrfs: handle errors returned from get_tree_block_key
diff mbox

Message ID 1366980964-14366-1-git-send-email-dsterba@suse.cz
State New, archived
Headers show

Commit Message

David Sterba April 26, 2013, 12:56 p.m. UTC
Signed-off-by: David Sterba <dsterba@suse.cz>
---
 fs/btrfs/relocation.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Zach Brown April 26, 2013, 6:26 p.m. UTC | #1
> @@ -2906,8 +2909,9 @@ int relocate_tree_blocks(struct btrfs_trans_handle *trans,
>  out:
>  	err = finish_pending_nodes(trans, rc, path, err);
>  
> +out_free_path:
>  	btrfs_free_path(path);
> -out_path:
> +out_free_blocks:
>  	free_block_list(blocks);
>  	return err;
>  }
> -- 
> 1.8.2

Yeah, that makes a lot more sense.

Reviewed-by: Zach Brown <zab@redhat.com>

- z
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index c22ccfe..39b7b64 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2864,7 +2864,7 @@  int relocate_tree_blocks(struct btrfs_trans_handle *trans,
 	path = btrfs_alloc_path();
 	if (!path) {
 		err = -ENOMEM;
-		goto out_path;
+		goto out_free_blocks;
 	}
 
 	rb_node = rb_first(blocks);
@@ -2878,8 +2878,11 @@  int relocate_tree_blocks(struct btrfs_trans_handle *trans,
 	rb_node = rb_first(blocks);
 	while (rb_node) {
 		block = rb_entry(rb_node, struct tree_block, rb_node);
-		if (!block->key_ready)
-			get_tree_block_key(rc, block);
+		if (!block->key_ready) {
+			err = get_tree_block_key(rc, block);
+			if (err)
+				goto out_free_path;
+		}
 		rb_node = rb_next(rb_node);
 	}
 
@@ -2906,8 +2909,9 @@  int relocate_tree_blocks(struct btrfs_trans_handle *trans,
 out:
 	err = finish_pending_nodes(trans, rc, path, err);
 
+out_free_path:
 	btrfs_free_path(path);
-out_path:
+out_free_blocks:
 	free_block_list(blocks);
 	return err;
 }