public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] overlay: add tests for casefolded layers
@ 2025-10-17 17:06 Amir Goldstein
  2025-11-10 18:09 ` Amir Goldstein
  2025-11-14 18:17 ` Zorro Lang
  0 siblings, 2 replies; 3+ messages in thread
From: Amir Goldstein @ 2025-10-17 17:06 UTC (permalink / raw)
  To: Zorro Lang
  Cc: Miklos Szeredi, Christian Brauner, André Almeida,
	linux-unionfs, fstests

Overalyfs did not allow mounting layers with casefold capable fs
until kernel v6.17-rc1 and did not allow casefold enabled layers
until kernel v6.18-rc1.

Since kernel v6.18-rc1, overalyfs allows this kind of setups,
as long as the layers have consistent encoding and all the directories
in the subtree have consistent casefolding.

Create test cases for the following scenarios:
- Mounting overlayfs with casefold disabled
- Mounting overlayfs with casefold enabled
- Lookup subdir in overlayfs with mismatch casefold to parent dir
- Change casefold of underlying subdir while overalyfs is mounted
- Mounting overlayfs with strict enconding, but casefold disabled
- Mounting overlayfs with strict enconding casefold enabled
- Mounting overlayfs with layers with inconsistent UTF8 version

Co-developed-by: André Almeida <andrealmeid@igalia.com>
Signed-off-by: André Almeida <andrealmeid@igalia.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
---

Zorro,

This test covers the overlayfs casefold feature that was introduced in
two steps - casefold disabled layers in 6.17-rc1 and casefold enabled
layers in 6.18-rc1.

I think there is less interest in testing the v6.17 changes on their own
so this test requires support for casefold enabled layers from 6.18-rc1
and will notrun on kernel < 6.18-rc1:

generic/999 5s ...  [12:43:16] [12:43:18] [not run]
	generic/999 -- overlayfs does not support casefold enabled layers

If there is a demand, we could split a test for the v6.17 support.

Note that this test is written as a generic and not an overlay test,
because we do not have the infrastructure to format and mount a base fs
with casefold support, so this test can run with e.g. ext4 FSTYP, but it
will notrun with e.g. xfs FSTYPE:

generic/999 6s ...  [12:30:03] [12:30:05] [not run]
	generic/999 -- xfs does not support casefold feature

I left the test number 999 for you to re-number.
If you prefer that I post with another test number assignment in the
future please let me know.

Thanks,
Amir.


 tests/generic/999     | 243 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/999.out |  13 +++
 2 files changed, 256 insertions(+)
 create mode 100755 tests/generic/999
 create mode 100644 tests/generic/999.out

