Skip to contentSkip to conversation

Problem with data=ordered ext4 mount option in linux-next

DISCUSSION Heiner Kallweit 3 participants 8 messages Dec 17, 2021 – Dec 26, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

On linux-next systemd-remount-fs complains about an invalid mount option here, resulting in a r/o root fs. After playing with the mount options it turned out that data=ordered causes the problem. linux-next from Dec 1st was ok, so it seems to be related to the new mount API patches.

At a first glance I saw no obvious problem, the following looks good. Maybe you have an idea where to look ..

static const struct constant_table ext4_param_data[] = {
	{"journal",	EXT4_MOUNT_JOURNAL_DATA},
	{"ordered",	EXT4_MOUNT_ORDERED_DATA},
	{"writeback",	EXT4_MOUNT_WRITEBACK_DATA},
	{}
};
	fsparam_enum	("data",		Opt_data, ext4_param_data),
#1 lore raw
Quoted 8 lines · Heiner Kallweit

On linux-next systemd-remount-fs complains about an invalid mount option here, resulting in a r/o root fs. After playing with the mount options it turned out that data=ordered causes the problem. linux-next from Dec 1st was ok, so it seems to be related to the new mount API patches.

At a first glance I saw no obvious problem, the following looks good. Maybe you have an idea where to look ..

Quoted 9 lines
static const struct constant_table ext4_param_data[] = {
	{"journal",	EXT4_MOUNT_JOURNAL_DATA},
	{"ordered",	EXT4_MOUNT_ORDERED_DATA},
	{"writeback",	EXT4_MOUNT_WRITEBACK_DATA},
	{}
};
	fsparam_enum	("data",		Opt_data, ext4_param_data),

Thank you for the report!

The ext4 mount has been reworked to use the new mount api and the work has been applied to linux-next couple of days ago so I definitelly assume there is a bug in there that I've missed. I will be looking into it.

Can you be a little bit more specific about how to reproduce the problem as well as the error it generates in the logs ? Any other mount options used simultaneously, non-default file system features, or mount options stored within the superblock ?

Can you reproduce it outside of the systemd unit, say a script ?

Thanks!
-Lukas

#2 lore raw
Quoted 26 lines · Lukas Czerner
Quoted 8 lines · Heiner Kallweit

On linux-next systemd-remount-fs complains about an invalid mount option here, resulting in a r/o root fs. After playing with the mount options it turned out that data=ordered causes the problem. linux-next from Dec 1st was ok, so it seems to be related to the new mount API patches.

At a first glance I saw no obvious problem, the following looks good. Maybe you have an idea where to look ..

Quoted 9 lines
static const struct constant_table ext4_param_data[] = {
	{"journal",	EXT4_MOUNT_JOURNAL_DATA},
	{"ordered",	EXT4_MOUNT_ORDERED_DATA},
	{"writeback",	EXT4_MOUNT_WRITEBACK_DATA},
	{}
};
	fsparam_enum	("data",		Opt_data, ext4_param_data),

Thank you for the report!

The ext4 mount has been reworked to use the new mount api and the work has been applied to linux-next couple of days ago so I definitelly assume there is a bug in there that I've missed. I will be looking into it.

Quoted 7 lines

Can you be a little bit more specific about how to reproduce the problem as well as the error it generates in the logs ? Any other mount options used simultaneously, non-default file system features, or mount options stored within the superblock ?

Can you reproduce it outside of the systemd unit, say a script ?

Yes:

[root@zotac ~]# mount -o remount,data=ordered /
mount: /: mount point not mounted or bad option.
[root@zotac ~]# mount -o remount,discard /
[root@zotac ~]#

"systemctl status systemd-remount-fs" shows the same error.

Following options I had in my fstab (ext4 fs):
rw,relatime,data=ordered,discard

No non-default system features.

Quoted 3 lines

Thanks!
-Lukas

Heiner

#3 lore raw
Quoted 46 lines · Heiner Kallweit
Quoted 26 lines · Lukas Czerner
Quoted 8 lines · Heiner Kallweit

On linux-next systemd-remount-fs complains about an invalid mount option here, resulting in a r/o root fs. After playing with the mount options it turned out that data=ordered causes the problem. linux-next from Dec 1st was ok, so it seems to be related to the new mount API patches.

