Skip to contentSkip to conversation

btrfs: handle errors returned from get_tree_block_key

PATCH Superseded David Sterba 2 participants 4 messages Apr 24, 2013 – Apr 26, 2013 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: handle errors returned from get_tree_block_key

---
 fs/btrfs/relocation.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
fs/btrfs/relocation.c +5 -2
index c22ccfe..e85be23 100644
@@ -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_path;
+		}
 		rb_node = rb_next(rb_node);
 	}
 
Signature · 6 lines
1.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-
#1 lore raw
Quoted 10 lines · David Sterba
---
 fs/btrfs/relocation.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
fs/btrfs/relocation.c +0 -0
index c22ccfe..e85be23 100644

fs/btrfs/relocation.c int relocate_tree_blocks(struct btrfs_trans_handle *trans, · line 2885

Quoted 10 lines
fs/btrfs/relocation.c +5 -2
@@ -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_path;
+		}

Doesn't this leak the path? Whoever named that label out_path was having a laugh :).

		btrfs_free_path(path);
	out_path:
		free_block_list(blocks);
		return err;
	}

- z

#2 lore raw

PATCH v2 1/1 btrfs: handle errors returned from get_tree_block_key

In reply to David Sterba
---
 fs/btrfs/relocation.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
fs/btrfs/relocation.c +8 -4
index c22ccfe..39b7b64 100644
@@ -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;
 }
Signature · 1 line
1.8.2
Reviewed-by on v2 1/1
#3 lore raw
Quoted 13 lines
fs/btrfs/relocation.c +2 -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;
 }
Signature · 1 line
1.8.2

Yeah, that makes a lot more sense.

- z