From: Tao Cui <cui.tao@linux.dev>
To: hughd@google.com, david@kernel.org, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, baolin.wang@linux.alibaba.com,
andrealmeid@igalia.com, krisman@suse.de,
linux-fsdevel@vger.kernel.org, cui.tao@linux.dev,
Tao Cui <cuitao@kylinos.cn>
Subject: [PATCH 1/2] shmem: do not inherit FS_CASEFOLD_FL onto non-directories
Date: Mon, 23 Nov 2026 13:16:28 +0800 [thread overview]
Message-ID: <20261123051629.2547645-2-cui.tao@linux.dev> (raw)
In-Reply-To: <20261123051629.2547645-1-cui.tao@linux.dev>
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
next prev parent reply other threads:[~2026-11-23 5:16 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2026-11-23 5:16 ` [PATCH 2/2] Documentation: tmpfs: document casefold option constraints Tao Cui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261123051629.2547645-2-cui.tao@linux.dev \
--to=cui.tao@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=andrealmeid@igalia.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=cuitao@kylinos.cn \
--cc=david@kernel.org \
--cc=hughd@google.com \
--cc=krisman@suse.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox