From patchwork Mon Sep 2 22:55:02 2024 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: 13787771 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FE3CCA0ED3 for ; Mon, 2 Sep 2024 22:55:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 867746B035B; Mon, 2 Sep 2024 18:55:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 815B68D0117; Mon, 2 Sep 2024 18:55:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B8B18D00EF; Mon, 2 Sep 2024 18:55:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 4B6BD6B03D4 for ; Mon, 2 Sep 2024 18:55:40 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id BDD59140780 for ; Mon, 2 Sep 2024 22:55:39 +0000 (UTC) X-FDA: 82521306798.19.3912E55 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf05.hostedemail.com (Postfix) with ESMTP id 00EE3100008 for ; Mon, 2 Sep 2024 22:55:37 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=GuwXvrTW; spf=pass (imf05.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com; dmarc=pass (policy=none) header.from=igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725317691; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=UaY8kTz9kpyX3qxIM+DomGqW9miwbtabmAU032CdbN0=; b=BEjW4U9N5dbaYXjVlnIzpwfW/oUAvWPm2VSIEb/tMVR+qJK0vki7/4hc587QgS0g6+62Zz vz32F255INOfPtXB+K96R5kUlH63d06EY/bM9ZISv9WX2HevBJwLwDXieJ1vOXsMxbMR3n h/t2Xb/kcFtNJkInTlaGFDXdUJRcYu4= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=GuwXvrTW; spf=pass (imf05.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com; dmarc=pass (policy=none) header.from=igalia.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725317691; a=rsa-sha256; cv=none; b=lyln2q77UEtInrZZsyQIDg9hERKY9k5h2XH1OxvqSxHSBgIOiTma7xz/CLNrwaKu7ZZdj4 FDI6wwOeRNYV6PXwaePlJGcLnvHQ7/Ppx20LvQgitB7oaMk+CGc26WCAdiFD1KDWgvP98x 7R5Vlyj0k4kFyd5qWE4Rd1F8rbmKWrI= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=UaY8kTz9kpyX3qxIM+DomGqW9miwbtabmAU032CdbN0=; b=GuwXvrTWencirwTezu0wssyUFu 8qlqA6/LpqupRS+C8t1WLBODgZYybbupRlVArbtf6WE+rmSfndfd+jhW9D8N7RrGY6tJ7rfOGQfOB VCfLyRnOSUF6gX7QPVmrBXKZ7LnjMO71ejTgTU1VcGgLH5QDzUhLfSB6GRetVy9ux1L6D3le5YtGP M6eCmg01xK+N4qPeu0h4BoneFdTQoNL76fKmeqaxYvvVjLsRSvwerPc2gewt96s6R/K7Ow4nRlXaN TwwbutKYcDtKGR6ouXuSoB3LlYDs6zdLwyT7hcmKKxOOewTY9D7ELutYDr0qz3nzSkfhDx450CwfH 6etb1RBA==; Received: from [177.172.122.98] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1slFxA-008VrL-Ap; Tue, 03 Sep 2024 00:55:20 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , =?utf-8?q?Andr=C3=A9_Almeida?= Subject: [PATCH v2 0/8] tmpfs: Add case-insesitive support for tmpfs Date: Mon, 2 Sep 2024 19:55:02 -0300 Message-ID: <20240902225511.757831-1-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 00EE3100008 X-Stat-Signature: 47nfs14gu1it9r1ihp8owd4jc4t3ud16 X-HE-Tag: 1725317737-335587 X-HE-Meta: U2FsdGVkX1+iAoJuoUtsnnV3rlRvRRUrEl03cF133RmoyK3mszhnjlfO5ahcBK1cxWFIzlAavZMJFiqs+HF86VGRjR3xglHk77Y2K94Tm/3burGMtyv+5J3fKc1+W2wPgZmFLULbmxF/riVo0aTVW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WTy7mbPpfP4JVWgamwiNmp1SLU1fATqf+n47ytXuD+ZKk0kGpUl5+2loGQnD03p9xBlxZ1w4QJitxqK+TfgqoFs2fuhGUktd/p7enVI8/F1b0kKWMRx6bl1owtrtxvgZLaDL/DxwWrRq3CV6xuK2/8smo4uVOO2qpk44i5a30pxddhV/97KiD26hYx0MfVDXCzLlQOkNAp0= 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: List-Subscribe: List-Unsubscribe: Hi, This series is based on [0]. This patchset adds support for case-insesitive file names lookups in tmpfs. The main difference from other casefold filesystems is that tmpfs has no information on disk, just on RAM, so we can't use mkfs to create a case-insensitive tmpfs. For this implementation, I opted to have a mount option for casefolding. The rest of the patchset follows a similar approach as ext4 and f2fs. * Use case (from the original cover letter) 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. * Testing I send a patch for xfstests to enable the casefold test (generic/556) for tmpfs.[1] The test succeed. You can test this patchset using: sudo mount -t tmpfs -o casefold=utf8-12.1.0 tmpfs mnt/ And making a dir case-insesitive: mkdir mnt/dir chattr +F mnt/dir [0] https://lore.kernel.org/linux-fsdevel/20210323195941.69720-1-andrealmeid@collabora.com/ [1] https://lore.kernel.org/fstests/20240823173008.280917-1-andrealmeid@igalia.com/ Changes in v2: - Found and fixed a bug in utf8_load() - Created a helper for checking strict file names (Krisman) - Merged patch 1/ and 3/ together (Krisman) - Reworded the explanation about d_compare (Krisman) - Removed bool casefold from shmem_sb_info (Krisman) - Reworked d_add(dentry, NULL) to be called as d_add(dentry, inode) (Krisman) - Moved utf8_parse_version to common unicode code - Fixed some smatch/sparse warnings (kernel test bot/Dan Carpenter) v1: https://lore.kernel.org/linux-fsdevel/20240823173332.281211-1-andrealmeid@igalia.com/ André Almeida (8): unicode: Fix utf8_load() error path unicode: Create utf8_check_strict_name ext4: Use utf8_check_strict_name helper unicode: Recreate utf8_parse_version() tmpfs: Add casefold lookup support tmpfs: Add flag FS_CASEFOLD_FL support for tmpfs dirs tmpfs: Expose filesystem features via sysfs docs: tmpfs: Add casefold options Documentation/filesystems/tmpfs.rst | 37 ++++++ fs/ext4/namei.c | 3 +- fs/unicode/utf8-core.c | 58 ++++++++- include/linux/shmem_fs.h | 6 +- include/linux/unicode.h | 5 + mm/shmem.c | 192 ++++++++++++++++++++++++++-- 6 files changed, 284 insertions(+), 17 deletions(-)