diff options
author | Yan <yanzheng@21cn.com> | 2007-08-29 09:11:44 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-08-29 09:11:44 -0400 |
commit | 252c38f0697b6889c03542fa3c96143d3db4d9d8 (patch) | |
tree | 3a2c99a46d8e43603baba9ffc35330a67569948a /fs/btrfs/ctree.c | |
parent | 58176a9604c5db1784d2c979aea472b3be40b6f0 (diff) |
Btrfs: ctree.c cleanups
Fixup a few buffer_head release errors, and fix an off by one in
balance_node_right.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r-- | fs/btrfs/ctree.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index c0782a5b04c5..89e282c35ce2 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -266,8 +266,10 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans, | |||
266 | err = __btrfs_cow_block(trans, root, cur_bh, parent, i, | 266 | err = __btrfs_cow_block(trans, root, cur_bh, parent, i, |
267 | &tmp_bh, search_start, | 267 | &tmp_bh, search_start, |
268 | min(8, end_slot - i)); | 268 | min(8, end_slot - i)); |
269 | if (err) | 269 | if (err) { |
270 | brelse(cur_bh); | ||
270 | break; | 271 | break; |
272 | } | ||
271 | search_start = bh_blocknr(tmp_bh); | 273 | search_start = bh_blocknr(tmp_bh); |
272 | *last_ret = search_start; | 274 | *last_ret = search_start; |
273 | if (parent_level == 1) | 275 | if (parent_level == 1) |
@@ -881,7 +883,6 @@ int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root | |||
881 | ins_len, int cow) | 883 | ins_len, int cow) |
882 | { | 884 | { |
883 | struct buffer_head *b; | 885 | struct buffer_head *b; |
884 | struct buffer_head *cow_buf; | ||
885 | struct btrfs_node *c; | 886 | struct btrfs_node *c; |
886 | u64 blocknr; | 887 | u64 blocknr; |
887 | int slot; | 888 | int slot; |
@@ -905,12 +906,11 @@ again: | |||
905 | wret = btrfs_cow_block(trans, root, b, | 906 | wret = btrfs_cow_block(trans, root, b, |
906 | p->nodes[level + 1], | 907 | p->nodes[level + 1], |
907 | p->slots[level + 1], | 908 | p->slots[level + 1], |
908 | &cow_buf); | 909 | &b); |
909 | if (wret) { | 910 | if (wret) { |
910 | btrfs_block_release(root, cow_buf); | 911 | btrfs_block_release(root, b); |
911 | return wret; | 912 | return wret; |
912 | } | 913 | } |
913 | b = cow_buf; | ||
914 | c = btrfs_buffer_node(b); | 914 | c = btrfs_buffer_node(b); |
915 | } | 915 | } |
916 | BUG_ON(!cow && ins_len); | 916 | BUG_ON(!cow && ins_len); |
@@ -1075,8 +1075,9 @@ static int balance_node_right(struct btrfs_trans_handle *trans, struct | |||
1075 | 1075 | ||
1076 | max_push = src_nritems / 2 + 1; | 1076 | max_push = src_nritems / 2 + 1; |
1077 | /* don't try to empty the node */ | 1077 | /* don't try to empty the node */ |
1078 | if (max_push > src_nritems) | 1078 | if (max_push >= src_nritems) |
1079 | return 1; | 1079 | return 1; |
1080 | |||
1080 | if (max_push < push_items) | 1081 | if (max_push < push_items) |
1081 | push_items = max_push; | 1082 | push_items = max_push; |
1082 | 1083 | ||
@@ -1465,6 +1466,7 @@ static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root | |||
1465 | ret = btrfs_cow_block(trans, root, t, path->nodes[1], slot - 1, &t); | 1466 | ret = btrfs_cow_block(trans, root, t, path->nodes[1], slot - 1, &t); |
1466 | if (ret) { | 1467 | if (ret) { |
1467 | /* we hit -ENOSPC, but it isn't fatal here */ | 1468 | /* we hit -ENOSPC, but it isn't fatal here */ |
1469 | btrfs_block_release(root, t); | ||
1468 | return 1; | 1470 | return 1; |
1469 | } | 1471 | } |
1470 | left = btrfs_buffer_leaf(t); | 1472 | left = btrfs_buffer_leaf(t); |