2015-05-16 11:05:13

by Holger Hoffstätte

[permalink] [raw]
Subject: Lazytime undone by/not working with remount?


Hi,

playing with lazytime on 4.0.4-rc1 + yesterday's fencepost patch) I noticed
something odd. Mounting secondary (non-root) partitions with lazytime works
fine, but / does not seem to retain the value from fstab - apparently because
it is remounted rw during boot, and lazytime gets swallowed/undone.

Same effect when trying to remount manually with lazytime:

tux>findmnt /
TARGET SOURCE FSTYPE OPTIONS
/ /dev/sda1 ext4 rw,noatime

tux>mount -o lazytime,remount /

tux>dmesg
[ 5208.482505] EXT4-fs (sda1): re-mounted. Opts: (null)

tux>findmnt /
TARGET SOURCE FSTYPE OPTIONS
/ /dev/sda1 ext4 rw,noatime

tux>mount --version
mount from util-linux 2.26.2 (libmount 2.26.0: assert, debug)

Newly mounting unmounted partitions works fine.

Any ideas?

Holger



2015-05-16 14:26:29

by Holger Hoffstätte

[permalink] [raw]
Subject: Re: Lazytime undone by/not working with remount?


(cc: kzak)

On Sat, 16 May 2015 11:05:04 +0000, Holger Hoffstätte wrote:

> Hi,
>
> playing with lazytime on 4.0.4-rc1 + yesterday's fencepost patch) I noticed
> something odd. Mounting secondary (non-root) partitions with lazytime works
> fine, but / does not seem to retain the value from fstab - apparently because
> it is remounted rw during boot, and lazytime gets swallowed/undone.
>
> Same effect when trying to remount manually with lazytime:
>
> tux>findmnt /
> TARGET SOURCE FSTYPE OPTIONS
> / /dev/sda1 ext4 rw,noatime
>
> tux>mount -o lazytime,remount /
>
> tux>dmesg
> [ 5208.482505] EXT4-fs (sda1): re-mounted. Opts: (null)
>
> tux>findmnt /
> TARGET SOURCE FSTYPE OPTIONS
> / /dev/sda1 ext4 rw,noatime
>
> tux>mount --version
> mount from util-linux 2.26.2 (libmount 2.26.0: assert, debug)
>
> Newly mounting unmounted partitions works fine.
>
> Any ideas?

