From patchwork Mon Oct 21 16:37:16 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: 13844438 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 C804CD15DBD for ; Mon, 21 Oct 2024 16:37:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A73416B0092; Mon, 21 Oct 2024 12:37:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 916206B0096; Mon, 21 Oct 2024 12:37:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7682B6B0093; Mon, 21 Oct 2024 12:37:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 4AFAD6B008C for ; Mon, 21 Oct 2024 12:37:53 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8B3DB140591 for ; Mon, 21 Oct 2024 16:37:36 +0000 (UTC) X-FDA: 82698165648.15.1F14534 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf28.hostedemail.com (Postfix) with ESMTP id 9ABDFC0028 for ; Mon, 21 Oct 2024 16:37:35 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=YM+Fk8f2; spf=pass (imf28.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=1729528520; 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=bE1HISIArA2j2KViABaSmRyrQJHUPNILIjYajIv+hcs=; b=RlN6rn4ykU45Bv1JilSNaZhf3L9QuFz9veJhdexFaW3JEDCfyZ2jHil+CupOKvwXLgtZsR 8pieYIgpP9ge21bNnqYr69FkOvFHMtBCYaiEyY33IwrsbeG6dNxj0K5NsGYrjAZec81q2/ tlGwWxVRjf8FrgkiMtI60wqJdOVscXc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729528520; a=rsa-sha256; cv=none; b=OQroF1v0bMxr8PsOYG5CsBzjUTusclWn/+3kJvW6nAQfRE/T5jUl+x7TzaiUAROOUZ9EmU MIM4ZTRQ3hUC2FGmg8RUfxiVv7NCknWTItLJ9FsTN7QPqob49CBK0zxoAxb4vYdqFETTLl vPRIAIPiJukzkfT1MVypWI5NB8u9SXs= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=YM+Fk8f2; spf=pass (imf28.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 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:Content-Transfer-Encoding:Content-Type:MIME-Version: Message-Id:Date:Subject: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=bE1HISIArA2j2KViABaSmRyrQJHUPNILIjYajIv+hcs=; b=YM+Fk8f2LsrGy9bK0lw0CK0g75 9U9CDU/m8f5rPnvZTajKVE58IsaiDnNXzCOOqXoxj0PktrcZHklDo7ikMQAC8xq3K5UPmisqUpIkx ewfURecokPYR9UQCAiwJMB0WdbrvupzHH0ZhZkyQW2JE8uLd+YBC3peBunhK/T0M1oR7GZBvFwsVL MFrQqDS8FCQKKpnR0Q2ARsGWME0eJOUFohyqlUPyY2AKL37ad8eUsgdZW5y4N9emYFtqKwH7f9IGH WRqHWf7wuolItIytRyzUerSY6V9PzY+3DaxYWHN5cMOl3YuLKsR9DM/OslEg0UD5hAlK/wM5a0ClK ntcS4T9A==; Received: from [191.204.195.205] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1t2vPV-00DECf-4w; Mon, 21 Oct 2024 18:37:37 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Subject: [PATCH v8 0/9] tmpfs: Add case-insensitive support for tmpfs Date: Mon, 21 Oct 2024 13:37:16 -0300 Message-Id: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> MIME-Version: 1.0 X-B4-Tracking: v=1; b=H4sIADyDFmcC/23MQQ6DIBRF0a0YxqUBtAKOuo+mA4If/WkVA4bUG PdedFSTDt9Lzl1JhIAQSVOsJEDCiH7MQ10KYnszdkCxzZsIJirOOKOzH5cXnYfJReraCrjimpe tIFlMARx+jtrjmXePcfZhOeKp3t//nVRTRqV2zAATUFl1x8680VytH8geSvIXyzOWGRtt2a12q tTcnfC2bV+tYmn55AAAAA== X-Change-ID: 20241010-tonyk-tmpfs-fd4e181913d2 To: Gabriel Krisman Bertazi , Alexander Viro , Christian Brauner , Jan Kara , Theodore Ts'o , Andreas Dilger , Hugh Dickins , Andrew Morton , Jonathan Corbet , smcv@collabora.com Cc: kernel-dev@igalia.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, Gabriel Krisman Bertazi , Gabriel Krisman Bertazi , =?utf-8?q?Andr=C3=A9_Almeida?= , Randy Dunlap X-Mailer: b4 0.14.2 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 9ABDFC0028 X-Stat-Signature: xns4ncer7wzg66jw7soibccnndr7j578 X-HE-Tag: 1729528655-291752 X-HE-Meta: U2FsdGVkX18RqxZ2hRbQgS1MyfyXfjbOPdKlc88M+kFRQpE4j0iiRrttIY5/UCaP7hOSF9RcNmbPb7ogBnDcL3BRK/SpT/QvNgqrqNNTuaGlh9pJ273e4V3hm7q4+E8eJTa5kHZ/SujrYzPNORmRWE0OM18rw4/pKDtDYx+dasIiKs1PuKFNQpwwcwxNO9Y0K8h3ymkSB+SxKVleyy8M6Qxodg9xt1Ft3BIdVIfzwIBFlaE0GSFDHwNX3FTzhrLwmZjS2wepjqSi4ih65dGTzjobhOPuGLJV6Z/kRu2WcFZVnwxXUeO3c4Ueg+Yy12U6n7djQlyag1VbcEtE01jW7BsEAHIifAW0g3LPvFMOb2MK63OXQNj3phCM3d6Slr3ymEF/5bPkOYWJ0ayCVVoVCthRw/OL2a9elmqzdHLO1vMU/BF48zmpUWeGz07i3+lT1xJQ+4onyOQd+xyR89zSzMXPrSmIUw9cgrdcOUJ3hdHY2a1YgmgrRKLQOsVL2krsiGXCcq2K1krMA3Ewy2g0Oa0wAhXYkrnjiN7QtLlsHi8Si3oxRCnetAQhficLeCBFXccq0J/iW0g0jMPqsIFuU8lh+AYeIy+ME69+Or27lSOdMletQl4n11bsoo+GrRLPWCaWqHz4s2DOdWr4Ae3gL6+92nTpVqa+kZvTzfheF51FHOYp8w37GBeGJ2ZLu4f0qKVvTytpZCZwJDEirrpTkrYq1m1AFw4c7qCGnzKdWDLFal/fgBFpD36QsS+EGgA7cNwpwinG3mxh7f/ajdvwJ69uk7vtHYWQNnTD2S/kqpJJAYVoD7zK4POOprmpBpydkU0I6a0DzTL6ojXaF0RbmWDhqP/Wf25CceYIQtqgwG+/3hLNdoQ1Rc55VPC6Iw8hJ5KW5ros9RG39uFpU9RijsJJ33cfyaI7NBZP5MOSSYbWFIlxNrdc/38iq8ndzkuQIIT3t+YZD6JVcaPucMd lMePByJ6 iZTrVXhtTo+tz9lQRJUTH0FqDaoqdNHAxqd1TOcnCMsWQs/GNeCWMpKpDtcqSM5Hyaik4yCC2IuBx7hcwRQJOqtvjPl4lky/5fJRKzIUsJpK0pMkSLyamBrN3zoLYc2mBSeGzBfTpOH858sYwgCkTCwXktCsefLwNRiFYsiDgucnyzr+EaOW1co//+P4kOVTdiEwm8rUz33c8QYqNzaeriy7h7se6H467xkWRoI3z76GcDJ8aRaAbERR3DQ6WCbSSdtNEK8zOYJJD323nuEBbimFJjM0CcP/Qg9d5BJdY4kvw0WWgeHeEA0VtNebRiSOgSNPbIsXQp1h+Z32kCHyck64wjJnJ9NUQ7h9Zxkvaei1etrw= 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 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 [1] https://lore.kernel.org/fstests/20240823173008.280917-1-andrealmeid@igalia.com/ Changes in v8: - Fix docs typo (Randy) - Consistently guard `encoding` and `strict_encoding` fields from struct shmem_options, so those fields only exists with CONFIG_UNICODE (Brauner) v7: https://lore.kernel.org/r/20241017-tonyk-tmpfs-v7-0-a9c056f8391f@igalia.com Changes in v7: - Fixed generic_ci_validate_strict_name() - Dropped patch "tmpfs: Always set simple_dentry_operations as dentry ops" - Re-place generic_ci_validate_strict_name() before inode creation v6: https://lore.kernel.org/r/20241010-tonyk-tmpfs-v6-0-79f0ae02e4c8@igalia.com Changes in v6: - Fixed kernel bot warning 'shmem_ci_dentry_ops' defined but not used v5: https://lore.kernel.org/lkml/20241002234444.398367-1-andrealmeid@igalia.com/ Changes in v5: - New patch "Always set simple_dentry_operations as dentry ops" - "Squashed libfs: Check for casefold dirs on simple_lookup()" into "tmpfs: Add casefold lookup support" - Fail to mount if strict_encoding is used without encoding - Inlined generic_ci_validate_strict_name() - Added IS_ENABLED(UNICODE) guards to public generic_ci_ funcs - Dropped .d_revalidate = fscrypt_d_revalidate, tmpfs doesn't support it v4: https://lore.kernel.org/lkml/20240911144502.115260-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 (9): libfs: Create the helper function generic_ci_validate_strict_name() ext4: Use generic_ci_validate_strict_name helper unicode: Export latest available UTF-8 version number unicode: Recreate utf8_parse_version() 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 | 5 +- fs/libfs.c | 12 +- fs/unicode/utf8-core.c | 26 ++++ fs/unicode/utf8-selftest.c | 3 - include/linux/fs.h | 49 ++++++++ include/linux/shmem_fs.h | 6 +- include/linux/unicode.h | 4 + mm/shmem.c | 234 ++++++++++++++++++++++++++++++++++-- 9 files changed, 340 insertions(+), 23 deletions(-) --- base-commit: 42f7652d3eb527d03665b09edac47f85fb600924 change-id: 20241010-tonyk-tmpfs-fd4e181913d2 Best regards,