fs/overlayfs/copy_up.c | 2 +- fs/overlayfs/dir.c | 6 +++ fs/overlayfs/inode.c | 1 + fs/overlayfs/namei.c | 17 +++---- fs/overlayfs/overlayfs.h | 8 ++-- fs/overlayfs/ovl_entry.h | 1 + fs/overlayfs/params.c | 15 +++++-- fs/overlayfs/params.h | 1 + fs/overlayfs/readdir.c | 115 +++++++++++++++++++++++++++++++++++++++-------- fs/overlayfs/super.c | 51 +++++++++++++++++++++ fs/overlayfs/util.c | 8 ++-- include/linux/fs.h | 27 ++++++++++- 12 files changed, 213 insertions(+), 39 deletions(-)
Hi all, We would like to support the usage of casefold layers with overlayfs to be used with container tools. This use case requires a simple setup, where every layer will have the same encoding setting (i.e. Unicode version and flags), using one upper and one lower layer. * Implementation When merge layers, ovl uses a red-black tree to check if a given dentry name from a lower layers already exists in the upper layer. For merging case-insensitive names, we need to store then in tree casefolded. However, when displaying to the user the dentry name, we need to respect the name chosen when the file was created (e.g. Picture.PNG, instead of picture.png). To achieve this, I create a new field for cache entries that stores the casefolded names and a function ovl_strcmp() that uses this name for searching the rb_tree. For composing the layer, ovl uses the original name, keeping it consistency with whatever name the user created. The rest of the patches are mostly for checking if casefold is being consistently used across the layers and dropping the mount restrictions that prevented case-insensitive filesystems to be mounted. Thanks for the feedback! --- Changes in v5: - Reordered commits. libfs commits come earlier in the series - First ovl commit just prepare and create ofs->casefold. The proper enablement is done in the last commit - Rework ovl_casefold() consumer/free buffer logic out to the caller - Replace `const char *aux` with `const char *c_name` - Add pr_warn_ratelimited() for ovl_create_real() error - Replace "filesystems" with "layers" in the commit messages - Add "Testing" section to cover letter v4: https://lore.kernel.org/r/20250813-tonyk-overlayfs-v4-0-357ccf2e12ad@igalia.com Changes in v4: - Split patch "ovl: Support case-insensitive lookup" and move patch that creates ofs->casefold to the begging of the series - Merge patch "Store casefold name..." and "Create ovl_casefold()..." - Make encoding restrictions apply just when casefold is enabled - Rework set_d_op() with new helper - Set encoding and encoding flags inside of ovl_get_layers() - Rework how inode flags are set and checked v3: https://lore.kernel.org/r/20250808-tonyk-overlayfs-v3-0-30f9be426ba8@igalia.com Changes in v3: - Rebased on top of vfs-6.18.misc branch - Added more guards for casefolding things inside of IS_ENABLED(UNICODE) - Refactor the strncmp() patch to do a single kmalloc() per rb_tree operation - Instead of casefolding the cache entry name everytime per strncmp(), casefold it once and reuse it for every strncmp(). - Created ovl_dentry_ci_operations to not override dentry ops set by ovl_dentry_operations - Instead of setting encoding just when there's a upper layer, set it for any first layer (ofs->fs[0].sb), regardless of it being upper or not. - Rewrote the patch that set inode flags - Check if every dentry is consistent with the root dentry regarding casefold v2: https://lore.kernel.org/r/20250805-tonyk-overlayfs-v2-0-0e54281da318@igalia.com Changes in v2: - Almost a full rewritten from the v1. v1: https://lore.kernel.org/lkml/20250409-tonyk-overlayfs-v1-0-3991616fe9a3@igalia.com/ --- André Almeida (9): fs: Create sb_encoding() helper fs: Create sb_same_encoding() helper ovl: Prepare for mounting case-insensitive enabled layers ovl: Create ovl_casefold() to support casefolded strncmp() ovl: Ensure that all layers have the same encoding ovl: Set case-insensitive dentry operations for ovl sb ovl: Add S_CASEFOLD as part of the inode flag to be copied ovl: Check for casefold consistency when creating new dentries ovl: Support mounting case-insensitive enabled layers fs/overlayfs/copy_up.c | 2 +- fs/overlayfs/dir.c | 6 +++ fs/overlayfs/inode.c | 1 + fs/overlayfs/namei.c | 17 +++---- fs/overlayfs/overlayfs.h | 8 ++-- fs/overlayfs/ovl_entry.h | 1 + fs/overlayfs/params.c | 15 +++++-- fs/overlayfs/params.h | 1 + fs/overlayfs/readdir.c | 115 +++++++++++++++++++++++++++++++++++++++-------- fs/overlayfs/super.c | 51 +++++++++++++++++++++ fs/overlayfs/util.c | 8 ++-- include/linux/fs.h | 27 ++++++++++- 12 files changed, 213 insertions(+), 39 deletions(-) --- base-commit: 0cc53520e68bea7fb80fdc6bdf8d226d1b6a98d9 change-id: 20250409-tonyk-overlayfs-591f5e4d407a Best regards, -- André Almeida <andrealmeid@igalia.com>
Em 14/08/2025 14:22, André Almeida escreveu: > Hi all, > > We would like to support the usage of casefold layers with overlayfs to > be used with container tools. This use case requires a simple setup, > where every layer will have the same encoding setting (i.e. Unicode > version and flags), using one upper and one lower layer. > Amir, I tried to run your xfstest for casefolded ovl[1] but I can see that it still requires some work. I tried to fix some of the TODO's but I didn't managed to mkfs the base fs with casefold enabled... but we might as well discuss this in a dedicated xfstest email thread if you want to send a RFC for the test. [1] https://github.com/amir73il/xfstests/commit/03b3facf60e14cab9fc563ad54893563b4cb18e4
On Thu, Aug 14, 2025 at 7:30 PM André Almeida <andrealmeid@igalia.com> wrote: > > Em 14/08/2025 14:22, André Almeida escreveu: > > Hi all, > > > > We would like to support the usage of casefold layers with overlayfs to > > be used with container tools. This use case requires a simple setup, > > where every layer will have the same encoding setting (i.e. Unicode > > version and flags), using one upper and one lower layer. > > > > Amir, > > I tried to run your xfstest for casefolded ovl[1] but I can see that it > still requires some work. I tried to fix some of the TODO's but I didn't > managed to mkfs the base fs with casefold enabled... When you write mkfs the base fs, I suspect that you are running check -overlay or something. This is not how this test should be run. It should run as a normal test on ext4 or any other fs that supports casefold. When you run check -g casefold, the generic test generic/556 will be run if the test fs supports casefold (e.g. ext4). The new added test belongs to the same group and should run if you run check -g casefold if the test fs supports casefold (e.g. ext4). > but we might as > well discuss this in a dedicated xfstest email thread if you want to > send a RFC for the test. > > [1] > https://github.com/amir73il/xfstests/commit/03b3facf60e14cab9fc563ad54893563b4cb18e4 > > Can you point me to a branch with your ovl patches, so I can pull it for testing? Feel free to fix the 2 minor review comments on v5 in your branch. Thanks, Amir.
Hi Amir, On 8/14/25 21:06, Amir Goldstein wrote: > On Thu, Aug 14, 2025 at 7:30 PM André Almeida <andrealmeid@igalia.com> wrote: >> Em 14/08/2025 14:22, André Almeida escreveu: >>> Hi all, >>> >>> We would like to support the usage of casefold layers with overlayfs to >>> be used with container tools. This use case requires a simple setup, >>> where every layer will have the same encoding setting (i.e. Unicode >>> version and flags), using one upper and one lower layer. >>> >> Amir, >> >> I tried to run your xfstest for casefolded ovl[1] but I can see that it >> still requires some work. I tried to fix some of the TODO's but I didn't >> managed to mkfs the base fs with casefold enabled... > When you write mkfs the base fs, I suspect that you are running > check -overlay or something. > > This is not how this test should be run. > It should run as a normal test on ext4 or any other fs that supports casefold. > > When you run check -g casefold, the generic test generic/556 will > be run if the test fs supports casefold (e.g. ext4). > > The new added test belongs to the same group and should run > if you run check -g casefold if the test fs supports casefold (e.g. ext4). > I see, I used `check -overlay` indeed, thanks! >> but we might as >> well discuss this in a dedicated xfstest email thread if you want to >> send a RFC for the test. >> >> [1] >> https://github.com/amir73il/xfstests/commit/03b3facf60e14cab9fc563ad54893563b4cb18e4 >> >> > Can you point me to a branch with your ovl patches, so I can pull it > for testing? You can find my branch here, based on top of vfs.all: https://gitlab.freedesktop.org/andrealmeid/linux/-/commits/ovl_casefold I fixed the following minor issues: - 4/9: dropped the `kfree(cf_name);` - 6/9: fixed kernel robot warning `unused variable 'ofs'` - 8/9: change pr_warn_ratelimited() string > > Feel free to fix the 2 minor review comments on v5 in your branch. > > Thanks, > Amir.
On Fri, Aug 15, 2025 at 3:34 PM André Almeida <andrealmeid@igalia.com> wrote: > > Hi Amir, > > On 8/14/25 21:06, Amir Goldstein wrote: > > On Thu, Aug 14, 2025 at 7:30 PM André Almeida <andrealmeid@igalia.com> wrote: > >> Em 14/08/2025 14:22, André Almeida escreveu: > >>> Hi all, > >>> > >>> We would like to support the usage of casefold layers with overlayfs to > >>> be used with container tools. This use case requires a simple setup, > >>> where every layer will have the same encoding setting (i.e. Unicode > >>> version and flags), using one upper and one lower layer. > >>> > >> Amir, > >> > >> I tried to run your xfstest for casefolded ovl[1] but I can see that it > >> still requires some work. I tried to fix some of the TODO's but I didn't > >> managed to mkfs the base fs with casefold enabled... > > When you write mkfs the base fs, I suspect that you are running > > check -overlay or something. > > > > This is not how this test should be run. > > It should run as a normal test on ext4 or any other fs that supports casefold. > > > > When you run check -g casefold, the generic test generic/556 will > > be run if the test fs supports casefold (e.g. ext4). > > > > The new added test belongs to the same group and should run > > if you run check -g casefold if the test fs supports casefold (e.g. ext4). > > > I see, I used `check -overlay` indeed, thanks! > Yeh that's a bit confusing I'll admit. It's an overlayfs test that "does not run on overlayfs" but requires extra overlayfs: _exclude_fs overlay _require_extra_fs overlay Because it does the overlayfs mount itself. That's the easiest way to test features (e.g. casefold) in basefs You should also run check -overlay -g overlay/quick, but that's only to verify your patches did not regress any non-casefolded test. > >> but we might as > >> well discuss this in a dedicated xfstest email thread if you want to > >> send a RFC for the test. > >> > >> [1] > >> https://github.com/amir73il/xfstests/commit/03b3facf60e14cab9fc563ad54893563b4cb18e4 > >> > >> > > Can you point me to a branch with your ovl patches, so I can pull it > > for testing? > > You can find my branch here, based on top of vfs.all: > https://gitlab.freedesktop.org/andrealmeid/linux/-/commits/ovl_casefold > > I fixed the following minor issues: > > - 4/9: dropped the `kfree(cf_name);` - 6/9: fixed kernel robot warning > `unused variable 'ofs'` - 8/9: change pr_warn_ratelimited() string > Cool. Let me know when the test is passing (regardless of TODOs). I'll try to test it next week. Thanks, Amir.
On Fri, Aug 15, 2025 at 3:50 PM Amir Goldstein <amir73il@gmail.com> wrote: > > On Fri, Aug 15, 2025 at 3:34 PM André Almeida <andrealmeid@igalia.com> wrote: > > > > Hi Amir, > > > > On 8/14/25 21:06, Amir Goldstein wrote: > > > On Thu, Aug 14, 2025 at 7:30 PM André Almeida <andrealmeid@igalia.com> wrote: > > >> Em 14/08/2025 14:22, André Almeida escreveu: > > >>> Hi all, > > >>> > > >>> We would like to support the usage of casefold layers with overlayfs to > > >>> be used with container tools. This use case requires a simple setup, > > >>> where every layer will have the same encoding setting (i.e. Unicode > > >>> version and flags), using one upper and one lower layer. > > >>> > > >> Amir, > > >> > > >> I tried to run your xfstest for casefolded ovl[1] but I can see that it > > >> still requires some work. I tried to fix some of the TODO's but I didn't > > >> managed to mkfs the base fs with casefold enabled... > > > When you write mkfs the base fs, I suspect that you are running > > > check -overlay or something. > > > > > > This is not how this test should be run. > > > It should run as a normal test on ext4 or any other fs that supports casefold. > > > > > > When you run check -g casefold, the generic test generic/556 will > > > be run if the test fs supports casefold (e.g. ext4). > > > > > > The new added test belongs to the same group and should run > > > if you run check -g casefold if the test fs supports casefold (e.g. ext4). > > > > > I see, I used `check -overlay` indeed, thanks! > > > > Yeh that's a bit confusing I'll admit. > It's an overlayfs test that "does not run on overlayfs" > but requires extra overlayfs: > > _exclude_fs overlay > _require_extra_fs overlay > > Because it does the overlayfs mount itself. > That's the easiest way to test features (e.g. casefold) in basefs > I tried to run the new test, which is able to mount an overlayfs with layers with disabled casefolding with kernel 6.17-rc1. It does not even succeed in passing this simple test with your patches, so something is clearly off. > You should also run check -overlay -g overlay/quick, > but that's only to verify your patches did not regress any > non-casefolded test. > > My tests also indicate that there are several regressions, so your patches must have changed code paths that should not have been changed. Thanks, Amir.
Em 17/08/2025 12:03, Amir Goldstein escreveu: > On Fri, Aug 15, 2025 at 3:50 PM Amir Goldstein <amir73il@gmail.com> wrote: >> >> On Fri, Aug 15, 2025 at 3:34 PM André Almeida <andrealmeid@igalia.com> wrote: >>> >>> Hi Amir, >>> >>> On 8/14/25 21:06, Amir Goldstein wrote: >>>> On Thu, Aug 14, 2025 at 7:30 PM André Almeida <andrealmeid@igalia.com> wrote: >>>>> Em 14/08/2025 14:22, André Almeida escreveu: >>>>>> Hi all, >>>>>> >>>>>> We would like to support the usage of casefold layers with overlayfs to >>>>>> be used with container tools. This use case requires a simple setup, >>>>>> where every layer will have the same encoding setting (i.e. Unicode >>>>>> version and flags), using one upper and one lower layer. >>>>>> >>>>> Amir, >>>>> >>>>> I tried to run your xfstest for casefolded ovl[1] but I can see that it >>>>> still requires some work. I tried to fix some of the TODO's but I didn't >>>>> managed to mkfs the base fs with casefold enabled... >>>> When you write mkfs the base fs, I suspect that you are running >>>> check -overlay or something. >>>> >>>> This is not how this test should be run. >>>> It should run as a normal test on ext4 or any other fs that supports casefold. >>>> >>>> When you run check -g casefold, the generic test generic/556 will >>>> be run if the test fs supports casefold (e.g. ext4). >>>> >>>> The new added test belongs to the same group and should run >>>> if you run check -g casefold if the test fs supports casefold (e.g. ext4). >>>> >>> I see, I used `check -overlay` indeed, thanks! >>> >> >> Yeh that's a bit confusing I'll admit. >> It's an overlayfs test that "does not run on overlayfs" >> but requires extra overlayfs: >> >> _exclude_fs overlay >> _require_extra_fs overlay >> >> Because it does the overlayfs mount itself. >> That's the easiest way to test features (e.g. casefold) in basefs >> > > I tried to run the new test, which is able to mount an overlayfs > with layers with disabled casefolding with kernel 6.17-rc1. > > It does not even succeed in passing this simple test with > your patches, so something is clearly off. Apart from the other changes I had done for v6, I also had to change the test itself. The directories need to be empty to set the +F attribute, so I had to do this change: --- a/tests/generic/999 +++ b/tests/generic/999 @@ -104,6 +104,9 @@ 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 @@ -112,7 +115,10 @@ 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 > >> You should also run check -overlay -g overlay/quick, >> but that's only to verify your patches did not regress any >> non-casefolded test. >> >> > > My tests also indicate that there are several regressions, so your patches > must have changed code paths that should not have been changed. > > Thanks, > Amir.
On Fri, Aug 22, 2025 at 4:16 PM André Almeida <andrealmeid@igalia.com> wrote: > > Em 17/08/2025 12:03, Amir Goldstein escreveu: > > On Fri, Aug 15, 2025 at 3:50 PM Amir Goldstein <amir73il@gmail.com> wrote: > >> > >> On Fri, Aug 15, 2025 at 3:34 PM André Almeida <andrealmeid@igalia.com> wrote: > >>> > >>> Hi Amir, > >>> > >>> On 8/14/25 21:06, Amir Goldstein wrote: > >>>> On Thu, Aug 14, 2025 at 7:30 PM André Almeida <andrealmeid@igalia.com> wrote: > >>>>> Em 14/08/2025 14:22, André Almeida escreveu: > >>>>>> Hi all, > >>>>>> > >>>>>> We would like to support the usage of casefold layers with overlayfs to > >>>>>> be used with container tools. This use case requires a simple setup, > >>>>>> where every layer will have the same encoding setting (i.e. Unicode > >>>>>> version and flags), using one upper and one lower layer. > >>>>>> > >>>>> Amir, > >>>>> > >>>>> I tried to run your xfstest for casefolded ovl[1] but I can see that it > >>>>> still requires some work. I tried to fix some of the TODO's but I didn't > >>>>> managed to mkfs the base fs with casefold enabled... > >>>> When you write mkfs the base fs, I suspect that you are running > >>>> check -overlay or something. > >>>> > >>>> This is not how this test should be run. > >>>> It should run as a normal test on ext4 or any other fs that supports casefold. > >>>> > >>>> When you run check -g casefold, the generic test generic/556 will > >>>> be run if the test fs supports casefold (e.g. ext4). > >>>> > >>>> The new added test belongs to the same group and should run > >>>> if you run check -g casefold if the test fs supports casefold (e.g. ext4). > >>>> > >>> I see, I used `check -overlay` indeed, thanks! > >>> > >> > >> Yeh that's a bit confusing I'll admit. > >> It's an overlayfs test that "does not run on overlayfs" > >> but requires extra overlayfs: > >> > >> _exclude_fs overlay > >> _require_extra_fs overlay > >> > >> Because it does the overlayfs mount itself. > >> That's the easiest way to test features (e.g. casefold) in basefs > >> > > > > I tried to run the new test, which is able to mount an overlayfs > > with layers with disabled casefolding with kernel 6.17-rc1. > > > > It does not even succeed in passing this simple test with > > your patches, so something is clearly off. > > Apart from the other changes I had done for v6, I also had to change the > test itself. The directories need to be empty to set the +F attribute, > so I had to do this change: Nice, so I suppose this test is passing with v6. I will try it. Can you help to complete the TODO: # TODO: test non-casefold subdir and casefold disabled after mount The test now ends with the ofs->casefold == true mount, but we need to test the error conditions same as the test cases for ofs->casefold == false: 1. Casefold disabled after mount 2. Casefold disabled lower subdir Those test cases are designed to trigger the "wrong parent casefold" and "wrong child casefold" lookup warnings. If you have an idea how to trigger the "wrong inherited casefold" warning that would be nice. Technically, test can delete the whiteout file inside $workdir/work and remove casefold from $workdir/work and then trigger a copy up. It may work. I am not sure if deleting the whietout file from work dir is going to break something though. Thanks, Amir.
Em 22/08/2025 14:21, Amir Goldstein escreveu: > On Fri, Aug 22, 2025 at 4:16 PM André Almeida <andrealmeid@igalia.com> wrote: >> >> Em 17/08/2025 12:03, Amir Goldstein escreveu: >>> On Fri, Aug 15, 2025 at 3:50 PM Amir Goldstein <amir73il@gmail.com> wrote: >>>> >>>> On Fri, Aug 15, 2025 at 3:34 PM André Almeida <andrealmeid@igalia.com> wrote: >>>>> >>>>> Hi Amir, >>>>> >>>>> On 8/14/25 21:06, Amir Goldstein wrote: >>>>>> On Thu, Aug 14, 2025 at 7:30 PM André Almeida <andrealmeid@igalia.com> wrote: >>>>>>> Em 14/08/2025 14:22, André Almeida escreveu: >>>>>>>> Hi all, >>>>>>>> >>>>>>>> We would like to support the usage of casefold layers with overlayfs to >>>>>>>> be used with container tools. This use case requires a simple setup, >>>>>>>> where every layer will have the same encoding setting (i.e. Unicode >>>>>>>> version and flags), using one upper and one lower layer. >>>>>>>> >>>>>>> Amir, >>>>>>> >>>>>>> I tried to run your xfstest for casefolded ovl[1] but I can see that it >>>>>>> still requires some work. I tried to fix some of the TODO's but I didn't >>>>>>> managed to mkfs the base fs with casefold enabled... >>>>>> When you write mkfs the base fs, I suspect that you are running >>>>>> check -overlay or something. >>>>>> >>>>>> This is not how this test should be run. >>>>>> It should run as a normal test on ext4 or any other fs that supports casefold. >>>>>> >>>>>> When you run check -g casefold, the generic test generic/556 will >>>>>> be run if the test fs supports casefold (e.g. ext4). >>>>>> >>>>>> The new added test belongs to the same group and should run >>>>>> if you run check -g casefold if the test fs supports casefold (e.g. ext4). >>>>>> >>>>> I see, I used `check -overlay` indeed, thanks! >>>>> >>>> >>>> Yeh that's a bit confusing I'll admit. >>>> It's an overlayfs test that "does not run on overlayfs" >>>> but requires extra overlayfs: >>>> >>>> _exclude_fs overlay >>>> _require_extra_fs overlay >>>> >>>> Because it does the overlayfs mount itself. >>>> That's the easiest way to test features (e.g. casefold) in basefs >>>> >>> >>> I tried to run the new test, which is able to mount an overlayfs >>> with layers with disabled casefolding with kernel 6.17-rc1. >>> >>> It does not even succeed in passing this simple test with >>> your patches, so something is clearly off. >> >> Apart from the other changes I had done for v6, I also had to change the >> test itself. The directories need to be empty to set the +F attribute, >> so I had to do this change: > > Nice, so I suppose this test is passing with v6. I will try it. > Can you help to complete the TODO: > Yes, I will handle that next week. Thanks!
© 2016 - 2025 Red Hat, Inc.