This turned out to be a regression in util-linux 2.26.x. :-(
I downgraded to 2.25.2 and behold:

tux>findmnt /
TARGET SOURCE FSTYPE OPTIONS
/ /dev/sda1 ext4 rw,noatime

tux>mount -o remount,lazytime /

root>findmnt /
TARGET SOURCE FSTYPE OPTIONS
/ /dev/sda1 ext4 rw,noatime,lazytime

Sorry for the noise.

Holger

2015-05-18 08:21:42

by Karel Zak

[permalink] [raw]
Subject: Re: Lazytime undone by/not working with remount?

On Sat, May 16, 2015 at 04:26:33PM +0200, Holger Hoffst?tte wrote:
> > playing with lazytime on 4.0.4-rc1 + yesterday's fencepost patch) I noticed
> > something odd. Mounting secondary (non-root) partitions with lazytime works
> > fine, but / does not seem to retain the value from fstab - apparently because
> > it is remounted rw during boot, and lazytime gets swallowed/undone.
> >
> > Same effect when trying to remount manually with lazytime:
> >
> > tux>findmnt /
> > TARGET SOURCE FSTYPE OPTIONS
> > / /dev/sda1 ext4 rw,noatime
> >
> > tux>mount -o lazytime,remount /
> >
> > tux>dmesg
> > [ 5208.482505] EXT4-fs (sda1): re-mounted. Opts: (null)
> >
> > tux>findmnt /
> > TARGET SOURCE FSTYPE OPTIONS
> > / /dev/sda1 ext4 rw,noatime
> >
> > tux>mount --version
> > mount from util-linux 2.26.2 (libmount 2.26.0: assert, debug)
> >
> > Newly mounting unmounted partitions works fine.
> >
> > Any ideas?
>
> This turned out to be a regression in util-linux 2.26.x. :-(

I don't think so. Try strace, for example:

# strace -e mount mount -o lazytime,remount /home/archive
mount("/dev/sdb1", "/home/archive", 0xcf1210, MS_REMOUNT|0x2000000, NULL) = 0
^^^^^^^^^
(1<<25) aka 0x2000000 is MS_LAZYTIME


The util-linux since version 2.26.2 supports MS_LAZYTIME flag.

I see the problem on another place. The ext4 fs driver has unique
feature that it's able to accept "lazytime" option as string
(util-linux < 2.26.2) as well as MS_LAZYTIME vfs flag (>= 2.26.2).

IMHO the function ext4_remount() does not check VFS *flags for
MS_LAZYTIME at all. The code probably cares about sb->s_flags only
(these flags are generated by parse_options() when parse options
string). It seems that only MS_RDONLY is expected in *flags.

Ted?

Karel


--
Karel Zak <[email protected]>
http://karelzak.blogspot.com

2015-05-18 15:18:40

by Eric Sandeen

[permalink] [raw]
Subject: Re: Lazytime undone by/not working with remount?

On 5/18/15 3:21 AM, Karel Zak wrote:
> On Sat, May 16, 2015 at 04:26:33PM +0200, Holger Hoffst?tte wrote:
>>> playing with lazytime on 4.0.4-rc1 + yesterday's fencepost patch) I noticed
>>> something odd. Mounting secondary (non-root) partitions with lazytime works
>>> fine, but / does not seem to retain the value from fstab - apparently because
>>> it is remounted rw during boot, and lazytime gets swallowed/undone.
>>>
>>> Same effect when trying to remount manually with lazytime:
>>>
>>> tux>findmnt /
>>> TARGET SOURCE FSTYPE OPTIONS
>>> / /dev/sda1 ext4 rw,noatime
>>>
>>> tux>mount -o lazytime,remount /
>>>
>>> tux>dmesg
>>> [ 5208.482505] EXT4-fs (sda1): re-mounted. Opts: (null)
>>>
>>> tux>findmnt /
>>> TARGET SOURCE FSTYPE OPTIONS
>>> / /dev/sda1 ext4 rw,noatime
>>>
>>> tux>mount --version
>>> mount from util-linux 2.26.2 (libmount 2.26.0: assert, debug)

And what does /proc/mounts say? That'll tell you what is actually set
on the superblock. Works here, on 4.1.0-rc2:

# mount /dev/sdb1 /mnt/test
# mount -o remount,lazytime /mnt/test
# grep sdb1 /proc/mounts
/dev/sdb1 /mnt/test ext4 rw,lazytime,seclabel,relatime,data=ordered 0 0

# dmesg | tail -n 2
[516203.450943] EXT4-fs (sdb1): mounted filesystem with ordered data mode. Opts: (null)
[516211.222020] EXT4-fs (sdb1): re-mounted. Opts: lazytime

-Eric

2015-05-18 15:23:25

by Theodore Ts'o

[permalink] [raw]
Subject: Re: Lazytime undone by/not working with remount?

On Mon, May 18, 2015 at 10:21:35AM +0200, Karel Zak wrote:
> I see the problem on another place. The ext4 fs driver has unique
> feature that it's able to accept "lazytime" option as string
> (util-linux < 2.26.2) as well as MS_LAZYTIME vfs flag (>= 2.26.2).
>
> IMHO the function ext4_remount() does not check VFS *flags for
> MS_LAZYTIME at all. The code probably cares about sb->s_flags only
> (these flags are generated by parse_options() when parse options
> string). It seems that only MS_RDONLY is expected in *flags.

Yep, the bug is on my side, in ext4_remount(). I'll get this fixed
and marked as something that should get bacported to the stable tree.
My apologies for the oversight.

- Ted

2015-05-18 15:43:31

by Holger Hoffstätte

[permalink] [raw]
Subject: Re: Lazytime undone by/not working with remount?


On 05/18/15 17:18, Eric Sandeen wrote:
> On 5/18/15 3:21 AM, Karel Zak wrote:
>> On Sat, May 16, 2015 at 04:26:33PM +0200, Holger Hoffstätte wrote:
>>>> playing with lazytime on 4.0.4-rc1 + yesterday's fencepost patch) I noticed
>>>> something odd. Mounting secondary (non-root) partitions with lazytime works
>>>> fine, but / does not seem to retain the value from fstab - apparently because
>>>> it is remounted rw during boot, and lazytime gets swallowed/undone.
>>>>
>>>> Same effect when trying to remount manually with lazytime:
>>>>
>>>> tux>findmnt /
>>>> TARGET SOURCE FSTYPE OPTIONS
>>>> / /dev/sda1 ext4 rw,noatime
>>>>
>>>> tux>mount -o lazytime,remount /
>>>>
>>>> tux>dmesg
>>>> [ 5208.482505] EXT4-fs (sda1): re-mounted. Opts: (null)
>>>>
>>>> tux>findmnt /
>>>> TARGET SOURCE FSTYPE OPTIONS
>>>> / /dev/sda1 ext4 rw,noatime
>>>>
>>>> tux>mount --version
>>>> mount from util-linux 2.26.2 (libmount 2.26.0: assert, debug)
>
> And what does /proc/mounts say? That'll tell you what is actually set
> on the superblock. Works here, on 4.1.0-rc2:
>
> # mount /dev/sdb1 /mnt/test
> # mount -o remount,lazytime /mnt/test
> # grep sdb1 /proc/mounts
> /dev/sdb1 /mnt/test ext4 rw,lazytime,seclabel,relatime,data=ordered 0 0
>
> # dmesg | tail -n 2
> [516203.450943] EXT4-fs (sdb1): mounted filesystem with ordered data mode. Opts: (null)
> [516211.222020] EXT4-fs (sdb1): re-mounted. Opts: lazytime

When I used util-linux 2.26.2 /proc/mounts never contained lazytime for the root device (sda1), despite the fact that it and other partitions explicitly had lazytime in fstab. Secondary drives & partitions *did* get the value right from the start, i.e. anything that didn't go through a ro->remount transition.

It all works reliably with 2.25.x since - as Karel mentioned - the bug seems with ext4's remount logic in combination with readonly (as was the case with the root partition) and mount now actually sending the MS_LAZYTIME flag, instead of relying on ext4's builtin extra handling.

-h

2015-05-18 15:48:32

by Holger Hoffstätte

[permalink] [raw]
Subject: Re: Lazytime undone by/not working with remount?

On 05/18/15 17:23, Theodore Ts'o wrote:
> On Mon, May 18, 2015 at 10:21:35AM +0200, Karel Zak wrote:
>> I see the problem on another place. The ext4 fs driver has unique
>> feature that it's able to accept "lazytime" option as string
>> (util-linux < 2.26.2) as well as MS_LAZYTIME vfs flag (>= 2.26.2).
>>
>> IMHO the function ext4_remount() does not check VFS *flags for
>> MS_LAZYTIME at all. The code probably cares about sb->s_flags only
>> (these flags are generated by parse_options() when parse options
>> string). It seems that only MS_RDONLY is expected in *flags.
>
> Yep, the bug is on my side, in ext4_remount(). I'll get this fixed
> and marked as something that should get bacported to the stable tree.
> My apologies for the oversight.

Thanks for confirming, Ted! I'll gladly test a patch for 4.0.x.

-h