All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/9] ovl: Enable support for casefold layers
@ 2025-08-14 17:22 André Almeida
  2025-08-14 17:22 ` [PATCH v5 1/9] fs: Create sb_encoding() helper André Almeida
                   ` (9 more replies)
  0 siblings, 10 replies; 29+ messages in thread
From: André Almeida @ 2025-08-14 17:22 UTC (permalink / raw)
  To: Miklos Szeredi, Amir Goldstein, Theodore Tso,
	Gabriel Krisman Bertazi
  Cc: linux-unionfs, linux-kernel, linux-fsdevel, Alexander Viro,
	Christian Brauner, Jan Kara, kernel-dev, André Almeida

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>


^ permalink raw reply	[flat|nested] 29+ messages in thread
* Re: [PATCH v5 4/9] ovl: Create ovl_casefold() to support casefolded strncmp()
@ 2025-08-16 10:32 ` Dan Carpenter
  0 siblings, 0 replies; 29+ messages in thread
From: kernel test robot @ 2025-08-16  6:40 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20250814-tonyk-overlayfs-v5-4-c5b80a909cbd@igalia.com>
References: <20250814-tonyk-overlayfs-v5-4-c5b80a909cbd@igalia.com>
TO: "André Almeida" <andrealmeid@igalia.com>

Hi André,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 0cc53520e68bea7fb80fdc6bdf8d226d1b6a98d9]

url:    https://github.com/intel-lab-lkp/linux/commits/Andr-Almeida/fs-Create-sb_encoding-helper/20250815-013213
base:   0cc53520e68bea7fb80fdc6bdf8d226d1b6a98d9
patch link:    https://lore.kernel.org/r/20250814-tonyk-overlayfs-v5-4-c5b80a909cbd%40igalia.com
patch subject: [PATCH v5 4/9] ovl: Create ovl_casefold() to support casefolded strncmp()
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago
config: alpha-randconfig-r071-20250816 (https://download.01.org/0day-ci/archive/20250816/202508161416.sbuLMXuI-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 10.5.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202508161416.sbuLMXuI-lkp@intel.com/

New smatch warnings:
fs/overlayfs/readdir.c:82 ovl_casefold() warn: variable dereferenced before check 'dst' (see line 80)

Old smatch warnings:
fs/overlayfs/readdir.c:1008 ovl_dir_fsync() warn: 'realfile' is an error pointer or valid

vim +/dst +82 fs/overlayfs/readdir.c

4edb83bb1041e2 Miklos Szeredi 2017-07-27  71  
3f345b5617fb37 André Almeida  2025-08-14  72  static int ovl_casefold(struct unicode_map *map, const char *str, int len, char **dst)
3f345b5617fb37 André Almeida  2025-08-14  73  {
3f345b5617fb37 André Almeida  2025-08-14  74  	const struct qstr qstr = { .name = str, .len = len };
3f345b5617fb37 André Almeida  2025-08-14  75  	int cf_len;
3f345b5617fb37 André Almeida  2025-08-14  76  
3f345b5617fb37 André Almeida  2025-08-14  77  	if (!IS_ENABLED(CONFIG_UNICODE) || !map || is_dot_dotdot(str, len))
3f345b5617fb37 André Almeida  2025-08-14  78  		return 0;
3f345b5617fb37 André Almeida  2025-08-14  79  
3f345b5617fb37 André Almeida  2025-08-14 @80  	*dst = kmalloc(NAME_MAX, GFP_KERNEL);
3f345b5617fb37 André Almeida  2025-08-14  81  
3f345b5617fb37 André Almeida  2025-08-14 @82  	if (dst) {
3f345b5617fb37 André Almeida  2025-08-14  83  		cf_len = utf8_casefold(map, &qstr, *dst, NAME_MAX);
3f345b5617fb37 André Almeida  2025-08-14  84  
3f345b5617fb37 André Almeida  2025-08-14  85  		if (cf_len > 0)
3f345b5617fb37 André Almeida  2025-08-14  86  			return cf_len;
3f345b5617fb37 André Almeida  2025-08-14  87  	}
3f345b5617fb37 André Almeida  2025-08-14  88  
3f345b5617fb37 André Almeida  2025-08-14  89  	kfree(*dst);
3f345b5617fb37 André Almeida  2025-08-14  90  	return 0;
3f345b5617fb37 André Almeida  2025-08-14  91  }
3f345b5617fb37 André Almeida  2025-08-14  92  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

end of thread, other threads:[~2025-08-22 17:39 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-14 17:22 [PATCH v5 0/9] ovl: Enable support for casefold layers André Almeida
2025-08-14 17:22 ` [PATCH v5 1/9] fs: Create sb_encoding() helper André Almeida
2025-08-14 17:22 ` [PATCH v5 2/9] fs: Create sb_same_encoding() helper André Almeida
2025-08-14 17:22 ` [PATCH v5 3/9] ovl: Prepare for mounting case-insensitive enabled layers André Almeida
2025-08-14 18:47   ` Amir Goldstein
2025-08-14 17:22 ` [PATCH v5 4/9] ovl: Create ovl_casefold() to support casefolded strncmp() André Almeida
2025-08-14 18:59   ` Amir Goldstein
2025-08-15 16:16   ` Amir Goldstein
2025-08-15 16:53     ` André Almeida
2025-08-17 14:33   ` Amir Goldstein
2025-08-22 14:07     ` André Almeida
2025-08-14 17:22 ` [PATCH v5 5/9] ovl: Ensure that all layers have the same encoding André Almeida
2025-08-14 17:22 ` [PATCH v5 6/9] ovl: Set case-insensitive dentry operations for ovl sb André Almeida
2025-08-15 11:52   ` kernel test robot
2025-08-14 17:22 ` [PATCH v5 7/9] ovl: Add S_CASEFOLD as part of the inode flag to be copied André Almeida
2025-08-14 17:22 ` [PATCH v5 8/9] ovl: Check for casefold consistency when creating new dentries André Almeida
2025-08-14 18:54   ` Amir Goldstein
2025-08-14 17:22 ` [PATCH v5 9/9] ovl: Support mounting case-insensitive enabled layers André Almeida
2025-08-14 18:48   ` Amir Goldstein
2025-08-14 17:30 ` [PATCH v5 0/9] ovl: Enable support for casefold layers André Almeida
2025-08-14 19:06   ` Amir Goldstein
2025-08-15 13:33     ` André Almeida
2025-08-15 13:50       ` Amir Goldstein
2025-08-17 15:03         ` Amir Goldstein
2025-08-22 14:15           ` André Almeida
2025-08-22 17:21             ` Amir Goldstein
2025-08-22 17:39               ` André Almeida
  -- strict thread matches above, loose matches on Subject: below --
2025-08-16  6:40 [PATCH v5 4/9] ovl: Create ovl_casefold() to support casefolded strncmp() kernel test robot
2025-08-16 10:32 ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.