summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-04-20 13:16:02 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-04-20 13:16:02 -0400
commite66f709b157ee8557166c14b67c01bae978ac32e (patch)
tree69a0c17aaffb173095e105a4680bedbefcb13c84 /fs/btrfs/disk-io.c
parent8fd17795b2261ecb1bad2a6df09ef14c4957a3fb (diff)
downloadlinux-stable-e66f709b157ee8557166c14b67c01bae978ac32e.tar.gz
linux-stable-e66f709b157ee8557166c14b67c01bae978ac32e.tar.bz2
linux-stable-e66f709b157ee8557166c14b67c01bae978ac32e.zip
Btrfs: write barriers on commit, balance level before split
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index b666c3571aee..13046295bf7a 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -540,6 +540,7 @@ struct btrfs_root *open_ctree(struct super_block *sb)
fs_info->btree_inode->i_nlink = 1;
fs_info->btree_inode->i_size = sb->s_bdev->bd_inode->i_size;
fs_info->btree_inode->i_mapping->a_ops = &btree_aops;
+ fs_info->do_barriers = 1;
BTRFS_I(fs_info->btree_inode)->root = tree_root;
memset(&BTRFS_I(fs_info->btree_inode)->location, 0,
sizeof(struct btrfs_key));
@@ -622,6 +623,7 @@ struct btrfs_root *open_ctree(struct super_block *sb)
int write_ctree_super(struct btrfs_trans_handle *trans, struct btrfs_root
*root)
{
+ int ret;
struct buffer_head *bh = root->fs_info->sb_buffer;
btrfs_set_super_root(root->fs_info->disk_super,
@@ -632,7 +634,15 @@ int write_ctree_super(struct btrfs_trans_handle *trans, struct btrfs_root
csum_tree_block(root, bh, 0);
bh->b_end_io = end_buffer_write_sync;
get_bh(bh);
- submit_bh(WRITE, bh);
+ if (root->fs_info->do_barriers)
+ ret = submit_bh(WRITE_BARRIER, bh);
+ else
+ ret = submit_bh(WRITE, bh);
+ if (ret == -EOPNOTSUPP) {
+ set_buffer_uptodate(bh);
+ root->fs_info->do_barriers = 0;
+ ret = submit_bh(WRITE, bh);
+ }
wait_on_buffer(bh);
if (!buffer_uptodate(bh)) {
WARN_ON(1);