From patchwork Wed Sep 11 14:44:52 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: 13800716 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 300BDEE49BC for ; Wed, 11 Sep 2024 14:45:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 78C71940051; Wed, 11 Sep 2024 10:45:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 73BD9940052; Wed, 11 Sep 2024 10:45:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B621940051; Wed, 11 Sep 2024 10:45:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3C508940021 for ; Wed, 11 Sep 2024 10:45:33 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A0A1CC1843 for ; Wed, 11 Sep 2024 14:45:32 +0000 (UTC) X-FDA: 82552730904.18.44E5EA5 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf25.hostedemail.com (Postfix) with ESMTP id 01ACBA001B for ; Wed, 11 Sep 2024 14:45:29 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=Nz36pbCX; spf=pass (imf25.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=1726065792; 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=MyvDI5SZJUc5TNBctReci30K/h4zQoO/K4PlGc3yjRw=; b=PcMNZ28Nqk0IsMO2BlwpWSdTY7YyNYH8ZJ7fzdniJyfS+Lu7JBj24ypULtRL1y8WY/pTjq oVlqpT+uEObEOrFmH/C+hrrfllHfDmyNTF1isHiAQAXlsR7tV73j7h/9y4b2xMDuU6e52b l0AUDSHQmxm//eQNGZ5e1oZ5poK7rBQ= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=Nz36pbCX; spf=pass (imf25.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=1726065792; a=rsa-sha256; cv=none; b=Mjao7SyRqIAv53ZN5CFn5vEMuDJURUJpLnW40x6w/Xd0sqBnBrIcoKS6ITIkgMeLPkXldu YV3cIFmSylE/X79Ak8P7cpyOMvYdqO8OCR8F96wNMc17xcIAmtiUxmZSMW+eyM3K2FJoO4 ZGFGDa98i43/b6ikk5Bhpowsj23I3Mw= 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=MyvDI5SZJUc5TNBctReci30K/h4zQoO/K4PlGc3yjRw=; b=Nz36pbCXKc/Gfi6yC2JOty6Ic3 6sOLZ33V7/pdNQG+uRuG8AqReIp8rffzcHizbqociOCwCYCuRQJ2k8ohvTwNEQvB9SRZUW6/vbiua MmzeWD5gvZzOvj/Wpi1VorfhQRwF1KVWY/pDynad+Yil4aiguQFPLQZkaCq2J0LYhmxRoHNyV771V DA4aEaUJbUJs4Hbj4GLyrFFMW6Nt66kyXn334T2SkDA6TlvC9I5gOWWBIZcxNlIaTLS8MValrALCB jrGf+AxaygcF+lFsf1s+iY1CVP2dho6CI2+ZDIHmSaZeZ74udzBBsaGS3xg+31quCsIMcBcUfbW8H b3VL4fDw==; 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 1soOal-00CTwi-Dv; Wed, 11 Sep 2024 16:45:11 +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 , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= Subject: [PATCH v4 00/10] tmpfs: Add case-insensitive support for tmpfs Date: Wed, 11 Sep 2024 11:44:52 -0300 Message-ID: <20240911144502.115260-1-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 01ACBA001B X-Stat-Signature: p9zmrx8onban6g9yffhrzbt6mbq5y6yr X-Rspam-User: X-HE-Tag: 1726065929-720067 X-HE-Meta: U2FsdGVkX1+lz58nKg/cB595TxQ2Xbv/049eInv0B/O0izyqtzEO+oWPib/MVPUHmk5IAKXK0pBv4wzTDAD+iFoE/BUBVK0HcTw0Q79Jtl+QkLHjvpjzWG2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yBj+mfP1Ncgu7dZMlRsflMYEP9ZqIJf+XFSU6YKsR6LCIchzJBa1pvAufILhdFYJm/0pNiaBTiafdmhpCZCGVDzs2z3YD6i0nWpuusj2EcOH0VpJ8JSFn594R8AhibSoqFMYw0Z358qt5YejM+gX9n/HNj+Ix7DANcuKuH0pPGM0Nq2MP1bc5sVHNgCSNTYc2U8S+YICGRs3TA/RAFV0C8PTXtizKqqfnDpFPdUoi3PjP11t27c= 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-insensitive 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 tmpfs mnt/ And making a dir case-insensitive: 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 v4: - Got rid of shmem_lookup() and changed simple_lookup() to cover casefold use case - Simplified shmem_parse_opt_casefold() and how it handle the lastest_version option - Simplified utf8_parse_version() to return the version in one variable instead of three - Rewrote part of the documentation patch - Make sure that d_sb->s_d_op is set during mount time - Moved `generic_ci_always_del_dentry_ops` to mm/shmem.c as `shmem_ci_dentry_ops` v3: https://lore.kernel.org/lkml/20240905190252.461639-1-andrealmeid@igalia.com/ Changes in v3: - Renamed utf8_check_strict_name() to generic_ci_validate_strict_name(), and reworked the big if(...) to be more clear - Expose the latest UTF-8 version in include/linux/unicode.h - shmem_lookup() now sets d_ops - reworked shmem_parse_opt_casefold() - if `mount -o casefold` has no param, load latest UTF-8 version - using (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir) when possible - Fixed bug when adding a non-casefold flag in a non-empty dir v2: https://lore.kernel.org/lkml/20240902225511.757831-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 (10): libfs: Create the helper function generic_ci_validate_strict_name() ext4: Use generic_ci_validate_strict_name helper unicode: Recreate utf8_parse_version() unicode: Export latest available UTF-8 version number libfs: Check for casefold dirs on simple_lookup() libfs: Export generic_ci_ dentry functions 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 | 24 +++ fs/ext4/namei.c | 3 +- fs/libfs.c | 50 +++++- fs/unicode/utf8-core.c | 26 ++++ fs/unicode/utf8-selftest.c | 3 - include/linux/fs.h | 4 + include/linux/shmem_fs.h | 6 +- include/linux/unicode.h | 4 + mm/shmem.c | 226 ++++++++++++++++++++++++++-- 9 files changed, 325 insertions(+), 21 deletions(-)