diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-06-26 10:06:50 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-06-26 10:06:50 -0400 |
commit | 4b52dff6d371b9b93bc99f64c32831ea9a8ec3ac (patch) | |
tree | 160a5fb1d8ab8e593775962aedac6ef770da7f3c /fs/btrfs/disk-io.c | |
parent | 79c44584ea346024e929ac0f2a3577aac33b7b3f (diff) |
Btrfs: Fix super block updates during transaction commit
The super block written during commit was not consistent with the state of
the trees. This change adds an in-memory copy of the super so that we can
make sure to write out consistent data during a commit.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r-- | fs/btrfs/disk-io.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index d7615e1578c..7081729d5b1 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); |