At a first glance I saw no obvious problem, the following looks good. Maybe you have an idea where to look ..

Quoted 9 lines
static const struct constant_table ext4_param_data[] = {
	{"journal",	EXT4_MOUNT_JOURNAL_DATA},
	{"ordered",	EXT4_MOUNT_ORDERED_DATA},
	{"writeback",	EXT4_MOUNT_WRITEBACK_DATA},
	{}
};
	fsparam_enum	("data",		Opt_data, ext4_param_data),

Thank you for the report!

The ext4 mount has been reworked to use the new mount api and the work has been applied to linux-next couple of days ago so I definitelly assume there is a bug in there that I've missed. I will be looking into it.

Quoted 7 lines

Can you be a little bit more specific about how to reproduce the problem as well as the error it generates in the logs ? Any other mount options used simultaneously, non-default file system features, or mount options stored within the superblock ?

Can you reproduce it outside of the systemd unit, say a script ?

Yes:

[root@zotac ~]# mount -o remount,data=ordered /
mount: /: mount point not mounted or bad option.
[root@zotac ~]# mount -o remount,discard /
[root@zotac ~]#

"systemctl status systemd-remount-fs" shows the same error.

Following options I had in my fstab (ext4 fs):
rw,relatime,data=ordered,discard

Quoted 6 lines

No non-default system features.

Quoted 3 lines

Thanks!
-Lukas

Heiner

Sorry, should have looked at dmesg earlier. There I see:
EXT4-fs: Cannot change data mode on remount
Message seems to be triggered from ext4_check_opt_consistency(). Not sure why this error doesn't occur with old mount API. And actually I don't change the data mode.

#4 lore raw
Quoted 52 lines · Heiner Kallweit
Quoted 51 lines · Heiner Kallweit
Quoted 26 lines · Lukas Czerner
Quoted 8 lines · Heiner Kallweit

On linux-next systemd-remount-fs complains about an invalid mount option here, resulting in a r/o root fs. After playing with the mount options it turned out that data=ordered causes the problem. linux-next from Dec 1st was ok, so it seems to be related to the new mount API patches.

At a first glance I saw no obvious problem, the following looks good. Maybe you have an idea where to look ..

Quoted 9 lines
static const struct constant_table ext4_param_data[] = {
	{"journal",	EXT4_MOUNT_JOURNAL_DATA},
	{"ordered",	EXT4_MOUNT_ORDERED_DATA},
	{"writeback",	EXT4_MOUNT_WRITEBACK_DATA},
	{}
};
	fsparam_enum	("data",		Opt_data, ext4_param_data),

Thank you for the report!

The ext4 mount has been reworked to use the new mount api and the work has been applied to linux-next couple of days ago so I definitelly assume there is a bug in there that I've missed. I will be looking into it.

Quoted 7 lines

Can you be a little bit more specific about how to reproduce the problem as well as the error it generates in the logs ? Any other mount options used simultaneously, non-default file system features, or mount options stored within the superblock ?

Can you reproduce it outside of the systemd unit, say a script ?

Yes:

[root@zotac ~]# mount -o remount,data=ordered /
mount: /: mount point not mounted or bad option.
[root@zotac ~]# mount -o remount,discard /
[root@zotac ~]#

"systemctl status systemd-remount-fs" shows the same error.

Following options I had in my fstab (ext4 fs):
rw,relatime,data=ordered,discard

No non-default system features.

Quoted 3 lines

Thanks!
-Lukas

Quoted 7 lines
Quoted 1 line

Heiner

Sorry, should have looked at dmesg earlier. There I see:
EXT4-fs: Cannot change data mode on remount
Message seems to be triggered from ext4_check_opt_consistency(). Not sure why this error doesn't occur with old mount API. And actually I don't change the data mode.

Based on the old API code: Maybe we need something like this? At least it works for me.

fs/ext4/super.c +3 -1
index b72d989b7..9ec7e526c 100644
@@ -2821,7 +2821,9 @@ static int ext4_check_opt_consistency(struct fs_context *fc,
                                 "Remounting file system with no journal "
                                 "so ignoring journalled data option");
                        ctx_clear_mount_opt(ctx, EXT4_MOUNT_DATA_FLAGS);
