From patchwork Tue Mar 23 19:59:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 12159175 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 476E3C433C1 for ; Tue, 23 Mar 2021 20:00:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CC5B4619C1 for ; Tue, 23 Mar 2021 20:00:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC5B4619C1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6DBD96B00E8; Tue, 23 Mar 2021 16:00:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 68A4B6B00F0; Tue, 23 Mar 2021 16:00:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 52B456B012E; Tue, 23 Mar 2021 16:00:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0158.hostedemail.com [216.40.44.158]) by kanga.kvack.org (Postfix) with ESMTP id 342FE6B00E8 for ; Tue, 23 Mar 2021 16:00:04 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id EA407180AD807 for ; Tue, 23 Mar 2021 20:00:03 +0000 (UTC) X-FDA: 77952205086.31.EC7C95E Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by imf10.hostedemail.com (Postfix) with ESMTP id 3AAE54080F6A for ; Tue, 23 Mar 2021 20:00:01 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: tonyk) with ESMTPSA id A653D1F44DA2 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro Cc: krisman@collabora.com, smcv@collabora.com, kernel@collabora.com, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Rosenberg , =?utf-8?q?Andr=C3=A9_Almeida?= Subject: [RFC PATCH 0/4] mm: shmem: Add case-insensitive support for tmpfs Date: Tue, 23 Mar 2021 16:59:37 -0300 Message-Id: <20210323195941.69720-1-andrealmeid@collabora.com> X-Mailer: git-send-email 2.31.0 MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 3AAE54080F6A X-Stat-Signature: 3jpkr1jb58o3mysmcfdobb5agosd9ikt Received-SPF: none (collabora.com>: No applicable sender policy available) receiver=imf10; identity=mailfrom; envelope-from=""; helo=bhuna.collabora.co.uk; client-ip=46.235.227.227 X-HE-DKIM-Result: none/none X-HE-Tag: 1616529601-802465 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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(-)