diff --git a/tests/generic/999 b/tests/generic/999
new file mode 100755
index 00000000..e81ea036
--- /dev/null
+++ b/tests/generic/999
@@ -0,0 +1,243 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2025 CTERA Networks. All Rights Reserved.
+#
+# FS QA Test 999
+#
+# Test overlayfs error cases with casefold enabled layers
+#
+# Overalyfs did not allow mounting layers with casefold capable fs
+# until kernel v6.17 and with casefold enabled until kernel v6.18.
+# Since kernel v6.17, overalyfs allows the mount, as long as casefolding
+# is disabled on all directories.
+# Since kernel v6.18, overalyfs allows the mount, as long as casefolding
+# is consistent on all directories and encoding is consistent on all layers.
+#
+. ./common/preamble
+_begin_fstest auto quick mount casefold
+
+# Override the default cleanup function.
+_cleanup()
+{
+	cd /
+	_unmount $merge 2>/dev/null
+	rm -r -f $tmp.*
+}
+
+
+# Import common functions.
+. ./common/filter
+. ./common/casefold
+
+_exclude_fs overlay
+_require_extra_fs overlay
+
+_require_scratch_casefold
+
+# Create casefold capable base fs
+_scratch_mkfs_casefold >>$seqres.full 2>&1
+_scratch_mount_casefold
+
+# Create lowerdir, upperdir and workdir without casefold enabled
+lowerdir="$SCRATCH_MNT/ovl-lower"
+upperdir="$SCRATCH_MNT/ovl-upper"
+workdir="$SCRATCH_MNT/ovl-work"
+merge="$SCRATCH_MNT/ovl-merge"
+
+mount_casefold_version()
+{
+	option="casefold=$1"
+	mount -t tmpfs -o $option tmpfs $2
+}
+
+mount_overlay()
+{
+	local lowerdirs=$1
+
+	_mount -t overlay overlay $merge \
+		-o lowerdir=$lowerdirs,upperdir=$upperdir,workdir=$workdir
+}
+
+unmount_overlay()
+{
+	_unmount $SCRATCH_MNT/ovl-merge 2>/dev/null
+}
+
+# Try to mount an overlay with casefold enabled layers.
+# On kernels older than v6.18 expect failure and skip the test
+mkdir -p $merge $upperdir $workdir $lowerdir
+_casefold_set_attr $upperdir >>$seqres.full
+_casefold_set_attr $workdir >>$seqres.full
+_casefold_set_attr $lowerdir >>$seqres.full
+mount_overlay $lowerdir >>$seqres.full 2>&1 || \
+	_notrun "overlayfs does not support casefold enabled layers"
+unmount_overlay
+
+# Re-create casefold disabled layers with lower subdir
+casefolddir=$lowerdir/casefold
+rm -rf $upperdir $workdir $lowerdir
+mkdir -p $upperdir $workdir $lowerdir $casefolddir
+
+# Try to mount an overlay with casefold capable but disabled layers.
+# Since we already verified that overalyfs supports casefold enabled layers
+# this is expected to succeed.
+echo Casefold disabled
+mount_overlay $lowerdir >>$seqres.full 2>&1 || \
+	echo "Overlayfs mount with casefold disabled layers failed (1)"
+ls $merge/casefold/ >>$seqres.full
+unmount_overlay
+
+# Use new upper/work dirs for each test to avoid ESTALE errors
+# on mismatch lowerdir/upperdir (see test overlay/037)
+rm -rf $upperdir $workdir
+mkdir $upperdir $workdir
+
+# Try to mount an overlay with casefold disabled layers and
+# enable casefold on lowerdir root after mount - expect ESTALE error on lookup.
+echo Casefold enabled after mount
+mount_overlay $casefolddir >>$seqres.full || \
+	echo "Overlayfs mount with casefold disabled layers failed (2)"
+_casefold_set_attr $casefolddir >>$seqres.full
+mkdir $casefolddir/subdir
+ls $merge/subdir |& _filter_scratch
+unmount_overlay
+
+# Try to mount an overlay with casefold enabled lowerdir root - expect EINVAL.
+# With libmount version >= v1.39, we expect the following descriptive error:
+# mount: overlay: case-insensitive directory on .../ovl-lower/casefold not supported
+# but we want the test to run with older libmount, so we so not expect this output
+# we just expect a mount failure.
+echo Casefold enabled lower dir
+mount_overlay $casefolddir >>$seqres.full 2>&1 && \
+	echo "Overlayfs mount with casefold enabled lowerdir should have failed" && \
+	unmount_overlay
+
+# Changing lower layer root again
+rm -rf $upperdir $workdir
+mkdir $upperdir $workdir
+
+# Try to mount an overlay with casefold disabled layers, but with
+# casefold enabled subdir in lowerdir - expect EREMOTE error on lookup.
+echo Casefold enabled lower subdir
+mount_overlay $lowerdir >>$seqres.full
+ls $merge/casefold/subdir |& _filter_scratch
+unmount_overlay
+
+# workdir needs to be empty to set casefold attribute
+rm -rf $workdir/*
+
+_casefold_set_attr $upperdir >>$seqres.full
+_casefold_set_attr $workdir >>$seqres.full
+
+echo Casefold enabled upper dir
+mount_overlay $lowerdir >>$seqres.full 2>&1 && \
+	echo "Overlayfs mount with casefold enabled upperdir should have failed" && \
+	unmount_overlay
+
+# lowerdir needs to be empty to set casefold attribute
+rm -rf $lowerdir/*
+_casefold_set_attr $lowerdir >>$seqres.full
+mkdir $casefolddir
+
+# Try to mount an overlay with casefold enabled layers.
+# On kernels older than v6.18 expect failure and skip the rest of the test
+# On kernels v6.18 and newer, expect success and run the rest of the test cases.
+echo Casefold enabled
+mount_overlay $lowerdir >>$seqres.full 2>&1 || \
+	echo "Overlayfs mount with casefold enabled layers failed (1)"
+ls $merge/casefold/ >>$seqres.full
+unmount_overlay
+
+# Try to mount an overlayfs with casefold enabled layers. After the mount,
+# disable casefold on the lower layer and try to lookup a file. Should return
+# -ESTALE
+echo Casefold disabled on lower after mount
+mount_overlay $lowerdir >>$seqres.full 2>&1 || \
+	echo "Overlayfs mount with casefold enabled layers failed (2)"
+rm -rf $lowerdir/*
+_casefold_unset_attr $lowerdir >>$seqres.full
+mkdir $lowerdir/dir
+ls $merge/dir/ |& _filter_scratch
+unmount_overlay
+
+# cleanup
+rm -rf $lowerdir/*
+_casefold_set_attr $lowerdir >>$seqres.full
+
+# Try to mount an overlayfs with casefold enabled layers. After the mount,
+# disable casefold on a subdir in  the lower layer and try to lookup it.
+# Should return -EREMOTE
+echo Casefold disabled on subdir after mount
+mkdir $lowerdir/casefold/
+mount_overlay $lowerdir >>$seqres.full 2>&1 || \
+	echo "Overlayfs mount with casefold enabled layers failed (3)"
+_casefold_unset_attr $lowerdir/casefold/
+mkdir $lowerdir/casefold/subdir
+ls $merge/casefold/subdir |& _filter_scratch
+unmount_overlay
+
+# cleanup
+rm -rf $lowerdir/*
+
+# Test strict enconding, but casefold not enabled. Should work
+_scratch_umount_idmapped
+
+_scratch_mkfs_casefold_strict >>$seqres.full 2>&1
+_scratch_mount_casefold
+
+mkdir -p $merge $upperdir $workdir $lowerdir
+
+mount_overlay $lowerdir >>$seqres.full 2>&1 || \
+	echo "Overlayfs mount with strict casefold disabled layers failed"
+unmount_overlay
+
+# Test strict enconding, with casefold enabled. Should fail
+# dmesg: overlayfs: strict encoding not supported
+rm -rf $upperdir $workdir
+mkdir $upperdir $workdir
+
+_casefold_set_attr $upperdir >>$seqres.full
+_casefold_set_attr $workdir >>$seqres.full
+_casefold_set_attr $lowerdir >>$seqres.full
+
+mount_overlay $lowerdir >>$seqres.full 2>&1 && \
+	echo "Overlayfs mount with strict casefold enabled should have failed" && \
+	unmount_overlay
+
+# Test inconsistent casefold version. Should fail
+# dmesg: overlayfs: all layers must have the same encoding
+
+# use tmpfs to make easier to create two different mount points with different
+# utf8 versions
+testdir="$SCRATCH_MNT/newdir/"
+mkdir $testdir
+
+MNT1="$testdir/mnt1"
+MNT2="$testdir/mnt2"
+
+mkdir $MNT1 $MNT2 "$testdir/merge"
+
+mount_casefold_version "utf8-12.1.0" $MNT1
+mount_casefold_version "utf8-11.0.0" $MNT2
+
+mkdir "$MNT1/dir" "$MNT2/dir"
+
+_casefold_set_attr "$MNT1/dir"
+_casefold_set_attr "$MNT2/dir"
+
+mkdir "$MNT1/dir/lower" "$MNT2/dir/upper" "$MNT2/dir/work"
+
+upperdir="$MNT2/dir/upper"
+workdir="$MNT2/dir/work"
+lowerdir="$MNT1/dir/lower"
+
+mount_overlay $lowerdir >>$seqres.full 2>&1  && \
+	echo "Overlayfs mount different unicode versions should have failed" && \
+	unmount_overlay
+
+umount $MNT1
+umount $MNT2
+
+# success, all done
+status=0
+exit
diff --git a/tests/generic/999.out b/tests/generic/999.out
new file mode 100644
index 00000000..ce383d94
--- /dev/null
+++ b/tests/generic/999.out
@@ -0,0 +1,13 @@
+QA output created by 999
+Casefold disabled
+Casefold enabled after mount
+ls: cannot access 'SCRATCH_MNT/ovl-merge/subdir': Stale file handle
+Casefold enabled lower dir
+Casefold enabled lower subdir
+ls: cannot access 'SCRATCH_MNT/ovl-merge/casefold/subdir': Object is remote
+Casefold enabled upper dir
+Casefold enabled
+Casefold disabled on lower after mount
+ls: cannot access 'SCRATCH_MNT/ovl-merge/dir/': Stale file handle
+Casefold disabled on subdir after mount
+ls: cannot access 'SCRATCH_MNT/ovl-merge/casefold/subdir': Object is remote
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] overlay: add tests for casefolded layers
  2025-10-17 17:06 [PATCH] overlay: add tests for casefolded layers Amir Goldstein
@ 2025-11-10 18:09 ` Amir Goldstein
  2025-11-14 18:17 ` Zorro Lang
  1 sibling, 0 replies; 3+ messages in thread
From: Amir Goldstein @ 2025-11-10 18:09 UTC (permalink / raw)
  To: Zorro Lang
  Cc: Miklos Szeredi, Christian Brauner, André Almeida,
	linux-unionfs, fstests

On Fri, Oct 17, 2025 at 7:06 PM Amir Goldstein <amir73il@gmail.com> wrote:
>
> Overalyfs did not allow mounting layers with casefold capable fs
> until kernel v6.17-rc1 and did not allow casefold enabled layers
> until kernel v6.18-rc1.
>
> Since kernel v6.18-rc1, overalyfs allows this kind of setups,
> as long as the layers have consistent encoding and all the directories
> in the subtree have consistent casefolding.
>
> Create test cases for the following scenarios:
> - Mounting overlayfs with casefold disabled
> - Mounting overlayfs with casefold enabled
> - Lookup subdir in overlayfs with mismatch casefold to parent dir
> - Change casefold of underlying subdir while overalyfs is mounted
> - Mounting overlayfs with strict enconding, but casefold disabled
> - Mounting overlayfs with strict enconding casefold enabled
> - Mounting overlayfs with layers with inconsistent UTF8 version
>
> Co-developed-by: André Almeida <andrealmeid@igalia.com>
> Signed-off-by: André Almeida <andrealmeid@igalia.com>
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
>
> Zorro,

Ping?

Thanks,
Amir.

>
> This test covers the overlayfs casefold feature that was introduced in
> two steps - casefold disabled layers in 6.17-rc1 and casefold enabled
> layers in 6.18-rc1.
>
> I think there is less interest in testing the v6.17 changes on their own
> so this test requires support for casefold enabled layers from 6.18-rc1
> and will notrun on kernel < 6.18-rc1:
>
> generic/999 5s ...  [12:43:16] [12:43:18] [not run]
>         generic/999 -- overlayfs does not support casefold enabled layers
>
> If there is a demand, we could split a test for the v6.17 support.
>
> Note that this test is written as a generic and not an overlay test,
> because we do not have the infrastructure to format and mount a base fs
> with casefold support, so this test can run with e.g. ext4 FSTYP, but it
> will notrun with e.g. xfs FSTYPE:
>
> generic/999 6s ...  [12:30:03] [12:30:05] [not run]
>         generic/999 -- xfs does not support casefold feature
>
> I left the test number 999 for you to re-number.
> If you prefer that I post with another test number assignment in the
> future please let me know.
>
> Thanks,
> Amir.
>
>
>  tests/generic/999     | 243 ++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/999.out |  13 +++
>  2 files changed, 256 insertions(+)
>  create mode 100755 tests/generic/999
>  create mode 100644 tests/generic/999.out
>
> diff --git a/tests/generic/999 b/tests/generic/999
> new file mode 100755
> index 00000000..e81ea036
> --- /dev/null
> +++ b/tests/generic/999
> @@ -0,0 +1,243 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (C) 2025 CTERA Networks. All Rights Reserved.
> +#
> +# FS QA Test 999
> +#
> +# Test overlayfs error cases with casefold enabled layers
> +#
> +# Overalyfs did not allow mounting layers with casefold capable fs
> +# until kernel v6.17 and with casefold enabled until kernel v6.18.
> +# Since kernel v6.17, overalyfs allows the mount, as long as casefolding
> +# is disabled on all directories.
> +# Since kernel v6.18, overalyfs allows the mount, as long as casefolding
> +# is consistent on all directories and encoding is consistent on all layers.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick mount casefold
> +
> +# Override the default cleanup function.
> +_cleanup()
> +{
> +       cd /
> +       _unmount $merge 2>/dev/null
> +       rm -r -f $tmp.*
> +}
> +
> +
> +# Import common functions.
> +. ./common/filter
> +. ./common/casefold
> +
> +_exclude_fs overlay
> +_require_extra_fs overlay
> +
> +_require_scratch_casefold
> +
> +# Create casefold capable base fs
> +_scratch_mkfs_casefold >>$seqres.full 2>&1
> +_scratch_mount_casefold
> +
> +# Create lowerdir, upperdir and workdir without casefold enabled
> +lowerdir="$SCRATCH_MNT/ovl-lower"
> +upperdir="$SCRATCH_MNT/ovl-upper"
> +workdir="$SCRATCH_MNT/ovl-work"
> +merge="$SCRATCH_MNT/ovl-merge"
> +
> +mount_casefold_version()
> +{
> +       option="casefold=$1"
> +       mount -t tmpfs -o $option tmpfs $2
> +}
> +
> +mount_overlay()
> +{
> +       local lowerdirs=$1
> +
> +       _mount -t overlay overlay $merge \
> +               -o lowerdir=$lowerdirs,upperdir=$upperdir,workdir=$workdir
> +}
> +
> +unmount_overlay()
> +{
> +       _unmount $SCRATCH_MNT/ovl-merge 2>/dev/null
> +}
> +
> +# Try to mount an overlay with casefold enabled layers.
> +# On kernels older than v6.18 expect failure and skip the test
> +mkdir -p $merge $upperdir $workdir $lowerdir
> +_casefold_set_attr $upperdir >>$seqres.full
> +_casefold_set_attr $workdir >>$seqres.full
> +_casefold_set_attr $lowerdir >>$seqres.full
> +mount_overlay $lowerdir >>$seqres.full 2>&1 || \
> +       _notrun "overlayfs does not support casefold enabled layers"
> +unmount_overlay
> +
> +# Re-create casefold disabled layers with lower subdir
> +casefolddir=$lowerdir/casefold
> +rm -rf $upperdir $workdir $lowerdir
> +mkdir -p $upperdir $workdir $lowerdir $casefolddir
> +
> +# Try to mount an overlay with casefold capable but disabled layers.
> +# Since we already verified that overalyfs supports casefold enabled layers
> +# this is expected to succeed.
> +echo Casefold disabled
> +mount_overlay $lowerdir >>$seqres.full 2>&1 || \
> +       echo "Overlayfs mount with casefold disabled layers failed (1)"
> +ls $merge/casefold/ >>$seqres.full
> +unmount_overlay
> +
> +# Use new upper/work dirs for each test to avoid ESTALE errors
> +# on mismatch lowerdir/upperdir (see test overlay/037)
> +rm -rf $upperdir $workdir
> +mkdir $upperdir $workdir
> +
> +# Try to mount an overlay with casefold disabled layers and
> +# enable casefold on lowerdir root after mount - expect ESTALE error on lookup.
> +echo Casefold enabled after mount
> +mount_overlay $casefolddir >>$seqres.full || \
> +       echo "Overlayfs mount with casefold disabled layers failed (2)"
> +_casefold_set_attr $casefolddir >>$seqres.full
> +mkdir $casefolddir/subdir
> +ls $merge/subdir |& _filter_scratch
> +unmount_overlay
> +
> +# Try to mount an overlay with casefold enabled lowerdir root - expect EINVAL.
> +# With libmount version >= v1.39, we expect the following descriptive error:
> +# mount: overlay: case-insensitive directory on .../ovl-lower/casefold not supported
> +# but we want the test to run with older libmount, so we so not expect this output
> +# we just expect a mount failure.
> +echo Casefold enabled lower dir
> +mount_overlay $casefolddir >>$seqres.full 2>&1 && \
> +       echo "Overlayfs mount with casefold enabled lowerdir should have failed" && \
> +       unmount_overlay
> +
> +# Changing lower layer root again
> +rm -rf $upperdir $workdir
> +mkdir $upperdir $workdir
> +
> +# Try to mount an overlay with casefold disabled layers, but with
> +# casefold enabled subdir in lowerdir - expect EREMOTE error on lookup.
> +echo Casefold enabled lower subdir
> +mount_overlay $lowerdir >>$seqres.full
> +ls $merge/casefold/subdir |& _filter_scratch
> +unmount_overlay
> +
> +# workdir needs to be empty to set casefold attribute
> +rm -rf $workdir/*
> +
> +_casefold_set_attr $upperdir >>$seqres.full
> +_casefold_set_attr $workdir >>$seqres.full
> +
> +echo Casefold enabled upper dir
> +mount_overlay $lowerdir >>$seqres.full 2>&1 && \
> +       echo "Overlayfs mount with casefold enabled upperdir should have failed" && \
> +       unmount_overlay
> +
> +# lowerdir needs to be empty to set casefold attribute
> +rm -rf $lowerdir/*
> +_casefold_set_attr $lowerdir >>$seqres.full
> +mkdir $casefolddir
> +
> +# Try to mount an overlay with casefold enabled layers.
> +# On kernels older than v6.18 expect failure and skip the rest of the test
> +# On kernels v6.18 and newer, expect success and run the rest of the test cases.
> +echo Casefold enabled
> +mount_overlay $lowerdir >>$seqres.full 2>&1 || \
> +       echo "Overlayfs mount with casefold enabled layers failed (1)"
> +ls $merge/casefold/ >>$seqres.full
> +unmount_overlay
> +
> +# Try to mount an overlayfs with casefold enabled layers. After the mount,
> +# disable casefold on the lower layer and try to lookup a file. Should return
> +# -ESTALE
> +echo Casefold disabled on lower after mount
> +mount_overlay $lowerdir >>$seqres.full 2>&1 || \
> +       echo "Overlayfs mount with casefold enabled layers failed (2)"
> +rm -rf $lowerdir/*
> +_casefold_unset_attr $lowerdir >>$seqres.full
> +mkdir $lowerdir/dir
> +ls $merge/dir/ |& _filter_scratch
> +unmount_overlay
> +
> +# cleanup
> +rm -rf $lowerdir/*
> +_casefold_set_attr $lowerdir >>$seqres.full
> +
> +# Try to mount an overlayfs with casefold enabled layers. After the mount,
> +# disable casefold on a subdir in  the lower layer and try to lookup it.
> +# Should return -EREMOTE
> +echo Casefold disabled on subdir after mount
> +mkdir $lowerdir/casefold/
> +mount_overlay $lowerdir >>$seqres.full 2>&1 || \
> +       echo "Overlayfs mount with casefold enabled layers failed (3)"
> +_casefold_unset_attr $lowerdir/casefold/
> +mkdir $lowerdir/casefold/subdir
> +ls $merge/casefold/subdir |& _filter_scratch
> +unmount_overlay
> +
> +# cleanup
> +rm -rf $lowerdir/*
> +
> +# Test strict enconding, but casefold not enabled. Should work
> +_scratch_umount_idmapped
> +
> +_scratch_mkfs_casefold_strict >>$seqres.full 2>&1
> +_scratch_mount_casefold
> +
> +mkdir -p $merge $upperdir $workdir $lowerdir
> +
> +mount_overlay $lowerdir >>$seqres.full 2>&1 || \
> +       echo "Overlayfs mount with strict casefold disabled layers failed"
> +unmount_overlay
> +
> +# Test strict enconding, with casefold enabled. Should fail
> +# dmesg: overlayfs: strict encoding not supported
> +rm -rf $upperdir $workdir
> +mkdir $upperdir $workdir
> +
> +_casefold_set_attr $upperdir >>$seqres.full
> +_casefold_set_attr $workdir >>$seqres.full
> +_casefold_set_attr $lowerdir >>$seqres.full
> +
> +mount_overlay $lowerdir >>$seqres.full 2>&1 && \
> +       echo "Overlayfs mount with strict casefold enabled should have failed" && \
> +       unmount_overlay
> +
> +# Test inconsistent casefold version. Should fail
> +# dmesg: overlayfs: all layers must have the same encoding
> +
> +# use tmpfs to make easier to create two different mount points with different
> +# utf8 versions
> +testdir="$SCRATCH_MNT/newdir/"
> +mkdir $testdir
> +
> +MNT1="$testdir/mnt1"
> +MNT2="$testdir/mnt2"
> +
> +mkdir $MNT1 $MNT2 "$testdir/merge"
> +
> +mount_casefold_version "utf8-12.1.0" $MNT1
> +mount_casefold_version "utf8-11.0.0" $MNT2
> +
> +mkdir "$MNT1/dir" "$MNT2/dir"
> +
> +_casefold_set_attr "$MNT1/dir"
> +_casefold_set_attr "$MNT2/dir"
> +
> +mkdir "$MNT1/dir/lower" "$MNT2/dir/upper" "$MNT2/dir/work"
> +
> +upperdir="$MNT2/dir/upper"
> +workdir="$MNT2/dir/work"
> +lowerdir="$MNT1/dir/lower"
> +
> +mount_overlay $lowerdir >>$seqres.full 2>&1  && \
> +       echo "Overlayfs mount different unicode versions should have failed" && \
> +       unmount_overlay
> +
> +umount $MNT1
> +umount $MNT2
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/generic/999.out b/tests/generic/999.out
> new file mode 100644
> index 00000000..ce383d94
> --- /dev/null
> +++ b/tests/generic/999.out
> @@ -0,0 +1,13 @@
> +QA output created by 999
> +Casefold disabled
> +Casefold enabled after mount
> +ls: cannot access 'SCRATCH_MNT/ovl-merge/subdir': Stale file handle
> +Casefold enabled lower dir
> +Casefold enabled lower subdir
> +ls: cannot access 'SCRATCH_MNT/ovl-merge/casefold/subdir': Object is remote
> +Casefold enabled upper dir
> +Casefold enabled
> +Casefold disabled on lower after mount
> +ls: cannot access 'SCRATCH_MNT/ovl-merge/dir/': Stale file handle
> +Casefold disabled on subdir after mount
> +ls: cannot access 'SCRATCH_MNT/ovl-merge/casefold/subdir': Object is remote
> --
> 2.50.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] overlay: add tests for casefolded layers
  2025-10-17 17:06 [PATCH] overlay: add tests for casefolded layers Amir Goldstein
  2025-11-10 18:09 ` Amir Goldstein
@ 2025-11-14 18:17 ` Zorro Lang
  1 sibling, 0 replies; 3+ messages in thread
From: Zorro Lang @ 2025-11-14 18:17 UTC (permalink / raw)
  To: Amir Goldstein
  Cc: Miklos Szeredi, Christian Brauner, André Almeida,
	linux-unionfs, fstests

On Fri, Oct 17, 2025 at 07:06:49PM +0200, Amir Goldstein wrote:
> Overalyfs did not allow mounting layers with casefold capable fs
> until kernel v6.17-rc1 and did not allow casefold enabled layers
> until kernel v6.18-rc1.
> 
> Since kernel v6.18-rc1, overalyfs allows this kind of setups,
> as long as the layers have consistent encoding and all the directories
> in the subtree have consistent casefolding.
> 
> Create test cases for the following scenarios:
> - Mounting overlayfs with casefold disabled
> - Mounting overlayfs with casefold enabled
> - Lookup subdir in overlayfs with mismatch casefold to parent dir
> - Change casefold of underlying subdir while overalyfs is mounted
> - Mounting overlayfs with strict enconding, but casefold disabled
> - Mounting overlayfs with strict enconding casefold enabled
> - Mounting overlayfs with layers with inconsistent UTF8 version
> 
> Co-developed-by: André Almeida <andrealmeid@igalia.com>
> Signed-off-by: André Almeida <andrealmeid@igalia.com>
> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
> 
> Zorro,
> 
> This test covers the overlayfs casefold feature that was introduced in
> two steps - casefold disabled layers in 6.17-rc1 and casefold enabled
> layers in 6.18-rc1.
> 
> I think there is less interest in testing the v6.17 changes on their own
> so this test requires support for casefold enabled layers from 6.18-rc1
> and will notrun on kernel < 6.18-rc1:
> 
> generic/999 5s ...  [12:43:16] [12:43:18] [not run]
> 	generic/999 -- overlayfs does not support casefold enabled layers
> 
> If there is a demand, we could split a test for the v6.17 support.
> 
> Note that this test is written as a generic and not an overlay test,
> because we do not have the infrastructure to format and mount a base fs
> with casefold support, so this test can run with e.g. ext4 FSTYP, but it
> will notrun with e.g. xfs FSTYPE:
> 
> generic/999 6s ...  [12:30:03] [12:30:05] [not run]
> 	generic/999 -- xfs does not support casefold feature
> 
> I left the test number 999 for you to re-number.
> If you prefer that I post with another test number assignment in the
> future please let me know.

Hi Amir,

Sorry for this late reviewing, most of this case looks good to me :)

I tried ext4 and f2fs on linux v6.16, v6.17 and v6.18-rc4+, the test
works on them. But when I test on tmpfs (due to _require_scratch_casefold
says tmpfs supports casefold feature), it fails:

FSTYP         -- tmpfs
PLATFORM      -- Linux/x86_64 dell-per750-41 6.18.0-0.rc4.251106gdc77806cf3b47.40.fc44.x86_64+debug #1 SMP PREEMPT_DYNAMIC Thu Nov  6 17:22:41 UTC 2025
MKFS_OPTIONS  -- tmpfs_scratch
MOUNT_OPTIONS -- -o size=1G -o context=system_u:object_r:root_t:s0 tmpfs_scratch /mnt/scratch

generic/999 15s ... - output mismatch (see /root/git/xfstests/results//generic/999.out.bad)
    --- tests/generic/999.out   2025-11-11 09:54:58.168783859 +0800
    +++ /root/git/xfstests/results//generic/999.out.bad 2025-11-15 01:55:37.137507467 +0800
    @@ -11,3 +11,4 @@
     ls: cannot access 'SCRATCH_MNT/ovl-merge/dir/': Stale file handle
     Casefold disabled on subdir after mount
     ls: cannot access 'SCRATCH_MNT/ovl-merge/casefold/subdir': Object is remote
    +Overlayfs mount with strict casefold enabled should have failed
    ...
    (Run 'diff -u /root/git/xfstests/tests/generic/999.out /root/git/xfstests/results//generic/999.out.bad'  to see the entire diff)
Ran: generic/999
Failures: generic/999
Failed 1 of 1 tests

# cat local.config
export FSTYP=tmpfs
export TEST_DEV=tmpfs_test
export TEST_DIR=/mnt/test
export SCRATCH_DEV=tmpfs_scratch
export SCRATCH_MNT=/mnt/scratch

> 
> Thanks,
> Amir.
> 
> 
>  tests/generic/999     | 243 ++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/999.out |  13 +++
>  2 files changed, 256 insertions(+)
>  create mode 100755 tests/generic/999
>  create mode 100644 tests/generic/999.out
> 

[snip]

> +# Create lowerdir, upperdir and workdir without casefold enabled
> +lowerdir="$SCRATCH_MNT/ovl-lower"
> +upperdir="$SCRATCH_MNT/ovl-upper"
> +workdir="$SCRATCH_MNT/ovl-work"
> +merge="$SCRATCH_MNT/ovl-merge"
> +
> +mount_casefold_version()
> +{
> +	option="casefold=$1"
> +	mount -t tmpfs -o $option tmpfs $2
> +}
> +
> +mount_overlay()
> +{
> +	local lowerdirs=$1
> +
> +	_mount -t overlay overlay $merge \
> +		-o lowerdir=$lowerdirs,upperdir=$upperdir,workdir=$workdir
> +}
> +
> +unmount_overlay()
> +{
> +	_unmount $SCRATCH_MNT/ovl-merge 2>/dev/null
                 ^^^^^^^^^^^^^^^^^^^^^^
                 $merge ?

> +}
> +
> +# Try to mount an overlay with casefold enabled layers.
> +# On kernels older than v6.18 expect failure and skip the test
> +mkdir -p $merge $upperdir $workdir $lowerdir
> +_casefold_set_attr $upperdir >>$seqres.full
> +_casefold_set_attr $workdir >>$seqres.full
> +_casefold_set_attr $lowerdir >>$seqres.full
> +mount_overlay $lowerdir >>$seqres.full 2>&1 || \
> +	_notrun "overlayfs does not support casefold enabled layers"
> +unmount_overlay

[snip]

> +MNT1="$testdir/mnt1"
> +MNT2="$testdir/mnt2"
> +
> +mkdir $MNT1 $MNT2 "$testdir/merge"
> +
> +mount_casefold_version "utf8-12.1.0" $MNT1
> +mount_casefold_version "utf8-11.0.0" $MNT2
> +
> +mkdir "$MNT1/dir" "$MNT2/dir"
> +
> +_casefold_set_attr "$MNT1/dir"
> +_casefold_set_attr "$MNT2/dir"
> +
> +mkdir "$MNT1/dir/lower" "$MNT2/dir/upper" "$MNT2/dir/work"
> +
> +upperdir="$MNT2/dir/upper"
> +workdir="$MNT2/dir/work"
> +lowerdir="$MNT1/dir/lower"
> +
> +mount_overlay $lowerdir >>$seqres.full 2>&1  && \
> +	echo "Overlayfs mount different unicode versions should have failed" && \
> +	unmount_overlay
> +
> +umount $MNT1
> +umount $MNT2

I think we can make sure $MNT1 and $MNT2 are unmounted in _cleanup phase,
as what you did for $merge in _cleanup.

Thanks,
Zorro

> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/generic/999.out b/tests/generic/999.out
> new file mode 100644
> index 00000000..ce383d94
> --- /dev/null
> +++ b/tests/generic/999.out
> @@ -0,0 +1,13 @@
> +QA output created by 999
> +Casefold disabled
> +Casefold enabled after mount
> +ls: cannot access 'SCRATCH_MNT/ovl-merge/subdir': Stale file handle
> +Casefold enabled lower dir
> +Casefold enabled lower subdir
> +ls: cannot access 'SCRATCH_MNT/ovl-merge/casefold/subdir': Object is remote
> +Casefold enabled upper dir
> +Casefold enabled
> +Casefold disabled on lower after mount
> +ls: cannot access 'SCRATCH_MNT/ovl-merge/dir/': Stale file handle
> +Casefold disabled on subdir after mount
> +ls: cannot access 'SCRATCH_MNT/ovl-merge/casefold/subdir': Object is remote
> -- 
> 2.50.1
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-11-14 18:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-17 17:06 [PATCH] overlay: add tests for casefolded layers Amir Goldstein
2025-11-10 18:09 ` Amir Goldstein
2025-11-14 18:17 ` Zorro Lang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox