diff options
-rw-r--r-- | fs/btrfs/ctree.h | 1 | ||||
-rw-r--r-- | fs/btrfs/disk-io.c | 5 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 16 | ||||
-rw-r--r-- | fs/btrfs/super.c | 2 | ||||
-rw-r--r-- | fs/btrfs/transaction.c | 8 |
5 files changed, 18 insertions, 14 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index fb6fffb71dd0..1998f86df08a 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -306,6 +306,7 @@ struct btrfs_fs_info { | |||
306 | u64 generation; | 306 | u64 generation; |
307 | struct btrfs_transaction *running_transaction; | 307 | struct btrfs_transaction *running_transaction; |
308 | struct btrfs_super_block *disk_super; | 308 | struct btrfs_super_block *disk_super; |
309 | struct btrfs_super_block super_copy; | ||
309 | struct buffer_head *sb_buffer; | 310 | struct buffer_head *sb_buffer; |
310 | struct super_block *sb; | 311 | struct super_block *sb; |
311 | struct inode *btree_inode; | 312 | struct inode *btree_inode; |
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index d7615e1578cc..7081729d5b16 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -471,6 +471,8 @@ struct btrfs_root *open_ctree(struct super_block *sb) | |||
471 | if (!fs_info->sb_buffer) | 471 | if (!fs_info->sb_buffer) |
472 | goto fail_iput; | 472 | goto fail_iput; |
473 | disk_super = (struct btrfs_super_block *)fs_info->sb_buffer->b_data; | 473 | disk_super = (struct btrfs_super_block *)fs_info->sb_buffer->b_data; |
474 | fs_info->disk_super = disk_super; | ||
475 | memcpy(&fs_info->super_copy, disk_super, sizeof(fs_info->super_copy)); | ||
474 | 476 | ||
475 | if (!btrfs_super_root(disk_super)) | 477 | if (!btrfs_super_root(disk_super)) |
476 | goto fail_sb_buffer; | 478 | goto fail_sb_buffer; |
@@ -479,7 +481,6 @@ struct btrfs_root *open_ctree(struct super_block *sb) | |||
479 | btrfs_super_total_blocks(disk_super) << | 481 | btrfs_super_total_blocks(disk_super) << |
480 | fs_info->btree_inode->i_blkbits); | 482 | fs_info->btree_inode->i_blkbits); |
481 | 483 | ||
482 | fs_info->disk_super = disk_super; | ||
483 | 484 | ||
484 | if (strncmp((char *)(&disk_super->magic), BTRFS_MAGIC, | 485 | if (strncmp((char *)(&disk_super->magic), BTRFS_MAGIC, |
485 | sizeof(disk_super->magic))) { | 486 | sizeof(disk_super->magic))) { |
@@ -527,8 +528,6 @@ int write_ctree_super(struct btrfs_trans_handle *trans, struct btrfs_root | |||
527 | int ret; | 528 | int ret; |
528 | struct buffer_head *bh = root->fs_info->sb_buffer; | 529 | struct buffer_head *bh = root->fs_info->sb_buffer; |
529 | 530 | ||
530 | btrfs_set_super_root(root->fs_info->disk_super, | ||
531 | bh_blocknr(root->fs_info->tree_root->node)); | ||
532 | lock_buffer(bh); | 531 | lock_buffer(bh); |
533 | WARN_ON(atomic_read(&bh->b_count) < 1); | 532 | WARN_ON(atomic_read(&bh->b_count) < 1); |
534 | clear_buffer_dirty(bh); | 533 | clear_buffer_dirty(bh); |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 8025e9f8ef19..7e550343aee7 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -796,8 +796,8 @@ static int finish_current_insert(struct btrfs_trans_handle *trans, struct | |||
796 | 796 | ||
797 | for (i = 0; i < extent_root->fs_info->extent_tree_insert_nr; i++) { | 797 | for (i = 0; i < extent_root->fs_info->extent_tree_insert_nr; i++) { |
798 | ins.objectid = extent_root->fs_info->extent_tree_insert[i]; | 798 | ins.objectid = extent_root->fs_info->extent_tree_insert[i]; |
799 | super_blocks_used = btrfs_super_blocks_used(info->disk_super); | 799 | super_blocks_used = btrfs_super_blocks_used(&info->super_copy); |
800 | btrfs_set_super_blocks_used(info->disk_super, | 800 | btrfs_set_super_blocks_used(&info->super_copy, |
801 | super_blocks_used + 1); | 801 | super_blocks_used + 1); |
802 | ret = btrfs_insert_item(trans, extent_root, &ins, &extent_item, | 802 | ret = btrfs_insert_item(trans, extent_root, &ins, &extent_item, |
803 | sizeof(extent_item)); | 803 | sizeof(extent_item)); |
@@ -892,8 +892,8 @@ static int __free_extent(struct btrfs_trans_handle *trans, struct btrfs_root | |||
892 | BUG_ON(ret); | 892 | BUG_ON(ret); |
893 | } | 893 | } |
894 | 894 | ||
895 | super_blocks_used = btrfs_super_blocks_used(info->disk_super); | 895 | super_blocks_used = btrfs_super_blocks_used(&info->super_copy); |
896 | btrfs_set_super_blocks_used(info->disk_super, | 896 | btrfs_set_super_blocks_used(&info->super_copy, |
897 | super_blocks_used - num_blocks); | 897 | super_blocks_used - num_blocks); |
898 | ret = btrfs_del_item(trans, extent_root, path); | 898 | ret = btrfs_del_item(trans, extent_root, path); |
899 | if (ret) { | 899 | if (ret) { |
@@ -1032,7 +1032,7 @@ static int find_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root | |||
1032 | info->extent_tree_prealloc_nr = 0; | 1032 | info->extent_tree_prealloc_nr = 0; |
1033 | } | 1033 | } |
1034 | if (search_end == (u64)-1) | 1034 | if (search_end == (u64)-1) |
1035 | search_end = btrfs_super_total_blocks(info->disk_super); | 1035 | search_end = btrfs_super_total_blocks(&info->super_copy); |
1036 | if (hint_block) { | 1036 | if (hint_block) { |
1037 | block_group = btrfs_lookup_block_group(info, hint_block); | 1037 | block_group = btrfs_lookup_block_group(info, hint_block); |
1038 | block_group = btrfs_find_block_group(root, block_group, | 1038 | block_group = btrfs_find_block_group(root, block_group, |
@@ -1361,8 +1361,8 @@ int btrfs_alloc_extent(struct btrfs_trans_handle *trans, | |||
1361 | } | 1361 | } |
1362 | } | 1362 | } |
1363 | 1363 | ||
1364 | super_blocks_used = btrfs_super_blocks_used(info->disk_super); | 1364 | super_blocks_used = btrfs_super_blocks_used(&info->super_copy); |
1365 | btrfs_set_super_blocks_used(info->disk_super, super_blocks_used + | 1365 | btrfs_set_super_blocks_used(&info->super_copy, super_blocks_used + |
1366 | num_blocks); | 1366 | num_blocks); |
1367 | ret = btrfs_insert_item(trans, extent_root, ins, &extent_item, | 1367 | ret = btrfs_insert_item(trans, extent_root, ins, &extent_item, |
1368 | sizeof(extent_item)); | 1368 | sizeof(extent_item)); |
@@ -1737,7 +1737,7 @@ int btrfs_read_block_groups(struct btrfs_root *root) | |||
1737 | BTRFS_BLOCK_GROUP_AVAIL); | 1737 | BTRFS_BLOCK_GROUP_AVAIL); |
1738 | } | 1738 | } |
1739 | if (key.objectid >= | 1739 | if (key.objectid >= |
1740 | btrfs_super_total_blocks(info->disk_super)) | 1740 | btrfs_super_total_blocks(&info->super_copy)) |
1741 | break; | 1741 | break; |
1742 | } | 1742 | } |
1743 | 1743 | ||
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index c11ecf500202..2e797d5fb281 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -144,7 +144,7 @@ static int btrfs_get_sb(struct file_system_type *fs_type, | |||
144 | static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf) | 144 | static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf) |
145 | { | 145 | { |
146 | struct btrfs_root *root = btrfs_sb(dentry->d_sb); | 146 | struct btrfs_root *root = btrfs_sb(dentry->d_sb); |
147 | struct btrfs_super_block *disk_super = root->fs_info->disk_super; | 147 | struct btrfs_super_block *disk_super = &root->fs_info->super_copy; |
148 | 148 | ||
149 | buf->f_namelen = BTRFS_NAME_LEN; | 149 | buf->f_namelen = BTRFS_NAME_LEN; |
150 | buf->f_blocks = btrfs_super_total_blocks(disk_super); | 150 | buf->f_blocks = btrfs_super_total_blocks(disk_super); |
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index a5a63d471e43..3b2face593e9 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -380,6 +380,12 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
380 | else | 380 | else |
381 | prev_trans->use_count++; | 381 | prev_trans->use_count++; |
382 | } | 382 | } |
383 | btrfs_set_super_generation(&root->fs_info->super_copy, | ||
384 | cur_trans->transid); | ||
385 | btrfs_set_super_root(&root->fs_info->super_copy, | ||
386 | bh_blocknr(root->fs_info->tree_root->node)); | ||
387 | memcpy(root->fs_info->disk_super, &root->fs_info->super_copy, | ||
388 | sizeof(root->fs_info->super_copy)); | ||
383 | mutex_unlock(&root->fs_info->trans_mutex); | 389 | mutex_unlock(&root->fs_info->trans_mutex); |
384 | mutex_unlock(&root->fs_info->fs_mutex); | 390 | mutex_unlock(&root->fs_info->fs_mutex); |
385 | ret = btrfs_write_and_wait_transaction(trans, root); | 391 | ret = btrfs_write_and_wait_transaction(trans, root); |
@@ -389,8 +395,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, | |||
389 | put_transaction(prev_trans); | 395 | put_transaction(prev_trans); |
390 | mutex_unlock(&root->fs_info->trans_mutex); | 396 | mutex_unlock(&root->fs_info->trans_mutex); |
391 | } | 397 | } |
392 | btrfs_set_super_generation(root->fs_info->disk_super, | ||
393 | cur_trans->transid); | ||
394 | BUG_ON(ret); | 398 | BUG_ON(ret); |
395 | write_ctree_super(trans, root); | 399 | write_ctree_super(trans, root); |
396 | 400 | ||