Re: [PATCH RFC 5/8] fs/ext4: Make DAX mount option a tri-state

Jan Kara
2020-04-15T12:52:11Z

On Mon 13-04-20 21:00:27, ira.weiny@intel.com wrote:
> From: Ira Weiny <ira.weiny@intel.com>
>
> We add 'always', 'never', and 'inode' (default). '-o dax' continue to
> operate the same.
>
> Specifically we introduce a 2nd DAX mount flag EXT4_MOUNT_NODAX and set
> it and EXT4_MOUNT_DAX appropriately.
>
> We also force EXT4_MOUNT_NODAX if !CONFIG_FS_DAX.
>
> https://lore.kernel.org/lkml/20200405061945.GA94792@iweiny-DESK2.sc.intel.com/
>
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>

...

> @@ -2303,6 +2325,13 @@ static int _ext4_show_options(struct seq_file *seq, struct super_block *sb,
> if (DUMMY_ENCRYPTION_ENABLED(sbi))
> SEQ_OPTS_PUTS("test_dummy_encryption");
>
> + if (test_opt2(sb, NODAX))
> + SEQ_OPTS_PUTS("dax=never");
> + else if (test_opt(sb, DAX))
> + SEQ_OPTS_PUTS("dax=always");
> + else
> + SEQ_OPTS_PUTS("dax=inode");
> +

We try to show only mount options that were explicitely set by the user, or
that are different from defaults - e.g., see how 'data=' mount option
printing is handled.

> ext4_show_quota_options(seq, sb);
> return 0;
> }
> @@ -5424,6 +5453,12 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
> sbi->s_mount_opt ^= EXT4_MOUNT_DAX;
> }
>
> + if ((sbi->s_mount_opt2 ^ old_opts.s_mount_opt2) & EXT4_MOUNT2_NODAX) {
> + ext4_msg(sb, KERN_WARNING, "warning: refusing change of "
> + "non-dax flag with busy inodes while remounting");
> + sbi->s_mount_opt2 ^= EXT4_MOUNT2_NODAX;
> + }
> +
> if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
> ext4_abort(sb, "Abort forced by user");

I'd just merge this with the check whether EXT4_MOUNT_DAX changed.

Honza

--
Jan Kara <jack@suse.com>
SUSE Labs, CR