2021-08-05 05:01:02

by Boyang Xue

[permalink] [raw]
Subject: [kernel-5.11 regression] tune2fs fails after shutdown

Hi,

kernel commit

4274f516d4bc ext4: recalucate superblock checksum after updating free
blocks/inodes

had been reverted by

81414b4dd48 ext4: remove redundant sb checksum recomputation

since kernel-5.11-rc1. As a result, the original reproducer fails again.

Reproducer:
```
mkdir mntpt
fallocate -l 256M mntpt.img
mkfs.ext4 -Fq -t ext4 mntpt.img 128M
LPDEV=$(losetup -f --show mntpt.img)
mount "$LPDEV" mntpt
cp /proc/version mntpt/
./godown mntpt # godown program attached.
umount mntpt
mount "$LPDEV" mntpt
tune2fs -l "$LPDEV"
```

tune2fs fails with
```
tune2fs 1.46.2 (28-Feb-2021)
tune2fs: Superblock checksum does not match superblock while trying to
open /dev/loop0
Couldn't find valid filesystem superblock.
```

Tested on e2fsprogs-1.46.2 + kernel-5.14.0-0.rc3.29. I think it's a
regression. If this is the case, can we fix it again please?

Thanks,
Boyang


Attachments:
godown.c (2.44 kB)

2021-08-12 01:49:02

by Boyang Xue

[permalink] [raw]
Subject: Re: [kernel-5.11 regression] tune2fs fails after shutdown

(Adding the author of the commits)

Hi Jan,

The commit

81414b4dd48 ext4: remove redundant sb checksum recomputation

breaks the original reproducer of

4274f516d4bc ext4: recalucate superblock checksum after updating free
blocks/inodes

I'm wondering is it expected please?

Thanks,
Boyang

On Thu, Aug 5, 2021 at 10:35 AM Boyang Xue <[email protected]> wrote:
>
> Hi,
>
> kernel commit
>
> 4274f516d4bc ext4: recalucate superblock checksum after updating free
> blocks/inodes
>
> had been reverted by
>
> 81414b4dd48 ext4: remove redundant sb checksum recomputation
>
> since kernel-5.11-rc1. As a result, the original reproducer fails again.
>
> Reproducer:
> ```
> mkdir mntpt
> fallocate -l 256M mntpt.img
> mkfs.ext4 -Fq -t ext4 mntpt.img 128M
> LPDEV=$(losetup -f --show mntpt.img)
> mount "$LPDEV" mntpt
> cp /proc/version mntpt/
> ./godown mntpt # godown program attached.
> umount mntpt
> mount "$LPDEV" mntpt
> tune2fs -l "$LPDEV"
> ```
>
> tune2fs fails with
> ```
> tune2fs 1.46.2 (28-Feb-2021)
> tune2fs: Superblock checksum does not match superblock while trying to
> open /dev/loop0
> Couldn't find valid filesystem superblock.
> ```
>
> Tested on e2fsprogs-1.46.2 + kernel-5.14.0-0.rc3.29. I think it's a
> regression. If this is the case, can we fix it again please?
>
> Thanks,
> Boyang

2021-08-12 13:10:53

by Jan Kara

[permalink] [raw]
Subject: Re: [kernel-5.11 regression] tune2fs fails after shutdown

Hello Boyang,

On Thu 12-08-21 09:47:30, Boyang Xue wrote:
> (Adding the author of the commits)
> Hi Jan,
>
> The commit
>
> 81414b4dd48 ext4: remove redundant sb checksum recomputation
>
> breaks the original reproducer of
>
> 4274f516d4bc ext4: recalucate superblock checksum after updating free
> blocks/inodes
>
> I'm wondering is it expected please?

Thanks for report! So for record the problem is not that superblock with
incorrect checksum would ever get to disk with my patches but the checksum
will be incorrect in the buffer cache until the moment we start writeout of
the superblock. And tune2fs accesses the buffer cache and sees the
incorrect (stale) checksum. It is impossible to fix this problem completely
(the tune2fs access is fundamentally racy) but yes, I guess returning the
checksum recalculation back will make the race window small and the cost is
small. I'll send a patch for this shortly.

Also can you perhaps make this sequence into a fstests testcase for ext4
filesystem so that we have it covered? Thanks!

Honza

