[RFC PATCH 0/4] mm: shmem: Add case-insensitive support for tmpfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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






[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux