aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/super.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2013-08-01 12:14:52 -0400
committerChris Mason <chris.mason@fusionio.com>2013-09-01 08:04:51 -0400
commit8b87dc17fbc7443bf4c6c096279c35e89fb51326 (patch)
treeaa53657898d003b48135fe4b959c97b48e591339 /fs/btrfs/super.c
parent9ec726775188906192f78ab9187640afd81ab996 (diff)
btrfs: add mount option to set commit interval
I'ts hardcoded to 30 seconds which is fine for most users. Higher values defer data being synced to permanent storage with obvious consequences when the system crashes. The upper bound is not forced, but a warning is printed if it's more than 300 seconds (5 minutes). Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r--fs/btrfs/super.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 2cc5b80eeae9..196790375bb3 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -321,6 +321,7 @@ enum {
321 Opt_no_space_cache, Opt_recovery, Opt_skip_balance, 321 Opt_no_space_cache, Opt_recovery, Opt_skip_balance,
322 Opt_check_integrity, Opt_check_integrity_including_extent_data, 322 Opt_check_integrity, Opt_check_integrity_including_extent_data,
323 Opt_check_integrity_print_mask, Opt_fatal_errors, 323 Opt_check_integrity_print_mask, Opt_fatal_errors,
324 Opt_commit_interval,
324 Opt_err, 325 Opt_err,
325}; 326};
326 327
@@ -361,6 +362,7 @@ static match_table_t tokens = {
361 {Opt_check_integrity_including_extent_data, "check_int_data"}, 362 {Opt_check_integrity_including_extent_data, "check_int_data"},
362 {Opt_check_integrity_print_mask, "check_int_print_mask=%d"}, 363 {Opt_check_integrity_print_mask, "check_int_print_mask=%d"},
363 {Opt_fatal_errors, "fatal_errors=%s"}, 364 {Opt_fatal_errors, "fatal_errors=%s"},
365 {Opt_commit_interval, "commit=%d"},
364 {Opt_err, NULL}, 366 {Opt_err, NULL},
365}; 367};
366 368
@@ -645,6 +647,29 @@ int btrfs_parse_options(struct btrfs_root *root, char *options)
645 goto out; 647 goto out;
646 } 648 }
647 break; 649 break;
650 case Opt_commit_interval:
651 intarg = 0;
652 ret = match_int(&args[0], &intarg);
653 if (ret < 0) {
654 printk(KERN_ERR
655 "btrfs: invalid commit interval\n");
656 ret = -EINVAL;
657 goto out;
658 }
659 if (intarg > 0) {
660 if (intarg > 300) {
661 printk(KERN_WARNING
662 "btrfs: excessive commit interval %d\n",
663 intarg);
664 }
665 info->commit_interval = intarg;
666 } else {
667 printk(KERN_INFO
668 "btrfs: using default commit interval %ds\n",
669 BTRFS_DEFAULT_COMMIT_INTERVAL);
670 info->commit_interval = BTRFS_DEFAULT_COMMIT_INTERVAL;
671 }
672 break;
648 case Opt_err: 673 case Opt_err:
649 printk(KERN_INFO "btrfs: unrecognized mount option " 674 printk(KERN_INFO "btrfs: unrecognized mount option "
650 "'%s'\n", p); 675 "'%s'\n", p);
@@ -981,6 +1006,8 @@ static int btrfs_show_options(struct seq_file *seq, struct dentry *dentry)
981 info->metadata_ratio); 1006 info->metadata_ratio);
982 if (btrfs_test_opt(root, PANIC_ON_FATAL_ERROR)) 1007 if (btrfs_test_opt(root, PANIC_ON_FATAL_ERROR))
983 seq_puts(seq, ",fatal_errors=panic"); 1008 seq_puts(seq, ",fatal_errors=panic");
1009 if (info->commit_interval != BTRFS_DEFAULT_COMMIT_INTERVAL)
1010 seq_printf(seq, ",commit=%d", info->commit_interval);
984 return 0; 1011 return 0;
985} 1012}
986 1013