Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 128255
b: refs/heads/master
c: 0f70abe
h: refs/heads/master
i:
  128253: 105d559
  128251: 73a57cd
  128247: d2f725c
  128239: e9a39c5
  128223: 993804e
  128191: 07381f3
  128127: a2ab7ef
  127999: c3235cf
v: v3
  • Loading branch information
Chris Mason authored and David Woodhouse committed Feb 28, 2007
1 parent 25451b6 commit ad8077d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: aa5d6bed255d7f8c655a8f10d760f4247bc8385c
refs/heads/master: 0f70abe2b39d19171d4133d2ffdf77fb9113106a
17 changes: 12 additions & 5 deletions trunk/fs/btrfs/ctree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,9 @@ static int del_ptr(struct ctree_root *root, struct ctree_path *path, int level)
break;
}
level++;
free_extent(root, blocknr, 1);
wret = free_extent(root, blocknr, 1);
if (wret)
ret = wret;
if (!path->nodes[level])
BUG();
}
Expand Down Expand Up @@ -1136,7 +1138,9 @@ int del_item(struct ctree_root *root, struct ctree_path *path)
wret = del_ptr(root, path, 1);
if (wret)
ret = wret;
free_extent(root, leaf_buf->blocknr, 1);
wret = free_extent(root, leaf_buf->blocknr, 1);
if (wret)
ret = wret;
}
} else {
int used = leaf_space_used(leaf, 0, leaf->header.nritems);
Expand Down Expand Up @@ -1173,7 +1177,9 @@ int del_item(struct ctree_root *root, struct ctree_path *path)
if (wret)
ret = wret;
tree_block_release(root, leaf_buf);
free_extent(root, blocknr, 1);
wret = free_extent(root, blocknr, 1);
if (wret)
ret = wret;
} else {
tree_block_release(root, leaf_buf);
}
Expand All @@ -1184,7 +1190,8 @@ int del_item(struct ctree_root *root, struct ctree_path *path)

/*
* walk up the tree as far as required to find the next leaf.
* returns 0 if it found something or -1 if there are no greater leaves.
* returns 0 if it found something or 1 if there are no greater leaves.
* returns < 0 on io errors.
*/
int next_leaf(struct ctree_root *root, struct ctree_path *path)
{
Expand All @@ -1196,7 +1203,7 @@ int next_leaf(struct ctree_root *root, struct ctree_path *path)

while(level < MAX_LEVEL) {
if (!path->nodes[level])
return -1;
return 1;
slot = path->slots[level] + 1;
c = path->nodes[level];
if (slot >= c->node.header.nritems) {
Expand Down
15 changes: 9 additions & 6 deletions trunk/fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ int free_extent(struct ctree_root *root, u64 blocknr, u64 num_blocks)
* ins->offset == number of blocks
* Any available blocks before search_start are skipped.
*/
int find_free_extent(struct ctree_root *orig_root, u64 num_blocks,
u64 search_start, u64 search_end, struct key *ins)
static int find_free_extent(struct ctree_root *orig_root, u64 num_blocks,
u64 search_start, u64 search_end, struct key *ins)
{
struct ctree_path path;
struct key *key;
Expand All @@ -125,10 +125,8 @@ int find_free_extent(struct ctree_root *orig_root, u64 num_blocks,
ins->flags = 0;
start_found = 0;
ret = search_slot(root, ins, &path, 0);
if (ret < 0) {
release_path(root, &path);
return ret;
}
if (ret < 0)
goto error;

while (1) {
l = &path.nodes[0]->leaf;
Expand All @@ -137,6 +135,8 @@ int find_free_extent(struct ctree_root *orig_root, u64 num_blocks,
ret = next_leaf(root, &path);
if (ret == 0)
continue;
if (ret < 0)
goto error;
if (!start_found) {
ins->objectid = search_start;
ins->offset = num_blocks;
Expand Down Expand Up @@ -187,6 +187,9 @@ int find_free_extent(struct ctree_root *orig_root, u64 num_blocks,
if (ins->offset != 1)
BUG();
return 0;
error:
release_path(root, &path);
return ret;
}

/*
Expand Down

0 comments on commit ad8077d

Please sign in to comment.