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>
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index d7615e1..7081729 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -471,6 +471,8 @@
if (!fs_info->sb_buffer)
goto fail_iput;
disk_super = (struct btrfs_super_block *)fs_info->sb_buffer->b_data;
+ fs_info->disk_super = disk_super;
+ memcpy(&fs_info->super_copy, disk_super, sizeof(fs_info->super_copy));
if (!btrfs_super_root(disk_super))
goto fail_sb_buffer;
@@ -479,7 +481,6 @@
btrfs_super_total_blocks(disk_super) <<
fs_info->btree_inode->i_blkbits);
- fs_info->disk_super = disk_super;
if (strncmp((char *)(&disk_super->magic), BTRFS_MAGIC,
sizeof(disk_super->magic))) {
@@ -527,8 +528,6 @@
int ret;
struct buffer_head *bh = root->fs_info->sb_buffer;
- btrfs_set_super_root(root->fs_info->disk_super,
- bh_blocknr(root->fs_info->tree_root->node));
lock_buffer(bh);
WARN_ON(atomic_read(&bh->b_count) < 1);
clear_buffer_dirty(bh);