archive mirror
 help / color / mirror / Atom feed
From: "André Almeida" <>
To: Hugh Dickins <>,
	Andrew Morton <>,
	Alexander Viro <>
	"Daniel Rosenberg" <>,
	"André Almeida" <>
Subject: [RFC PATCH 0/4] mm: shmem: Add case-insensitive support for tmpfs
Date: Tue, 23 Mar 2021 16:59:37 -0300	[thread overview]
Message-ID: <> (raw)


This patchset adds support for case-insensitive file name lookups in
tmpfs. The implementation (and even the commit message) was based on the
work done at b886ee3e778e ("ext4: Support case-insensitive file name

* Use case

The use case for this feature is similar to the use case for ext4, to
better support compatibility layers (like Wine), particularly in
combination with sandboxing/container tools (like Flatpak). Those
containerization tools can share a subset of the host filesystem with an
application. In the container, the root directory and any parent
directories required for a shared directory are on tmpfs, with the
shared directories bind-mounted into the container's view of the

If the host filesystem is using case-insensitive directories, then the
application can do lookups inside those directories in a
case-insensitive way, without this needing to be implemented in
user-space. However, if the host is only sharing a subset of a
case-insensitive directory with the application, then the parent
directories of the mount point will be part of the container's root
tmpfs. When the application tries to do case-insensitive lookups of
those parent directories on a case-sensitive tmpfs, the lookup will

For example, if /srv/games is a case-insensitive directory on the host,
then applications will expect /srv/games/Steam/Half-Life and
/srv/games/steam/half-life to be interchangeable; but if the
container framework is only sharing /srv/games/Steam/Half-Life and
/srv/games/Steam/Portal (and not the rest of /srv/games) with the
container, with /srv, /srv/games and /srv/games/Steam as part of the
container's tmpfs root, then making /srv/games a case-insensitive
directory inside the container would be necessary to meet that

* The patchset

Note that, since there's no on disk information about this filesystem
(and thus, no mkfs support) we need to pass this information in the
mount options. This is the main difference with other fs supporting
casefolding like ext4 and f2fs. The folder attribute uses the same value
used by ext4/f2fs, so userspace tools like chattr already works with
this implementation.

- Patch 1 reverts the unexportation of casefolding functions for dentry
operations that are going to be used by tmpfs.

- Patch 2 does the wiring up of casefold functions inside tmpfs, along
with creating the mounting options for casefold support.

- Patch 3 gives tmpfs support for IOCTL for get/set file flags. This is
needed since the casefold is done in a per-directory basis at supported
mount points, via directory flags.

- Patch 4 documents the new options, along with an usage example.

This work is also available at

* Testing

xfstests already has a test for casefold filesystems (generic/556). I
have adapted it to work with tmpfs in a hacky way and this work can be
found at All tests succeed.

Whenever we manage to get in a common ground around the interface, I'll
make it more upstreamable so it can get merged along with the kernel


- Can't this be done in userspace?

Yes, but it's slow and can't assure correctness (imagine two files named
file.c and FILE.C; an app asks for FiLe.C, which one is the correct?).

- Which changes are required in userspace?

Apart of the container tools that will use this feature, no change is
needed. Both mount and chattr already work with this patchset.

- This will completely obliterate my setup!
Casefold support in tmpfs is disabled by default.


André Almeida (4):
  Revert "libfs: unexport generic_ci_d_compare() and
  mm: shmem: Support case-insensitive file name lookups
  mm: shmem: Add IOCTL support for tmpfs
  docs: tmpfs: Add casefold options

 Documentation/filesystems/tmpfs.rst |  26 +++++
 fs/libfs.c                          |   8 +-
 include/linux/fs.h                  |   5 +
 include/linux/shmem_fs.h            |   5 +
 mm/shmem.c                          | 175 +++++++++++++++++++++++++++-
 5 files changed, 213 insertions(+), 6 deletions(-)


             reply	other threads:[~2021-03-23 20:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-23 19:59 André Almeida [this message]
2021-03-23 19:59 ` [RFC PATCH 1/4] Revert "libfs: unexport generic_ci_d_compare() and generic_ci_d_hash()" André Almeida
2021-03-23 20:15   ` Matthew Wilcox
2021-03-24 20:09     ` André Almeida
2021-03-23 19:59 ` [RFC PATCH 2/4] mm: shmem: Support case-insensitive file name lookups André Almeida
2021-03-23 20:18   ` Gabriel Krisman Bertazi
2021-03-24 20:17     ` André Almeida
2021-03-23 23:19   ` Al Viro
2021-03-24 20:44     ` André Almeida
2021-03-23 19:59 ` [RFC PATCH 3/4] mm: shmem: Add IOCTL support for tmpfs André Almeida
2021-03-23 22:15   ` Gabriel Krisman Bertazi
2021-03-23 19:59 ` [RFC PATCH 4/4] docs: tmpfs: Add casefold options André Almeida
2021-03-23 21:58   ` Randy Dunlap
2021-03-25 14:27     ` André Almeida
2021-03-23 22:19   ` Gabriel Krisman Bertazi
2021-03-24 20:47     ` André Almeida

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \ \ \

* 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;
as well as URLs for NNTP newsgroup(s).