* [PATCH] ext4: Add mount options in superblock
@ 2010-08-02 3:15 Theodore Ts'o
2010-08-03 17:55 ` Andreas Dilger
0 siblings, 1 reply; 3+ messages in thread
From: Theodore Ts'o @ 2010-08-02 3:15 UTC (permalink / raw)
To: Ext4 Developers List; +Cc: Theodore Ts'o
Allow mount options to be stored in the superblock. Also add default
mount option bits for nobarrier, block_validity, discard, and nodelalloc.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
fs/ext4/ext4.h | 9 +++++++--
fs/ext4/super.c | 29 +++++++++++++++++++++++------
2 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 9ca3637..ed14e1d 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1025,8 +1025,9 @@ struct ext4_super_block {
__le32 s_last_error_line; /* line number where error happened */
__le64 s_last_error_block; /* block involved of last error */
__u8 s_last_error_func[32]; /* function where the error happened */
-#define EXT4_S_ERR_END offsetof(struct ext4_super_block, s_reserved)
- __le32 s_reserved[128]; /* Padding to the end of the block */
+#define EXT4_S_ERR_END offsetof(struct ext4_super_block, s_mount_opts)
+ __u8 s_mount_opts[64];
+ __le32 s_reserved[112]; /* Padding to the end of the block */
};
#define EXT4_S_ERR_LEN (EXT4_S_ERR_END - EXT4_S_ERR_START)
@@ -1341,6 +1342,10 @@ EXT4_INODE_BIT_FNS(state, state_flags)
#define EXT4_DEFM_JMODE_DATA 0x0020
#define EXT4_DEFM_JMODE_ORDERED 0x0040
#define EXT4_DEFM_JMODE_WBACK 0x0060
+#define EXT4_DEFM_NOBARRIER 0x0100
+#define EXT4_DEFM_BLOCK_VALIDITY 0x0200
+#define EXT4_DEFM_DISCARD 0x0400
+#define EXT4_DEFM_NODELALLOC 0x0800
/*
* Default journal batch times
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 3e3f648..3fd65eb 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1003,10 +1003,10 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs)
seq_puts(seq, ",journal_checksum");
if (test_opt(sb, I_VERSION))
seq_puts(seq, ",i_version");
- if (!test_opt(sb, DELALLOC))
+ if (!test_opt(sb, DELALLOC) &&
+ !(def_mount_opts & EXT4_DEFM_NODELALLOC))
seq_puts(seq, ",nodelalloc");
-
if (sbi->s_stripe)
seq_printf(seq, ",stripe=%lu", sbi->s_stripe);
/*
@@ -1030,7 +1030,7 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs)
if (test_opt(sb, NO_AUTO_DA_ALLOC))
seq_puts(seq, ",noauto_da_alloc");
- if (test_opt(sb, DISCARD))
+ if (test_opt(sb, DISCARD) && !(def_mount_opts & EXT4_DEFM_DISCARD))
seq_puts(seq, ",discard");
if (test_opt(sb, NOLOAD))
@@ -1039,6 +1039,10 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs)
if (test_opt(sb, DIOREAD_NOLOCK))
seq_puts(seq, ",dioread_nolock");
+ if (test_opt(sb, BLOCK_VALIDITY) &&
+ !(def_mount_opts & EXT4_DEFM_BLOCK_VALIDITY))
+ seq_puts(seq, ",block_validity");
+
ext4_show_quota_options(seq, sb);
return 0;
@@ -2655,6 +2659,10 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
set_opt(sbi->s_mount_opt, ERRORS_CONT);
else
set_opt(sbi->s_mount_opt, ERRORS_RO);
+ if (def_mount_opts & EXT4_DEFM_BLOCK_VALIDITY)
+ set_opt(sbi->s_mount_opt, BLOCK_VALIDITY);
+ if (def_mount_opts & EXT4_DEFM_DISCARD)
+ set_opt(sbi->s_mount_opt, DISCARD);
sbi->s_resuid = le16_to_cpu(es->s_def_resuid);
sbi->s_resgid = le16_to_cpu(es->s_def_resgid);
@@ -2662,15 +2670,23 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
sbi->s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME;
sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME;
- set_opt(sbi->s_mount_opt, BARRIER);
+ if ((def_mount_opts & EXT4_DEFM_NOBARRIER) == 0)
+ set_opt(sbi->s_mount_opt, BARRIER);
/*
* enable delayed allocation by default
* Use -o nodelalloc to turn it off
*/
- if (!IS_EXT3_SB(sb))
+ if (!IS_EXT3_SB(sb) &&
+ ((def_mount_opts & EXT4_DEFM_NODELALLOC) == 0))
set_opt(sbi->s_mount_opt, DELALLOC);
+ if (!parse_options((char *) sbi->s_es->s_mount_opts, sb,
+ &journal_devnum, &journal_ioprio, NULL, 0)) {
+ ext4_msg(sb, KERN_WARNING,
+ "failed to parse options in superblock: %s",
+ sbi->s_es->s_mount_opts);
+ }
if (!parse_options((char *) data, sb, &journal_devnum,
&journal_ioprio, NULL, 0))
goto failed_mount;
@@ -3141,7 +3157,8 @@ no_journal:
descr = "out journal";
ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. "
- "Opts: %s", descr, orig_data);
+ "Opts: %s%s%s", descr, sbi->s_es->s_mount_opts,
+ *sbi->s_es->s_mount_opts ? "; " : "", orig_data);
init_timer(&sbi->s_err_report);
sbi->s_err_report.function = print_daily_error_info;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ext4: Add mount options in superblock
2010-08-02 3:15 [PATCH] ext4: Add mount options in superblock Theodore Ts'o
@ 2010-08-03 17:55 ` Andreas Dilger
2010-08-03 18:31 ` Ted Ts'o
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Dilger @ 2010-08-03 17:55 UTC (permalink / raw)
To: Theodore Ts'o; +Cc: Ext4 Developers List
On 2010-08-01, at 21:15, Theodore Ts'o wrote:
> Allow mount options to be stored in the superblock. Also add default
> mount option bits for nobarrier, block_validity, discard, and nodelalloc.
Don't we already store mount options in s_default_mount_opts? It seems more efficient to store them as binary flags instead of as a string.
Cheers, Andreas
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ext4: Add mount options in superblock
2010-08-03 17:55 ` Andreas Dilger
@ 2010-08-03 18:31 ` Ted Ts'o
0 siblings, 0 replies; 3+ messages in thread
From: Ted Ts'o @ 2010-08-03 18:31 UTC (permalink / raw)
To: Andreas Dilger; +Cc: Ext4 Developers List
On Tue, Aug 03, 2010 at 11:55:39AM -0600, Andreas Dilger wrote:
> On 2010-08-01, at 21:15, Theodore Ts'o wrote:
> > Allow mount options to be stored in the superblock. Also add default
> > mount option bits for nobarrier, block_validity, discard, and nodelalloc.
>
> Don't we already store mount options in s_default_mount_opts? It
> seems more efficient to store them as binary flags instead of as a
> string.
For mount options that are going to be around for a long time, this
makes sense and it is indeed the preferred mechanism. The problem is
that if we are adding and removing mount options, perhaps for internal
testing purposes using binary bitfields don't work as well, because
(a) it means we have to synchronize e2fsprogs with the kernel updates,
and (b) once used, it's hard to recycle a binary bit position since
there might be old file systems around. So the 64 byte character
array is intended to be used as an adjunct for the binary bitfield.
- Ted
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-08-03 18:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-02 3:15 [PATCH] ext4: Add mount options in superblock Theodore Ts'o
2010-08-03 17:55 ` Andreas Dilger
2010-08-03 18:31 ` Ted Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).