Commit e4e58e5d authored by Ojaswin Mujoo's avatar Ojaswin Mujoo Committed by Theodore Ts'o
Browse files

ext4: fix journal_ioprio mount option handling



In __ext4_super() we always overwrote the user specified journal_ioprio
value with a default value, expecting parse_apply_sb_mount_options() to
later correctly set ctx->journal_ioprio to the user specified value.
However, if parse_apply_sb_mount_options() returned early because of
empty sbi->es_s->s_mount_opts, the correct journal_ioprio value was
never set.

This patch fixes __ext4_super() to only use the default value if the
user has not specified any value for journal_ioprio.

Similarly, the remount behavior was to either use journal_ioprio
value specified during initial mount, or use the default value
irrespective of the journal_ioprio value specified during remount.
This patch modifies this to first check if a new value for ioprio
has been passed during remount and apply it.  If no new value is
passed, use the value specified during initial mount.

Signed-off-by: default avatarOjaswin Mujoo <ojaswin@linux.ibm.com>
Reviewed-by: default avatarRitesh Harjani <riteshh@linux.ibm.com>
Tested-by: default avatarRitesh Harjani <riteshh@linux.ibm.com>
Link: https://lore.kernel.org/r/20220418083545.45778-1-ojaswin@linux.ibm.com


Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
Cc: stable@kernel.org
parent d63c00ea
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -4411,6 +4411,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
	int silent = fc->sb_flags & SB_SILENT;

	/* Set defaults for the variables that will be set during parsing */
	if (!(ctx->spec & EXT4_SPEC_JOURNAL_IOPRIO))
		ctx->journal_ioprio = DEFAULT_JOURNAL_IOPRIO;

	sbi->s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS;
@@ -6278,7 +6279,6 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb)
	char *to_free[EXT4_MAXQUOTAS];
#endif

	ctx->journal_ioprio = DEFAULT_JOURNAL_IOPRIO;

	/* Store the original options */
	old_sb_flags = sb->s_flags;
@@ -6304,9 +6304,14 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb)
		} else
			old_opts.s_qf_names[i] = NULL;
#endif
	if (!(ctx->spec & EXT4_SPEC_JOURNAL_IOPRIO)) {
		if (sbi->s_journal && sbi->s_journal->j_task->io_context)
			ctx->journal_ioprio =
				sbi->s_journal->j_task->io_context->ioprio;
		else
			ctx->journal_ioprio = DEFAULT_JOURNAL_IOPRIO;

	}

	ext4_apply_options(fc, sb);