diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-02-28 16:46:22 -0500 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-02-28 16:46:22 -0500 |
commit | 0f70abe2b39d19171d4133d2ffdf77fb9113106a (patch) | |
tree | 98e6b00b38579385e64c085be43c65ab66780772 /fs/btrfs | |
parent | aa5d6bed255d7f8c655a8f10d760f4247bc8385c (diff) |
Btrfs: more return code checking
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/ctree.c | 17 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 15 |
2 files changed, 21 insertions, 11 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index be2be0272513..273239932255 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -1087,7 +1087,9 @@ static int del_ptr(struct ctree_root *root, struct ctree_path *path, int level) | |||
1087 | break; | 1087 | break; |
1088 | } | 1088 | } |
1089 | level++; | 1089 | level++; |
1090 | free_extent(root, blocknr, 1); | 1090 | wret = free_extent(root, blocknr, 1); |
1091 | if (wret) | ||
1092 | ret = wret; | ||
1091 | if (!path->nodes[level]) | 1093 | if (!path->nodes[level]) |
1092 | BUG(); | 1094 | BUG(); |
1093 | } | 1095 | } |
@@ -1136,7 +1138,9 @@ int del_item(struct ctree_root *root, struct ctree_path *path) | |||
1136 | wret = del_ptr(root, path, 1); | 1138 | wret = del_ptr(root, path, 1); |
1137 | if (wret) | 1139 | if (wret) |
1138 | ret = wret; | 1140 | ret = wret; |
1139 | free_extent(root, leaf_buf->blocknr, 1); | 1141 | wret = free_extent(root, leaf_buf->blocknr, 1); |
1142 | if (wret) | ||
1143 | ret = wret; | ||
1140 | } | 1144 | } |
1141 | } else { | 1145 | } else { |
1142 | int used = leaf_space_used(leaf, 0, leaf->header.nritems); | 1146 | int used = leaf_space_used(leaf, 0, leaf->header.nritems); |
@@ -1173,7 +1177,9 @@ int del_item(struct ctree_root *root, struct ctree_path *path) | |||
1173 | if (wret) | 1177 | if (wret) |
1174 | ret = wret; | 1178 | ret = wret; |
1175 | tree_block_release(root, leaf_buf); | 1179 | tree_block_release(root, leaf_buf); |
1176 | free_extent(root, blocknr, 1); | 1180 | wret = free_extent(root, blocknr, 1); |
1181 | if (wret) | ||
1182 | ret = wret; | ||
1177 | } else { | 1183 | } else { |
1178 | tree_block_release(root, leaf_buf); | 1184 | tree_block_release(root, leaf_buf); |
1179 | } | 1185 | } |
@@ -1184,7 +1190,8 @@ int del_item(struct ctree_root *root, struct ctree_path *path) | |||
1184 | 1190 | ||
1185 | /* | 1191 | /* |
1186 | * walk up the tree as far as required to find the next leaf. | 1192 | * walk up the tree as far as required to find the next leaf. |
1187 | * returns 0 if it found something or -1 if there are no greater leaves. | 1193 | * returns 0 if it found something or 1 if there are no greater leaves. |
1194 | * returns < 0 on io errors. | ||
1188 | */ | 1195 | */ |
1189 | int next_leaf(struct ctree_root *root, struct ctree_path *path) | 1196 | int next_leaf(struct ctree_root *root, struct ctree_path *path) |
1190 | { | 1197 | { |
@@ -1196,7 +1203,7 @@ int next_leaf(struct ctree_root *root, struct ctree_path *path) | |||
1196 | 1203 | ||
1197 | while(level < MAX_LEVEL) { | 1204 | while(level < MAX_LEVEL) { |
1198 | if (!path->nodes[level]) | 1205 | if (!path->nodes[level]) |
1199 | return -1; | 1206 | return 1; |
1200 | slot = path->slots[level] + 1; | 1207 | slot = path->slots[level] + 1; |
1201 | c = path->nodes[level]; | 1208 | c = path->nodes[level]; |
1202 | if (slot >= c->node.header.nritems) { | 1209 | if (slot >= c->node.header.nritems) { |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 97715bae7847..074f4b182f16 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -105,8 +105,8 @@ int free_extent(struct ctree_root *root, u64 blocknr, u64 num_blocks) | |||
105 | * ins->offset == number of blocks | 105 | * ins->offset == number of blocks |
106 | * Any available blocks before search_start are skipped. | 106 | * Any available blocks before search_start are skipped. |
107 | */ | 107 | */ |
108 | int find_free_extent(struct ctree_root *orig_root, u64 num_blocks, | 108 | static int find_free_extent(struct ctree_root *orig_root, u64 num_blocks, |
109 | u64 search_start, u64 search_end, struct key *ins) | 109 | u64 search_start, u64 search_end, struct key *ins) |
110 | { | 110 | { |
111 | struct ctree_path path; | 111 | struct ctree_path path; |
112 | struct key *key; | 112 | struct key *key; |
@@ -125,10 +125,8 @@ check_failed: | |||
125 | ins->flags = 0; | 125 | ins->flags = 0; |
126 | start_found = 0; | 126 | start_found = 0; |
127 | ret = search_slot(root, ins, &path, 0); | 127 | ret = search_slot(root, ins, &path, 0); |
128 | if (ret < 0) { | 128 | if (ret < 0) |
129 | release_path(root, &path); | 129 | goto error; |
130 | return ret; | ||
131 | } | ||
132 | 130 | ||
133 | while (1) { | 131 | while (1) { |
134 | l = &path.nodes[0]->leaf; | 132 | l = &path.nodes[0]->leaf; |
@@ -137,6 +135,8 @@ check_failed: | |||
137 | ret = next_leaf(root, &path); | 135 | ret = next_leaf(root, &path); |
138 | if (ret == 0) | 136 | if (ret == 0) |
139 | continue; | 137 | continue; |
138 | if (ret < 0) | ||
139 | goto error; | ||
140 | if (!start_found) { | 140 | if (!start_found) { |
141 | ins->objectid = search_start; | 141 | ins->objectid = search_start; |
142 | ins->offset = num_blocks; | 142 | ins->offset = num_blocks; |
@@ -187,6 +187,9 @@ check_pending: | |||
187 | if (ins->offset != 1) | 187 | if (ins->offset != 1) |
188 | BUG(); | 188 | BUG(); |
189 | return 0; | 189 | return 0; |
190 | error: | ||
191 | release_path(root, &path); | ||
192 | return ret; | ||
190 | } | 193 | } |
191 | 194 | ||
192 | /* | 195 | /* |