From patchwork Mon Oct 21 16:37:17 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: 13844439 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 9F4ABD15DBA for ; Mon, 21 Oct 2024 16:37:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 40F886B0093; Mon, 21 Oct 2024 12:37:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3BF146B0095; Mon, 21 Oct 2024 12:37:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 286DC6B0096; Mon, 21 Oct 2024 12:37:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 094176B0093 for ; Mon, 21 Oct 2024 12:37:54 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 96E3AA1AEA for ; Mon, 21 Oct 2024 16:37:25 +0000 (UTC) X-FDA: 82698165606.30.B437F79 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf20.hostedemail.com (Postfix) with ESMTP id B3B461C0022 for ; Mon, 21 Oct 2024 16:37:33 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=TzOvSN86; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf20.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729528561; a=rsa-sha256; cv=none; b=VMKXh8BmiTKa83sJ1gkyW/tJJFW8TMh4OYe8X4JiMRUJpdqk7FJqrKpQzCXIiThxCaNco+ 7+jNYNvwQp+17CwCaknCWrpQIp15QvZaDJLUDsa95YGUQ1SfZbyUL4xtPFoNHplG3G5UAu UVBZbYKgYQLJfXh8vsyVGmyiim5zByY= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=TzOvSN86; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf20.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729528561; 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:in-reply-to:references:references:dkim-signature; bh=obDU9EHbEhqof+DC3Mpb90bnlOdtfiD2TGUUZBgS1/4=; b=OvmRw5onvtSIHludoztpLbDRuAZHATK4V4L99kom4S54HITbULWMd6ppwc4F1JwogJ0Fx4 ccrXy5MDab2tANh1tMqpJpJA7kHnHGq2W/jhFA3nBw8iQpa/Rz/UHOPYJ5jfePRrglYJZ+ 6DVVahfd9JidpQNxbHK8WogHMpaiH0M= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=obDU9EHbEhqof+DC3Mpb90bnlOdtfiD2TGUUZBgS1/4=; b=TzOvSN86Pc5lOEJyIyNaopXvpo pXtrTFCTvteTp4CsMQc2j3sz+uwaQGRL3vXhHKdUBCR0UDWeJhnePOpF32OB8TROfpZSJexcW7Nt2 L0DgsV3sWGDWMgstbgBiuyxDNZAad/yNAX5NubC3zf4bkMtBHishTKKeKeXXkFEBjL4Lj1pk/6FKN o+2nw9fFaQUTZ6Dfr9zssLw50nWf3/+wU+TsFYkTg8nvvpMOHtH+0VuqwUyGOnlnmpJwF/sG6gNSa +3T3MhfiVC7KKag5fLdXGYf7eDTVA/lo/WHREEPwf6jCH5yiJ9VXX0Uj34rVZsr4iPjztD3en9SJO VLVbeL5A==; 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 1t2vPa-00DECf-1w; Mon, 21 Oct 2024 18:37:42 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Mon, 21 Oct 2024 13:37:17 -0300 Subject: [PATCH v8 1/9] libfs: Create the helper function generic_ci_validate_strict_name() MIME-Version: 1.0 Message-Id: <20241021-tonyk-tmpfs-v8-1-f443d5814194@igalia.com> References: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> In-Reply-To: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> 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?= X-Mailer: b4 0.14.2 X-Rspamd-Queue-Id: B3B461C0022 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 5g9o8wrbkay1roqbdhp99wcy1sho73xe X-HE-Tag: 1729528653-976192 X-HE-Meta: U2FsdGVkX18bllKT2/ecRvt2GqnIISIMJXR1pkMKyAhrhFbpjR0gkQnvJXYUvH45loroeTJXnXMMzNH3RE4ZKzO3p+ByqDI8V0BpoWWzXSK1ib1S8XB9tA9O2my1MayKX94SWIEX6WW/4rq6enyuz4aJKl6uh4U9Z7X8f7fENgHig4gc1dGkBNSyly0AHCNf5uzQEE3rxTe4xiOmT0SNGBkebquUi/H5/fmi4fzJQdrL4N2crif1fboNRMQQtZj5DH5PO1VlEZPbz2vwKBx5nD0TYhPBTvgo3tP4dgxLLj4S0FnRrlQ9ds5RV2D/0lgz65pQAYXkwVq7mymZwah3hGw37vYNyyRDr7OgJPTwLMDuDpkt2sopvuJtFjAIDyvGD1754Y+I6k9P+VieFDBlmeLu0Li5VF57MnvadFjIBw/B6XZmUCy14HGfouz+RjySlL7++o7YSyGAifQEvM4aQ4jbnoPhlP4SecEuc8DZY+pgicewruxwXIsnm1LK7eDXWK20Zrb1ovG2jxPn9Rzk14d7/30jkoGK32XcEV2YF7jdf9quTxT45Hd0o6USO6qNAWD4tNt1GHgyH5VF+FTZ1GGLZUlgxmmilRvG5LzNR1j0UlVTsJfJuMD68e7YtBCuy/jR/oou49jAgZp6Y2cfekiTX/iYr5cYsvPIW4dqgTW8l9rZPzPLadKX33zKFJY+kY2ybLZHXAkxD/lODZsB4v0V1PVRBIHuvESBNDCOd1TF2LucEFhBMYhJ15dXH9botyRNTvtsHq3GOWqlgTITKEeIhtWNTlcdttTkF5dfVMuCTwzlwu57Ifn7GRaSZWmpLKqxThoG1KgMypx6cU0Twt7FAuUI/2bDglMRklKpnehmE94M/DmtX3OMDTsnpy+66rU33a9T93EwC4be762NIrS74CEB9cvlh3T19ZxQUnvsMySY9njT1+fqN5snqUJc0igBqeRM5G5omGo9i55 T2x2tG84 /oX9HgkGTWLSQMA/CotZ7LWe5jM2r08rQW3FF7SYR69ms8BN08ROSa7wspq0aFW/qHLdGa/Mrz9FA8XYfRCpy29Q+Kc0GYcbfDzcl7j1Ylv7okvBWplUGo20VYkH3zMMhq02s4gGMA5dUhke/ndNHU6zSmzKBMb2lBJQLKrM+r5uaeH4V3ZKM2n+Is0BqoOCU6sukJQ0g6dMZXVI78pORMWW0UASUTyu2IURh854rGPYOB9qpXlrk7YeYJVSWHdXvVmdiQ+q3VI4cJQ8AsxLpl0oG3pGxys1I/6KdY0B0Jzhe0xye1Rkjk4l9qPzn77cdQHXqg96oiX7DVtmF3KY6RSR8+14A9J58B4AYAsALWN7pP7ddt3/TKjVbfzYRq9qOVy8OuUy6ddhkO//A7mGt2FJlXXJF8HXSqQEI 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: Create a helper function for filesystems do the checks required for casefold directories and strict encoding. Suggested-by: Gabriel Krisman Bertazi Reviewed-by: Gabriel Krisman Bertazi Signed-off-by: André Almeida --- Changes from v6: - Correctly negate utf8_validate() return Changes from v4: - Inline this function Changes from v2: - Moved function to libfs and adpated its name - Wrapped at 72 chars column - Decomposed the big if (...) to be more clear --- include/linux/fs.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/include/linux/fs.h b/include/linux/fs.h index 3559446279c152c70b7f1f3e0154f6e66a5aba33..403ee5d54c60a0a97e2eba9ef80d8fb4bbd2288f 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -3456,6 +3457,50 @@ extern int generic_ci_match(const struct inode *parent, const struct qstr *folded_name, const u8 *de_name, u32 de_name_len); +#if IS_ENABLED(CONFIG_UNICODE) +/** + * generic_ci_validate_strict_name - Check if a given name is suitable + * for a directory + * + * This functions checks if the proposed filename is valid for the + * parent directory. That means that only valid UTF-8 filenames will be + * accepted for casefold directories from filesystems created with the + * strict encoding flag. That also means that any name will be + * accepted for directories that doesn't have casefold enabled, or + * aren't being strict with the encoding. + * + * @dir: inode of the directory where the new file will be created + * @name: name of the new file + * + * Return: + * * True if the filename is suitable for this directory. It can be + * true if a given name is not suitable for a strict encoding + * directory, but the directory being used isn't strict + * * False if the filename isn't suitable for this directory. This only + * happens when a directory is casefolded and the filesystem is strict + * about its encoding. + */ +static inline bool generic_ci_validate_strict_name(struct inode *dir, struct qstr *name) +{ + if (!IS_CASEFOLDED(dir) || !sb_has_strict_encoding(dir->i_sb)) + return true; + + /* + * A casefold dir must have a encoding set, unless the filesystem + * is corrupted + */ + if (WARN_ON_ONCE(!dir->i_sb->s_encoding)) + return true; + + return !utf8_validate(dir->i_sb->s_encoding, name); +} +#else +static inline bool generic_ci_validate_strict_name(struct inode *dir, struct qstr *name) +{ + return true; +} +#endif + static inline bool sb_has_encoding(const struct super_block *sb) { #if IS_ENABLED(CONFIG_UNICODE) From patchwork Mon Oct 21 16:37:18 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: 13844437 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 6496BD15DBB for ; Mon, 21 Oct 2024 16:37:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8552D6B008C; Mon, 21 Oct 2024 12:37:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 804DA6B0092; 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 6A56F6B0095; Mon, 21 Oct 2024 12:37:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4BD266B0092 for ; Mon, 21 Oct 2024 12:37:53 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 321251619B0 for ; Mon, 21 Oct 2024 16:37:35 +0000 (UTC) X-FDA: 82698165732.11.EE83C32 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf23.hostedemail.com (Postfix) with ESMTP id 43219140005 for ; Mon, 21 Oct 2024 16:37:41 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=htpsQRv8; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf23.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729528620; a=rsa-sha256; cv=none; b=t9NnJC/2C2AMNQB2FOhi2k+JOrkDGhMu8ljBqAgz+baDHhKjoUhWfyn4UO+DeaCCLiXXv4 W5O+7US2/GOOS7/Gk/X32sGlIimS2EZeqjq0xLAh5G3cvRvzmJ5dK4J4FU+v5E1nqx7eCy v3ivD7FMBUjpIOxr+o2akFQv7Ufvn+o= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=htpsQRv8; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf23.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729528620; 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:in-reply-to:references:references:dkim-signature; bh=sdXGjKgs/rhRe8l19F01/brI44jeC/ablpb8vlTIOo4=; b=exgKWhGMK+HOt9e1k0pi3WZ8xEK7cyZvcb+J8dBatAIVY8An6oBS/Ik4dlWak5NKKAT2A6 3BsBBQ1T2AJnc9B00KGypaMr7SULk+Rp/Of+G0ejSCQWBYPvc9XpbWX+TZVLnwWmxa+36g C/k5RIFZQrAvu0ickS8ALlxKQiGUjWk= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=sdXGjKgs/rhRe8l19F01/brI44jeC/ablpb8vlTIOo4=; b=htpsQRv8/js4yHpaG1piv1c4Hv NHNUWc+pkc3mBPO5T68D4cNjjpjP0Rl7v1cJ+4EWzTVdbfawo8BtBEnSbSYAUIa3pAWQQpPf+sA47 6mj33mGgynQTvSiBvpJKx67Rb3MMNAPQJZEfNohKIpuWtoYcjtnjHpUEiFqfm4Q5v8jygXKZb4Htx EddtzcoEllFmljbnX6S5FAO+goy7Gu+iw+wisXgV8l9hLVLbP3Qa+oLNQGFZ2o5fm3MPgnnIhwvw/ OZsrCCBNfJ+daFre0ewfTcDWzFDOlxtDb22Q3LZemdwcmeqQalNya0XkOzAseXR8zPy9Rx4hYmWFf 4i8Eg/RA==; 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 1t2vPe-00DECf-OQ; Mon, 21 Oct 2024 18:37:46 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Mon, 21 Oct 2024 13:37:18 -0300 Subject: [PATCH v8 2/9] ext4: Use generic_ci_validate_strict_name helper MIME-Version: 1.0 Message-Id: <20241021-tonyk-tmpfs-v8-2-f443d5814194@igalia.com> References: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> In-Reply-To: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> 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 , =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.14.2 X-Rspam-User: X-Rspamd-Queue-Id: 43219140005 X-Rspamd-Server: rspam01 X-Stat-Signature: mqkma8b4db6t3heeea8yz8c11kbm71nb X-HE-Tag: 1729528661-273708 X-HE-Meta: U2FsdGVkX1991eeELr1L0oNkXv+4buanhAOyrcGwm4HcqSdHEokciExt8OJQjD06oFqu72cwZYCAyi7d/xCRmlU+4RcqNKIJVfc8/SSJ0rslb4n8eCfee2XSqQDx9gHjkMaaoyB7XFLKCiwSjhzh89+QCyO6w2nY+buVqapAMXWrEzTVeAdeg1iXdTiF5zY2vHRCmfhV9ffltLSWO00aFcUOZynlG/bn3WFQtApHIy9YBitAE47PwHI7YVL4zJy/oc/g+fgTOAmZ7tNoZE3dEH6/2gv39HxaTscChXaWdG6dUK4pVvgAyG7elRECLMRXU50acXIGZsBLEggyNa8A9ztLhCCdZQjqyJyFgk+Fg3HbLXLy45mac8OCdUGZRUcb9TfhqnQd4qFSNJ+/8D/pbsNCAf9BIOq0pubDMbjpy55uokSgZzyjsbTmYroeattP7Nm+XOyQRDkQHISQQhs8zA1SVBlSewFhrpkHPCmaXXNNT9mrIvah7WS8ZhIbJyYQ6Mk+U78lWlwr/kVYSgL7CoioG7JxJH56hguR5TSqBA9qKw+G3i7BGMzapzI5u0GkYlbm6kPpIwyK4B4eVoYrGFRV0h5plQB5mPtrHHe6HvA4Mk6IbIQT5TEv6EIMqKOAiGFDFMdg6E3ioGnN216DMpC0qTZ6XIMs1aFdMwsvVHYypFHNIg8vwPZkvvUbw3qHS5eGkd62rbV4Og3BxTcKT+b8b4rBa/7BVUkOTYGILkd5y25cbzMiwV2AHCHKMGJPyA+U92NWoRnsrkXxfNEeIfc3Vh53am6hUgbyS0dqn+qZOTgmgqYSsUmgf2vCPHkRqvgXt8mki8oVm1s8mI7mNw/DZdjtZEOECZv06r6NchGcze1z65gCwA17NPQ6gAnwFJZAaFZUpZtn66G4oXXoBAHoHpzrbJsRkWgPdvgm0xTB++y2VzMJw7Ok55ni8Rw4uImnob1ENcRWcY7cM/g kko9xPUO 57MEv+5njSg3DBNkUCHCS4Zr9mBxA0c19BrGUlg03Vae9f7f6q25f1o6N4/Xx0zHtJj/w7BDkhu7KA5RcmRwqxqwKjx6aGw4d0nVximjyMtzJlALyqcmiaKHtVRw6J4EYtYaxYqUFZgcutKLYfISShBFcqBWBxuLQyw0LshFYRDCsQa0/4HriYbRk9acr0WY/5FAROUxGb/V0ioOdsqpnAoo8K9LhKM0l3xS7UV6N/2WlwMspcbN+v5a6SjvR7SloK1P0Rz70Zu5vUUcXN0weLNofvRygA2hPXUrlTIPTLm6cqnhRyGrWjVXZN2kqZ2c3GBJn0XJ5RLorSgkiCyRMSuuDZj1NZHguU2EmrqbfiBzqNxtarEhzlg3YSicf/CqZ1BzHosANaVtBjjEaTqzc728RIj2345UpHKDwPUc+kRxYRRg8IgfYzGbSboza+Ty9cXbpXfUr187eMzY= 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: Use the helper function to check the requirements for casefold directories using strict encoding. Suggested-by: Gabriel Krisman Bertazi Signed-off-by: André Almeida Acked-by: Theodore Ts'o Reviewed-by: Gabriel Krisman Bertazi --- Changes from v4: - Now we can drop the if IS_ENABLED() guard --- fs/ext4/namei.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 790db7eac6c2ad5e1790e363e4ac273162e35013..612ccbeb493b8d901c123221ef6573457193dd16 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -2395,11 +2395,8 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry, if (fscrypt_is_nokey_name(dentry)) return -ENOKEY; -#if IS_ENABLED(CONFIG_UNICODE) - if (sb_has_strict_encoding(sb) && IS_CASEFOLDED(dir) && - utf8_validate(sb->s_encoding, &dentry->d_name)) + if (!generic_ci_validate_strict_name(dir, &dentry->d_name)) return -EINVAL; -#endif retval = ext4_fname_setup_filename(dir, &dentry->d_name, 0, &fname); if (retval) From patchwork Mon Oct 21 16:37:19 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: 13844440 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 0AFEDD15DBB for ; Mon, 21 Oct 2024 16:38:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4AEF66B0095; Mon, 21 Oct 2024 12:37:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 45EB26B0096; Mon, 21 Oct 2024 12:37:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2FE456B0098; Mon, 21 Oct 2024 12:37:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 0CA3C6B0095 for ; Mon, 21 Oct 2024 12:37:56 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 98BFE141854 for ; Mon, 21 Oct 2024 16:37:39 +0000 (UTC) X-FDA: 82698165984.28.9AD83DA Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf09.hostedemail.com (Postfix) with ESMTP id 648E4140004 for ; Mon, 21 Oct 2024 16:37:43 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=C29AF0jh; spf=pass (imf09.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=1729528525; 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:in-reply-to:references:references:dkim-signature; bh=hhDlIiM2rMTHaWInpW6Q+AoMhFTJClxESMUDFdoVjOU=; b=aBa+6aKDCUD4V6WbVjuswRuZvHgF0V+dR7BsMlZbWSbsLKJdMGRHw0dKJiiqEuppawQMx0 R6x6gbIwOkb0CdHQ3Dq1ECiOSSWJj/0l9QL03+tighaykVmdBWOiWNc9OYDCWKKKAkcQiV dlMeSXTRNFUT919lfJJ1jusaOxd0ZtQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729528525; a=rsa-sha256; cv=none; b=zetv4Y+g/Dg445rxLYuuXsN1X60MKZ0lZCXHA2HVGa5BWCP3eBoIJUIcxHFRC6Joq1TKTK wBYnbpeyuw2sccIOBXqaMj3ryFRi5zIWG6hb0ot4Bf5V8OI2zTlVFhGBKnYa7usq7UjY3F calyo/2LEo4YEnp+4Rozm+Wa+aHbORU= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=C29AF0jh; spf=pass (imf09.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:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=hhDlIiM2rMTHaWInpW6Q+AoMhFTJClxESMUDFdoVjOU=; b=C29AF0jhf/70FsDOIGe1moxLiB 9HfrcKFOoUW8+pGeTI+NXydfUGMXn8fRG5era7LfgkFEgcXXCjC8Z67gWRip96J0g15wVsDJuHeoF ZXm5vs5dY2mibJWzViiXdAxmEtJrGlrlq4z0ML4hkabRCy0sRE3jkZxHTddf++sn3AehP2RwWinzT 7jQSPOCVlNTV/HSgGHVI2/5CfYk419N3/xu4Xra1QJfroM2TVn+GHUt3yoSOwPyljX6Z+sTG/DHwn 2X7untZ77TGOEnEzxvVXJtc6mV1XxO1g84PjNrn2yAQzMsodyJ9S0gPEo/vOjhfxrvLYbfG37A4EN Lf1H7Wvw==; 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 1t2vPj-00DECf-DN; Mon, 21 Oct 2024 18:37:51 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Mon, 21 Oct 2024 13:37:19 -0300 Subject: [PATCH v8 3/9] unicode: Export latest available UTF-8 version number MIME-Version: 1.0 Message-Id: <20241021-tonyk-tmpfs-v8-3-f443d5814194@igalia.com> References: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> In-Reply-To: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> 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, =?utf-8?q?Andr=C3=A9_Almeid?= =?utf-8?q?a?= , Gabriel Krisman Bertazi X-Mailer: b4 0.14.2 X-Rspamd-Queue-Id: 648E4140004 X-Stat-Signature: afwxk7eawi8p79gypcn1w7e3mzd7x1j3 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1729528663-520873 X-HE-Meta: U2FsdGVkX18fr9INOuLmoSx73pTVomsD1J2O7R076RrU12YXY36CrgwmwTxbEj2qDsHR5HrjXvPQfOsDlnB6Iju1KDy50UP8udnAO/iuj+Lfsi6qUk4w06wLJv2gzs5YkrwqbzGP/TrKETji8/sRpKgDZJHgC9RcIOVbKMImJ7/Rhr/uwJNfukLNqghBbbwGeBx8yTxd1L8Bdc8LiCBBWTlIQcI/HgyALp0Ns1ZHVS6xhTXe6k2Yg04I8YBsX8eVr9D0TgNDfqRcchz5aK2uQtY8+IKzStMr8lx+xPzBCTtY/I9pQbL2XIb25oqHp9dYSaXA8n5dViaf04QS+WRVeQfi0vwWn7nQgW1UwPlwOjlrTXiSmYhR8v/URnUEy2SyWkoL2f9BrdoVV9exfiF62dpk51ioTycWC2K2sjXbUsBvblA+cst0ejS8u3te6woN7jsqfweq1OPLXhmVGQB0okAA+5dyNdaWJel9/sr9H87xSWApM+ktQjQnnLV9gctkoJiExrY1V8nsUrcsQNQeRa3KhzU7l9lvfrWX42c6x4A5j8g0cVj95nTzeZTHCIP9VDlCcr92RwzSBkQXjUrOys0ibCLIGoRz13KVx71CQrBzjaknNxb9NH7JcmRvjHmkf5mR6FUtstD5bHseSwyfqUzOXGXh4lqrqmaMRlU9QYp9j8HrIUW3dbUCe7Xgp0SnpgFbnr9BkR2xLCZW/isjN0GsyscBCA3VuW/ZEt13BFAbtpgCUN703dzAEdQEP+96GlK0Oo+aLXoIgMtjYHkYHm3aRVVNU8Xpz2V3NQb7rKyvLRwkzUpALe8d+fWCYIZAs/L3ZR0SsIWjy5nfGNMMCC/J4Hw43YPw2c41dHHcVZ1mE10zmtlkQiYrsJ/vH1NzN5j6VADiNWa9W0lWNtKtKVVfpweQRR7dZXTUgeEeVb3JuA4kvCN6Q+Spvo1l78JaVKYzO+lZeJieUCm1dSg T/edZ4a5 /ZiR5LcX2IMsJQWh9ad8XX+53aFl7c3V3uqHy37XdTeiiu2x4ooqdy0kmmuriYzsCMyPmMUFkZx2Ur2GGFOnrbVma5EUqkkn2SWA9sig17CiEOS6VfGft2YGU7HKELOAUCK/gGpl920Q4s7RdXTIV4zmd3Jn5f5hzC0dNPZxJyAM4G4Ana+DLohNBPughyA3vDYXGuxPCuPG1JwpvkBqEWtgmcDhj2gtmvG4WF/HvdlIFvSq9yCvxNkpn63ZpQ25n8gHbQj1M5IEo0E0CHvaSbJg3pZ33fXME8uvza7Ire+weh+qZvmgN4cprR5oSOVjvRLyJpnXPcadw00IsPOsGgQ9YkBVaeekYTzvyE+pUGlRwj/D2Ip28EO6W4drOxHY4pr9P9fGJ7gBuXcfHAbwXRC6zxZ22lJs/Mij3 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: Export latest available UTF-8 version number so filesystems can easily load the newest one. Signed-off-by: André Almeida Acked-by: Gabriel Krisman Bertazi --- fs/unicode/utf8-selftest.c | 3 --- include/linux/unicode.h | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/unicode/utf8-selftest.c b/fs/unicode/utf8-selftest.c index 600e15efe9edfdf6d04cecd162e84f1f5a59c5e1..5ddaf27b21a6543770917d5a837e86e12eee0b81 100644 --- a/fs/unicode/utf8-selftest.c +++ b/fs/unicode/utf8-selftest.c @@ -17,9 +17,6 @@ static unsigned int failed_tests; static unsigned int total_tests; -/* Tests will be based on this version. */ -#define UTF8_LATEST UNICODE_AGE(12, 1, 0) - #define _test(cond, func, line, fmt, ...) do { \ total_tests++; \ if (!cond) { \ diff --git a/include/linux/unicode.h b/include/linux/unicode.h index 4d39e6e11a950c76f78d775fd6f351296f3d7d53..0c0ab04e84ee80227f9390ad0498f21a7ab7d34b 100644 --- a/include/linux/unicode.h +++ b/include/linux/unicode.h @@ -16,6 +16,8 @@ struct utf8data_table; ((unsigned int)(MIN) << UNICODE_MIN_SHIFT) | \ ((unsigned int)(REV))) +#define UTF8_LATEST UNICODE_AGE(12, 1, 0) + static inline u8 unicode_major(unsigned int age) { return (age >> UNICODE_MAJ_SHIFT) & 0xff; From patchwork Mon Oct 21 16:37:20 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: 13844441 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 68DBED15DBC for ; Mon, 21 Oct 2024 16:38:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9DF706B0096; Mon, 21 Oct 2024 12:38:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 917FE6B0098; Mon, 21 Oct 2024 12:38:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7917C6B0099; Mon, 21 Oct 2024 12:38:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 50ABC6B0096 for ; Mon, 21 Oct 2024 12:38:00 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 7FDF2AB04B for ; Mon, 21 Oct 2024 16:37:29 +0000 (UTC) X-FDA: 82698165606.01.8A9374E Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf28.hostedemail.com (Postfix) with ESMTP id 72766C001B for ; Mon, 21 Oct 2024 16:37:43 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=TWyfiSiM; 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=1729528628; 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:in-reply-to:references:references:dkim-signature; bh=xvtpXgeaP5+3Qey4SeTiBPWN2JmcKdnKWOsB+lrnGJo=; b=f0Y7Y/uPKqBCqjpYYwcqgiCfV5r72iZCst4Cn1CiEyljPZVo91WBLRFBe7eTROwxmoWe/o Z7q80EUOttafEKK5p60oilxCuQVK7g8sLmBcQAB/FviY9VyHomh1toWni+vWRWcwzceVDD TvDDFISNlKRioz9Qtd1tCvuh0eV9bcU= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=TWyfiSiM; 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729528628; a=rsa-sha256; cv=none; b=IGKb4Xa4UWUGuKv8LLrUvKsHygdoA5T05kvfBOHZiNCegya7m6SKhYl60GJIHP60K12um/ 7+AfoB9yLv+n+3PjXHIubQ96BqTlb2zzekZfNdjlE8vxApxL//urAqc3hVqdP+i4XfGf3J hH1B9n1mkHLvju7/ZlAWRs+6CQ/7xHY= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=xvtpXgeaP5+3Qey4SeTiBPWN2JmcKdnKWOsB+lrnGJo=; b=TWyfiSiMpn2JY+LAKRTmhYlWm0 ctHt/AVzOxuRttTp1AjNMOv8enBzWmA/p0TaQJBuTdFZTN3bH0P/LlKL2UzpIqu1cJJescJqSlQtw FjGjK+HFZ0K8aXxXh63UIjs4icp1ME5rw4sXMVwMZvcTvbbRApgXEqqATGFCekTNnRmakbdodbfv9 ZAsvZI3iSsDSEmgCa6fdNlbMkB9tDqjqFJFF+/byI9/Zj/IueginCoUSXBYTHQApbzfG+L0VEW6me LloWvz/NEwxuQognsc29f3R/4/h90YVP0wjNItE+1r9uzMKRgZjUQ0Kclk6q7Ci5lnnqH5+ydInM5 riVbX8WA==; 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 1t2vPo-00DECf-2D; Mon, 21 Oct 2024 18:37:56 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Mon, 21 Oct 2024 13:37:20 -0300 Subject: [PATCH v8 4/9] unicode: Recreate utf8_parse_version() MIME-Version: 1.0 Message-Id: <20241021-tonyk-tmpfs-v8-4-f443d5814194@igalia.com> References: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> In-Reply-To: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> 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, =?utf-8?q?Andr=C3=A9_Almeid?= =?utf-8?q?a?= , Gabriel Krisman Bertazi X-Mailer: b4 0.14.2 X-Rspam-User: X-Stat-Signature: ejgpe7yh1u9nec7j5ufuwnhjfgayhzcp X-Rspamd-Queue-Id: 72766C001B X-Rspamd-Server: rspam11 X-HE-Tag: 1729528663-376986 X-HE-Meta: U2FsdGVkX18llB2w2ewTh42U7LLJ3QAAixJUYIOUrCu7pdyFhh+vPhHUBFBm+rI1r/38gai7FzKfynI97+rUcIGxe38E3xWnQ6FOD4pJbDO7BOiXNf/nTSuDuSRpJPl5pQt/WedNgWeW8OM763Mp4TT7SdW4eZ2uMxPbGjUeE78B96obZy5ibz4DFFA448+TridRfNBuKNlogv0B6GhR4ty1oMFdM+bzQMKahSB9+AF9KlMvLKRPrjlLm6bzzmSuZ7rfdL20mYHRUBReS6VvwAGkL2bzvzo6DroiREk/iO4eZwIZiKGxpEmkCpW07ebO/71EjqUINrorVpqGPLgVwkK+Kxn1p7Fk+R4nyNdWJYHJ+DJ0tTQn0ionhEQUep8pGjPBwb1ZUvTeOrzO7bdcC8jXLyhxZtC2NDTF+me1BewwzbKdbSNZzVHGGG8ZVhVRCd7uABi7nwPeq4IKX3E7ZobQjVZAL0HOIzrAWvosTkSiW9GdjeI+A6Hio4bwuCq4P+H+CT97O6yotNyaVqT/3N9dHlFvw/d6ttI2pRxPgNCEIjah0UH4WkYJq/3Qg6LTN+bkH4qrQJ+9v5qlJcmBmrXDU0JgoWzNx+hjlvwJD97nt6FMgfs+U3VafMz97jFEfaExghyXvhKuWEabZCsP9yvD5xGttfCnPRzl00HFxW7HyrrpyILHL9g3CAqhejW5n8WzqSpnf9MQBbXwDB+U6q70+gNSx+c6dv8VTkhb2Xx9GzcxGOzuvRUwmIlKZJHyZ8oLEdPAVd44vtBy9e3C4+ECViV+rpjfmaSESTF0ywsdp3I71RkR13o1j69LrpiMDzTb+AjlhAL0k589IawoO55MeIXCBLjo79mYOes2yB4SgKSfXNUN0Bg9Z+MFxCtf5iaukMSbX+AWac08tsJoJAu5qybCeMwInoprC23R9o5tPwrXr4/mYGpPIy9jnWjx4ckz7b0RjWtTkpgkf+o 1z5ouG8Y l5r28vhfeMoP8CQl6s51DBZ/QwUW5caDFTG9RmgZwGcBRZc3fjpkdaBLyucNPmepNaxuZPsUrodQpXu0hGMg1FXsi8cwjiC0ghn2adswo/a6jxkiE3pECocpCsA9nBYxhq13VyESNQA04PKg/2PhsGffynxnMcXBPIOTTA1v3+/pBg0wjEwqxHr20xbyMjnTnrw0pN6zSRo7aCiYXT0O3ppxt0AZpLApuz+2o9uJjEaB3Tkw8O5sJZtaE9SrZ/0phQ14uSn01Enad4AjMXv4vwQB9//R3AnANxXdm0mlnUv51MQOBA19wruR1JDcAEjkPY1OpMK5Qqn9eP0ZhmXYQUiwnTICpYGQtcmYts6v/Z1vbpgtn2XKU+lbkyunsQ2WcyQByrVK2vEsgCW8Mx/4FO/7duaOn1eX1/bYG6/i54otFyftCnw8uaKvau6VP+1Eid0oP6odgkD7bhMw= 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: All filesystems that currently support UTF-8 casefold can fetch the UTF-8 version from the filesystem metadata stored on disk. They can get the data stored and directly match it to a integer, so they can skip the string parsing step, which motivated the removal of this function in the first place. However, for tmpfs, the only way to tell the kernel which UTF-8 version we are about to use is via mount options, using a string. Re-introduce utf8_parse_version() to be used by tmpfs. This version differs from the original by skipping the intermediate step of copying the version string to an auxiliary string before calling match_token(). This versions calls match_token() in the argument string. The paramenters are simpler now as well. utf8_parse_version() was created by 9d53690f0d4 ("unicode: implement higher level API for string handling") and later removed by 49bd03cc7e9 ("unicode: pass a UNICODE_AGE() tripple to utf8_load"). Signed-off-by: André Almeida Reviewed-by: Theodore Ts'o Reviewed-by: Gabriel Krisman Bertazi --- Changes from v3: - Return version on the return value, instead of returning version at function args. --- fs/unicode/utf8-core.c | 26 ++++++++++++++++++++++++++ include/linux/unicode.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/fs/unicode/utf8-core.c b/fs/unicode/utf8-core.c index 8395066341a437d0c20d6ab49b0a022eac7eec5c..7f7cb14e01ce8aa87d14dffdd767f63a90cf11f7 100644 --- a/fs/unicode/utf8-core.c +++ b/fs/unicode/utf8-core.c @@ -214,3 +214,29 @@ void utf8_unload(struct unicode_map *um) } EXPORT_SYMBOL(utf8_unload); +/** + * utf8_parse_version - Parse a UTF-8 version number from a string + * + * @version: input string + * + * Returns the parsed version on success, negative code on error + */ +int utf8_parse_version(char *version) +{ + substring_t args[3]; + unsigned int maj, min, rev; + static const struct match_token token[] = { + {1, "%d.%d.%d"}, + {0, NULL} + }; + + if (match_token(version, token, args) != 1) + return -EINVAL; + + if (match_int(&args[0], &maj) || match_int(&args[1], &min) || + match_int(&args[2], &rev)) + return -EINVAL; + + return UNICODE_AGE(maj, min, rev); +} +EXPORT_SYMBOL(utf8_parse_version); diff --git a/include/linux/unicode.h b/include/linux/unicode.h index 0c0ab04e84ee80227f9390ad0498f21a7ab7d34b..5e6b212a2aedab7ebf4363083339f4c5e9b82f8f 100644 --- a/include/linux/unicode.h +++ b/include/linux/unicode.h @@ -78,4 +78,6 @@ int utf8_casefold_hash(const struct unicode_map *um, const void *salt, struct unicode_map *utf8_load(unsigned int version); void utf8_unload(struct unicode_map *um); +int utf8_parse_version(char *version); + #endif /* _LINUX_UNICODE_H */ From patchwork Mon Oct 21 16:37:21 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: 13844442 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 17125D15DBB for ; Mon, 21 Oct 2024 16:38:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F2996B0098; Mon, 21 Oct 2024 12:38:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A1DF6B0099; Mon, 21 Oct 2024 12:38:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 71CD76B009A; Mon, 21 Oct 2024 12:38:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 488A56B0098 for ; Mon, 21 Oct 2024 12:38:05 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 47CBCABF6D for ; Mon, 21 Oct 2024 16:37:34 +0000 (UTC) X-FDA: 82698166068.22.545A0EB Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf07.hostedemail.com (Postfix) with ESMTP id 6F0604001E for ; Mon, 21 Oct 2024 16:37:42 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=sGul22ii; spf=pass (imf07.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=1729528607; 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:in-reply-to:references:references:dkim-signature; bh=8aBA/4S2L2Ycc2qCfgyFM1A0m9yiA602YgSs0LOAPsQ=; b=mNKHM080H05j47rAun+Jsqn/usPjtEwnMvn6h6PGNTZCYRKHjBwTWSxmDhdoT8Vrzf0jf7 V87o9H01UYFKUyoeoqpjwc2Ax9JG3hQu4rIhNR1LQ3X4wabyW+JmQvRPVId+6ZqHT7Ln+2 T6oCKoZ6WBjXkywf2D0tlxFBukUtx08= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=sGul22ii; spf=pass (imf07.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=1729528607; a=rsa-sha256; cv=none; b=v+xORrU+w6avDGhFASUr1nC0PatbYSpBgPQnsel2hs14b4/B+e5s0RTXMv99hs5zyHLQLZ 6GMMG9Dm+VZCFzw703F4L8QRN+ZqoGCI3h30sLvdAS1CHyj55KEo8bgKnzBxC67EDTM7ye /rGHdsrCLOevtPZDrH1LZQFVdSddGac= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=8aBA/4S2L2Ycc2qCfgyFM1A0m9yiA602YgSs0LOAPsQ=; b=sGul22iiToBRcAg432HG8WKaK8 OOM4ct/fDT+3GzvG1GOYF5ejXlXvNfkh4FeOox+qpLIxl65ivUMmTP1EOuWqrLhYiiaQ9sv4mm9DX Wmd79Eh8hZFhzmA/+cDNcyXmLChy0jNGbj0HFTFjnZGvDHv9KcLLXhTR0MzwV6y/UJjVxx+Dzw2u8 uSKQKJIA1LGoWjDcBM9qn1bbnVYSvCu3vL9EHzcAPQIpxeVxIglUDA/RZ34N9Zf0o9aJ8fORLBc20 EsXY7TqCHU1k9o0cOzOY5fRyWtUECSdCDaMrNdRktVOqDka7A8aSadtRtsgtKyUHyAJkewJkCTYTJ kDXn3ujA==; 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 1t2vPs-00DECf-NR; Mon, 21 Oct 2024 18:38:00 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Mon, 21 Oct 2024 13:37:21 -0300 Subject: [PATCH v8 5/9] libfs: Export generic_ci_ dentry functions MIME-Version: 1.0 Message-Id: <20241021-tonyk-tmpfs-v8-5-f443d5814194@igalia.com> References: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> In-Reply-To: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> 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 , =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.14.2 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 6F0604001E X-Stat-Signature: w15r9gq7a1tuhunrkj8ht66bxcufxro4 X-HE-Tag: 1729528662-438551 X-HE-Meta: U2FsdGVkX19DcnbjEbApD7J9PhGpRS3HKQ32f+0KaMQW7Nw+27Q1n7SPIwV9eKIc5BfhaTfHedZGdIsu7KLKZaHo1I27jNigF2tFn0yLG9WyVMhYRD0VnA7toKTc+0GNRyYW7RgZwgF0IyJKM34VN+HY4b4APpx1mndQc5TbU2adwuXj9qF+CHQXDpEsXI6mtozRJY8U31isiUL7gknxgg2KRmJY9UMqfP6aVD0Xfl9loFEzuhEz/B37YxOdsLdSJY5lvAIRucVOVXt9NEgTDYwjyxYvpXJhQwz/gfiQNIFvael7N9hJJZPbpkCWWVl/iVWoqGpLeiLEhpUEiRuKL2bPea8W/7IaObOBeE+Ft43jbTv3NHr/mvsyi5QEI6qA9cIGlO+vagv06Dp8uIv8fy7dLc+Zt2rbLQrgqgAYaaRtmOa6dPhZDZFPQ4IJh1Hft/7f1MsrLX4rU/qcPOiiLFLfxCoV5j3KTaXgf/reLocXzAZTZj+3du72lRgYxQio0ndec3sdrjDH8WT/1ly/cSLH3tG2dzr9YdlTl0U4mSAGjlMs8H5CIO14rXj/YS/buc6XUxjw0Slo6xw3lhrVYxmCjH7RPRuvY0zHLvSrMJ540lTg6wWBqSth597gn0HVzCAQTShd+6hnAtEzNNA/DJCQKTk4NwLEW+KxQUrxbGmDLqvnUPeNgRvJ8ATMSjDn0NnTM4YbqYmJ0NkUbSjMl72niYNSVjPeD9dexnljYweXrJVu690CavfmblItxUQVprYYkLR5qWTu1+DV5KhPGFotPSy3mRE7inhFBxvGZikVbVAuV5d7BfvAP0aYzSQQVEpKBMYJLN5LNrh0AZy00bxItIen795mG4qnf63k/deojBwImECyWHZB+vz0RYKQxR//hLUEHHDKzi3CB/6T5lX4ymdWkrl7w6FGWXiCrCIW85KSNMoc1/xK5ErMvvE7/vdhnA42QUdh34G+ZAB W7s/ae78 34qCupqaroSobhKqeXlw5YGcm7YEzrF02Ukg0ypRgfxN4IoShSWPInv2cOxdt8pM1op6Q+ON827OJEs3lJNKl31k0G7vEp33X77LoHTTrFMeqVeaY8CysjWIgDx4yjCVV7PtIzEJDCqB5ZJSOX6I+xQpmYbaFJCcyhRYD4f3/lA88xlE/4tCIieqdiWw8b3J16Mmq/UmI864Tmd1NH2hmiht0As74JCtlLkKzo9o9wuHC0UfdfM8mdgB1jJi+6HcX12ag3VEifZuvJXF6yTOvPTefKd58IjMBvhLhLqSy7l+HeKxoSpyRqpXD9ShkTUdrkLOnwLIm6a6BcKntKNZJRyR9Wlpon/fcpz3/7mFWVYLi/vG7jIeG9O+5yqEXDuVdk017ABqRxmB+jnbrC9MizBg49voRw8momxuDBv4Om/jp0F88hnnkGygScpXdrnrD5ek6qIK/S/tEf5o= 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: Export generic_ci_ dentry functions so they can be used by case-insensitive filesystems that need something more custom than the default one set by `struct generic_ci_dentry_ops`. Reviewed-by: Gabriel Krisman Bertazi Signed-off-by: André Almeida --- Changes from v4: - Guard func signatures inside IS_ENABLED(CONFIG_UNICODE) Changes from v3: - New patch --- fs/libfs.c | 8 +++++--- include/linux/fs.h | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/libfs.c b/fs/libfs.c index 46966fd8bcf9f042e85d0b66134e59fbef83abfd..7b290404c5f9901010ada2f921a214dbc94eb5fa 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1791,8 +1791,8 @@ bool is_empty_dir_inode(struct inode *inode) * * Return: 0 if names match, 1 if mismatch, or -ERRNO */ -static int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, - const char *str, const struct qstr *name) +int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, + const char *str, const struct qstr *name) { const struct dentry *parent; const struct inode *dir; @@ -1835,6 +1835,7 @@ static int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, return utf8_strncasecmp(dentry->d_sb->s_encoding, name, &qstr); } +EXPORT_SYMBOL(generic_ci_d_compare); /** * generic_ci_d_hash - generic d_hash implementation for casefolding filesystems @@ -1843,7 +1844,7 @@ static int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, * * Return: 0 if hash was successful or unchanged, and -EINVAL on error */ -static int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str) +int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str) { const struct inode *dir = READ_ONCE(dentry->d_inode); struct super_block *sb = dentry->d_sb; @@ -1858,6 +1859,7 @@ static int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str) return -EINVAL; return 0; } +EXPORT_SYMBOL(generic_ci_d_hash); static const struct dentry_operations generic_ci_dentry_ops = { .d_hash = generic_ci_d_hash, diff --git a/include/linux/fs.h b/include/linux/fs.h index 403ee5d54c60a0a97e2eba9ef80d8fb4bbd2288f..b277369672a140eba13dce7fa7b0883359c643f8 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3458,6 +3458,10 @@ extern int generic_ci_match(const struct inode *parent, const u8 *de_name, u32 de_name_len); #if IS_ENABLED(CONFIG_UNICODE) +int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str); +int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, + const char *str, const struct qstr *name); + /** * generic_ci_validate_strict_name - Check if a given name is suitable * for a directory From patchwork Mon Oct 21 16:37:22 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: 13844443 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 010A3D15DBB for ; Mon, 21 Oct 2024 16:38:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 82D376B0099; Mon, 21 Oct 2024 12:38:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7DD446B009A; Mon, 21 Oct 2024 12:38:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 67E326B009B; Mon, 21 Oct 2024 12:38:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4B4CD6B0099 for ; Mon, 21 Oct 2024 12:38:12 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B6D0F806CE for ; Mon, 21 Oct 2024 16:37:58 +0000 (UTC) X-FDA: 82698166446.05.97DD4A6 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf20.hostedemail.com (Postfix) with ESMTP id EBCFF1C0019 for ; Mon, 21 Oct 2024 16:37:51 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=mTOv6970; spf=pass (imf20.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=1729528491; 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:in-reply-to:references:references:dkim-signature; bh=SYqDKiNCj94D/RjQ3mqSngWF/SOfGh3llXqpE7JA7tA=; b=2vX4w7zzX8Usse5m6P7X6gZmNfh60XQepxiMrc1Y53OibA8ZxSrCCzp7fFgo5xl46L3DcL jz3xP+CLoPdP7gRoUnLiiyrj/mZLpRjj/wL6iIv38pWEHd0b14xVvNuTXHpU7qMn6ziyTl a3NG3WY+lnoGLBde/OnUJJX7p563gII= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=mTOv6970; spf=pass (imf20.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=1729528491; a=rsa-sha256; cv=none; b=1YsFMPwjJhpEzWwpd6MGVqQHkh0sO4xhwA9bS2ivPEpLi6NXylkj7bNWAixpyn0GJmiGm5 X/jHiDMZQTmpJQCZNxxMBuVz6jPs0GhDp9C9OZkH9DQTbvp6cnpZErMfcwHU2iR3ZmGMau oAzAyPmrthbHUyoZH1HwdIAA5JxP4mQ= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=SYqDKiNCj94D/RjQ3mqSngWF/SOfGh3llXqpE7JA7tA=; b=mTOv6970u9vULdRkC82HYxMNTq fi9Y1qtnmPAR6Ej6TQVXdugc/rgR/299vmYJ6Qe7gJpwzX3kV+AdKZXsboBhxYKXPPAJQ7tAnRMPK /cyaK8a0po2U2kDfmt+bucxt+h+xUIkDFuH5uUCl3Fsyhn3fNcidJOoVEw4PWVHsRl+EWjLWltWX9 +A/TN64QnQPpII5SMjQ/7QWWEGoLlAmn0RrmzPEH+vmEY1daG/v2PfK3KqkpWzmC54Rocwqkyb+Ls lBR/JvWl4hXQZc5IlfrezJUejPz2h3VfCGvC5bfswj7rbCvHFhPoDLnXbPHnXv6631oUV86+6aHaG /8KraFlg==; 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 1t2vPx-00DECf-K1; Mon, 21 Oct 2024 18:38:05 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Mon, 21 Oct 2024 13:37:22 -0300 Subject: [PATCH v8 6/9] tmpfs: Add casefold lookup support MIME-Version: 1.0 Message-Id: <20241021-tonyk-tmpfs-v8-6-f443d5814194@igalia.com> References: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> In-Reply-To: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> 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?= X-Mailer: b4 0.14.2 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: EBCFF1C0019 X-Stat-Signature: bd3waoy5fmha8ij4bgi4us6zsre3tony X-Rspam-User: X-HE-Tag: 1729528671-745688 X-HE-Meta: U2FsdGVkX1/cR2YL1gtrIM7GJYSj2Dy7ObG5ShqFwnSzwN1T8m+6KvCFC/4r0u8IFh2tA22/wgfnTbcV4PAVF+PmVz18/JNxux4Q5WjIPbZQHifxKM+d+9D9pizzpcNpsYQGQCiJ8VGzsM3EK4QdnX4/cLE6/z2FwDrFc2kOdyhmNsy4+WNz+MVz5h3ItsEu7vnpxLjpaQ2+wy63HUDUbzgONuyokDPX86PU4mLWqOqpBujf2NEKI3Iu8TR/5j3V0RtMlb1IkA7/oYYiZNnOMEdGtYx5NZYHYo8gERWtZj2plMs+d4274zCln9sVl/BcsHCF1/EIUQTKEpj9/wlUiKyA0QoXpZgR6GJqi++XY5Mrs92SiauFLjoe2WJIZT+cbdZBec0YeVXzSbBaThLNunqkp2FE0OQOG1KBlWR3qqNKhR8pAHYPdc45O0iQMNhupOfsZ6OGqAIurYh1k3Urw9B4QGdRKsZuZqKoGjZHALg4nWHN/IFvDKMPtuiAdNSwxTcSW4Vii0DWVfaSrmQbUxgA2tWs/lJRMLvKt2gLLjQSLhOTFSTl4QSbq9SBprffekjmnzXEGkrl23TkV2w/hPWSmWScFPWtvW6VNtpivHyg50o965maTVjTG1Sm+kekH1iA7EfcPVfkq+9ZaVUVl6VsriDbsA/XxSL/gibNFPygCi429Luj1KrxiP0L85/bIA4lal+PFu7jkAgWkCXvFwfX1ceA/oj4lwM2yf6++wT7jaJ4TlT2XSQ0tNCkTktFlRV6g13bVUlH7WNL2E1tXhpKkVumXkmlie4EdKQcrW08166BL0/VnAawBjMSx+dctyTO781YPXUbdLTHo3OhztvA4ZtMtzfs1mJVGAou/8Mbx6/uvGI/b054u/6pE8a/qaJFccu1ebaqieAmTsSWX3rPoLjDagxvGFFIEp0UIxcg3zSrNF+ezD2t6dEoEXHmvt5/gJIqh/8oqt+2Z68 4vcXpeSj k+uUtAS996ibOziZM/2q91+/vEqk4vrGT+tLtxSt5Sza/bAeDtR6bJUHDLKYE0eCwyv/21xUR03t1DFQNFbH2jYvGZHP5/4rSItTIW7JvL7L5n98ppdVJtjodjfOV8H/NH1krSOYQnOw5lp/qofm+TBViOMb3KulpmxunV6X+wZ8gciwcTY3BrNJdvBCznwIMjIQ32EURggG3sRujOzvo6Bx8yJXAaz73EOfkY/67GZjMFBX2dMTseBX1/bb41YcTKrVM/FNnUAjjuDlrHETXQxJKECwCE/pJ4D1SQdtQ9QJd91GqGkIdCOXYR5CYmfSeiU/jEpzardTkKTal+E1pEYZXfQ== 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: Enable casefold lookup in tmpfs, based on the encoding defined by userspace. That means that instead of comparing byte per byte a file name, it compares to a case-insensitive equivalent of the Unicode string. * Dcache handling There's a special need when dealing with case-insensitive dentries. First of all, we currently invalidated every negative casefold dentries. That happens because currently VFS code has no proper support to deal with that, giving that it could incorrectly reuse a previous filename for a new file that has a casefold match. For instance, this could happen: $ mkdir DIR $ rm -r DIR $ mkdir dir $ ls DIR/ And would be perceived as inconsistency from userspace point of view, because even that we match files in a case-insensitive manner, we still honor whatever is the initial filename. Along with that, tmpfs stores only the first equivalent name dentry used in the dcache, preventing duplications of dentries in the dcache. The d_compare() version for casefold files uses a normalized string, so the filename under lookup will be compared to another normalized string for the existing file, achieving a casefolded lookup. * Enabling casefold via mount options Most filesystems have their data stored in disk, so casefold option need to be enabled when building a filesystem on a device (via mkfs). However, as tmpfs is a RAM backed filesystem, there's no disk information and thus no mkfs to store information about casefold. For tmpfs, create casefold options for mounting. Userspace can then enable casefold support for a mount point using: $ mount -t tmpfs -o casefold=utf8-12.1.0 fs_name mount_dir/ Userspace must set what Unicode standard is aiming to. The available options depends on what the kernel Unicode subsystem supports. And for strict encoding: $ mount -t tmpfs -o casefold=utf8-12.1.0,strict_encoding fs_name mount_dir/ Strict encoding means that tmpfs will refuse to create invalid UTF-8 sequences. When this option is not enabled, any invalid sequence will be treated as an opaque byte sequence, ignoring the encoding thus not being able to be looked up in a case-insensitive way. * Check for casefold dirs on simple_lookup() On simple_lookup(), do not create dentries for casefold directories. Currently, VFS does not support case-insensitive negative dentries and can create inconsistencies in the filesystem. Prevent such dentries to being created in the first place. Reviewed-by: Gabriel Krisman Bertazi Reviewed-by: Gabriel Krisman Bertazi Signed-off-by: André Almeida --- Changes from v7: - Consistently guard `encoding` and `strict_encoding` fields from struct shmem_options, so those fields only exists with CONFIG_UNICODE. Changes from v6: - Dropped patch "tmpfs: Always set simple_dentry_operations as dentry ops" - Re-place generic_ci_validate_strict_name() before inode creation Changes from v4: - Squash commit Check for casefold dirs on simple_lookup() here - Fails to mount if strict_encoding is used without encoding - tmpfs doesn't support fscrypt, so I dropped d_revalidate line Changes from v3: - Simplified shmem_parse_opt_casefold() - sb->s_d_op is set to shmem_ci_dentry_ops during mount time - got rid of shmem_lookup(), modified simple_lookup() Changes from v2: - simple_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 --- fs/libfs.c | 4 ++ mm/shmem.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 127 insertions(+), 4 deletions(-) diff --git a/fs/libfs.c b/fs/libfs.c index 7b290404c5f9901010ada2f921a214dbc94eb5fa..a168ece5cc61b74114f537f5b7b8a07f2d48b2aa 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -77,6 +77,10 @@ struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry, unsigned return ERR_PTR(-ENAMETOOLONG); if (!dentry->d_sb->s_d_op) d_set_d_op(dentry, &simple_dentry_operations); + + if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) + return NULL; + d_add(dentry, NULL); return NULL; } diff --git a/mm/shmem.c b/mm/shmem.c index c5adb987b23cf9ba5b8117ece2b467a434f7c0a3..f26488ff3d6ae1abb9b63d55ca74909249dbf4eb 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -40,6 +40,7 @@ #include #include #include +#include #include "swap.h" static struct vfsmount *shm_mnt __ro_after_init; @@ -123,6 +124,10 @@ struct shmem_options { bool noswap; unsigned short quota_types; struct shmem_quota_limits qlimits; +#if IS_ENABLED(CONFIG_UNICODE) + struct unicode_map *encoding; + bool strict_encoding; +#endif #define SHMEM_SEEN_BLOCKS 1 #define SHMEM_SEEN_INODES 2 #define SHMEM_SEEN_HUGE 4 @@ -3565,6 +3570,9 @@ shmem_mknod(struct mnt_idmap *idmap, struct inode *dir, struct inode *inode; int error; + if (!generic_ci_validate_strict_name(dir, &dentry->d_name)) + return -EINVAL; + inode = shmem_get_inode(idmap, dir->i_sb, dir, mode, dev, VM_NORESERVE); if (IS_ERR(inode)) return PTR_ERR(inode); @@ -3584,7 +3592,12 @@ shmem_mknod(struct mnt_idmap *idmap, struct inode *dir, dir->i_size += BOGO_DIRENT_SIZE; inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); inode_inc_iversion(dir); - d_instantiate(dentry, inode); + + if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) + d_add(dentry, inode); + else + d_instantiate(dentry, inode); + dget(dentry); /* Extra count - pin the dentry in core */ return error; @@ -3675,7 +3688,10 @@ static int shmem_link(struct dentry *old_dentry, struct inode *dir, inc_nlink(inode); ihold(inode); /* New dentry reference */ dget(dentry); /* Extra pinning count for the created dentry */ - d_instantiate(dentry, inode); + if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) + d_add(dentry, inode); + else + d_instantiate(dentry, inode); out: return ret; } @@ -3695,6 +3711,14 @@ static int shmem_unlink(struct inode *dir, struct dentry *dentry) inode_inc_iversion(dir); drop_nlink(inode); dput(dentry); /* Undo the count from "create" - does all the work */ + + /* + * For now, VFS can't deal with case-insensitive negative dentries, so + * we invalidate them + */ + if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) + d_invalidate(dentry); + return 0; } @@ -3839,7 +3863,10 @@ static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir, dir->i_size += BOGO_DIRENT_SIZE; inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); inode_inc_iversion(dir); - d_instantiate(dentry, inode); + if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) + d_add(dentry, inode); + else + d_instantiate(dentry, inode); dget(dentry); return 0; @@ -4192,6 +4219,9 @@ enum shmem_param { Opt_usrquota_inode_hardlimit, Opt_grpquota_block_hardlimit, Opt_grpquota_inode_hardlimit, + Opt_casefold_version, + Opt_casefold, + Opt_strict_encoding, }; static const struct constant_table shmem_param_enums_huge[] = { @@ -4223,9 +4253,54 @@ const struct fs_parameter_spec shmem_fs_parameters[] = { fsparam_string("grpquota_block_hardlimit", Opt_grpquota_block_hardlimit), fsparam_string("grpquota_inode_hardlimit", Opt_grpquota_inode_hardlimit), #endif + fsparam_string("casefold", Opt_casefold_version), + fsparam_flag ("casefold", Opt_casefold), + fsparam_flag ("strict_encoding", Opt_strict_encoding), {} }; +#if IS_ENABLED(CONFIG_UNICODE) +static int shmem_parse_opt_casefold(struct fs_context *fc, struct fs_parameter *param, + bool latest_version) +{ + struct shmem_options *ctx = fc->fs_private; + unsigned int version = UTF8_LATEST; + struct unicode_map *encoding; + char *version_str = param->string + 5; + + if (!latest_version) { + if (strncmp(param->string, "utf8-", 5)) + return invalfc(fc, "Only UTF-8 encodings are supported " + "in the format: utf8-"); + + version = utf8_parse_version(version_str); + if (version < 0) + return invalfc(fc, "Invalid UTF-8 version: %s", version_str); + } + + encoding = utf8_load(version); + + if (IS_ERR(encoding)) { + return invalfc(fc, "Failed loading UTF-8 version: utf8-%u.%u.%u\n", + unicode_major(version), unicode_minor(version), + unicode_rev(version)); + } + + pr_info("tmpfs: Using encoding : utf8-%u.%u.%u\n", + unicode_major(version), unicode_minor(version), unicode_rev(version)); + + ctx->encoding = encoding; + + return 0; +} +#else +static int shmem_parse_opt_casefold(struct fs_context *fc, struct fs_parameter *param, + bool latest_version) +{ + return invalfc(fc, "tmpfs: Kernel not built with CONFIG_UNICODE\n"); +} +#endif + static int shmem_parse_one(struct fs_context *fc, struct fs_parameter *param) { struct shmem_options *ctx = fc->fs_private; @@ -4384,6 +4459,17 @@ static int shmem_parse_one(struct fs_context *fc, struct fs_parameter *param) "Group quota inode hardlimit too large."); ctx->qlimits.grpquota_ihardlimit = size; break; + case Opt_casefold_version: + return shmem_parse_opt_casefold(fc, param, false); + case Opt_casefold: + return shmem_parse_opt_casefold(fc, param, true); + case Opt_strict_encoding: +#if IS_ENABLED(CONFIG_UNICODE) + ctx->strict_encoding = true; + break; +#else + return invalfc(fc, "tmpfs: Kernel not built with CONFIG_UNICODE\n"); +#endif } return 0; @@ -4613,6 +4699,11 @@ static void shmem_put_super(struct super_block *sb) { struct shmem_sb_info *sbinfo = SHMEM_SB(sb); +#if IS_ENABLED(CONFIG_UNICODE) + if (sb->s_encoding) + utf8_unload(sb->s_encoding); +#endif + #ifdef CONFIG_TMPFS_QUOTA shmem_disable_quotas(sb); #endif @@ -4623,6 +4714,14 @@ static void shmem_put_super(struct super_block *sb) sb->s_fs_info = NULL; } +#if IS_ENABLED(CONFIG_UNICODE) && defined(CONFIG_TMPFS) +static const struct dentry_operations shmem_ci_dentry_ops = { + .d_hash = generic_ci_d_hash, + .d_compare = generic_ci_d_compare, + .d_delete = always_delete_dentry, +}; +#endif + static int shmem_fill_super(struct super_block *sb, struct fs_context *fc) { struct shmem_options *ctx = fc->fs_private; @@ -4657,9 +4756,25 @@ static int shmem_fill_super(struct super_block *sb, struct fs_context *fc) } sb->s_export_op = &shmem_export_ops; sb->s_flags |= SB_NOSEC | SB_I_VERSION; + +#if IS_ENABLED(CONFIG_UNICODE) + if (!ctx->encoding && ctx->strict_encoding) { + pr_err("tmpfs: strict_encoding option without encoding is forbidden\n"); + error = -EINVAL; + goto failed; + } + + if (ctx->encoding) { + sb->s_encoding = ctx->encoding; + sb->s_d_op = &shmem_ci_dentry_ops; + if (ctx->strict_encoding) + sb->s_encoding_flags = SB_ENC_STRICT_MODE_FL; + } +#endif + #else sb->s_flags |= SB_NOUSER; -#endif +#endif /* CONFIG_TMPFS */ sbinfo->max_blocks = ctx->blocks; sbinfo->max_inodes = ctx->inodes; sbinfo->free_ispace = sbinfo->max_inodes * BOGO_INODE_SIZE; @@ -4933,6 +5048,10 @@ int shmem_init_fs_context(struct fs_context *fc) ctx->uid = current_fsuid(); ctx->gid = current_fsgid(); +#if IS_ENABLED(CONFIG_UNICODE) + ctx->encoding = NULL; +#endif + fc->fs_private = ctx; fc->ops = &shmem_fs_context_ops; return 0; From patchwork Mon Oct 21 16:37:23 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: 13844444 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 DC398D15DBB for ; Mon, 21 Oct 2024 16:38:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A7826B009A; Mon, 21 Oct 2024 12:38:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6570C6B009B; Mon, 21 Oct 2024 12:38:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 520186B009C; Mon, 21 Oct 2024 12:38:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 33AA16B009A for ; Mon, 21 Oct 2024 12:38:17 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id ECEAE12064D for ; Mon, 21 Oct 2024 16:38:02 +0000 (UTC) X-FDA: 82698166572.30.EAA5BBE Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf17.hostedemail.com (Postfix) with ESMTP id 8CAF840014 for ; Mon, 21 Oct 2024 16:38:03 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=ssz0k7vO; spf=pass (imf17.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=1729528618; a=rsa-sha256; cv=none; b=tIvIXCisx4tDwE3MdE5PEZUZ/K1esHK+IYnU19qtXzB9f3nETMZ80SBsqIbys386H2M7dB aFasjbOUpkmOnn8JLiasQ7o4FLQCiOiuSTkZ0LEemlhjan7rZARwIXA08gtlRjEaJaIA1L 5GiZ+RAcZLAekS+8mdWRpIz4kAU1g00= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=ssz0k7vO; spf=pass (imf17.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=1729528618; 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:in-reply-to:references:references:dkim-signature; bh=q02ijIMJQIrChEbtR3X8eciq/6AW4aNz0epCTvb52no=; b=2cdCNEYhlW61QLtaOxStDi2kIhkPjEUTvdRFLcazs5zeaFfxTxW6YyHz0/doMLQ7r+OV7b FuDcXtDBOnVqkHa+V76M8ARmF/9gj0YdQPDFFulpYBnDPMNoKxG0aOZ5z3xCSRkXeROlK/ etN+2M7kvE4q3Hg+Y6cicMDGCL8kai0= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=q02ijIMJQIrChEbtR3X8eciq/6AW4aNz0epCTvb52no=; b=ssz0k7vOogf/9lEXxWRLIbMC5m 40jx4wEKB2ZtppeN9mWGSaUBES5N5lWdcKfi0hwIOJgHsvASvu5gPHgDrFaAVBTQ6YkkzXKH3ZAXK 6C56v9dkdm8F8B6ifSxy93lAyBcQ9tAi+lAnmf8WqLGyYF2RlwB7g7DjF+9Y53d5tubzSwaHaPKGy 9zz04KLihV1oNnW7o4YG6j0R/Lg6LTuJg1uBMupZrF3+QfPlfu0Ya6rr6g+uG70qT+3iwnQshutQK leTL/FWI3B08fsxeZNbECooKTflrDqrm8LQdBO0eftBeBz67ztuJne0g/1pNTuwkGxDqvn1U6tGxs l4Hnu3aA==; 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 1t2vQ2-00DECf-G9; Mon, 21 Oct 2024 18:38:10 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Mon, 21 Oct 2024 13:37:23 -0300 Subject: [PATCH v8 7/9] tmpfs: Add flag FS_CASEFOLD_FL support for tmpfs dirs MIME-Version: 1.0 Message-Id: <20241021-tonyk-tmpfs-v8-7-f443d5814194@igalia.com> References: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> In-Reply-To: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> 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?= X-Mailer: b4 0.14.2 X-Stat-Signature: een98jxtxtfenejgyd8mikuexgjmomkp X-Rspamd-Queue-Id: 8CAF840014 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1729528683-67323 X-HE-Meta: U2FsdGVkX1+f8NBFHajiQtDo/RohLsKt8OZpC0y99PZYOConS+/AQ4F7/0J1y6gNOCZVILcS9BoNQ9VwhuDKBDd1271aP9tMztHtxbwF2nu5lUuhwCsH66FtSHvVFw2p/SMP/NrvnV1eBxdWwUQlhdJ4tMQNhFuBzraWUNm1nKNynkkFap+hk0h+QidF4IRB1PBQG6iVXpYQXfI7UF9zwhVreGxM9VuWHz8XonGkEU+tgbouwRvVA84vhGYLNMwVRGz32S7EzotSRpukVYaWZm6qLL5YgZQHJGvM/Ua8GGogfBRwvCrYmg6bSQdNy96bb9dhJfE/h4k+5mDBhL+vS1yRPfIC0cyiiS9GdggQCmacHrJt5xsDQFUss9444KIekla1jYrGoIlM8K1EnsCG9Z5Szl+oezpsowj2slDQClElvx7r+lal5kBGboYt+Ce/uzu5krjJWr573m8Lbb2WFfOAYbUTxXuz6CzFpfLoSmFiFNP/VrkueNXxMfQsuag9Jaq8suSHb8a+MkB9cC6rGqCK6+mRceLz4IL4sHP8H47LzM4JO6rg/o+DTDlnXQH0k700BN1k7UMC628uz0aAC8UEQd2H4lkF+Qv70bZjBtwtGTyDfnQzZ30ea3pUld+GJKlsOg59TVZuiHAIeVFULgsRjn5eMYdXHfDyWWI8KrdKK+NOdPLpcAqJXVlwHW7m0Sqkakkp+exLlyXf1AZprN57+qnacU39VM1ywd55QN1MygsuIegXWShoBhM0KzEcbYVeSNDATAu6QV3mqyt+rtePKjrKSL7RB82Hw3O1J0ePh3vNyYvJIGfJp50KeSxtl0YXZ0iztSIhLpiAqGCTou0xBG589Vs287LL0ohMg+fJe4hdpe46SP9jm4uOzZPBcVaGw1ie71oLvEV/H9fQ2uBlKHyB90GQy+6lZMgtng6GXuxsgb/4uaFpJicKo663sD/f0PuQOVmyr/s+mE9 X0Xg/NwK sG4INuA+uVbTGarnHjMPfiAofEQRIFr+srAf9klcvfm4votbBlFqhBwnrfFqHuzP/7NXDG7v4XNK8kaw/6cCRe/akBy+B1l99gWThxu2GLroYYyFkMbZ8dvYJ18LKHrIuK8dRSzp/XaylSFAVGYmjdf2tCcyxQnNPpdThUoo0mUKijcxZginn3+t7CdyYMkVkoQs4FBkLkvNylbcvWZWEi152FA/bgjBABIshxNzFCkJ5S7UxRfB4GaidakRb6KVewx1zSaGUrgpF65ZiKMbQyRKKsv2cjawtosRcseL40PdrvsDX23sPObi22aff6VbTl4TWdLwqldvYhfvCORjWY1uDZmgiL3BHWBKnZNXj3m4MXJyyMs6qHO1/W5THFqVH9iIpF3frM1RHixXpB090Fr01mrsTK9gcGuQyGQwZadmiZyHuF8iGcmUOcbc3O7DJp1PJ+vhT7e3ZP50= 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: Enable setting flag FS_CASEFOLD_FL for tmpfs directories, when tmpfs is mounted with casefold support. A special check is need for this flag, since it can't be set for non-empty directories. Reviewed-by: Gabriel Krisman Bertazi Reviewed-by: Gabriel Krisman Bertazi Signed-off-by: André Almeida --- Changes from v2: - Fixed bug when adding a non-casefold flag in a non-empty dir --- include/linux/shmem_fs.h | 6 ++--- mm/shmem.c | 70 +++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 67 insertions(+), 9 deletions(-) diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h index 515a9a6a3c6f82c55952d821887514217a6a00d1..018da28c01e7d71b8fb00bfb23c000248c8a83f4 100644 --- a/include/linux/shmem_fs.h +++ b/include/linux/shmem_fs.h @@ -42,10 +42,10 @@ struct shmem_inode_info { struct inode vfs_inode; }; -#define SHMEM_FL_USER_VISIBLE FS_FL_USER_VISIBLE +#define SHMEM_FL_USER_VISIBLE (FS_FL_USER_VISIBLE | FS_CASEFOLD_FL) #define SHMEM_FL_USER_MODIFIABLE \ - (FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NODUMP_FL | FS_NOATIME_FL) -#define SHMEM_FL_INHERITED (FS_NODUMP_FL | FS_NOATIME_FL) + (FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NODUMP_FL | FS_NOATIME_FL | FS_CASEFOLD_FL) +#define SHMEM_FL_INHERITED (FS_NODUMP_FL | FS_NOATIME_FL | FS_CASEFOLD_FL) struct shmem_quota_limits { qsize_t usrquota_bhardlimit; /* Default user quota block hard limit */ diff --git a/mm/shmem.c b/mm/shmem.c index f26488ff3d6ae1abb9b63d55ca74909249dbf4eb..ea01628e443423d82d44277e085b867ab9bf4b28 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2757,13 +2757,62 @@ static int shmem_file_open(struct inode *inode, struct file *file) #ifdef CONFIG_TMPFS_XATTR static int shmem_initxattrs(struct inode *, const struct xattr *, void *); +#if IS_ENABLED(CONFIG_UNICODE) +/* + * shmem_inode_casefold_flags - Deal with casefold file attribute flag + * + * The casefold file attribute needs some special checks. I can just be added to + * an empty dir, and can't be removed from a non-empty dir. + */ +static int shmem_inode_casefold_flags(struct inode *inode, unsigned int fsflags, + struct dentry *dentry, unsigned int *i_flags) +{ + unsigned int old = inode->i_flags; + struct super_block *sb = inode->i_sb; + + if (fsflags & FS_CASEFOLD_FL) { + if (!(old & S_CASEFOLD)) { + if (!sb->s_encoding) + return -EOPNOTSUPP; + + if (!S_ISDIR(inode->i_mode)) + return -ENOTDIR; + + if (dentry && !simple_empty(dentry)) + return -ENOTEMPTY; + } + + *i_flags = *i_flags | S_CASEFOLD; + } else if (old & S_CASEFOLD) { + if (dentry && !simple_empty(dentry)) + return -ENOTEMPTY; + } + + return 0; +} +#else +static int shmem_inode_casefold_flags(struct inode *inode, unsigned int fsflags, + struct dentry *dentry, unsigned int *i_flags) +{ + if (fsflags & FS_CASEFOLD_FL) + return -EOPNOTSUPP; + + return 0; +} +#endif + /* * chattr's fsflags are unrelated to extended attributes, * but tmpfs has chosen to enable them under the same config option. */ -static void shmem_set_inode_flags(struct inode *inode, unsigned int fsflags) +static int shmem_set_inode_flags(struct inode *inode, unsigned int fsflags, struct dentry *dentry) { unsigned int i_flags = 0; + int ret; + + ret = shmem_inode_casefold_flags(inode, fsflags, dentry, &i_flags); + if (ret) + return ret; if (fsflags & FS_NOATIME_FL) i_flags |= S_NOATIME; @@ -2774,10 +2823,12 @@ static void shmem_set_inode_flags(struct inode *inode, unsigned int fsflags) /* * But FS_NODUMP_FL does not require any action in i_flags. */ - inode_set_flags(inode, i_flags, S_NOATIME | S_APPEND | S_IMMUTABLE); + inode_set_flags(inode, i_flags, S_NOATIME | S_APPEND | S_IMMUTABLE | S_CASEFOLD); + + return 0; } #else -static void shmem_set_inode_flags(struct inode *inode, unsigned int fsflags) +static void shmem_set_inode_flags(struct inode *inode, unsigned int fsflags, struct dentry *dentry) { } #define shmem_initxattrs NULL @@ -2824,7 +2875,7 @@ static struct inode *__shmem_get_inode(struct mnt_idmap *idmap, info->fsflags = (dir == NULL) ? 0 : SHMEM_I(dir)->fsflags & SHMEM_FL_INHERITED; if (info->fsflags) - shmem_set_inode_flags(inode, info->fsflags); + shmem_set_inode_flags(inode, info->fsflags, NULL); INIT_LIST_HEAD(&info->shrinklist); INIT_LIST_HEAD(&info->swaplist); simple_xattrs_init(&info->xattrs); @@ -3931,16 +3982,23 @@ static int shmem_fileattr_set(struct mnt_idmap *idmap, { struct inode *inode = d_inode(dentry); struct shmem_inode_info *info = SHMEM_I(inode); + int ret, flags; if (fileattr_has_fsx(fa)) return -EOPNOTSUPP; if (fa->flags & ~SHMEM_FL_USER_MODIFIABLE) return -EOPNOTSUPP; - info->fsflags = (info->fsflags & ~SHMEM_FL_USER_MODIFIABLE) | + flags = (info->fsflags & ~SHMEM_FL_USER_MODIFIABLE) | (fa->flags & SHMEM_FL_USER_MODIFIABLE); - shmem_set_inode_flags(inode, info->fsflags); + ret = shmem_set_inode_flags(inode, flags, dentry); + + if (ret) + return ret; + + info->fsflags = flags; + inode_set_ctime_current(inode); inode_inc_iversion(inode); return 0; From patchwork Mon Oct 21 16:37:24 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: 13844445 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 28194D15DBA for ; Mon, 21 Oct 2024 16:38:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9DC9B6B008C; Mon, 21 Oct 2024 12:38:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 964546B009B; Mon, 21 Oct 2024 12:38:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B9346B009C; Mon, 21 Oct 2024 12:38:19 -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 5724A6B008C for ; Mon, 21 Oct 2024 12:38:19 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E65ACA1AF6 for ; Mon, 21 Oct 2024 16:37:50 +0000 (UTC) X-FDA: 82698166572.06.928FC27 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf23.hostedemail.com (Postfix) with ESMTP id C5391140012 for ; Mon, 21 Oct 2024 16:38:07 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=ng3tGDT4; spf=pass (imf23.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=1729528547; 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:in-reply-to:references:references:dkim-signature; bh=SbTvLQbuG7yeLrygZxqm3PkbVldfcIwV1lI2HDmaGB0=; b=uDpuajjT//TlJMb8dCxmLOcMe7Qn0FNnXZKJpDqllLp5ICU9Lm6K/152kWQFcakBdYIUtB HEW4hezS5kpdy3uwF0UCoT/DXgEg97AJUIAP+MqEh1grO4nfKyem94Ja6IhOAA24Ae+5vn JM574Uq0vj1gwykrU5U3Ooya9iqUcKo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729528547; a=rsa-sha256; cv=none; b=HzETHdmCusL90Zlb3cdJZXauKKMvzPwCkxCEECZnermglSnyhdv3+3PGBtNtvIkLvGcU3G thMzD1ys8gYE9874bC1pvmRy8j72VmNLTQh3sDQZX5hOwZuW7mMuexb8Rx/QgDJV4w8sae Y0rzKxxocfcn90cuGMxBJ9Nim0RnEGY= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=ng3tGDT4; spf=pass (imf23.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:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=SbTvLQbuG7yeLrygZxqm3PkbVldfcIwV1lI2HDmaGB0=; b=ng3tGDT4cx9xfXAgnjbczk8AVt 8VDuXwyw4Nz7jqIThpbDd5tui0FNOI/+nvnS1lw9Jov8iFzGRpkVK+PaeceBs8GE1eh9uKxeGT7Iu nGGX3uWpKbFTnYT7zWcK+X+DpbOjFg+O3xObm6DP+quVe3X0RP/k6QyJY0yUTp3dITyGt6X2VQT54 p9LSsgj7k2hB3qISbYBFcNhnA445dYuOKRzcNN0ZFJ59n/3bek/jxYUdIq8RwX3+mCvPpcIvYsG3Z 1bOrLwofFZXvPLWeOjsweF7w0AuOLQKuwSzlKH83sNHYtRCI9lwN2F4Zro3Zb10FMJ5u0PM/ARfY1 lGRkU2Hg==; 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 1t2vQ7-00DECf-5L; Mon, 21 Oct 2024 18:38:15 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Mon, 21 Oct 2024 13:37:24 -0300 Subject: [PATCH v8 8/9] tmpfs: Expose filesystem features via sysfs MIME-Version: 1.0 Message-Id: <20241021-tonyk-tmpfs-v8-8-f443d5814194@igalia.com> References: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> In-Reply-To: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> 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, =?utf-8?q?Andr=C3=A9_Almeid?= =?utf-8?q?a?= , Gabriel Krisman Bertazi X-Mailer: b4 0.14.2 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: C5391140012 X-Stat-Signature: msrx8fjm93g6rktytmxgmnyunghh34xs X-HE-Tag: 1729528687-526620 X-HE-Meta: U2FsdGVkX1+ptdYn5B6IoKlia8vIlCCNdkQlykdbwSA2rzCC/q2TE/oy8apBZqe5bA1UFJUEs8UQcEGSWkPzXa1mrGbOu2KgRslT2TFQ7HbFkjEHEHOB2gNYE8l0nrEdA07owX1kLgVaa2u4U8pWAMf5jyoZhOc+zXRUDuPzNUsaBj5o2CY7luwUod7V+zvd1jooRIT3IUpQR2S5odZdE6tyEukq/m0VoKFBbVPgBHQ3ZkFaRudPJ0ArOk9A95YFBZHmvIRwHOj69mGZOv2ij5YWqez/dZy4qewjZ5kB701/uf2QECbBrTtT1Y9Y691jGnHRhwrpSZ3aeyyUZonPDDYMcY+EtXAe7Bs50Qcp1zPgQ5T+NYJb6viz8tr5lBJTuuKvNKZvput/uY/usHoNZWZ5ubTEj1NzJOomHPgbyMf1Anh3ORkkUNuDzbhSe5r/NXh4JEn6XM6z5AgtxhSYoP1ASH8nqzb8xvFmhRn5km2LFVpbTP6sL+KuhxjxNJ/IDZfpwYMsJlZFCI4erU1HikguaYs5k3XjYoS1V547REq2EWohrU0MJRm+Dda7MfVZ0+JNM0ayPWW5GgbMRbr8rC1pFqfyGrJ6R+6Cl3Iovt6n9C/Wmh6y4TiLuVRUYLx0ZS0dDNAMeuGxOS7TofAqurA0KvrZTm39DZ3UUnq4W2on/d42PQ0cIYM9CE1cRve/55LoEC7k863LLJU8aSmYUC7p5HC3hepGZW1D3e3zZm6IUabmsddd2Xa/oqiD0gy5sn1yMYBTqJIkq96reDpk3FsRhtwFTCbtWt3Qi2kWuXhRrwSvme536knAs4XXWBjWrjHf/Rz7RBX0RZ1jovM3gAeQWpiE5gcExcBGYEfUX5vZVebONJZTAFtSODRkz1+/4i3TRnMfo5cMUinZOObb39gZ1dR0BowU/T832ANdaC8X4kPtoL53DNI8WnHTk+tNGuW9JRod0Rj7p0tgsi3 5VFMIx94 8LIpf8S28fOONRH2RxwCAA/pnKnK0qqdBB1fWZpSYLQTOawXSCJVR9URwxi4H4BjKoj4+XgJz3HV6jXGLk9vvsFUHFP/VQ3I6iu5Boe8uyksNZ5Ntd/zA6ikMgTbcufaIMd676LVKkYmPB0Pe97I5DzE/FNjeCL+yvX5FhYdWAWKtLByLReOpFuimmqamPwe7UdPWQ31Qfvbla4WpQESmDMgZu+zZOsrEHLiDW3TEZrBS6xy7Fp8za66d9lHx+qvw8fIvCR9rSs29oXcA+KWDUrBnB+910W6MTgwUw3bmgbR+7suQebxM+g9AnBKHXlSIpM6YjJhpb2RlP5zrMoflERCXjgjpBNou3zUGH9smE6x9LalCxt0BFiSEdtiBF+QJV5pBfbnn9nqx1CyaCC+jjo0y8UbaNv8WmXC3 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: Expose filesystem features through sysfs, so userspace can query if tmpfs support casefold. This follows the same setup as defined by ext4 and f2fs to expose casefold support to userspace. Signed-off-by: André Almeida Reviewed-by: Gabriel Krisman Bertazi --- mm/shmem.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/mm/shmem.c b/mm/shmem.c index ea01628e443423d82d44277e085b867ab9bf4b28..0739143d1419c732359d3a3c3457c3acb90c5b22 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -5546,3 +5546,40 @@ struct page *shmem_read_mapping_page_gfp(struct address_space *mapping, return page; } EXPORT_SYMBOL_GPL(shmem_read_mapping_page_gfp); + +#if defined(CONFIG_SYSFS) && defined(CONFIG_TMPFS) +#if IS_ENABLED(CONFIG_UNICODE) +static DEVICE_STRING_ATTR_RO(casefold, 0444, "supported"); +#endif + +static struct attribute *tmpfs_attributes[] = { +#if IS_ENABLED(CONFIG_UNICODE) + &dev_attr_casefold.attr.attr, +#endif + NULL +}; + +static const struct attribute_group tmpfs_attribute_group = { + .attrs = tmpfs_attributes, + .name = "features" +}; + +static struct kobject *tmpfs_kobj; + +static int __init tmpfs_sysfs_init(void) +{ + int ret; + + tmpfs_kobj = kobject_create_and_add("tmpfs", fs_kobj); + if (!tmpfs_kobj) + return -ENOMEM; + + ret = sysfs_create_group(tmpfs_kobj, &tmpfs_attribute_group); + if (ret) + kobject_put(tmpfs_kobj); + + return ret; +} + +fs_initcall(tmpfs_sysfs_init); +#endif /* CONFIG_SYSFS && CONFIG_TMPFS */ From patchwork Mon Oct 21 16:37:25 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: 13844446 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 63382D15DBB for ; Mon, 21 Oct 2024 16:38:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E6F1A6B009C; Mon, 21 Oct 2024 12:38:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E1F3B6B009D; Mon, 21 Oct 2024 12:38:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE7A36B009E; Mon, 21 Oct 2024 12:38:27 -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 A85AD6B009C for ; Mon, 21 Oct 2024 12:38:27 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 62DFD12071D for ; Mon, 21 Oct 2024 16:38:13 +0000 (UTC) X-FDA: 82698167160.18.0C0A4DF Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf17.hostedemail.com (Postfix) with ESMTP id 04E5B40004 for ; Mon, 21 Oct 2024 16:38:13 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=V2FlZGvv; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf17.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729528583; a=rsa-sha256; cv=none; b=wT1kcjChMJRlKI9cav95pqO4PseloG5HJlOIqIzjypIReHinbfanhnJ5rqR7noV+z4EZat g7Kdit9BSg+wBCrgG4SCA/6kR+kz9C4b3UOlWpzXfm6GIW1ZYIEi+H8+P968GzwiiSjrmW kceTyY/t63663OP3nADFYGHRGfoK17Y= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=V2FlZGvv; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf17.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729528583; 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:in-reply-to:references:references:dkim-signature; bh=IRWzJ2ihFV+Or6Yh2tTDHkDcDI2/Jt0crAI74pE29VE=; b=Nlkv0VGN0KJrtyO1o3ujWja4pg2Dc6E/NZ499wUQ5Ds4TdEpAJEx6xwBRAL81xdHC6luzK PjrqHCv96sf6CknaU2/aUc/7lQtVizEwZ5znHnOwg/WbrVPbOiea2jIiQVJryIxucKhRT8 KU/VWtfeNLEFTaE69sE37L90yy9VoN4= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=IRWzJ2ihFV+Or6Yh2tTDHkDcDI2/Jt0crAI74pE29VE=; b=V2FlZGvv0GJNi7LqNPWoCYWe6T IkwHBJYGJ+UMuht6t72Uh3VCoWz68gVRWqEbZFagUWe9x7/A0ezMs/UiC/c4DJmOYrRcFZ3Lyxjot 47BDGhrMfAYzpMpD2UVR9+/fldHg+jpxD2KQ5PHkjAcWueBNoH9mq+ZUjG8DvwdhDW6/U3mTkxnVG XNUawWorxooLY1LtJwijslHO5Q3PEh4xE6Ijzu9Hz6byJ4CiNigt+12Fn0h1nxM0EBM0Or8V4CKac pFzUu5ary992udtZ0y2pP0Qp0lvbOhTcP8801kQmPgA6te+sRvFoFyKoDgkhpOTq/rvslEYjRjawC CF8EthZw==; 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 1t2vQC-00DECf-1s; Mon, 21 Oct 2024 18:38:20 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Mon, 21 Oct 2024 13:37:25 -0300 Subject: [PATCH v8 9/9] docs: tmpfs: Add casefold options MIME-Version: 1.0 Message-Id: <20241021-tonyk-tmpfs-v8-9-f443d5814194@igalia.com> References: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> In-Reply-To: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> 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 , Randy Dunlap , =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.14.2 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 04E5B40004 X-Stat-Signature: ieuo4k3ribswswab9kjc55urrpy47r9s X-Rspam-User: X-HE-Tag: 1729528693-494667 X-HE-Meta: U2FsdGVkX1+YjQqO5mDmuPnVgHDWocsKATa4j65rvDvoP/TEPWFZ0RjWsIw43XWu7gMIPSwOWoXfX+oFz1s2Zs07k16zCNjhAwHXVtneOdBrU9ilFACTf01HQqv+UbQQerWzjUWZv/g+r+oNQOPU6Rcs65kZUMdZBsoaGWULXe6GblPDeu+mzofLbSjf5zW72K+xId5R8cKenD6LQ3tUbe/TQUfs3tPxo6/EIkKdl9f+6AFCrJ6FDOYpJGNpLvON3VfPlhYR04P7cqNyQniQc6hbiFk6PYqCt6i9evMCGy30NoXDTWrZbLFn4wmbFFGOB6Vbj7WTnCN8OjATnxHtUCQxf6hkdzXHUohosNc77l+4g0zKVVBxvdxX0eqt8m2OrRY5R3QAckglXxftdYeeOwtRXyakBUAc1e8Wn3GsE8JOSsdEzrSHWE/8GOLvcub/CFGi6VfNb7Mk4z0UX8VvuNnNFqZMC81HiRVa1yOUxr/ZaAu+zKp2ehzpv+VKK5oWxW3l3Txt8MKmH6YIQGoZIQ8Nte1Dhcn004L6XfdnpyPqy+WafdsDYxIVVF2DL1KCXNX+pSBdXiodxZoDLGVIV67HMvkb/2sNSTUsKTM2Yjm1fW/Bl6bSLxXYTFfyCaJ33cfCRt+4h+tGZ0ilCshdHBaWV1Ul2hTstni3ZcqVkTknNPpCqSRvLv2TsdHwqOEayvGq8l2yiUzhQiyUxl4clXn+VrJbMhXz+qO3BxtNzLEq8G45WZCqGHu/yBQ8YN5nJ3IMCVaJzx2UIlRY9yDvjOw6F5TbBDARCuegKTz4ez9Z5wxi4ne10iS7TDktrOYROXw/Q6jyDWsIB6FKm/p5laTsX5dt8Q7cRosuHO0g2WRZ90WjGTtFAsYlBwdLkn6PL4LH00unxZifB7UhtOd1qjeEHKhRxsJVMoLf/3yg/sli3YzMcbn6ouWJzi5a5kcDAwNwM6gA5uoINk69qTm RA++a+pY Xnh05v9wJ/0mB/m0uM23JZh1wNFLZOVCtC1KnO7Okc1Xgf+FtrjMqj+omSq47H7cEWKnbizVO73JFfDBrBRm2JLnghmh1Non3q21/NXCs9j6JHtojCBWn4MVlPxBPbIXY1uOdOlC6DdURDjr+vdEZ/FdL80un1VFvX4FRo1f8kiB25Syi8TQZZydPpKuX1WoyTfBa3AoYsb11lsd6u04wMm0xhl3b3oWk6GKBPxF1z9BYxubMrqLtjiiLktvquI66STlG1X6FDoOiH99Nchid8+S9HbtsoGBNvOVRwdr2tGm9UvlosRUIv2UbhoFr5pumNrVobaujBl8xCZfqNO+ZIGxqwZ9W1FRM9s+MJesIR/MIPNdsPC+GVJirO8gMP6IuTMR2+q63yPiLSI0Sk8HmFg1pxlU1zvq1iUCu 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: Document mounting options for casefold support in tmpfs. Reviewed-by: Gabriel Krisman Bertazi Reviewed-by: Randy Dunlap Signed-off-by: André Almeida --- Changes from v3: - Rewrote note about "this doesn't enable casefold by default" (Krisman) --- Documentation/filesystems/tmpfs.rst | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Documentation/filesystems/tmpfs.rst b/Documentation/filesystems/tmpfs.rst index 56a26c843dbe964086503dda9b4e8066a1242d72..d677e0428c3f68148a3761bb232bbed5b9a41f76 100644 --- a/Documentation/filesystems/tmpfs.rst +++ b/Documentation/filesystems/tmpfs.rst @@ -241,6 +241,28 @@ So 'mount -t tmpfs -o size=10G,nr_inodes=10k,mode=700 tmpfs /mytmpfs' will give you tmpfs instance on /mytmpfs which can allocate 10GB RAM/SWAP in 10240 inodes and it is only accessible by root. +tmpfs has the following mounting options for case-insensitive lookup support: + +================= ============================================================== +casefold Enable casefold support at this mount point using the given + argument as the encoding standard. Currently only UTF-8 + encodings are supported. If no argument is used, it will load + the latest UTF-8 encoding available. +strict_encoding Enable strict encoding at this mount point (disabled by + default). In this mode, the filesystem refuses to create file + and directory with names containing invalid UTF-8 characters. +================= ============================================================== + +This option doesn't render the entire filesystem case-insensitive. One needs to +still set the casefold flag per directory, by flipping the +F attribute in an +empty directory. Nevertheless, new directories will inherit the attribute. The +mountpoint itself cannot be made case-insensitive. + +Example:: + + $ mount -t tmpfs -o casefold=utf8-12.1.0,strict_encoding fs_name /mytmpfs + $ mount -t tmpfs -o casefold fs_name /mytmpfs + :Author: Christoph Rohland , 1.12.01 @@ -250,3 +272,5 @@ RAM/SWAP in 10240 inodes and it is only accessible by root. KOSAKI Motohiro, 16 Mar 2010 :Updated: Chris Down, 13 July 2020 +:Updated: + André Almeida, 23 Aug 2024