Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tao Cui <cui.tao@linux.dev>
To: brauner@kernel.org
Cc: hughd@google.com, david@kernel.org, akpm@linux-foundation.org,
	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 v2 1/2] shmem: do not inherit FS_CASEFOLD_FL onto non-directories
Date: Wed,  2 Dec 2026 20:38:33 +0800	[thread overview]
Message-ID: <20261202123834.2439906-2-cui.tao@linux.dev> (raw)
In-Reply-To: <20261202123834.2439906-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")
Reviewed-by: Gabriel Krisman Bertazi <krisman@suse.de>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Reviewed-by: André Almeida <andrealmeid@igalia.com>
Signed-off-by: Tao Cui <cuitao@kylinos.cn>
---
 mm/shmem.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/shmem.c b/mm/shmem.c
index a79e9b82d1f5..a674162fcd3b 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -3352,6 +3352,9 @@ 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;
+	/* Only directories inherit the casefold flag. */
+	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.43.0



  reply	other threads:[~2026-12-02 12:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 12:38 [PATCH v2 0/2] tmpfs: fix casefold flag inheritance and document mount constraints Tao Cui
2026-12-02 12:38 ` Tao Cui [this message]
2026-12-02 12:38 ` [PATCH v2 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=20261202123834.2439906-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=brauner@kernel.org \
    --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