mounting with lazytime doesn't work on ext4
I switched back to ext4 yesterday, because my btrfs fs got corrupted. However mounting with lazytime doesn't work, neither specifying it in /etc/fstab nor a manual remount. It looks like the option is simply ignored.
Strace shows, e.g.:
# mount -o lazytime /boot
mount("/dev/sdc2", "/boot", "ext4", MS_LAZYTIME, NULL) = 0
EXT4-fs (sdc2): mounted filesystem with ordered data mode. Opts: (null)
/dev/sdc2 on /boot type ext4 (rw,relatime,data=ordered) # mount -o remount,lazytime /var
mount("/dev/sdb2", "/var", 0x12c4460, MS_REMOUNT|MS_NOATIME|MS_LAZYTIME, NULL) = 0
EXT4-fs (sdb2): re-mounted. Opts: (null)
/dev/sdb2 on /var type ext4 (rw,noatime,data=ordered)When I set "sb->s_flags |= MS_LAZYTIME;" unconditionally in fs/ext4/super.c:5057 (just deleting the if statement), then lazytime gets used when I remount.
I'm running the latest git tree (4.14.0-rc1).
Signature · 1 line
Markus
Quoted 17 lines · Markus Trippelsdorf
I switched back to ext4 yesterday, because my btrfs fs got corrupted. However mounting with lazytime doesn't work, neither specifying it in
/etc/fstabnor a manual remount. It looks like the option is simply ignored.Strace shows, e.g.:
# mount -o lazytime /boot mount("/dev/sdc2", "/boot", "ext4", MS_LAZYTIME, NULL) = 0 EXT4-fs (sdc2): mounted filesystem with ordered data mode. Opts: (null) /dev/sdc2 on /boot type ext4 (rw,relatime,data=ordered)# mount -o remount,lazytime /var mount("/dev/sdb2", "/var", 0x12c4460, MS_REMOUNT|MS_NOATIME|MS_LAZYTIME, NULL) = 0 EXT4-fs (sdb2): re-mounted. Opts: (null) /dev/sdb2 on /var type ext4 (rw,noatime,data=ordered)
Quoted 5 lines
When I set "
sb->s_flags|=MS_LAZYTIME;" unconditionally infs/ext4/super.c:5057(just deleting the if statement), then lazytime gets used when I remount.I'm running the latest git tree (4.14.0-rc1).
The following patch seems to fix the issue for remounts:
fs/namespace.c +5 -0
@@ -2322,6 +2322,9 @@ static int do_remount(struct path *path, int ms_flags, int sb_flags,if (err)return err; +if (mnt_flags &MS_LAZYTIME ) + sb_flags |=MS_LAZYTIME ; +down_write (&sb->s_umount);if (ms_flags &MS_BIND ) err =change_mount_flags (path->mnt, ms_flags);
@@ -2809,6 +2812,8 @@ long do_mount(const char *dev_name, const char __user *dir_name, mnt_flags &= ~(MNT_RELATIME |MNT_NOATIME );if (flags &SB_RDONLY ) mnt_flags |=MNT_READONLY ; +if (flags &MS_LAZYTIME ) + mnt_flags |=MS_LAZYTIME ;/* The default atime for remount is preservation */ if ((flags & MS_REMOUNT) &&
Signature · 1 line
Markus
PATCH 1/1 VFS: Handle lazytime in do_mount()
The lazytime option didn't get passed on when using current util-linux, which passes MS_LAZYTIME in the mountflags directly.
Fix the issue by handling the option in do_mount().
--- fs/namespace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/namespace.c +2 -1
@@ -2823,7 +2823,8 @@ long do_mount(const char *dev_name, const char __user *dir_name,SB_MANDLOCK |SB_DIRSYNC |SB_SILENT | - SB_POSIXACL); +SB_POSIXACL | + MS_LAZYTIME);if (flags &MS_REMOUNT ) retval = do_remount(&path, flags, sb_flags, mnt_flags,
Signature · 1 line
Markus
PATCH v2 1/1 VFS: Handle lazytime in do_mount()
Since commit e462ec50cb5fa ("VFS: Differentiate mount flags (MS_*) from internal superblock flags") the lazytime mount option didn't get passed on anymore.
Fix the issue by handling the option in do_mount().
--- fs/namespace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/namespace.c +2 -1
@@ -2823,7 +2823,8 @@ long do_mount(const char *dev_name, const char __user *dir_name,SB_MANDLOCK |SB_DIRSYNC |SB_SILENT | - SB_POSIXACL); +SB_POSIXACL | + SB_LAZYTIME);if (flags &MS_REMOUNT ) retval = do_remount(&path, flags, sb_flags, mnt_flags,
Signature · 1 line
Markus
Re: [PATCH v2] VFS: Handle lazytime in do_mount()
Quoted 16 lines · Markus Trippelsdorf
Since commit
e462ec50cb5fa("VFS: Differentiate mount flags (MS_*) from internal superblock flags") the lazytime mount option didn't get passed on anymore.Fix the issue by handling the option in
do_mount().Signed-off-by Markus Trippelsdorf <[email protected]>--- fs/namespace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/namespace.c +0
-0
fs/namespace.c long do_mount(const char *dev_name, const char __user *dir_name, · line 2827
Quoted 6 lines
fs/namespace.c +2
-1@@ -2823,7 +2823,8 @@ long do_mount(const char *dev_name, const char __user *dir_name,SB_MANDLOCK |SB_DIRSYNC |SB_SILENT | - SB_POSIXACL); +SB_POSIXACL | + SB_LAZYTIME);
Looks good. Although I still think that this can be per mountpoint options.
Regardless of that, you can add
Quoted 5 lines
fs/namespace.c +0
-1if (flags &MS_REMOUNT ) retval = do_remount(&path, flags, sb_flags, mnt_flags, --Markus
Re: [PATCH v2] VFS: Handle lazytime in do_mount()
Quoted 26 lines · Lukas Czerner
Quoted 16 lines · Markus Trippelsdorf
Since commit
e462ec50cb5fa("VFS: Differentiate mount flags (MS_*) from internal superblock flags") the lazytime mount option didn't get passed on anymore.Fix the issue by handling the option in
do_mount().Signed-off-by Markus Trippelsdorf <[email protected]>--- fs/namespace.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/namespace.c +0
-0fs/namespace.c long do_mount(const char *dev_name, const char __user *dir_name, · line 2827
Quoted 6 lines
fs/namespace.c +2
-1@@ -2823,7 +2823,8 @@ long do_mount(const char *dev_name, const char __user *dir_name,SB_MANDLOCK |SB_DIRSYNC |SB_SILENT | - SB_POSIXACL); +SB_POSIXACL | + SB_LAZYTIME);Looks good. Although I still think that this can be per mountpoint options.
Quoted 2 lines
Regardless of that, you can add
Reviewed-by Lukas Czerner <[email protected]>
Ping?
Al could you please take look?
Thanks.
Signature · 1 line
Markus
Quoted 41 lines · Markus Trippelsdorf
Quoted 17 lines · Markus Trippelsdorf
I switched back to ext4 yesterday, because my btrfs fs got corrupted. However mounting with lazytime doesn't work, neither specifying it in
/etc/fstabnor a manual remount. It looks like the option is simply ignored.Strace shows, e.g.:
# mount -o lazytime /boot mount("/dev/sdc2", "/boot", "ext4", MS_LAZYTIME, NULL) = 0 EXT4-fs (sdc2): mounted filesystem with ordered data mode. Opts: (null) /dev/sdc2 on /boot type ext4 (rw,relatime,data=ordered)# mount -o remount,lazytime /var mount("/dev/sdb2", "/var", 0x12c4460, MS_REMOUNT|MS_NOATIME|MS_LAZYTIME, NULL) = 0 EXT4-fs (sdb2): re-mounted. Opts: (null) /dev/sdb2 on /var type ext4 (rw,noatime,data=ordered)Quoted 5 lines
When I set "
sb->s_flags|=MS_LAZYTIME;" unconditionally infs/ext4/super.c:5057(just deleting the if statement), then lazytime gets used when I remount.I'm running the latest git tree (4.14.0-rc1).
The following patch seems to fix the issue for remounts:
fs/namespace.c +3
-0@@ -2322,6 +2322,9 @@ static int do_remount(struct path *path, int ms_flags, int sb_flags,if (err)return err; +if (mnt_flags &MS_LAZYTIME ) + sb_flags |=MS_LAZYTIME ; +down_write (&sb->s_umount);if (ms_flags &MS_BIND ) err =change_mount_flags (path->mnt, ms_flags);
fs/namespace.c long do_mount(const char *dev_name, const char __user *dir_name, · line 2816
Quoted 5 lines
fs/namespace.c +2
-0@@ -2809,6 +2812,8 @@ long do_mount(const char *dev_name, const char __user *dir_name, mnt_flags &= ~(MNT_RELATIME |MNT_NOATIME );if (flags &SB_RDONLY ) mnt_flags |=MNT_READONLY ; +if (flags &MS_LAZYTIME ) + mnt_flags |=MS_LAZYTIME ;
Hi,
this is definitely not right. Currently it seems that MS_LAZYTIME is supposed to be per sb option, even though I do not see a reason why it should not be per mnt options, in fact I'd prefer that.
However the problem happened when e462ec50cb5fad19f6003a3d8087f4a0945dd2b1 switched from masking out per mnt flags to masking in per sb flags. However David missed SB_LAZYFLAG. The fix should be easy like this:
fs/namespace.c +2 -1
@@ -2823,7 +2823,8 @@ long do_mount(const char *dev_name, const char __user *dir_name,SB_MANDLOCK |SB_DIRSYNC |SB_SILENT | - SB_POSIXACL); +SB_POSIXACL | + SB_LAZYTIME);if (flags &MS_REMOUNT ) retval = do_remount(&path, flags, sb_flags, mnt_flags,
I can send a proper patch, however maybe it would be better to convert it to per-mountpoint flags instead ? Any thoughts Ted ?
-Lukas
Quoted 50 lines · Lukas Czerner
Quoted 41 lines · Markus Trippelsdorf
Quoted 17 lines · Markus Trippelsdorf
I switched back to ext4 yesterday, because my btrfs fs got corrupted. However mounting with lazytime doesn't work, neither specifying it in
/etc/fstabnor a manual remount. It looks like the option is simply ignored.Strace shows, e.g.:
# mount -o lazytime /boot mount("/dev/sdc2", "/boot", "ext4", MS_LAZYTIME, NULL) = 0 EXT4-fs (sdc2): mounted filesystem with ordered data mode. Opts: (null) /dev/sdc2 on /boot type ext4 (rw,relatime,data=ordered)# mount -o remount,lazytime /var mount("/dev/sdb2", "/var", 0x12c4460, MS_REMOUNT|MS_NOATIME|MS_LAZYTIME, NULL) = 0 EXT4-fs (sdb2): re-mounted. Opts: (null) /dev/sdb2 on /var type ext4 (rw,noatime,data=ordered)Quoted 5 lines
When I set "
sb->s_flags|=MS_LAZYTIME;" unconditionally infs/ext4/super.c:5057(just deleting the if statement), then lazytime gets used when I remount.I'm running the latest git tree (4.14.0-rc1).
The following patch seems to fix the issue for remounts:
fs/namespace.c +3
-0@@ -2322,6 +2322,9 @@ static int do_remount(struct path *path, int ms_flags, int sb_flags,if (err)return err; +if (mnt_flags &MS_LAZYTIME ) + sb_flags |=MS_LAZYTIME ; +down_write (&sb->s_umount);if (ms_flags &MS_BIND ) err =change_mount_flags (path->mnt, ms_flags);fs/namespace.c long do_mount(const char *dev_name, const char __user *dir_name, · line 2816
Quoted 5 lines
fs/namespace.c +2
-0@@ -2809,6 +2812,8 @@ long do_mount(const char *dev_name, const char __user *dir_name, mnt_flags &= ~(MNT_RELATIME |MNT_NOATIME );if (flags &SB_RDONLY ) mnt_flags |=MNT_READONLY ; +if (flags &MS_LAZYTIME ) + mnt_flags |=MS_LAZYTIME ;Hi,
Quoted 8 lines
this is definitely not right. Currently it seems that
MS_LAZYTIMEis supposed to be per sb option, even though I do not see a reason why it should not be per mnt options, in fact I'd prefer that.However the problem happened when
e462ec50cb5fad19f6003a3d8087f4a0945dd2b1switched from masking out per mnt flags to masking in per sb flags. However David missedSB_LAZYFLAG. The fix should be easy like this:
Yes. I already send the identical patch. Please see:
https://lkml.org/lkml/2017/9/19/186
Signature · 1 line
Markus
Quoted 17 lines · Markus Trippelsdorf
I switched back to ext4 yesterday, because my btrfs fs got corrupted. However mounting with lazytime doesn't work, neither specifying it in
/etc/fstabnor a manual remount. It looks like the option is simply ignored.Strace shows, e.g.:
# mount -o lazytime /boot mount("/dev/sdc2", "/boot", "ext4", MS_LAZYTIME, NULL) = 0 EXT4-fs (sdc2): mounted filesystem with ordered data mode. Opts: (null) /dev/sdc2 on /boot type ext4 (rw,relatime,data=ordered)# mount -o remount,lazytime /var mount("/dev/sdb2", "/var", 0x12c4460, MS_REMOUNT|MS_NOATIME|MS_LAZYTIME, NULL) = 0 EXT4-fs (sdb2): re-mounted. Opts: (null) /dev/sdb2 on /var type ext4 (rw,noatime,data=ordered)
Quoted 5 lines
When I set "
sb->s_flags|=MS_LAZYTIME;" unconditionally infs/ext4/super.c:5057(just deleting the if statement), then lazytime gets used when I remount.I'm running the latest git tree (4.14.0-rc1).
Hi,
I can't really see the problem on my system (4.14.0-rc1)
# mount -o lazytime /dev/vdb /mnt/test # mount | grep vdb /dev/vdb on /mnt/test type ext4 (rw,relatime,lazytime,seclabel,data=ordered)
Log says:
EXT4-fs (vdb): mounted filesystem with ordered data mode. Opts: lazytime
or even via remount
# mount /dev/vdb /mnt/test # mount | grep vdb /dev/vdb on /mnt/test type ext4 (rw,relatime,seclabel,data=ordered) # mount -o remount,lazytime /mnt/test # mount | grep vdb /dev/vdb on /mnt/test type ext4 (rw,relatime,lazytime,seclabel,data=ordered)
Log says:
EXT4-fs (vdb): re-mounted. Opts: data=ordered,lazytime
This is probably because I have older version of util-linux that did now knew about MS_LAZYTIME so it passed "lazytime" option down to the filesystem. So we're definitelly missing something in kernel for this to work properly.
Indeed with newer version of util-linux, specifically the one containing commit v2.26-169-g8c7f073 I can reproduce.
Thanks!
-Lukas
Quoted 3 lines
Signature · 2 lines
-- Markus
Quoted 47 lines · Lukas Czerner
Quoted 17 lines · Markus Trippelsdorf
I switched back to ext4 yesterday, because my btrfs fs got corrupted. However mounting with lazytime doesn't work, neither specifying it in
/etc/fstabnor a manual remount. It looks like the option is simply ignored.Strace shows, e.g.:
# mount -o lazytime /boot mount("/dev/sdc2", "/boot", "ext4", MS_LAZYTIME, NULL) = 0 EXT4-fs (sdc2): mounted filesystem with ordered data mode. Opts: (null) /dev/sdc2 on /boot type ext4 (rw,relatime,data=ordered)# mount -o remount,lazytime /var mount("/dev/sdb2", "/var", 0x12c4460, MS_REMOUNT|MS_NOATIME|MS_LAZYTIME, NULL) = 0 EXT4-fs (sdb2): re-mounted. Opts: (null) /dev/sdb2 on /var type ext4 (rw,noatime,data=ordered)Quoted 5 lines
When I set "
sb->s_flags|=MS_LAZYTIME;" unconditionally infs/ext4/super.c:5057(just deleting the if statement), then lazytime gets used when I remount.I'm running the latest git tree (4.14.0-rc1).
Hi,
I can't really see the problem on my system (4.14.0-rc1)
# mount -o lazytime /dev/vdb /mnt/test # mount | grep vdb /dev/vdb on /mnt/test type ext4 (rw,relatime,lazytime,seclabel,data=ordered)Log says:
EXT4-fs (vdb): mounted filesystem with ordered data mode. Opts: lazytimeor even via remount
# mount /dev/vdb /mnt/test # mount | grep vdb /dev/vdb on /mnt/test type ext4 (rw,relatime,seclabel,data=ordered) # mount -o remount,lazytime /mnt/test # mount | grep vdb /dev/vdb on /mnt/test type ext4 (rw,relatime,lazytime,seclabel,data=ordered)Log says:
EXT4-fs (vdb): re-mounted. Opts: data=ordered,lazytime
Quoted 7 lines
This is probably because I have older version of util-linux that did now knew about
MS_LAZYTIMEso it passed "lazytime" option down to the filesystem. So we're definitelly missing something in kernel for this to work properly.Indeed with newer version of util-linux, specifically the one containing commit v2.26-169-g8c7f073 I can reproduce.
Yes. It took me some time to figure out that this is a very recent Linux regression (since commit e462ec50cb5). I've have send a simple patch to fix the issue.
Signature · 1 line
Markus