-               } else if (ctx->mask_s_mount_opt & EXT4_MOUNT_DATA_FLAGS) {
+               } else if (ctx->mask_s_mount_opt & EXT4_MOUNT_DATA_FLAGS &&
+                          (ctx->vals_s_mount_opt & EXT4_MOUNT_DATA_FLAGS) !=
+                          (sbi->s_mount_opt & EXT4_MOUNT_DATA_FLAGS)) {
                        ext4_msg(NULL, KERN_ERR, "Cannot change data mode "
                                 "on remount");
                        return -EINVAL;
#5 lore raw
Quoted 69 lines · Heiner Kallweit
Quoted 52 lines · Heiner Kallweit
Quoted 51 lines · Heiner Kallweit
Quoted 26 lines · Lukas Czerner
Quoted 8 lines · Heiner Kallweit

On linux-next systemd-remount-fs complains about an invalid mount option here, resulting in a r/o root fs. After playing with the mount options it turned out that data=ordered causes the problem. linux-next from Dec 1st was ok, so it seems to be related to the new mount API patches.

At a first glance I saw no obvious problem, the following looks good. Maybe you have an idea where to look ..

Quoted 9 lines
static const struct constant_table ext4_param_data[] = {
	{"journal",	EXT4_MOUNT_JOURNAL_DATA},
	{"ordered",	EXT4_MOUNT_ORDERED_DATA},
	{"writeback",	EXT4_MOUNT_WRITEBACK_DATA},
	{}
};
	fsparam_enum	("data",		Opt_data, ext4_param_data),

Thank you for the report!

The ext4 mount has been reworked to use the new mount api and the work has been applied to linux-next couple of days ago so I definitelly assume there is a bug in there that I've missed. I will be looking into it.

Quoted 7 lines

Can you be a little bit more specific about how to reproduce the problem as well as the error it generates in the logs ? Any other mount options used simultaneously, non-default file system features, or mount options stored within the superblock ?

Can you reproduce it outside of the systemd unit, say a script ?

Yes:

[root@zotac ~]# mount -o remount,data=ordered /
mount: /: mount point not mounted or bad option.
[root@zotac ~]# mount -o remount,discard /
[root@zotac ~]#

"systemctl status systemd-remount-fs" shows the same error.

Following options I had in my fstab (ext4 fs):
rw,relatime,data=ordered,discard

No non-default system features.

Quoted 3 lines

Thanks!
-Lukas

Quoted 7 lines
Quoted 1 line

Heiner

Sorry, should have looked at dmesg earlier. There I see:
EXT4-fs: Cannot change data mode on remount
Message seems to be triggered from ext4_check_opt_consistency(). Not sure why this error doesn't occur with old mount API. And actually I don't change the data mode.

Based on the old API code: Maybe we need something like this? At least it works for me.

fs/ext4/super.c +0 -0
index b72d989b7..9ec7e526c 100644

fs/ext4/super.c static int ext4_check_opt_consistency(struct fs_context *fc, · line 2826

Quoted 7 lines
fs/ext4/super.c +3 -1
@@ -2821,7 +2821,9 @@ static int ext4_check_opt_consistency(struct fs_context *fc,
                                 "Remounting file system with no journal "
                                 "so ignoring journalled data option");
                        ctx_clear_mount_opt(ctx, EXT4_MOUNT_DATA_FLAGS);
-               } else if (ctx->mask_s_mount_opt & EXT4_MOUNT_DATA_FLAGS) {
+               } else if (ctx->mask_s_mount_opt & EXT4_MOUNT_DATA_FLAGS &&
+                          (ctx->vals_s_mount_opt & EXT4_MOUNT_DATA_FLAGS) !=
+                          (sbi->s_mount_opt & EXT4_MOUNT_DATA_FLAGS)) {

Hi,

indeed that's where the problem is. It's not enogh to check whether we have a data= mount options set, we also have to check whether it's the same as it already is set on the file system during remount. In which case we just ignore it, rather then error out.

Thanks for tracking it down. I think the condition can be simplified a bit. I also have to update the xfstest test to check for plain remount without changing anything to catch errors like these. I'll send patch soon.

Thanks!
-Lukas

Quoted 4 lines
fs/ext4/super.c +0 -0
                        ext4_msg(NULL, KERN_ERR, "Cannot change data mode "
                                 "on remount");
                        return -EINVAL;
#6 lore raw
Quoted 86 lines · Lukas Czerner
Quoted 69 lines · Heiner Kallweit
Quoted 52 lines · Heiner Kallweit
Quoted 51 lines · Heiner Kallweit
Quoted 26 lines · Lukas Czerner
Quoted 8 lines · Heiner Kallweit

On linux-next systemd-remount-fs complains about an invalid mount option here, resulting in a r/o root fs. After playing with the mount options it turned out that data=ordered causes the problem. linux-next from Dec 1st was ok, so it seems to be related to the new mount API patches.

At a first glance I saw no obvious problem, the following looks good. Maybe you have an idea where to look ..

Quoted 9 lines

static const struct constant_table ext4_param_data[] = {

 {"journal",     EXT4_MOUNT_JOURNAL_DATA},
 {"ordered",     EXT4_MOUNT_ORDERED_DATA},
 {"writeback",   EXT4_MOUNT_WRITEBACK_DATA},

{}
};

fsparam_enum ("data", Opt_data, ext4_param_data),

Thank you for the report!

The ext4 mount has been reworked to use the new mount api and the work has been applied to linux-next couple of days ago so I definitelly assume there is a bug in there that I've missed. I will be looking into it.

Quoted 7 lines

Can you be a little bit more specific about how to reproduce the problem as well as the error it generates in the logs ? Any other mount options used simultaneously, non-default file system features, or mount options stored within the superblock ?

Can you reproduce it outside of the systemd unit, say a script ?

Yes:

[root@zotac ~]# mount -o remount,data=ordered /
mount: /: mount point not mounted or bad option.
[root@zotac ~]# mount -o remount,discard /
[root@zotac ~]#

"systemctl status systemd-remount-fs" shows the same error.

Following options I had in my fstab (ext4 fs):
rw,relatime,data=ordered,discard

No non-default system features.

Quoted 3 lines

Thanks!
-Lukas

Quoted 7 lines
Quoted 1 line

Heiner

Sorry, should have looked at dmesg earlier. There I see:
EXT4-fs: Cannot change data mode on remount
Message seems to be triggered from ext4_check_opt_consistency(). Not sure why this error doesn't occur with old mount API. And actually I don't change the data mode.

Based on the old API code: Maybe we need something like this? At least it works for me.

fs/ext4/super.c +0 -0
index b72d989b7..9ec7e526c 100644

fs/ext4/super.c static int ext4_check_opt_consistency(struct fs_context *fc, · line 2826

Quoted 7 lines
fs/ext4/super.c +3 -1
@@ -2821,7 +2821,9 @@ static int ext4_check_opt_consistency(struct fs_context *fc,
                                 "Remounting file system with no journal "
                                 "so ignoring journalled data option");
                        ctx_clear_mount_opt(ctx, EXT4_MOUNT_DATA_FLAGS);
-               } else if (ctx->mask_s_mount_opt & EXT4_MOUNT_DATA_FLAGS) {
+               } else if (ctx->mask_s_mount_opt & EXT4_MOUNT_DATA_FLAGS &&
+                          (ctx->vals_s_mount_opt & EXT4_MOUNT_DATA_FLAGS) !=
+                          (sbi->s_mount_opt & EXT4_MOUNT_DATA_FLAGS)) {

Hi,

indeed that's where the problem is. It's not enogh to check whether we have a data= mount options set, we also have to check whether it's the same as it already is set on the file system during remount. In which case we just ignore it, rather then error out.

Quoted 5 lines

Thanks for tracking it down. I think the condition can be simplified a bit. I also have to update the xfstest test to check for plain remount without changing anything to catch errors like these. I'll send patch soon.

Is "ext4: don't fail remount if journalling mode didn't change" the fix for the issue reported by Heiner?

- Sedat -

[1] https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git/commit/?h=dev&id=4c2467287779f744cdd70c8ec70903034d6584f0

Quoted 8 lines

Thanks!
-Lukas

Quoted 4 lines
fs/ext4/super.c +0 -0
                        ext4_msg(NULL, KERN_ERR, "Cannot change data mode "
                                 "on remount");
                        return -EINVAL;
#7 lore raw
Quoted 87 lines · Sedat Dilek
Quoted 86 lines · Lukas Czerner
Quoted 69 lines · Heiner Kallweit
Quoted 52 lines · Heiner Kallweit
Quoted 51 lines · Heiner Kallweit
Quoted 26 lines · Lukas Czerner
Quoted 8 lines · Heiner Kallweit

On linux-next systemd-remount-fs complains about an invalid mount option here, resulting in a r/o root fs. After playing with the mount options it turned out that data=ordered causes the problem. linux-next from Dec 1st was ok, so it seems to be related to the new mount API patches.

At a first glance I saw no obvious problem, the following looks good. Maybe you have an idea where to look ..

Quoted 9 lines

static const struct constant_table ext4_param_data[] = {

 {"journal",     EXT4_MOUNT_JOURNAL_DATA},
 {"ordered",     EXT4_MOUNT_ORDERED_DATA},
 {"writeback",   EXT4_MOUNT_WRITEBACK_DATA},

{}
};

fsparam_enum ("data", Opt_data, ext4_param_data),

Thank you for the report!

The ext4 mount has been reworked to use the new mount api and the work has been applied to linux-next couple of days ago so I definitelly assume there is a bug in there that I've missed. I will be looking into it.

Quoted 7 lines

Can you be a little bit more specific about how to reproduce the problem as well as the error it generates in the logs ? Any other mount options used simultaneously, non-default file system features, or mount options stored within the superblock ?

Can you reproduce it outside of the systemd unit, say a script ?

Yes:

[root@zotac ~]# mount -o remount,data=ordered /
mount: /: mount point not mounted or bad option.
[root@zotac ~]# mount -o remount,discard /
[root@zotac ~]#

"systemctl status systemd-remount-fs" shows the same error.

Following options I had in my fstab (ext4 fs):
rw,relatime,data=ordered,discard

No non-default system features.

Quoted 3 lines

Thanks!
-Lukas

Quoted 7 lines
Quoted 1 line

Heiner

Sorry, should have looked at dmesg earlier. There I see:
EXT4-fs: Cannot change data mode on remount
Message seems to be triggered from ext4_check_opt_consistency(). Not sure why this error doesn't occur with old mount API. And actually I don't change the data mode.

Based on the old API code: Maybe we need something like this? At least it works for me.

fs/ext4/super.c +0 -0
index b72d989b7..9ec7e526c 100644

fs/ext4/super.c static int ext4_check_opt_consistency(struct fs_context *fc, · line 2826

Quoted 7 lines
fs/ext4/super.c +3 -1
@@ -2821,7 +2821,9 @@ static int ext4_check_opt_consistency(struct fs_context *fc,
                                 "Remounting file system with no journal "
                                 "so ignoring journalled data option");
                        ctx_clear_mount_opt(ctx, EXT4_MOUNT_DATA_FLAGS);
-               } else if (ctx->mask_s_mount_opt & EXT4_MOUNT_DATA_FLAGS) {
+               } else if (ctx->mask_s_mount_opt & EXT4_MOUNT_DATA_FLAGS &&
+                          (ctx->vals_s_mount_opt & EXT4_MOUNT_DATA_FLAGS) !=
+                          (sbi->s_mount_opt & EXT4_MOUNT_DATA_FLAGS)) {

Hi,

indeed that's where the problem is. It's not enogh to check whether we have a data= mount options set, we also have to check whether it's the same as it already is set on the file system during remount. In which case we just ignore it, rather then error out.

Quoted 8 lines
Quoted 5 lines

Thanks for tracking it down. I think the condition can be simplified a bit. I also have to update the xfstest test to check for plain remount without changing anything to catch errors like these. I'll send patch soon.

Is "ext4: don't fail remount if journalling mode didn't change" the fix for the issue reported by Heiner?

Yes, it is.

-Lukas

Quoted 14 lines

- Sedat -

[1] https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git/commit/?h=dev&id=4c2467287779f744cdd70c8ec70903034d6584f0

Quoted 8 lines

Thanks!
-Lukas

Quoted 4 lines
fs/ext4/super.c +0 -0
                        ext4_msg(NULL, KERN_ERR, "Cannot change data mode "
                                 "on remount");
                        return -EINVAL;