* [PATCH 1/2] ext4: explicit mount options parsing cleanup @ 2015-10-09 9:09 Dmitry Monakhov 2015-10-09 9:09 ` [PATCH 2/2] ext4: do not allow journal_opts for fs w/o journal Dmitry Monakhov 2015-10-19 3:57 ` [PATCH 1/2] ext4: explicit mount options parsing cleanup Theodore Ts'o 0 siblings, 2 replies; 5+ messages in thread From: Dmitry Monakhov @ 2015-10-09 9:09 UTC (permalink / raw) To: linux-ext4; +Cc: tytso, Dmitry Monakhov Currently MOPT_EXPLICIT treated as EXPLICIT_DELALLOC which may be changed in future. Let's fix it now. Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> --- fs/ext4/super.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 7ef3fa5..e91f6d4 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1503,8 +1503,12 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token, return -1; if (args->from && (m->flags & MOPT_GTE0) && (arg < 0)) return -1; - if (m->flags & MOPT_EXPLICIT) - set_opt2(sb, EXPLICIT_DELALLOC); + if (m->flags & MOPT_EXPLICIT) { + if (m->mount_opt & EXT4_MOUNT_DELALLOC) { + set_opt2(sb, EXPLICIT_DELALLOC); + } else + return -1; + } if (m->flags & MOPT_CLEAR_ERR) clear_opt(sb, ERRORS_MASK); if (token == Opt_noquota && sb_any_quota_loaded(sb)) { -- 1.7.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] ext4: do not allow journal_opts for fs w/o journal 2015-10-09 9:09 [PATCH 1/2] ext4: explicit mount options parsing cleanup Dmitry Monakhov @ 2015-10-09 9:09 ` Dmitry Monakhov 2015-10-09 20:53 ` Andreas Dilger 2015-10-19 3:57 ` [PATCH 1/2] ext4: explicit mount options parsing cleanup Theodore Ts'o 1 sibling, 1 reply; 5+ messages in thread From: Dmitry Monakhov @ 2015-10-09 9:09 UTC (permalink / raw) To: linux-ext4; +Cc: tytso, Dmitry Monakhov It is appeared that we can pass journal related mount options and such options be shown in /proc/mounts Example: #mkfs.ext4 -F /dev/vdb #tune2fs -O ^has_journal /dev/vdb #mount /dev/vdb /mnt/ -ocommit=20,journal_async_commit #cat /proc/mounts | grep /mnt /dev/vdb /mnt ext4 rw,relatime,journal_checksum,journal_async_commit,commit=20,data=ordered 0 0 But options:"journal_checksum,journal_async_commit,commit=20,data=ordered" has nothing with reality because there is no jornall at all. This patch disallow following options for journalless configurations: - journal_checksum - journal_async_commit - commit=%ld - data={writeback,ordered,journal} Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> --- fs/ext4/ext4.h | 3 +++ fs/ext4/super.c | 31 +++++++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 3f248c9..871cdc6 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -1019,6 +1019,9 @@ struct ext4_inode_info { #define EXT4_MOUNT2_HURD_COMPAT 0x00000004 /* Support HURD-castrated file systems */ +#define EXT4_MOUNT2_EXPLICIT_JOURNAL_CHECKSUM 0x00000008 /* User explicitly + specified journal checksum */ + #define clear_opt(sb, opt) EXT4_SB(sb)->s_mount_opt &= \ ~EXT4_MOUNT_##opt #define set_opt(sb, opt) EXT4_SB(sb)->s_mount_opt |= \ diff --git a/fs/ext4/super.c b/fs/ext4/super.c index e91f6d4..a29b32b 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -1371,10 +1371,10 @@ static const struct mount_opts { {Opt_nojournal_checksum, EXT4_MOUNT_JOURNAL_CHECKSUM, MOPT_EXT4_ONLY | MOPT_CLEAR}, {Opt_journal_checksum, EXT4_MOUNT_JOURNAL_CHECKSUM, - MOPT_EXT4_ONLY | MOPT_SET}, + MOPT_EXT4_ONLY | MOPT_SET | MOPT_EXPLICIT}, {Opt_journal_async_commit, (EXT4_MOUNT_JOURNAL_ASYNC_COMMIT | EXT4_MOUNT_JOURNAL_CHECKSUM), - MOPT_EXT4_ONLY | MOPT_SET}, + MOPT_EXT4_ONLY | MOPT_SET | MOPT_EXPLICIT}, {Opt_noload, EXT4_MOUNT_NOLOAD, MOPT_NO_EXT2 | MOPT_SET}, {Opt_err_panic, EXT4_MOUNT_ERRORS_PANIC, MOPT_SET | MOPT_CLEAR_ERR}, {Opt_err_ro, EXT4_MOUNT_ERRORS_RO, MOPT_SET | MOPT_CLEAR_ERR}, @@ -1506,6 +1506,8 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token, if (m->flags & MOPT_EXPLICIT) { if (m->mount_opt & EXT4_MOUNT_DELALLOC) { set_opt2(sb, EXPLICIT_DELALLOC); + } else if (m->mount_opt & EXT4_MOUNT_JOURNAL_CHECKSUM) { + set_opt2(sb, EXPLICIT_JOURNAL_CHECKSUM); } else return -1; } @@ -3675,6 +3677,31 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) "suppressed and not mounted read-only"); goto failed_mount_wq; } else { + /* Nojournal mode, all journal mount options are illegal */ + if (test_opt2(sb, EXPLICIT_JOURNAL_CHECKSUM)) { + ext4_msg(sb, KERN_ERR, "can't mount with " + "journal_checksum, fs mounted w/o journal"); + goto failed_mount_wq; + } + if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) { + ext4_msg(sb, KERN_ERR, "can't mount with " + "journal_async_commit, fs mounted w/o journal"); + goto failed_mount_wq; + } + if (sbi->s_commit_interval != JBD2_DEFAULT_MAX_COMMIT_AGE*HZ) { + ext4_msg(sb, KERN_ERR, "can't mount with " + "commit=%lu, fs mounted w/o journal", + sbi->s_commit_interval / HZ); + goto failed_mount_wq; + } + if (EXT4_MOUNT_DATA_FLAGS & + (sbi->s_mount_opt ^ sbi->s_def_mount_opt)) { + ext4_msg(sb, KERN_ERR, "can't mount with " + "data=, fs mounted w/o journal"); + goto failed_mount_wq; + } + sbi->s_def_mount_opt &= EXT4_MOUNT_JOURNAL_CHECKSUM; + clear_opt(sb, JOURNAL_CHECKSUM); clear_opt(sb, DATA_FLAGS); sbi->s_journal = NULL; needs_recovery = 0; -- 1.7.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] ext4: do not allow journal_opts for fs w/o journal 2015-10-09 9:09 ` [PATCH 2/2] ext4: do not allow journal_opts for fs w/o journal Dmitry Monakhov @ 2015-10-09 20:53 ` Andreas Dilger 2015-10-19 3:57 ` Theodore Ts'o 0 siblings, 1 reply; 5+ messages in thread From: Andreas Dilger @ 2015-10-09 20:53 UTC (permalink / raw) To: Dmitry Monakhov; +Cc: linux-ext4, tytso [-- Attachment #1: Type: text/plain, Size: 4405 bytes --] On Oct 9, 2015, at 3:09 AM, Dmitry Monakhov <dmonakhov@openvz.org> wrote: > > It is appeared that we can pass journal related mount options and such options > be shown in /proc/mounts > > Example: > #mkfs.ext4 -F /dev/vdb > #tune2fs -O ^has_journal /dev/vdb > #mount /dev/vdb /mnt/ -ocommit=20,journal_async_commit > #cat /proc/mounts | grep /mnt > /dev/vdb /mnt ext4 rw,relatime,journal_checksum,journal_async_commit,commit=20,data=ordered 0 0 > > But options:"journal_checksum,journal_async_commit,commit=20,data=ordered" has > nothing with reality because there is no jornall at all. (typo) s/jornall/journal/ but looks reasonable otherwise. Reviewed-by: Andreas Dilger <adilger@dilger.ca> > This patch disallow following options for journalless configurations: > - journal_checksum > - journal_async_commit > - commit=%ld > - data={writeback,ordered,journal} > > Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> > --- > fs/ext4/ext4.h | 3 +++ > fs/ext4/super.c | 31 +++++++++++++++++++++++++++++-- > 2 files changed, 32 insertions(+), 2 deletions(-) > > diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h > index 3f248c9..871cdc6 100644 > --- a/fs/ext4/ext4.h > +++ b/fs/ext4/ext4.h > @@ -1019,6 +1019,9 @@ struct ext4_inode_info { > #define EXT4_MOUNT2_HURD_COMPAT 0x00000004 /* Support HURD-castrated > file systems */ > > +#define EXT4_MOUNT2_EXPLICIT_JOURNAL_CHECKSUM 0x00000008 /* User explicitly > + specified journal checksum */ > + > #define clear_opt(sb, opt) EXT4_SB(sb)->s_mount_opt &= \ > ~EXT4_MOUNT_##opt > #define set_opt(sb, opt) EXT4_SB(sb)->s_mount_opt |= \ > diff --git a/fs/ext4/super.c b/fs/ext4/super.c > index e91f6d4..a29b32b 100644 > --- a/fs/ext4/super.c > +++ b/fs/ext4/super.c > @@ -1371,10 +1371,10 @@ static const struct mount_opts { > {Opt_nojournal_checksum, EXT4_MOUNT_JOURNAL_CHECKSUM, > MOPT_EXT4_ONLY | MOPT_CLEAR}, > {Opt_journal_checksum, EXT4_MOUNT_JOURNAL_CHECKSUM, > - MOPT_EXT4_ONLY | MOPT_SET}, > + MOPT_EXT4_ONLY | MOPT_SET | MOPT_EXPLICIT}, > {Opt_journal_async_commit, (EXT4_MOUNT_JOURNAL_ASYNC_COMMIT | > EXT4_MOUNT_JOURNAL_CHECKSUM), > - MOPT_EXT4_ONLY | MOPT_SET}, > + MOPT_EXT4_ONLY | MOPT_SET | MOPT_EXPLICIT}, > {Opt_noload, EXT4_MOUNT_NOLOAD, MOPT_NO_EXT2 | MOPT_SET}, > {Opt_err_panic, EXT4_MOUNT_ERRORS_PANIC, MOPT_SET | MOPT_CLEAR_ERR}, > {Opt_err_ro, EXT4_MOUNT_ERRORS_RO, MOPT_SET | MOPT_CLEAR_ERR}, > @@ -1506,6 +1506,8 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token, > if (m->flags & MOPT_EXPLICIT) { > if (m->mount_opt & EXT4_MOUNT_DELALLOC) { > set_opt2(sb, EXPLICIT_DELALLOC); > + } else if (m->mount_opt & EXT4_MOUNT_JOURNAL_CHECKSUM) { > + set_opt2(sb, EXPLICIT_JOURNAL_CHECKSUM); > } else > return -1; > } > @@ -3675,6 +3677,31 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) > "suppressed and not mounted read-only"); > goto failed_mount_wq; > } else { > + /* Nojournal mode, all journal mount options are illegal */ > + if (test_opt2(sb, EXPLICIT_JOURNAL_CHECKSUM)) { > + ext4_msg(sb, KERN_ERR, "can't mount with " > + "journal_checksum, fs mounted w/o journal"); > + goto failed_mount_wq; > + } > + if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) { > + ext4_msg(sb, KERN_ERR, "can't mount with " > + "journal_async_commit, fs mounted w/o journal"); > + goto failed_mount_wq; > + } > + if (sbi->s_commit_interval != JBD2_DEFAULT_MAX_COMMIT_AGE*HZ) { > + ext4_msg(sb, KERN_ERR, "can't mount with " > + "commit=%lu, fs mounted w/o journal", > + sbi->s_commit_interval / HZ); > + goto failed_mount_wq; > + } > + if (EXT4_MOUNT_DATA_FLAGS & > + (sbi->s_mount_opt ^ sbi->s_def_mount_opt)) { > + ext4_msg(sb, KERN_ERR, "can't mount with " > + "data=, fs mounted w/o journal"); > + goto failed_mount_wq; > + } > + sbi->s_def_mount_opt &= EXT4_MOUNT_JOURNAL_CHECKSUM; > + clear_opt(sb, JOURNAL_CHECKSUM); > clear_opt(sb, DATA_FLAGS); > sbi->s_journal = NULL; > needs_recovery = 0; > -- > 1.7.1 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-ext4" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html Cheers, Andreas [-- Attachment #2: Message signed with OpenPGP using GPGMail --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] ext4: do not allow journal_opts for fs w/o journal 2015-10-09 20:53 ` Andreas Dilger @ 2015-10-19 3:57 ` Theodore Ts'o 0 siblings, 0 replies; 5+ messages in thread From: Theodore Ts'o @ 2015-10-19 3:57 UTC (permalink / raw) To: Andreas Dilger; +Cc: Dmitry Monakhov, linux-ext4 On Fri, Oct 09, 2015 at 02:53:39PM -0600, Andreas Dilger wrote: > On Oct 9, 2015, at 3:09 AM, Dmitry Monakhov <dmonakhov@openvz.org> wrote: > > > > It is appeared that we can pass journal related mount options and such options > > be shown in /proc/mounts > > > > Example: > > #mkfs.ext4 -F /dev/vdb > > #tune2fs -O ^has_journal /dev/vdb > > #mount /dev/vdb /mnt/ -ocommit=20,journal_async_commit > > #cat /proc/mounts | grep /mnt > > /dev/vdb /mnt ext4 rw,relatime,journal_checksum,journal_async_commit,commit=20,data=ordered 0 0 > > > > But options:"journal_checksum,journal_async_commit,commit=20,data=ordered" has > > nothing with reality because there is no jornall at all. > > (typo) s/jornall/journal/ > > but looks reasonable otherwise. > > Reviewed-by: Andreas Dilger <adilger@dilger.ca> Applied, thanks. - Ted ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] ext4: explicit mount options parsing cleanup 2015-10-09 9:09 [PATCH 1/2] ext4: explicit mount options parsing cleanup Dmitry Monakhov 2015-10-09 9:09 ` [PATCH 2/2] ext4: do not allow journal_opts for fs w/o journal Dmitry Monakhov @ 2015-10-19 3:57 ` Theodore Ts'o 1 sibling, 0 replies; 5+ messages in thread From: Theodore Ts'o @ 2015-10-19 3:57 UTC (permalink / raw) To: Dmitry Monakhov; +Cc: linux-ext4 On Fri, Oct 09, 2015 at 01:09:58PM +0400, Dmitry Monakhov wrote: > Currently MOPT_EXPLICIT treated as EXPLICIT_DELALLOC which may be changed > in future. Let's fix it now. > > Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org> Applied, thanks. - Ted ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-10-19 3:57 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-10-09 9:09 [PATCH 1/2] ext4: explicit mount options parsing cleanup Dmitry Monakhov 2015-10-09 9:09 ` [PATCH 2/2] ext4: do not allow journal_opts for fs w/o journal Dmitry Monakhov 2015-10-09 20:53 ` Andreas Dilger 2015-10-19 3:57 ` Theodore Ts'o 2015-10-19 3:57 ` [PATCH 1/2] ext4: explicit mount options parsing cleanup Theodore 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).