Skip to contentSkip to conversation

fix cache_block_group error handling

PATCH New Josef Bacik 1 participant 1 message Sep 17, 2008 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix cache_block_group error handling

Hello,

I had this patch last month before I started on my allocator stuff, and my allocator patches depend on this patch (just so they apply properly). Please take this before my allocator patches (which should be coming along in a day or so). Thanks,

Josef

extent-tree.c +5 -4
diff -r 4ae4b933e0eb extent-tree.c
@@ -65,7 +65,7 @@ static int cache_block_group(struct btrf
 			     struct btrfs_block_group_cache *block_group)
 {
 	struct btrfs_path *path;
-	int ret;
+	int ret = 0;
 	struct btrfs_key key;
 	struct extent_buffer *leaf;
 	struct extent_io_tree *free_space_cache;
@@ -101,10 +101,10 @@ static int cache_block_group(struct btrf
 	btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY);
 	ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
 	if (ret < 0)
-		return ret;
+		goto err;
 	ret = btrfs_previous_item(root, path, 0, BTRFS_EXTENT_ITEM_KEY);
 	if (ret < 0)
-		return ret;
+		goto err;
 	if (ret == 0) {
 		leaf = path->nodes[0];
 		btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
@@ -160,9 +160,10 @@ next:
 				 last + hole_size - 1, GFP_NOFS);
 	}
 	block_group->cached = 1;
+	ret = 0;
 err:
 	btrfs_free_path(path);
-	return 0;
+	return ret;
 }
 
 struct btrfs_block_group_cache *btrfs_lookup_first_block_group(struct