提交 0636c73e 编写于 作者: E Eric Sandeen 提交者: Jan Kara

ext3: make barrier options consistent with ext4

ext4 was updated to accept barrier/nobarrier mount options
in addition to the older barrier=0/1.  The barrier story
is complex enough, we should help people by making the options
the same at least, even if the defaults are different.

This patch allows the barrier/nobarrier mount options for ext3,
while keeping nobarrier the default.

It also unconditionally displays barrier status in show_options,
and prints a message at mount time if barriers are not enabled,
just as ext4 does.
Signed-off-by: NEric Sandeen <sandeen@redhat.com>
Signed-off-by: NJan Kara <jack@suse.cz>
上级 dde95888
...@@ -59,8 +59,19 @@ commit=nrsec (*) Ext3 can be told to sync all its data and metadata ...@@ -59,8 +59,19 @@ commit=nrsec (*) Ext3 can be told to sync all its data and metadata
Setting it to very large values will improve Setting it to very large values will improve
performance. performance.
barrier=1 This enables/disables barriers. barrier=0 disables barrier=<0(*)|1> This enables/disables the use of write barriers in
it, barrier=1 enables it. barrier the jbd code. barrier=0 disables, barrier=1 enables.
nobarrier (*) This also requires an IO stack which can support
barriers, and if jbd gets an error on a barrier
write, it will disable again with a warning.
Write barriers enforce proper on-disk ordering
of journal commits, making volatile disk write caches
safe to use, at some performance penalty. If
your disks are battery-backed in one way or another,
disabling barriers may safely improve performance.
The mount options "barrier" and "nobarrier" can
also be used to enable or disable barriers, for
consistency with other ext3 mount options.
orlov (*) This enables the new Orlov block allocator. It is orlov (*) This enables the new Orlov block allocator. It is
enabled by default. enabled by default.
......
...@@ -653,8 +653,12 @@ static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs) ...@@ -653,8 +653,12 @@ static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs)
seq_printf(seq, ",commit=%u", seq_printf(seq, ",commit=%u",
(unsigned) (sbi->s_commit_interval / HZ)); (unsigned) (sbi->s_commit_interval / HZ));
} }
if (test_opt(sb, BARRIER))
seq_puts(seq, ",barrier=1"); /*
* Always display barrier state so it's clear what the status is.
*/
seq_puts(seq, ",barrier=");
seq_puts(seq, test_opt(sb, BARRIER) ? "1" : "0");
if (test_opt(sb, NOBH)) if (test_opt(sb, NOBH))
seq_puts(seq, ",nobh"); seq_puts(seq, ",nobh");
...@@ -810,8 +814,8 @@ enum { ...@@ -810,8 +814,8 @@ enum {
Opt_data_err_abort, Opt_data_err_ignore, Opt_data_err_abort, Opt_data_err_ignore,
Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota, Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota, Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
Opt_noquota, Opt_ignore, Opt_barrier, Opt_err, Opt_resize, Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
Opt_usrquota, Opt_grpquota Opt_resize, Opt_usrquota, Opt_grpquota
}; };
static const match_table_t tokens = { static const match_table_t tokens = {
...@@ -865,6 +869,8 @@ static const match_table_t tokens = { ...@@ -865,6 +869,8 @@ static const match_table_t tokens = {
{Opt_quota, "quota"}, {Opt_quota, "quota"},
{Opt_usrquota, "usrquota"}, {Opt_usrquota, "usrquota"},
{Opt_barrier, "barrier=%u"}, {Opt_barrier, "barrier=%u"},
{Opt_barrier, "barrier"},
{Opt_nobarrier, "nobarrier"},
{Opt_resize, "resize"}, {Opt_resize, "resize"},
{Opt_err, NULL}, {Opt_err, NULL},
}; };
...@@ -967,7 +973,11 @@ static int parse_options (char *options, struct super_block *sb, ...@@ -967,7 +973,11 @@ static int parse_options (char *options, struct super_block *sb,
int token; int token;
if (!*p) if (!*p)
continue; continue;
/*
* Initialize args struct so we know whether arg was
* found; some options take optional arguments.
*/
args[0].to = args[0].from = 0;
token = match_token(p, tokens, args); token = match_token(p, tokens, args);
switch (token) { switch (token) {
case Opt_bsd_df: case Opt_bsd_df:
...@@ -1215,9 +1225,15 @@ static int parse_options (char *options, struct super_block *sb, ...@@ -1215,9 +1225,15 @@ static int parse_options (char *options, struct super_block *sb,
case Opt_abort: case Opt_abort:
set_opt(sbi->s_mount_opt, ABORT); set_opt(sbi->s_mount_opt, ABORT);
break; break;
case Opt_nobarrier:
clear_opt(sbi->s_mount_opt, BARRIER);
break;
case Opt_barrier: case Opt_barrier:
if (args[0].from) {
if (match_int(&args[0], &option)) if (match_int(&args[0], &option))
return 0; return 0;
} else
option = 1; /* No argument, default to 1 */
if (option) if (option)
set_opt(sbi->s_mount_opt, BARRIER); set_opt(sbi->s_mount_opt, BARRIER);
else else
...@@ -2276,6 +2292,9 @@ static int ext3_load_journal(struct super_block *sb, ...@@ -2276,6 +2292,9 @@ static int ext3_load_journal(struct super_block *sb,
return -EINVAL; return -EINVAL;
} }
if (!(journal->j_flags & JFS_BARRIER))
printk(KERN_INFO "EXT3-fs: barriers not enabled\n");
if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) { if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) {
err = journal_update_format(journal); err = journal_update_format(journal);
if (err) { if (err) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册