* [PATCH 0/2] tmpfs: fix casefold flag inheritance and document mount constraints
@ 2026-11-23 5:16 Tao Cui
2026-11-23 5:16 ` [PATCH 1/2] shmem: do not inherit FS_CASEFOLD_FL onto non-directories Tao Cui
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Tao Cui @ 2026-11-23 5:16 UTC (permalink / raw)
To: hughd, david, akpm
Cc: linux-mm, baolin.wang, andrealmeid, krisman, linux-fsdevel,
cui.tao, Tao Cui
From: Tao Cui <cuitao@kylinos.cn>
Files created in a casefold tmpfs directory inherit the
directory-only FS_CASEFOLD_FL flag, which shmem_set_inode_flags()
then rejects with -ENOTDIR on non-directories: the inode records a
phantom F flag, so the value FS_IOC_GETFLAGS reports can never be
written back and attribute changes via chattr fail, dropping
NOATIME/NODUMP from the same request. The casefold mount option
constraints that commit 5cd9aecbc72c ("tmpfs: Add flag
FS_CASEFOLD_FL support for tmpfs dirs") landed with are also
undocumented.
- P1: mask FS_CASEFOLD_FL for non-directory inodes the way
ext4_mask_flags()/f2fs_mask_flags() do.
- P2: document the CONFIG_UNICODE prerequisite, the
strict_encoding pairing and that both options are ignored on
remount.
Testing: on a VM with CONFIG_UNICODE=y, before the patch a file
created in a +F directory advertises the F flag via
FS_IOC_GETFLAGS and chattr +i on it fails with ENOTDIR; after,
the flag is not recorded and chattr works as usual.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] shmem: do not inherit FS_CASEFOLD_FL onto non-directories
2026-11-23 5:16 [PATCH 0/2] tmpfs: fix casefold flag inheritance and document mount constraints Tao Cui
@ 2026-11-23 5:16 ` Tao Cui
2026-12-01 6:09 ` Baolin Wang
2026-12-01 14:37 ` André Almeida
2026-11-23 5:16 ` [PATCH 2/2] Documentation: tmpfs: document casefold option constraints Tao Cui
` (2 subsequent siblings)
3 siblings, 2 replies; 9+ messages in thread
From: Tao Cui @ 2026-11-23 5:16 UTC (permalink / raw)
To: hughd, david, akpm
Cc: linux-mm, baolin.wang, andrealmeid, krisman, linux-fsdevel,
cui.tao, Tao Cui
From: Tao Cui <cuitao@kylinos.cn>
__shmem_get_inode() copies the parent's SHMEM_FL_INHERITED flags,
which include FS_CASEFOLD_FL, onto every new inode and ignores the
-ENOTDIR that shmem_set_inode_flags() returns for non-directories.
A regular file created in a casefold directory therefore reports a
phantom F flag via FS_IOC_GETFLAGS, and chattr, which writes the
full reported set back, then fails with ENOTDIR on every flag
change while dropping NOATIME/NODUMP from the same request.
ext4 and f2fs mask inherited flags by file type; mask
FS_CASEFOLD_FL for non-directory inodes here too.
Fixes: 5cd9aecbc72c ("tmpfs: Add flag FS_CASEFOLD_FL support for tmpfs dirs")
Signed-off-by: Tao Cui <cuitao@kylinos.cn>
---
mm/shmem.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/mm/shmem.c b/mm/shmem.c
index 1ecda28178e3..46e30b1f5ab8 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -3321,6 +3321,13 @@ static struct inode *__shmem_get_inode(const struct mnt_idmap *idmap,
info->i_crtime = inode_get_mtime(inode);
info->fsflags = (dir == NULL) ? 0 :
SHMEM_I(dir)->fsflags & SHMEM_FL_INHERITED;
+ /*
+ * FS_CASEFOLD_FL is directory-only; mask it for non-directories
+ * like ext4_mask_flags()/f2fs_mask_flags() do, or the
+ * shmem_set_inode_flags() call below fails with -ENOTDIR.
+ */
+ if (!S_ISDIR(mode))
+ info->fsflags &= ~FS_CASEFOLD_FL;
if (info->fsflags)
shmem_set_inode_flags(inode, info->fsflags, NULL);
INIT_LIST_HEAD(&info->shrinklist);
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/2] Documentation: tmpfs: document casefold option constraints
2026-11-23 5:16 [PATCH 0/2] tmpfs: fix casefold flag inheritance and document mount constraints Tao Cui
2026-11-23 5:16 ` [PATCH 1/2] shmem: do not inherit FS_CASEFOLD_FL onto non-directories Tao Cui
@ 2026-11-23 5:16 ` Tao Cui
2026-12-01 6:22 ` Baolin Wang
2026-12-01 14:35 ` André Almeida
2026-11-23 15:40 ` [PATCH 0/2] tmpfs: fix casefold flag inheritance and document mount constraints Gabriel Krisman Bertazi
2026-12-01 9:25 ` Christian Brauner
3 siblings, 2 replies; 9+ messages in thread
From: Tao Cui @ 2026-11-23 5:16 UTC (permalink / raw)
To: hughd, david, akpm
Cc: linux-mm, baolin.wang, andrealmeid, krisman, linux-fsdevel,
cui.tao, Tao Cui
From: Tao Cui <cuitao@kylinos.cn>
The casefold and strict_encoding options require CONFIG_UNICODE (both
are refused without it), strict_encoding must be given together with
casefold, and availability can be probed via
/sys/fs/tmpfs/features/casefold. None of this was documented.
Also disclose that both options only take effect at initial mount and
are ignored on remount: shmem_reconfigure() never looks at the parsed
encoding, so e.g. "remount,casefold=utf8-12.1.0" succeeds without
changing anything, the same way as the mode, uid and gid options.
Signed-off-by: Tao Cui <cuitao@kylinos.cn>
---
Documentation/filesystems/tmpfs.rst | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/Documentation/filesystems/tmpfs.rst b/Documentation/filesystems/tmpfs.rst
index d677e0428c3f..032fa55b0411 100644
--- a/Documentation/filesystems/tmpfs.rst
+++ b/Documentation/filesystems/tmpfs.rst
@@ -253,6 +253,15 @@ strict_encoding Enable strict encoding at this mount point (disabled by
and directory with names containing invalid UTF-8 characters.
================= ==============================================================
+These options require kernel support for casefolding (CONFIG_UNICODE)
+and are refused without it. strict_encoding must be given together
+with casefold on the same mount; a mount with strict_encoding but no
+encoding fails. Whether the running kernel supports casefold at all
+can be probed by reading /sys/fs/tmpfs/features/casefold.
+
+casefold and strict_encoding only take effect when given at initial
+mount; on remount they are ignored.
+
This option doesn't render the entire filesystem case-insensitive. One needs to
still set the casefold flag per directory, by flipping the +F attribute in an
empty directory. Nevertheless, new directories will inherit the attribute. The
--
2.53.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] tmpfs: fix casefold flag inheritance and document mount constraints
2026-11-23 5:16 [PATCH 0/2] tmpfs: fix casefold flag inheritance and document mount constraints Tao Cui
2026-11-23 5:16 ` [PATCH 1/2] shmem: do not inherit FS_CASEFOLD_FL onto non-directories Tao Cui
2026-11-23 5:16 ` [PATCH 2/2] Documentation: tmpfs: document casefold option constraints Tao Cui
@ 2026-11-23 15:40 ` Gabriel Krisman Bertazi
2026-12-01 9:25 ` Christian Brauner
3 siblings, 0 replies; 9+ messages in thread
From: Gabriel Krisman Bertazi @ 2026-11-23 15:40 UTC (permalink / raw)
To: Tao Cui, hughd, david, akpm
Cc: linux-mm, baolin.wang, andrealmeid, linux-fsdevel, cui.tao,
Tao Cui
Tao Cui <cui.tao@linux.dev> writes:
> From: Tao Cui <cuitao@kylinos.cn>
>
> Files created in a casefold tmpfs directory inherit the
> directory-only FS_CASEFOLD_FL flag, which shmem_set_inode_flags()
> then rejects with -ENOTDIR on non-directories: the inode records a
> phantom F flag, so the value FS_IOC_GETFLAGS reports can never be
> written back and attribute changes via chattr fail, dropping
> NOATIME/NODUMP from the same request. The casefold mount option
> constraints that commit 5cd9aecbc72c ("tmpfs: Add flag
> FS_CASEFOLD_FL support for tmpfs dirs") landed with are also
> undocumented.
>
> - P1: mask FS_CASEFOLD_FL for non-directory inodes the way
> ext4_mask_flags()/f2fs_mask_flags() do.
> - P2: document the CONFIG_UNICODE prerequisite, the
> strict_encoding pairing and that both options are ignored on
> remount.
>
> Testing: on a VM with CONFIG_UNICODE=y, before the patch a file
> created in a +F directory advertises the F flag via
> FS_IOC_GETFLAGS and chattr +i on it fails with ENOTDIR; after,
> the flag is not recorded and chattr works as usual.
The series looks good to me. Feel free to add:
Reviewed-by: Gabriel Krisman Bertazi <krisman@suse.de>
--
Gabriel Krisman Bertazi
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] shmem: do not inherit FS_CASEFOLD_FL onto non-directories
2026-11-23 5:16 ` [PATCH 1/2] shmem: do not inherit FS_CASEFOLD_FL onto non-directories Tao Cui
@ 2026-12-01 6:09 ` Baolin Wang
2026-12-01 14:37 ` André Almeida
1 sibling, 0 replies; 9+ messages in thread
From: Baolin Wang @ 2026-12-01 6:09 UTC (permalink / raw)
To: Tao Cui, hughd, david, akpm
Cc: linux-mm, andrealmeid, krisman, linux-fsdevel, Tao Cui
On 11/23/26 1:16 PM, Tao Cui wrote:
> From: Tao Cui <cuitao@kylinos.cn>
>
> __shmem_get_inode() copies the parent's SHMEM_FL_INHERITED flags,
> which include FS_CASEFOLD_FL, onto every new inode and ignores the
> -ENOTDIR that shmem_set_inode_flags() returns for non-directories.
> A regular file created in a casefold directory therefore reports a
> phantom F flag via FS_IOC_GETFLAGS, and chattr, which writes the
> full reported set back, then fails with ENOTDIR on every flag
> change while dropping NOATIME/NODUMP from the same request.
>
> ext4 and f2fs mask inherited flags by file type; mask
> FS_CASEFOLD_FL for non-directory inodes here too.
>
> Fixes: 5cd9aecbc72c ("tmpfs: Add flag FS_CASEFOLD_FL support for tmpfs dirs")
> Signed-off-by: Tao Cui <cuitao@kylinos.cn>
> ---
Changes look good to me with one nit.
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba>
> mm/shmem.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 1ecda28178e3..46e30b1f5ab8 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -3321,6 +3321,13 @@ static struct inode *__shmem_get_inode(const struct mnt_idmap *idmap,
> info->i_crtime = inode_get_mtime(inode);
> info->fsflags = (dir == NULL) ? 0 :
> SHMEM_I(dir)->fsflags & SHMEM_FL_INHERITED;
> + /*
> + * FS_CASEFOLD_FL is directory-only; mask it for non-directories
> + * like ext4_mask_flags()/f2fs_mask_flags() do, or the
> + * shmem_set_inode_flags() call below fails with -ENOTDIR.
> + */
The comment seems verbose and can be simplified as
/* Only directories inherit the casefold flag. */
?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] Documentation: tmpfs: document casefold option constraints
2026-11-23 5:16 ` [PATCH 2/2] Documentation: tmpfs: document casefold option constraints Tao Cui
@ 2026-12-01 6:22 ` Baolin Wang
2026-12-01 14:35 ` André Almeida
1 sibling, 0 replies; 9+ messages in thread
From: Baolin Wang @ 2026-12-01 6:22 UTC (permalink / raw)
To: Tao Cui, hughd, david, akpm
Cc: linux-mm, andrealmeid, krisman, linux-fsdevel, Tao Cui
On 11/23/26 1:16 PM, Tao Cui wrote:
> From: Tao Cui <cuitao@kylinos.cn>
>
> The casefold and strict_encoding options require CONFIG_UNICODE (both
> are refused without it), strict_encoding must be given together with
> casefold, and availability can be probed via
> /sys/fs/tmpfs/features/casefold. None of this was documented.
>
> Also disclose that both options only take effect at initial mount and
> are ignored on remount: shmem_reconfigure() never looks at the parsed
> encoding, so e.g. "remount,casefold=utf8-12.1.0" succeeds without
> changing anything, the same way as the mode, uid and gid options.
>
> Signed-off-by: Tao Cui <cuitao@kylinos.cn>
> ---
Not a casefold expert, but this looks reasonable to me.
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/2] tmpfs: fix casefold flag inheritance and document mount constraints
2026-11-23 5:16 [PATCH 0/2] tmpfs: fix casefold flag inheritance and document mount constraints Tao Cui
` (2 preceding siblings ...)
2026-11-23 15:40 ` [PATCH 0/2] tmpfs: fix casefold flag inheritance and document mount constraints Gabriel Krisman Bertazi
@ 2026-12-01 9:25 ` Christian Brauner
3 siblings, 0 replies; 9+ messages in thread
From: Christian Brauner @ 2026-12-01 9:25 UTC (permalink / raw)
To: hughd, david, akpm, Tao Cui
Cc: linux-mm, baolin.wang, andrealmeid, krisman, linux-fsdevel,
Tao Cui
On Mon, 23 Nov 2026 13:16:27 +0800, Tao Cui wrote:
> From: Tao Cui <cuitao@kylinos.cn>
>
> Files created in a casefold tmpfs directory inherit the
> directory-only FS_CASEFOLD_FL flag, which shmem_set_inode_flags()
> then rejects with -ENOTDIR on non-directories: the inode records a
> phantom F flag, so the value FS_IOC_GETFLAGS reports can never be
> written back and attribute changes via chattr fail, dropping
> NOATIME/NODUMP from the same request. The casefold mount option
> constraints that commit 5cd9aecbc72c ("tmpfs: Add flag
> FS_CASEFOLD_FL support for tmpfs dirs") landed with are also
> undocumented.
>
> [...]
Applied to the vfs-7.5.misc branch of the vfs/vfs.git tree.
Patches in the vfs-7.5.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-7.5.misc
[1/2] shmem: do not inherit FS_CASEFOLD_FL onto non-directories
https://git.kernel.org/vfs/vfs/c/2532f393a4ae
[2/2] Documentation: tmpfs: document casefold option constraints
https://git.kernel.org/vfs/vfs/c/275acb3e342c
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] Documentation: tmpfs: document casefold option constraints
2026-11-23 5:16 ` [PATCH 2/2] Documentation: tmpfs: document casefold option constraints Tao Cui
2026-12-01 6:22 ` Baolin Wang
@ 2026-12-01 14:35 ` André Almeida
1 sibling, 0 replies; 9+ messages in thread
From: André Almeida @ 2026-12-01 14:35 UTC (permalink / raw)
To: Tao Cui
Cc: linux-mm, david, akpm, baolin.wang, krisman, linux-fsdevel,
Tao Cui, hughd, Christian Brauner
Em 23/11/2026 02:16, Tao Cui escreveu:
> From: Tao Cui <cuitao@kylinos.cn>
>
> The casefold and strict_encoding options require CONFIG_UNICODE (both
> are refused without it), strict_encoding must be given together with
> casefold, and availability can be probed via
> /sys/fs/tmpfs/features/casefold. None of this was documented.
>
> Also disclose that both options only take effect at initial mount and
> are ignored on remount: shmem_reconfigure() never looks at the parsed
> encoding, so e.g. "remount,casefold=utf8-12.1.0" succeeds without
> changing anything, the same way as the mode, uid and gid options.
>
> Signed-off-by: Tao Cui <cuitao@kylinos.cn>
Reviewed-by: André Almeida <andrealmeid@igalia.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] shmem: do not inherit FS_CASEFOLD_FL onto non-directories
2026-11-23 5:16 ` [PATCH 1/2] shmem: do not inherit FS_CASEFOLD_FL onto non-directories Tao Cui
2026-12-01 6:09 ` Baolin Wang
@ 2026-12-01 14:37 ` André Almeida
1 sibling, 0 replies; 9+ messages in thread
From: André Almeida @ 2026-12-01 14:37 UTC (permalink / raw)
To: Tao Cui
Cc: linux-mm, akpm, baolin.wang, krisman, linux-fsdevel, Tao Cui,
hughd, david, Christian Brauner
Em 23/11/2026 02:16, Tao Cui escreveu:
> From: Tao Cui <cuitao@kylinos.cn>
>
> __shmem_get_inode() copies the parent's SHMEM_FL_INHERITED flags,
> which include FS_CASEFOLD_FL, onto every new inode and ignores the
> -ENOTDIR that shmem_set_inode_flags() returns for non-directories.
> A regular file created in a casefold directory therefore reports a
> phantom F flag via FS_IOC_GETFLAGS, and chattr, which writes the
> full reported set back, then fails with ENOTDIR on every flag
> change while dropping NOATIME/NODUMP from the same request.
>
> ext4 and f2fs mask inherited flags by file type; mask
> FS_CASEFOLD_FL for non-directory inodes here too.
>
> Fixes: 5cd9aecbc72c ("tmpfs: Add flag FS_CASEFOLD_FL support for tmpfs dirs")
> Signed-off-by: Tao Cui <cuitao@kylinos.cn>
Reviewed-by: André Almeida <andrealmeid@igalia.com>
> ---
> mm/shmem.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 1ecda28178e3..46e30b1f5ab8 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -3321,6 +3321,13 @@ static struct inode *__shmem_get_inode(const struct mnt_idmap *idmap,
> info->i_crtime = inode_get_mtime(inode);
> info->fsflags = (dir == NULL) ? 0 :
> SHMEM_I(dir)->fsflags & SHMEM_FL_INHERITED;
> + /*
> + * FS_CASEFOLD_FL is directory-only; mask it for non-directories
> + * like ext4_mask_flags()/f2fs_mask_flags() do, or the
> + * shmem_set_inode_flags() call below fails with -ENOTDIR.
> + */
I agree with Baolin that this comment could be shorter.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-12-01 14:37 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 5:16 [PATCH 0/2] tmpfs: fix casefold flag inheritance and document mount constraints Tao Cui
2026-11-23 5:16 ` [PATCH 1/2] shmem: do not inherit FS_CASEFOLD_FL onto non-directories Tao Cui
2026-12-01 6:09 ` Baolin Wang
2026-12-01 14:37 ` André Almeida
2026-11-23 5:16 ` [PATCH 2/2] Documentation: tmpfs: document casefold option constraints Tao Cui
2026-12-01 6:22 ` Baolin Wang
2026-12-01 14:35 ` André Almeida
2026-11-23 15:40 ` [PATCH 0/2] tmpfs: fix casefold flag inheritance and document mount constraints Gabriel Krisman Bertazi
2026-12-01 9:25 ` Christian Brauner
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.