All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/4] mm: shmem: Add case-insensitive support for tmpfs
@ 2021-03-23 19:59 André Almeida
  2021-03-23 19:59 ` [RFC PATCH 1/4] Revert "libfs: unexport generic_ci_d_compare() and generic_ci_d_hash()" André Almeida
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: André Almeida @ 2021-03-23 19:59 UTC (permalink / raw)
  To: Hugh Dickins, Andrew Morton, Alexander Viro
  Cc: krisman, smcv, kernel, linux-mm, linux-fsdevel, linux-kernel,
	Daniel Rosenberg, André Almeida

Hello,

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
lookups").

* 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
filesystem.

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
fail.

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
expectation.

* 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
https://gitlab.collabora.com/tonyk/linux/-/tree/tmpfs-ic

* 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 https://gitlab.collabora.com/tonyk/xfstests. 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
work.

* FAQ

- 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.

Thanks,
	André

André Almeida (4):
  Revert "libfs: unexport generic_ci_d_compare() and
    generic_ci_d_hash()"
  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(-)

-- 
2.31.0


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

end of thread, other threads:[~2021-03-25 14:29 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-23 19:59 [RFC PATCH 0/4] mm: shmem: Add case-insensitive support for tmpfs André Almeida
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-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 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-23 22:19     ` Gabriel Krisman Bertazi
2021-03-24 20:47     ` André Almeida

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.