> On Thu, Aug 5, 2021 at 10:35 AM Boyang Xue <[email protected]> wrote:
> >
> > Hi,
> >
> > kernel commit
> >
> > 4274f516d4bc ext4: recalucate superblock checksum after updating free
> > blocks/inodes
> >
> > had been reverted by
> >
> > 81414b4dd48 ext4: remove redundant sb checksum recomputation
> >
> > since kernel-5.11-rc1. As a result, the original reproducer fails again.
> >
> > Reproducer:
> > ```
> > mkdir mntpt
> > fallocate -l 256M mntpt.img
> > mkfs.ext4 -Fq -t ext4 mntpt.img 128M
> > LPDEV=$(losetup -f --show mntpt.img)
> > mount "$LPDEV" mntpt
> > cp /proc/version mntpt/
> > ./godown mntpt # godown program attached.
> > umount mntpt
> > mount "$LPDEV" mntpt
> > tune2fs -l "$LPDEV"
> > ```
> >
> > tune2fs fails with
> > ```
> > tune2fs 1.46.2 (28-Feb-2021)
> > tune2fs: Superblock checksum does not match superblock while trying to
> > open /dev/loop0
> > Couldn't find valid filesystem superblock.
> > ```
> >
> > Tested on e2fsprogs-1.46.2 + kernel-5.14.0-0.rc3.29. I think it's a
> > regression. If this is the case, can we fix it again please?
> >
> > Thanks,
> > Boyang
>
--
Jan Kara <[email protected]>
SUSE Labs, CR

2021-08-12 13:41:51

by Boyang Xue

[permalink] [raw]
Subject: Re: [kernel-5.11 regression] tune2fs fails after shutdown

Thanks Jan!

Yes. I will create a test case for fstests.

Thanks,
Boyang

On Thu, Aug 12, 2021 at 8:47 PM Jan Kara <[email protected]> wrote:
>
> Hello Boyang,
>
> On Thu 12-08-21 09:47:30, Boyang Xue wrote:
> > (Adding the author of the commits)
> > Hi Jan,
> >
> > The commit
> >
> > 81414b4dd48 ext4: remove redundant sb checksum recomputation
> >
> > breaks the original reproducer of
> >
> > 4274f516d4bc ext4: recalucate superblock checksum after updating free
> > blocks/inodes
> >
> > I'm wondering is it expected please?
>
> Thanks for report! So for record the problem is not that superblock with
> incorrect checksum would ever get to disk with my patches but the checksum
> will be incorrect in the buffer cache until the moment we start writeout of
> the superblock. And tune2fs accesses the buffer cache and sees the
> incorrect (stale) checksum. It is impossible to fix this problem completely
> (the tune2fs access is fundamentally racy) but yes, I guess returning the
> checksum recalculation back will make the race window small and the cost is
> small. I'll send a patch for this shortly.
>
> Also can you perhaps make this sequence into a fstests testcase for ext4
> filesystem so that we have it covered? Thanks!
>
> Honza
>
> > On Thu, Aug 5, 2021 at 10:35 AM Boyang Xue <[email protected]> wrote:
> > >
> > > Hi,
> > >
> > > kernel commit
> > >
> > > 4274f516d4bc ext4: recalucate superblock checksum after updating free
> > > blocks/inodes
> > >
> > > had been reverted by
> > >
> > > 81414b4dd48 ext4: remove redundant sb checksum recomputation
> > >
> > > since kernel-5.11-rc1. As a result, the original reproducer fails again.
> > >
> > > Reproducer:
> > > ```
> > > mkdir mntpt
> > > fallocate -l 256M mntpt.img
> > > mkfs.ext4 -Fq -t ext4 mntpt.img 128M
> > > LPDEV=$(losetup -f --show mntpt.img)
> > > mount "$LPDEV" mntpt
> > > cp /proc/version mntpt/
> > > ./godown mntpt # godown program attached.
> > > umount mntpt
> > > mount "$LPDEV" mntpt
> > > tune2fs -l "$LPDEV"
> > > ```
> > >
> > > tune2fs fails with
> > > ```
> > > tune2fs 1.46.2 (28-Feb-2021)
> > > tune2fs: Superblock checksum does not match superblock while trying to
> > > open /dev/loop0
> > > Couldn't find valid filesystem superblock.
> > > ```
> > >
> > > Tested on e2fsprogs-1.46.2 + kernel-5.14.0-0.rc3.29. I think it's a
> > > regression. If this is the case, can we fix it again please?
> > >
> > > Thanks,
> > > Boyang
> >
> --
> Jan Kara <[email protected]>
> SUSE Labs, CR
>