diff mbox series

generic/604: Fix for overlayfs

Message ID 20230618124506.2642352-1-amir73il@gmail.com (mailing list archive)
State New, archived
Headers show
Series generic/604: Fix for overlayfs | expand

Commit Message

Amir Goldstein June 18, 2023, 12:45 p.m. UTC
Since v6.3, I noticed that generic/604 does not run on overlayfs
because:

  generic/604 -- upper fs needs to support d_type

This is odd because the base fs I am using (xfs) does support d_type.

The reason is that for overlayfs, this sequence run by this test:

  _scratch_unmount &
  _scratch_mount

Translates to:

  umount $OVL_MNT; umount $BASE_MNT &
  mount $BASE_MNT ...; mount $OVL_MNT ...

Which can end up reordred as:

  umount $OVL_MNT;
  mount $BASE_MNT ...
                  umount $BASE_MNT &
                  mount $OVL_MNT ...

and overlayfs is trying to use a non-existing upper fs.

Use UMOUNT_PROG directly instead of the _scratch_unmount
helper, to avoid unmounting the base fs.

Incidently, the only thing that has changed in overlayfs in v6.3
is idmapped mounts support and the test in question was run without
idmapped mounts enabled, so the cahnge in behavior must be related
to some subtle timing change.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---
 tests/generic/604 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Christian Brauner June 20, 2023, 9:49 a.m. UTC | #1
On Sun, Jun 18, 2023 at 03:45:06PM +0300, Amir Goldstein wrote:
> Since v6.3, I noticed that generic/604 does not run on overlayfs
> because:
> 
>   generic/604 -- upper fs needs to support d_type
> 
> This is odd because the base fs I am using (xfs) does support d_type.
> 
> The reason is that for overlayfs, this sequence run by this test:
> 
>   _scratch_unmount &
>   _scratch_mount
> 
> Translates to:
> 
>   umount $OVL_MNT; umount $BASE_MNT &
>   mount $BASE_MNT ...; mount $OVL_MNT ...
> 
> Which can end up reordred as:
> 
>   umount $OVL_MNT;
>   mount $BASE_MNT ...
>                   umount $BASE_MNT &
>                   mount $OVL_MNT ...
> 
> and overlayfs is trying to use a non-existing upper fs.
> 
> Use UMOUNT_PROG directly instead of the _scratch_unmount
> helper, to avoid unmounting the base fs.
> 
> Incidently, the only thing that has changed in overlayfs in v6.3
> is idmapped mounts support and the test in question was run without
> idmapped mounts enabled, so the cahnge in behavior must be related
> to some subtle timing change.

I implemented testing overlayfs on top of idmapped mounts in xfstests
and changed a lot of the overlayfs test infrastructure. So I wouldn't be
surprised if that's the reason.

> 
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---

Looks good to me,
Reviewed-by: Christian Brauner <brauner@kernel.org>
Amir Goldstein June 20, 2023, 10:05 a.m. UTC | #2
On Tue, Jun 20, 2023 at 12:50 PM Christian Brauner <brauner@kernel.org> wrote:
>
> On Sun, Jun 18, 2023 at 03:45:06PM +0300, Amir Goldstein wrote:
> > Since v6.3, I noticed that generic/604 does not run on overlayfs
> > because:
> >
> >   generic/604 -- upper fs needs to support d_type
> >
> > This is odd because the base fs I am using (xfs) does support d_type.
> >
> > The reason is that for overlayfs, this sequence run by this test:
> >
> >   _scratch_unmount &
> >   _scratch_mount
> >
> > Translates to:
> >
> >   umount $OVL_MNT; umount $BASE_MNT &
> >   mount $BASE_MNT ...; mount $OVL_MNT ...
> >
> > Which can end up reordred as:
> >
> >   umount $OVL_MNT;
> >   mount $BASE_MNT ...
> >                   umount $BASE_MNT &
> >                   mount $OVL_MNT ...
> >
> > and overlayfs is trying to use a non-existing upper fs.
> >
> > Use UMOUNT_PROG directly instead of the _scratch_unmount
> > helper, to avoid unmounting the base fs.
> >
> > Incidently, the only thing that has changed in overlayfs in v6.3
> > is idmapped mounts support and the test in question was run without
> > idmapped mounts enabled, so the cahnge in behavior must be related
> > to some subtle timing change.
>
> I implemented testing overlayfs on top of idmapped mounts in xfstests
> and changed a lot of the overlayfs test infrastructure. So I wouldn't be
> surprised if that's the reason.

Could be, but to clarify, I was comparing kernel v6.2 to v6.3 with
same xfstests and in both cases I did not set IDMAPPED_MOUNTS,
so _idmapped_mount() should have been a noop.

Thanks,
Amir.
diff mbox series

Patch

diff --git a/tests/generic/604 b/tests/generic/604
index 9c53fd57..cc6a4b21 100755
--- a/tests/generic/604
+++ b/tests/generic/604
@@ -24,7 +24,9 @@  _scratch_mount
 for i in $(seq 0 500); do
 	$XFS_IO_PROG -f -c "pwrite 0 4K" $SCRATCH_MNT/$i >/dev/null
 done
-_scratch_unmount &
+# For overlayfs, avoid unmouting the base fs after _scratch_mount
+# tries to mount the base fs
+$UMOUNT_PROG $SCRATCH_MNT &
 _scratch_mount
 wait