Skip to content

Commit 960e0ab

Browse files
Lukas Czernertytso
authored andcommitted
ext4: fix i_version handling on remount
i_version mount option is getting lost on remount. This is because the 'i_version' mount option differs from the util-linux mount option 'iversion', but it has exactly the same functionality. We have to specifically notify the vfs that this is what we want by setting appropriate flag in fc->sb_flags. Fix it and as a result we can remove *flags argument from __ext4_remount(); do the same for __ext4_fill_super(). In addition set out to deprecate ext4 specific 'i_version' mount option in favor or 'iversion' by kernel version 5.20. Signed-off-by: Lukas Czerner <[email protected]> Fixes: cebe85d ("ext4: switch to the new mount api") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 4437992 commit 960e0ab

File tree

1 file changed

+18
-25
lines changed

1 file changed

+18
-25
lines changed

fs/ext4/super.c

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,6 +2246,8 @@ static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *param)
22462246
ctx_set_mount_flags(ctx, EXT4_MF_FS_ABORTED);
22472247
return 0;
22482248
case Opt_i_version:
2249+
ext4_msg(NULL, KERN_WARNING, deprecated_msg, param->key, "5.20");
2250+
ext4_msg(NULL, KERN_WARNING, "Use iversion instead\n");
22492251
ctx_set_flags(ctx, SB_I_VERSION);
22502252
return 0;
22512253
case Opt_inlinecrypt:
@@ -2875,6 +2877,14 @@ static int ext4_apply_options(struct fs_context *fc, struct super_block *sb)
28752877
sb->s_flags &= ~ctx->mask_s_flags;
28762878
sb->s_flags |= ctx->vals_s_flags;
28772879

2880+
/*
2881+
* i_version differs from common mount option iversion so we have
2882+
* to let vfs know that it was set, otherwise it would get cleared
2883+
* on remount
2884+
*/
2885+
if (ctx->mask_s_flags & SB_I_VERSION)
2886+
fc->sb_flags |= SB_I_VERSION;
2887+
28782888
#define APPLY(X) ({ if (ctx->spec & EXT4_SPEC_##X) sbi->X = ctx->X; })
28792889
APPLY(s_commit_interval);
28802890
APPLY(s_stripe);
@@ -4342,8 +4352,7 @@ static struct ext4_sb_info *ext4_alloc_sbi(struct super_block *sb)
43424352
return NULL;
43434353
}
43444354

4345-
static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb,
4346-
int silent)
4355+
static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
43474356
{
43484357
struct buffer_head *bh, **group_desc;
43494358
struct ext4_super_block *es = NULL;
@@ -4363,6 +4372,7 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb,
43634372
int err = 0;
43644373
ext4_group_t first_not_zeroed;
43654374
struct ext4_fs_context *ctx = fc->fs_private;
4375+
int silent = fc->sb_flags & SB_SILENT;
43664376

43674377
/* Set defaults for the variables that will be set during parsing */
43684378
ctx->journal_ioprio = DEFAULT_JOURNAL_IOPRIO;
@@ -5540,7 +5550,7 @@ static int ext4_fill_super(struct super_block *sb, struct fs_context *fc)
55405550
if (ctx->spec & EXT4_SPEC_s_sb_block)
55415551
sbi->s_sb_block = ctx->s_sb_block;
55425552

5543-
ret = __ext4_fill_super(fc, sb, fc->sb_flags & SB_SILENT);
5553+
ret = __ext4_fill_super(fc, sb);
55445554
if (ret < 0)
55455555
goto free_sbi;
55465556

@@ -6199,13 +6209,12 @@ struct ext4_mount_options {
61996209
#endif
62006210
};
62016211

6202-
static int __ext4_remount(struct fs_context *fc, struct super_block *sb,
6203-
int *flags)
6212+
static int __ext4_remount(struct fs_context *fc, struct super_block *sb)
62046213
{
62056214
struct ext4_fs_context *ctx = fc->fs_private;
62066215
struct ext4_super_block *es;
62076216
struct ext4_sb_info *sbi = EXT4_SB(sb);
6208-
unsigned long old_sb_flags, vfs_flags;
6217+
unsigned long old_sb_flags;
62096218
struct ext4_mount_options old_opts;
62106219
ext4_group_t g;
62116220
int err = 0;
@@ -6245,14 +6254,6 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb,
62456254
ctx->journal_ioprio =
62466255
sbi->s_journal->j_task->io_context->ioprio;
62476256

6248-
/*
6249-
* Some options can be enabled by ext4 and/or by VFS mount flag
6250-
* either way we need to make sure it matches in both *flags and
6251-
* s_flags. Copy those selected flags from *flags to s_flags
6252-
*/
6253-
vfs_flags = SB_I_VERSION;
6254-
sb->s_flags = (sb->s_flags & ~vfs_flags) | (*flags & vfs_flags);
6255-
62566257
ext4_apply_options(fc, sb);
62576258

62586259
if ((old_opts.s_mount_opt & EXT4_MOUNT_JOURNAL_CHECKSUM) ^
@@ -6306,13 +6307,13 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb,
63066307
/* Flush outstanding errors before changing fs state */
63076308
flush_work(&sbi->s_error_work);
63086309

6309-
if ((bool)(*flags & SB_RDONLY) != sb_rdonly(sb)) {
6310+
if ((bool)(fc->sb_flags & SB_RDONLY) != sb_rdonly(sb)) {
63106311
if (ext4_test_mount_flag(sb, EXT4_MF_FS_ABORTED)) {
63116312
err = -EROFS;
63126313
goto restore_opts;
63136314
}
63146315

6315-
if (*flags & SB_RDONLY) {
6316+
if (fc->sb_flags & SB_RDONLY) {
63166317
err = sync_filesystem(sb);
63176318
if (err < 0)
63186319
goto restore_opts;
@@ -6460,13 +6461,6 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb,
64606461
if (!ext4_has_feature_mmp(sb) || sb_rdonly(sb))
64616462
ext4_stop_mmpd(sbi);
64626463

6463-
/*
6464-
* Some options can be enabled by ext4 and/or by VFS mount flag
6465-
* either way we need to make sure it matches in both *flags and
6466-
* s_flags. Copy those selected flags from s_flags to *flags
6467-
*/
6468-
*flags = (*flags & ~vfs_flags) | (sb->s_flags & vfs_flags);
6469-
64706464
return 0;
64716465

64726466
restore_opts:
@@ -6498,7 +6492,6 @@ static int __ext4_remount(struct fs_context *fc, struct super_block *sb,
64986492
static int ext4_reconfigure(struct fs_context *fc)
64996493
{
65006494
struct super_block *sb = fc->root->d_sb;
6501-
int flags = fc->sb_flags;
65026495
int ret;
65036496

65046497
fc->s_fs_info = EXT4_SB(sb);
@@ -6507,7 +6500,7 @@ static int ext4_reconfigure(struct fs_context *fc)
65076500
if (ret < 0)
65086501
return ret;
65096502

6510-
ret = __ext4_remount(fc, sb, &flags);
6503+
ret = __ext4_remount(fc, sb);
65116504
if (ret < 0)
65126505
return ret;
65136506

0 commit comments

Comments
 (0)