[PATCH RFC v3 0/7] ovl: Enable support for casefold filesystems

André Almeida posted 7 patches 1 month, 3 weeks ago
There is a newer version of this series
fs/overlayfs/namei.c     |  17 +++---
fs/overlayfs/overlayfs.h |   2 +-
fs/overlayfs/ovl_entry.h |   1 +
fs/overlayfs/params.c    |   7 +--
fs/overlayfs/readdir.c   | 133 ++++++++++++++++++++++++++++++++++++++++++-----
fs/overlayfs/super.c     |  39 ++++++++++++++
fs/overlayfs/util.c      |   8 +--
include/linux/fs.h       |  19 +++++++
8 files changed, 195 insertions(+), 31 deletions(-)
[PATCH RFC v3 0/7] ovl: Enable support for casefold filesystems
Posted by André Almeida 1 month, 3 weeks ago
Hi all,

We would like to support the usage of casefold filesystems 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 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 (7):
      ovl: Store casefold name for case-insentive dentries
      ovl: Create ovl_casefold() to support casefolded strncmp()
      fs: Create sb_same_encoding() helper
      ovl: Ensure that all mount points 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: Support case-insensitive lookup

 fs/overlayfs/namei.c     |  17 +++---
 fs/overlayfs/overlayfs.h |   2 +-
 fs/overlayfs/ovl_entry.h |   1 +
 fs/overlayfs/params.c    |   7 +--
 fs/overlayfs/readdir.c   | 133 ++++++++++++++++++++++++++++++++++++++++++-----
 fs/overlayfs/super.c     |  39 ++++++++++++++
 fs/overlayfs/util.c      |   8 +--
 include/linux/fs.h       |  19 +++++++
 8 files changed, 195 insertions(+), 31 deletions(-)
---
base-commit: 0fdf709a849f773c9b23b0d9fff2a25de056ddd5
change-id: 20250409-tonyk-overlayfs-591f5e4d407a

Best regards,
-- 
André Almeida <andrealmeid@igalia.com>

Re: [PATCH RFC v3 0/7] ovl: Enable support for casefold filesystems
Posted by Amir Goldstein 1 month, 3 weeks ago
On Fri, Aug 8, 2025 at 10:59 PM André Almeida <andrealmeid@igalia.com> wrote:
>
> Hi all,
>
> We would like to support the usage of casefold filesystems 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!

Hi Andre,

This v3 is getting close.
Still some small details to fix.
With v4, please include a link to fstest so I can test your work.
I already had a draft for the casefold capable and disabled layers
in 6.17 but I did not post it yet.
Decide it would be better to test the final result after your work.
I'd started to adapt the test to the expected behavior for 6.18,
but it's just an untested draft for you to extend:
https://github.com/amir73il/xfstests/commits/ovl-casefold/

Please make sure that you run at least check -overlay -g overlay/quick
sanity check for v4 and that you run check -g casefold,
which should run the new generic test.

>
> ---
> Changes in v3:
> - Rebased on top of vfs-6.18.misc branch
> - Added more guards for casefolding things inside of IS_ENABLED(UNICODE)

There are too many ifdefs in overlayfs c code to my taste.
Need to see how we can reduce them a bit..

Thanks,
Amir.

> - 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 (7):
>       ovl: Store casefold name for case-insentive dentries
>       ovl: Create ovl_casefold() to support casefolded strncmp()
>       fs: Create sb_same_encoding() helper
>       ovl: Ensure that all mount points 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: Support case-insensitive lookup
>
>  fs/overlayfs/namei.c     |  17 +++---
>  fs/overlayfs/overlayfs.h |   2 +-
>  fs/overlayfs/ovl_entry.h |   1 +
>  fs/overlayfs/params.c    |   7 +--
>  fs/overlayfs/readdir.c   | 133 ++++++++++++++++++++++++++++++++++++++++++-----
>  fs/overlayfs/super.c     |  39 ++++++++++++++
>  fs/overlayfs/util.c      |   8 +--
>  include/linux/fs.h       |  19 +++++++
>  8 files changed, 195 insertions(+), 31 deletions(-)
> ---
> base-commit: 0fdf709a849f773c9b23b0d9fff2a25de056ddd5
> change-id: 20250409-tonyk-overlayfs-591f5e4d407a
>
> Best regards,
> --
> André Almeida <andrealmeid@igalia.com>
>
Re: [PATCH RFC v3 0/7] ovl: Enable support for casefold filesystems
Posted by Amir Goldstein 1 month, 3 weeks ago
On Sat, Aug 9, 2025 at 11:17 AM Amir Goldstein <amir73il@gmail.com> wrote:
>
> On Fri, Aug 8, 2025 at 10:59 PM André Almeida <andrealmeid@igalia.com> wrote:
> >
> > Hi all,
> >
> > We would like to support the usage of casefold filesystems 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!
>
> Hi Andre,
>
> This v3 is getting close.
> Still some small details to fix.
> With v4, please include a link to fstest so I can test your work.
> I already had a draft for the casefold capable and disabled layers
> in 6.17 but I did not post it yet.
> Decide it would be better to test the final result after your work.
> I'd started to adapt the test to the expected behavior for 6.18,
> but it's just an untested draft for you to extend:
> https://github.com/amir73il/xfstests/commits/ovl-casefold/
>
> Please make sure that you run at least check -overlay -g overlay/quick
> sanity check for v4 and that you run check -g casefold,
> which should run the new generic test.
>

Also, please remove the RFC label for v4.
We are pass the point of RFC.

Thanks,
Amir.