aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-01-09 09:23:21 -0500
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:59 -0400
commit21ad10cf3e9c1ef42e725e5c3a593c49f779a16b (patch)
tree94eaa869bd3af0329ce3d5ed74d63f041c39dc5c
parentbcd987feefe8da66bc59b4e6bd51761a9820588c (diff)
Btrfs: Add flush barriers on commit
Signed-off-by: Chris Mason <chris.mason@oracle.com>
-rw-r--r--fs/btrfs/ctree.h5
-rw-r--r--fs/btrfs/disk-io.c5
-rw-r--r--fs/btrfs/super.c9
3 files changed, 16 insertions, 3 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 7eda51542d17..0c0edacbc14c 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -440,8 +440,9 @@ struct btrfs_root {
440 */ 440 */
441#define BTRFS_STRING_ITEM_KEY 253 441#define BTRFS_STRING_ITEM_KEY 253
442 442
443#define BTRFS_MOUNT_NODATASUM 0x1 443#define BTRFS_MOUNT_NODATASUM (1 << 0)
444#define BTRFS_MOUNT_NODATACOW 0x2 444#define BTRFS_MOUNT_NODATACOW (1 << 1)
445#define BTRFS_MOUNT_NOBARRIER (1 << 2)
445 446
446#define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt) 447#define btrfs_clear_opt(o, opt) ((o) &= ~BTRFS_MOUNT_##opt)
447#define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt) 448#define btrfs_set_opt(o, opt) ((o) |= BTRFS_MOUNT_##opt)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index e0940a39ff07..a481b970608c 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -762,10 +762,15 @@ int write_ctree_super(struct btrfs_trans_handle *trans, struct btrfs_root
762 int ret; 762 int ret;
763 struct extent_buffer *super = root->fs_info->sb_buffer; 763 struct extent_buffer *super = root->fs_info->sb_buffer;
764 struct inode *btree_inode = root->fs_info->btree_inode; 764 struct inode *btree_inode = root->fs_info->btree_inode;
765 struct super_block *sb = root->fs_info->sb;
765 766
767 if (!btrfs_test_opt(root, NOBARRIER))
768 blkdev_issue_flush(sb->s_bdev, NULL);
766 set_extent_buffer_dirty(&BTRFS_I(btree_inode)->extent_tree, super); 769 set_extent_buffer_dirty(&BTRFS_I(btree_inode)->extent_tree, super);
767 ret = sync_page_range_nolock(btree_inode, btree_inode->i_mapping, 770 ret = sync_page_range_nolock(btree_inode, btree_inode->i_mapping,
768 super->start, super->len); 771 super->start, super->len);
772 if (!btrfs_test_opt(root, NOBARRIER))
773 blkdev_issue_flush(sb->s_bdev, NULL);
769 return ret; 774 return ret;
770} 775}
771 776
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index f1b56eb77b1d..9ab4086d463c 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -64,13 +64,14 @@ static void btrfs_put_super (struct super_block * sb)
64 64
65enum { 65enum {
66 Opt_subvol, Opt_nodatasum, Opt_nodatacow, Opt_max_extent, 66 Opt_subvol, Opt_nodatasum, Opt_nodatacow, Opt_max_extent,
67 Opt_alloc_start, Opt_err, 67 Opt_alloc_start, Opt_nobarrier, Opt_err,
68}; 68};
69 69
70static match_table_t tokens = { 70static match_table_t tokens = {
71 {Opt_subvol, "subvol=%s"}, 71 {Opt_subvol, "subvol=%s"},
72 {Opt_nodatasum, "nodatasum"}, 72 {Opt_nodatasum, "nodatasum"},
73 {Opt_nodatacow, "nodatacow"}, 73 {Opt_nodatacow, "nodatacow"},
74 {Opt_nobarrier, "nobarrier"},
74 {Opt_max_extent, "max_extent=%s"}, 75 {Opt_max_extent, "max_extent=%s"},
75 {Opt_alloc_start, "alloc_start=%s"}, 76 {Opt_alloc_start, "alloc_start=%s"},
76 {Opt_err, NULL} 77 {Opt_err, NULL}
@@ -148,6 +149,12 @@ static int parse_options (char * options,
148 btrfs_set_opt(info->mount_opt, NODATASUM); 149 btrfs_set_opt(info->mount_opt, NODATASUM);
149 } 150 }
150 break; 151 break;
152 case Opt_nobarrier:
153 if (info) {
154 printk("btrfs: turning off barriers\n");
155 btrfs_set_opt(info->mount_opt, NOBARRIER);
156 }
157 break;
151 case Opt_max_extent: 158 case Opt_max_extent:
152 if (info) { 159 if (info) {
153 char *num = match_strdup(&args[0]); 160 char *num = match_strdup(&args[0]);