aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@redhat.com>2008-09-23 13:14:11 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:07 -0400
commitef8bbdfe7e12dc9b4e80756f6d606c4639c65851 (patch)
treeaf8ba03fb6113dd9dfaf37f15c70595bfd8b2a92
parentf25956cc582f5954033cca3f9488c0a5d5193541 (diff)
Btrfs: fix cache_block_group error handling
cache block group had a few bugs in the error handling code, this makes sure paths get properly released and the correct return value goes out. Signed-off-by: Chris Mason <chris.mason@oracle.com>
-rw-r--r--fs/btrfs/extent-tree.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index c0bb6b9ac4c6..1c10ffc837c8 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -66,7 +66,7 @@ static int cache_block_group(struct btrfs_root *root,
66 struct btrfs_block_group_cache *block_group) 66 struct btrfs_block_group_cache *block_group)
67{ 67{
68 struct btrfs_path *path; 68 struct btrfs_path *path;
69 int ret; 69 int ret = 0;
70 struct btrfs_key key; 70 struct btrfs_key key;
71 struct extent_buffer *leaf; 71 struct extent_buffer *leaf;
72 struct extent_io_tree *free_space_cache; 72 struct extent_io_tree *free_space_cache;
@@ -102,10 +102,10 @@ static int cache_block_group(struct btrfs_root *root,
102 btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY); 102 btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY);
103 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); 103 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
104 if (ret < 0) 104 if (ret < 0)
105 return ret; 105 goto err;
106 ret = btrfs_previous_item(root, path, 0, BTRFS_EXTENT_ITEM_KEY); 106 ret = btrfs_previous_item(root, path, 0, BTRFS_EXTENT_ITEM_KEY);
107 if (ret < 0) 107 if (ret < 0)
108 return ret; 108 goto err;
109 if (ret == 0) { 109 if (ret == 0) {
110 leaf = path->nodes[0]; 110 leaf = path->nodes[0];
111 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); 111 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
@@ -161,9 +161,10 @@ next:
161 last + hole_size - 1, GFP_NOFS); 161 last + hole_size - 1, GFP_NOFS);
162 } 162 }
163 block_group->cached = 1; 163 block_group->cached = 1;
164 ret = 0;
164err: 165err:
165 btrfs_free_path(path); 166 btrfs_free_path(path);
166 return 0; 167 return ret;
167} 168}
168 169
169struct btrfs_block_group_cache *btrfs_lookup_first_block_group(struct 170struct btrfs_block_group_cache *btrfs_lookup_first_block_group(struct