aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/transaction.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-10-15 16:15:53 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:56 -0400
commitdb94535db75e67fab12ccbb7f5ee548e33fed891 (patch)
tree1ad7dfc82b003294a94ee87d7329b24b902b369f /fs/btrfs/transaction.c
parent1a5bc167f6707542b79a55452075525620ed43f5 (diff)
Btrfs: Allow tree blocks larger than the page size
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r--fs/btrfs/transaction.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 55289b71056e..60f61345a8d0 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -205,12 +205,13 @@ int btrfs_commit_tree_roots(struct btrfs_trans_handle *trans,
205 205
206 btrfs_write_dirty_block_groups(trans, extent_root); 206 btrfs_write_dirty_block_groups(trans, extent_root);
207 while(1) { 207 while(1) {
208 old_extent_block = btrfs_root_blocknr(&extent_root->root_item); 208 old_extent_block = btrfs_root_bytenr(&extent_root->root_item);
209 if (old_extent_block == 209 if (old_extent_block == extent_root->node->start)
210 extent_buffer_blocknr(extent_root->node))
211 break; 210 break;
212 btrfs_set_root_blocknr(&extent_root->root_item, 211 btrfs_set_root_bytenr(&extent_root->root_item,
213 extent_buffer_blocknr(extent_root->node)); 212 extent_root->node->start);
213 btrfs_set_root_level(&extent_root->root_item,
214 btrfs_header_level(extent_root->node));
214 ret = btrfs_update_root(trans, tree_root, 215 ret = btrfs_update_root(trans, tree_root,
215 &extent_root->root_key, 216 &extent_root->root_key,
216 &extent_root->root_item); 217 &extent_root->root_item);
@@ -284,8 +285,8 @@ static int add_dirty_roots(struct btrfs_trans_handle *trans,
284 (unsigned long)root->root_key.objectid, 285 (unsigned long)root->root_key.objectid,
285 BTRFS_ROOT_TRANS_TAG); 286 BTRFS_ROOT_TRANS_TAG);
286 if (root->commit_root == root->node) { 287 if (root->commit_root == root->node) {
287 WARN_ON(extent_buffer_blocknr(root->node) != 288 WARN_ON(root->node->start !=
288 btrfs_root_blocknr(&root->root_item)); 289 btrfs_root_bytenr(&root->root_item));
289 free_extent_buffer(root->commit_root); 290 free_extent_buffer(root->commit_root);
290 root->commit_root = NULL; 291 root->commit_root = NULL;
291 292
@@ -314,8 +315,10 @@ static int add_dirty_roots(struct btrfs_trans_handle *trans,
314 root->commit_root = NULL; 315 root->commit_root = NULL;
315 316
316 root->root_key.offset = root->fs_info->generation; 317 root->root_key.offset = root->fs_info->generation;
317 btrfs_set_root_blocknr(&root->root_item, 318 btrfs_set_root_bytenr(&root->root_item,
318 extent_buffer_blocknr(root->node)); 319 root->node->start);
320 btrfs_set_root_level(&root->root_item,
321 btrfs_header_level(root->node));
319 err = btrfs_insert_root(trans, root->fs_info->tree_root, 322 err = btrfs_insert_root(trans, root->fs_info->tree_root,
320 &root->root_key, 323 &root->root_key,
321 &root->root_item); 324 &root->root_item);
@@ -407,8 +410,8 @@ static int drop_dirty_roots(struct btrfs_root *tree_root,
407 struct dirty_root *dirty; 410 struct dirty_root *dirty;
408 struct btrfs_trans_handle *trans; 411 struct btrfs_trans_handle *trans;
409 unsigned long nr; 412 unsigned long nr;
410 u64 num_blocks; 413 u64 num_bytes;
411 u64 blocks_used; 414 u64 bytes_used;
412 int ret = 0; 415 int ret = 0;
413 int err; 416 int err;
414 417
@@ -419,7 +422,7 @@ static int drop_dirty_roots(struct btrfs_root *tree_root,
419 dirty = list_entry(list->next, struct dirty_root, list); 422 dirty = list_entry(list->next, struct dirty_root, list);
420 list_del_init(&dirty->list); 423 list_del_init(&dirty->list);
421 424
422 num_blocks = btrfs_root_used(&dirty->root->root_item); 425 num_bytes = btrfs_root_used(&dirty->root->root_item);
423 root = dirty->latest_root; 426 root = dirty->latest_root;
424 427
425 while(1) { 428 while(1) {
@@ -446,12 +449,12 @@ static int drop_dirty_roots(struct btrfs_root *tree_root,
446 } 449 }
447 BUG_ON(ret); 450 BUG_ON(ret);
448 451
449 num_blocks -= btrfs_root_used(&dirty->root->root_item); 452 num_bytes -= btrfs_root_used(&dirty->root->root_item);
450 blocks_used = btrfs_root_used(&root->root_item); 453 bytes_used = btrfs_root_used(&root->root_item);
451 if (num_blocks) { 454 if (num_bytes) {
452 record_root_in_trans(root); 455 record_root_in_trans(root);
453 btrfs_set_root_used(&root->root_item, 456 btrfs_set_root_used(&root->root_item,
454 blocks_used - num_blocks); 457 bytes_used - num_bytes);
455 } 458 }
456 ret = btrfs_del_root(trans, tree_root, &dirty->root->root_key); 459 ret = btrfs_del_root(trans, tree_root, &dirty->root->root_key);
457 if (ret) { 460 if (ret) {
@@ -560,7 +563,9 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
560 btrfs_set_super_generation(&root->fs_info->super_copy, 563 btrfs_set_super_generation(&root->fs_info->super_copy,
561 cur_trans->transid); 564 cur_trans->transid);
562 btrfs_set_super_root(&root->fs_info->super_copy, 565 btrfs_set_super_root(&root->fs_info->super_copy,
563 extent_buffer_blocknr(root->fs_info->tree_root->node)); 566 root->fs_info->tree_root->node->start);
567 btrfs_set_super_root_level(&root->fs_info->super_copy,
568 btrfs_header_level(root->fs_info->tree_root->node));
564 569
565 write_extent_buffer(root->fs_info->sb_buffer, 570 write_extent_buffer(root->fs_info->sb_buffer,
566 &root->fs_info->super_copy, 0, 571 &root->fs_info->super_copy, 0,