diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-04-20 13:48:57 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-04-20 13:48:57 -0400 |
commit | 33ade1f826a7c348856a98930814f33ced6d1337 (patch) | |
tree | 86e40baecec46ffde0e58206ef148e212d980a32 /fs/btrfs | |
parent | e66f709b157ee8557166c14b67c01bae978ac32e (diff) |
Btrfs: node balance optimizations
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/ctree.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 744fd728e5d9..1bae035f5171 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -151,11 +151,6 @@ static int check_node(struct btrfs_root *root, struct btrfs_path *path, | |||
151 | for (i = 0; nritems > 1 && i < nritems - 2; i++) { | 151 | for (i = 0; nritems > 1 && i < nritems - 2; i++) { |
152 | struct btrfs_key cpukey; | 152 | struct btrfs_key cpukey; |
153 | btrfs_disk_key_to_cpu(&cpukey, &node->ptrs[i + 1].key); | 153 | btrfs_disk_key_to_cpu(&cpukey, &node->ptrs[i + 1].key); |
154 | if (comp_keys(&node->ptrs[i].key, &cpukey) >= 0) { | ||
155 | struct btrfs_key bad; | ||
156 | btrfs_disk_key_to_cpu(&bad, &node->ptrs[i].key); | ||
157 | printk("check_node level %d i is %d bad comp %Lu %u %Lu, %Lu %u %Lu\n",level, i, bad.objectid, bad.flags, bad.offset, cpukey.objectid, cpukey.flags, cpukey.offset); | ||
158 | } | ||
159 | BUG_ON(comp_keys(&node->ptrs[i].key, &cpukey) >= 0); | 154 | BUG_ON(comp_keys(&node->ptrs[i].key, &cpukey) >= 0); |
160 | } | 155 | } |
161 | return 0; | 156 | return 0; |
@@ -492,11 +487,16 @@ static int push_nodes_for_insert(struct btrfs_trans_handle *trans, | |||
492 | /* first, try to make some room in the middle buffer */ | 487 | /* first, try to make some room in the middle buffer */ |
493 | if (left_buf) { | 488 | if (left_buf) { |
494 | u32 left_nr; | 489 | u32 left_nr; |
495 | btrfs_cow_block(trans, root, left_buf, parent_buf, pslot - 1, | ||
496 | &left_buf); | ||
497 | left = btrfs_buffer_node(left_buf); | 490 | left = btrfs_buffer_node(left_buf); |
498 | left_nr = btrfs_header_nritems(&left->header); | 491 | left_nr = btrfs_header_nritems(&left->header); |
499 | wret = push_node_left(trans, root, left_buf, mid_buf); | 492 | if (left_nr >= BTRFS_NODEPTRS_PER_BLOCK(root) - 1) { |
493 | wret = 1; | ||
494 | } else { | ||
495 | btrfs_cow_block(trans, root, left_buf, parent_buf, | ||
496 | pslot - 1, &left_buf); | ||
497 | left = btrfs_buffer_node(left_buf); | ||
498 | wret = push_node_left(trans, root, left_buf, mid_buf); | ||
499 | } | ||
500 | if (wret < 0) | 500 | if (wret < 0) |
501 | ret = wret; | 501 | ret = wret; |
502 | if (wret == 0) { | 502 | if (wret == 0) { |
@@ -528,10 +528,18 @@ static int push_nodes_for_insert(struct btrfs_trans_handle *trans, | |||
528 | * then try to empty the right most buffer into the middle | 528 | * then try to empty the right most buffer into the middle |
529 | */ | 529 | */ |
530 | if (right_buf) { | 530 | if (right_buf) { |
531 | btrfs_cow_block(trans, root, right_buf, parent_buf, pslot + 1, | 531 | u32 right_nr; |
532 | &right_buf); | ||
533 | right = btrfs_buffer_node(right_buf); | 532 | right = btrfs_buffer_node(right_buf); |
534 | wret = balance_node_right(trans, root, right_buf, mid_buf); | 533 | right_nr = btrfs_header_nritems(&right->header); |
534 | if (right_nr >= BTRFS_NODEPTRS_PER_BLOCK(root) - 1) { | ||
535 | wret = 1; | ||
536 | } else { | ||
537 | btrfs_cow_block(trans, root, right_buf, | ||
538 | parent_buf, pslot + 1, &right_buf); | ||
539 | right = btrfs_buffer_node(right_buf); | ||
540 | wret = balance_node_right(trans, root, | ||
541 | right_buf, mid_buf); | ||
542 | } | ||
535 | if (wret < 0) | 543 | if (wret < 0) |
536 | ret = wret; | 544 | ret = wret; |
537 | if (wret == 0) { | 545 | if (wret == 0) { |