From patchwork Thu Oct 17 21:14:11 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: 13840838 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 B8BA3D3C533 for ; Thu, 17 Oct 2024 21:15:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E8E736B0083; Thu, 17 Oct 2024 17:15:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E3E896B0082; Thu, 17 Oct 2024 17:15:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D06456B0088; Thu, 17 Oct 2024 17:15:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id B18B96B0082 for ; Thu, 17 Oct 2024 17:15:11 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 9B99C40333 for ; Thu, 17 Oct 2024 21:15:04 +0000 (UTC) X-FDA: 82684349412.18.0B5F456 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf28.hostedemail.com (Postfix) with ESMTP id 2A507C0009 for ; Thu, 17 Oct 2024 21:14:58 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=kxKSNa9s; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf28.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=1729199676; a=rsa-sha256; cv=none; b=cXDUJ0EYHinKEzb8e/FE/kBmmvMesJmyMiIX0y542OmB67hTQcwT1CGKygNlcbHcxyWVqX R2pyLZxc8jIbgMRUSeblJL4g/lIsIVHXlSn4cLI+GKQOgR7lz3q2vExz2cWMdx5lupcjz0 wWFj0FrPxFkaH4nUFP5GdSFcCMMRfjQ= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=kxKSNa9s; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf28.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=1729199676; 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=8dI7Vp/FrIA/hgTEdP08qCKbl15yNUWf7v4zv+kdBu4=; b=wggYV8AxXCYvvSULTltvqo23yw/jvcRxx9Kp0cRTl2toQVTDEsR/cAaCrIyGF3w7jWXaQA MZU7pi87t08eN7KBcC0smKcT30l5xBLnG2gboazJ75nVbIjGCP1W8cfdZ2mjJBSKA/drAp BbJ1p1swGjrn3dScGYenvbovXX3C2sQ= 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=8dI7Vp/FrIA/hgTEdP08qCKbl15yNUWf7v4zv+kdBu4=; b=kxKSNa9s+2zS7JilNTuBJKTUIo vqm9cP3VwpRLKFNNiR6MWrQhE0x+mSO83pzF6h6ysRxOcjHNi7tt3uKXUtMWNFOk39CGBhe7Mgz5U 7NJQVPC/3ji8Es8CM1a1v0DBIrk7QNpITYFz3LhtuxeA49L3FoeVwg0zpzt5UHbSDMoQ75pGW9Rjd h7GWU4yYl/22lulvtIoRF4te3vFgzUvEadAPGUmzOzhAvYwe2SzKNs3gAuXbG6eYGyKRFPKqrhqRO B3v2F0X5bEIkjE+lIeh67RsnhggJP5ldnf2fJwbdtKzf8eQY7FbzrrSdAbEEh9jvJ5cWX/bXbbZcV KYnRyO6A==; Received: from [179.118.186.49] (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 1t1XpV-00Bnlc-Bl; Thu, 17 Oct 2024 23:14:45 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 17 Oct 2024 18:14:11 -0300 Subject: [PATCH v7 1/9] libfs: Create the helper function generic_ci_validate_strict_name() MIME-Version: 1.0 Message-Id: <20241017-tonyk-tmpfs-v7-1-a9c056f8391f@igalia.com> References: <20241017-tonyk-tmpfs-v7-0-a9c056f8391f@igalia.com> In-Reply-To: <20241017-tonyk-tmpfs-v7-0-a9c056f8391f@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-Stat-Signature: cjewt1rmoc1wymot1z4tmph59prbx9gn X-Rspamd-Queue-Id: 2A507C0009 X-Rspamd-Server: rspam02 X-HE-Tag: 1729199698-526253 X-HE-Meta: U2FsdGVkX19L7/pzizg5jOabXmkLW4Y30aAZ6GPHaPOde5rBgrxEmU2QeXxUHyhDt0QU69J8x7/AnudfUiZyzWyO0LHziTnNcbqmoWq0pWCSs/wYHbEU1n5YmUXEpZJwxxBs1k1rtB3BA+Cx9FmoegacMSgVdl9vjq5gCei57+PbUFSkYYBfl9nyrPKyjFIvy1EiacTdR7H/gD02zEeKWHJ5U4VzFo6wmJMIxhYDFQ3V4/xNNt721H+Mw+/h8d9IdeJRh5HqnbBvupHlFpnn1w06gTpG2CE8C/TImtYHgKJuxXNFWhHY+XF0bupZZIdatkd+ApGU+1SZHtfITw4o6UqduFkxdvKnPMI0rhnFmTsMVEParbSFeap+uVS845wv5VMHnUJ97L2ZNbAHLuhvUdzOcVUHMTIggLXhhKfcH2Ke4uIuWfnqejwZbNswJh/pwWsA3441KCIbipn2FRBFmI6rJ6T/+OUHKfbJkTUJ6skyl3I9TDd5Dry1OhKoFHwt6d4RNBtXl/nzK7MWy6PnPWhrXR01gvU90UYYzGOWnPkSmnKjqYCd548LP4umgLIHSrSwcgc8VKAYbATzm35i84EhCaa6gY68O76PfFSZzwemkRt8uMHihEWNVY9T1aNIQnCdy2GWfHt4CNSH51jQNMNb38RvaHPBB65WtPPA/ErgGR31s2vG0nU49QDo2t8C0sssozYkeb4QOw29Y8YipPLqd+ts3k3W0yFnDCaQgH8W+lE2Ed/r8QUxP2iwIv6MIbKEOMJv4509BXW2G2vpeq03B7/BwX/EEX7n9UKTClO0TeYSgtIiumsZcAVE9kx+SP76h/rvDIGSmvmI2ARJKG01U9SRv3UBm7EUH5/UsFM4055fkJTR+osZVGPV+U4qgcLqdsoWeRerVDr/7Zs2Mkmbb7NZ4LOktknvfwc/wnfoW98xxGGVPzgCikXtipWDl9aPjZFcKqW/oTr/irI fDtSMq/x fIskAnApT0jRoAzbIWIoxAr1em+lQEYMt2eM2Und3SS88gCuMwu6/aaGJDXaS04dNBqcMDRGMtlpNsetPfedKXpsYa3mueS0haCeClsu+IrbnVkSEqTQE4GftEUQtJwyK5E+S/SIE3s6ycmtHNILvGSLHvEj3Oc9A7b5dq6ElHm/sRnnoQ8BVsn14aJ/EnC1+RNUDHwNagYVA22+cKidjv1RDmSZtSSAACK9aye9YOQY9HaD+noXhog2o6Mhgqagj74aH8+/HnBzhBep4vw4zDEKZtm9yZ85LbcrzfRrLHJSDfef4FNoY6kHKn7fknen40ev04J7ZUlapCB+F4ntUmfCh79dVcTjLPfUkGMbaQiKlqAzEzNcZ3tRjJ03dq5J6pXAO7FEgYpQNiiNF1AvapWVfiu1r053x7v3/ 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 Signed-off-by: André Almeida Reviewed-by: Gabriel Krisman Bertazi --- 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 Thu Oct 17 21:14:12 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: 13840841 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 27228D3C538 for ; Thu, 17 Oct 2024 21:15:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 62B936B0085; Thu, 17 Oct 2024 17:15:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 53ECC6B0088; Thu, 17 Oct 2024 17:15:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3434D6B0089; Thu, 17 Oct 2024 17:15:14 -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 128266B0085 for ; Thu, 17 Oct 2024 17:15:14 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 10E0B1602FA for ; Thu, 17 Oct 2024 21:15:01 +0000 (UTC) X-FDA: 82684349454.05.822035A Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf30.hostedemail.com (Postfix) with ESMTP id BE30980013 for ; Thu, 17 Oct 2024 21:14:52 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=aHd1RBwu; spf=pass (imf30.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=1729199637; a=rsa-sha256; cv=none; b=mTpCi96Ix4GEMvhMH8R1slWJ7P2JDh6DTBZODEaLeNezxuj+xVeE9/Z3SYequLSKqiyeOD uIS3rc3/jHD2h7pok5qksoFxZOjTr+3n5XU7Yzxn4jHJXd8Y+rhlfR0xw4R+fKb47wRhuS Ykej1s3wBZXpfc2tbDS3G2aer1QH/z8= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=aHd1RBwu; spf=pass (imf30.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=1729199637; 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=LT0wuGHoEva2xfXTRVweZEALpwDAIgwaKYJkj8VNcwhBvmbP5XIrV7wL+XKFE9Agr/OH5P iUJGnbbonDeIWgycI+VXO8qafvowNFtw0xAQ6AYluJ6Ftofu9V4ZZcF7PVEp391h9XSCsi xm3Nu2WJZC7TihZOV/VrhM5nspP6WGY= 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=aHd1RBwuJnYKAAbtP2Yfezw+8I 2PC4JlmTiVs6vwBZeuda4ovEutYVBnolq0TSsGS0RU614r5mzpMktl4vS4+lKdJpCEgQkHHiWMg7J Na5rV9q16hIJpT1AnU+YWxnFPG1X6RuD6fX0YTPcZpmBLQcm5+Fky1802d/zGITMcm/LQ9WJiJD07 E9vJpYiK73JpidObV8ArRYiwDPPSSoblz71efvX4ktX+tppvh4gWgl8qJHaWBo3wm+4jl1FlGc1rL Pg/EvQhhWC4+cD2jkxeM5wRa5Crnh89AkYqI9UvN1pRj2nWCuZtvUO5SU92fTRGon5Sps8M7owuYo d/zNX3ZA==; Received: from [179.118.186.49] (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 1t1Xpa-00Bnlc-1J; Thu, 17 Oct 2024 23:14:50 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 17 Oct 2024 18:14:12 -0300 Subject: [PATCH v7 2/9] ext4: Use generic_ci_validate_strict_name helper MIME-Version: 1.0 Message-Id: <20241017-tonyk-tmpfs-v7-2-a9c056f8391f@igalia.com> References: <20241017-tonyk-tmpfs-v7-0-a9c056f8391f@igalia.com> In-Reply-To: <20241017-tonyk-tmpfs-v7-0-a9c056f8391f@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-Stat-Signature: k1xir8bika1i3shmp45hcg7zgch4qmfi X-Rspamd-Queue-Id: BE30980013 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1729199692-626213 X-HE-Meta: U2FsdGVkX18zrHYdCVbUsWi0dD2DVaRJzgUufJv28foX4YSE83dImmiwGKcZk+3yIMok2dizQMvr2yKEK22Jvmw0zqQdmgaAOUfYW8+Nl4Xcpwzo6GGqbMvZ0BGB4dDIfnRNbIKe2glJoqEzoa0idwc2jm2ILFEzJpt13/5TWui87o/RFAdWaI9xUdvj7KgaZ566lyjkRKipMRh8fFZSxJgSro7/B1rbNp/Y/mkAFxn7J90ESksVLplIhqcZQ3TG5Qu4svWZ1yTEDJUfj4ifNk1oy2j2ErDXkmJa7LP8m1bb3e5t3PYWDjFxE+w4Yl+4aHMrXSXdLwzU6p123nmXy6Hfir7zjpCecGuFMMnm+NhYUJxUclPw9J8qjO91hBANKOcXCvonL8AkWKZMdUgwsuBZhV35tlx/n8cODsg55R41opgtbG9eMD5nd4Knc9xtzvY0Zjq1RvklNTIQ9Nv5rbv4EH1qsZj+tIwTB3USAzGCzMZHrzp8y3O7Rvby30no+qbyh5od3BYrXUyiaWV6p0bTmMmxYzh4/Bcnt0o7gc/n5PkDBpC3knh8An9Tu+/OPcyMZMzsFHwyT2Y5TkDVaHgcZYUTBgbLjQeSBiOfOFlD/4K4DWgWfhZ1GCcpDJF8m05jhy52+8cU++HMxX2cX8hHUq3ab2mqi/7i/sXqLN2dFW6Fyfm4My1i3zslSoI7u7ybE4z1JhVQRH8O3i02SDYCL1L1fW/OGzPuRBaiLsrmGFftan2h01aHrLqFe9btPS4zUbY7YlKRkJwsNIsx2C50f1PfIeBH8p5fUW95trD4ZLHm7/UoH5pATmGkimApKNuvOOhlFEb+bCDR1CgqbAVhYaHt0+QDiuBj6SdMzfJPwPvVgkBo3eRQfJJC2JbWNDblPtZkwE6va/NLRD2qylk2bid1BlzsxqZf+e9tuDAFEb1AqebtSB2FO3apr/JiS0d4kWDYspwLWjkefr/ Ruz6cGay xLX5wiVj2PzqL226bWcfnTkvX14iI7WpAdoRGnUBkl3QStL1Xw6Blo36ZG6aqzGtuEMyldbS9fN/rLLzJAuQhnd/tVAiNKlyRR7unQ8E5Fk8yrOuro5SQj108hNZCZTPwH3QUP28i9/Sjyb67f1cEiGCrC/K1zRNV1qNz76SWuUg0SNG4/7oMf4/N71mkSBcqVtKMT//9pJjvG/fCaxV4569X5UXyaFx+CD/rj6ZcP1nyd4PdgC4KqchEQD+tY37NKaxDKgui6Xnhh+NdoanIoNIFCYkzEZ8kPfieleZF9TNnQ5CHanYI4wl6kEwHgAPGjekZkBZ4CEdlepb+5GIEf6PkpHLmR4K7DVljg7m80IIHrLat6knM/1avJ0aNbyD6n8ZXDk0dkEMLTqdJ0twICP+3vlHAwa64a9lcMR8F2CZrRssa0oAqAVWUYeBgXmN1uaLncIznAlCaNSs= 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 Thu Oct 17 21:14:13 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: 13840840 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 57369D3C536 for ; Thu, 17 Oct 2024 21:15:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 232586B0088; Thu, 17 Oct 2024 17:15:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 193C86B0089; Thu, 17 Oct 2024 17:15:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0335C6B008A; Thu, 17 Oct 2024 17:15:14 -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 D84F66B0088 for ; Thu, 17 Oct 2024 17:15:14 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CC6CC1C60C1 for ; Thu, 17 Oct 2024 21:15:01 +0000 (UTC) X-FDA: 82684349454.12.EDCF993 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf02.hostedemail.com (Postfix) with ESMTP id 3F5A98000D for ; Thu, 17 Oct 2024 21:14:53 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=iSDw60lg; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf02.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=1729199552; 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=DjhSLnQzTrw2COCTCgROqkaDLSF7vG/akA8K+EaGbGxEvmwdjSh8wIEo8N4ZxcLPQMtBYU Na8UQIrzF+bfzOoJ+hGlPvPi1iHaKqxQmTjZ+SSXybJltYKVYYq+yWk7IWyhAp37IQXWke VALv1G+XgLeyyKxbpz6p36+OR37EMjY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729199552; a=rsa-sha256; cv=none; b=VN8XrnO5LNNswbe55N7Q4zn3bmC2yuHUT+o3Sex4q3fiZPnKF4/g4Y+Jew8+OrBWjUhbKR EMw8Hq2CNsv6Y2l0Tkg1dWkW3XFYdlwSeqAI/pAnjHIGWHJQsNpRTByc8gXbKHt5zmaQVl p6ssC/k5uWqE3+/Vq9W6/fMfp1sfxS8= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=iSDw60lg; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf02.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@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=iSDw60lge7F7jzxnfBIsI91WxB qUzuh1/WBRtByHLpt4cxcSlLviYC4/jFyhvBZPy6uEmS+VF+oW6ak2o4bVutpmBW4bQMfsQIo8mAG +juqzsuDe8HB4B2hREQeCPz+RS0WKS67EQ8L0EtlER/ESOs2wgSLKhsE9K74dwfkl6hOp8+ObcTD6 6LAhbhdeWd6gHFQxhL5oWdJNLB8m5P54vbdwXwmuGnmDFJwvdhGoLjjHGEd/h0K1wItgADP9RWYET joaTf9z6dhkOUy/M/LYT2u93fRdprG0iDxu4FwtKK5rszT7/Tg/gkOt6luCYqdTQqHzGvncfCSJJ/ NajR5XjA==; Received: from [179.118.186.49] (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 1t1Xpe-00Bnlc-NG; Thu, 17 Oct 2024 23:14:54 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 17 Oct 2024 18:14:13 -0300 Subject: [PATCH v7 3/9] unicode: Export latest available UTF-8 version number MIME-Version: 1.0 Message-Id: <20241017-tonyk-tmpfs-v7-3-a9c056f8391f@igalia.com> References: <20241017-tonyk-tmpfs-v7-0-a9c056f8391f@igalia.com> In-Reply-To: <20241017-tonyk-tmpfs-v7-0-a9c056f8391f@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-Server: rspam07 X-Rspamd-Queue-Id: 3F5A98000D X-Stat-Signature: f4mt9ymdy9aka7x847asagom1n5jhn61 X-Rspam-User: X-HE-Tag: 1729199693-7209 X-HE-Meta: U2FsdGVkX1+r2Xo5q0ykmEvplY6LFA68ZCMi4bRcuAv9diI8ApR8fHmVp7WHGdqR3f2fihCFh0gdJnXdf9+wE6hpTrVZZCoPl2KZxGUzBv6JBou8ie9YDovRX/ytmskKzsezFFjb1gDbVBxvxCam/Dkoz7pG0QJD5qGct7wjHsJBI5NIUKcC99pqoo5tmKvDwLViBHmK7eVqJDOISWP5AfGS4VPpmNTFvukM+R8AXRFlfyrR30+zWwM5LH6HypCH0V6pAwMAwyzyhaUW4qAff2pizLnkUF4Jp6id5gnmAER98J7QsVosvcCI9goOO12u2iRf03LgQPdXam1iyneegSsc5QUVVEQlTuIQigxUcJwI6MLzLr1hKtDlDIXfnWGbcDXQ4VAiZCu0IvA0T1htyfdiDmKUrINh1cIps3BV9Nz28oEvljXg469euOtjyYPT6QXuMDFNOu/uIztowKNbEAfjdnokpDWFvA191FrNY2X33gjyL9/CW0Fr1tEdw87SnkFVcTbGvkAHNReTbMXzPN0SoNXln8DAakx9MOQGsT19Qc48siSNvY/dJNseIkSV25DukKee1YL0GsUN+NUXH7Y3Qnyjy5+e55RBKUSSt6UMD4h4lgVeTgQ7xGrYbwukP5EWIZXCuAHbinvziIOXegQuY1jAoFNCLJgd6hEfpXq0A/zvQVVX7S8o7CWQoHdCdhpoSTKeMFC0ZE+hX4naTZXlhAUrYbfN0mJ8SoY1MyoOlxOktqTpd6r9ipV+vVnbbvdQs/S/biHaOWJvDaUiFwKRZKNvFU15w7e8LMGtK9NNa8Ud+JZpFkStOEgIBHMQhYPr4kGeOddsqQBGdseHA0lbwBQjl3bpAX9j6J3ysfMts/RdSFLrUuJ0zgCb1RCVDPWDNA34oFBYBoqFQ/ATvlNvEQsxm8WLdGxrdVqXMwXXYRgUeOPjRX8dbHK0m6a1fkR8FQyrz8uQ8bIBlCq uPZfcSSV Sk9iUe8YFvWNVlYrWRz3D5qg8caT09tZnE84aOiQNBKj3UMheBspnAWAXn2a3ps7e9elGj0oeCNOKsmrlWL9PjdkFGx9IazzQGAFyoQ5KJRnPZ6+f4Qb3T4qFGbQcvlIRqw79IsVa8pH0WN1S2pVzXxgNnzvGCCDSmToQrb3sbyaRyD+JpVj+/KzOEgp7jzeU7kCsHSeE5lIY120V9jS154cuOSEt2DiW9WT5TPAWlBAtwuXkEHNvxdl35bNHh23Fk0vFiOmzsymhP4eDn2DD3Znc4jLk6agSbi30ruyvZ9nR8HrSDftijnNAn4iJGlS9o1bUfNyruVHKeO1h2DnopoePCgKDDGfCW6n6DtUnpwaA2zexm2/Dwh8Ci09lEI09FsLBawHwkpj6Jq9nO4aEa46YMHGGaUvrjSHy 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 Thu Oct 17 21:14:14 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: 13840842 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 B3A5FD3C537 for ; Thu, 17 Oct 2024 21:15:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F1226B008A; Thu, 17 Oct 2024 17:15:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A0B96B008C; Thu, 17 Oct 2024 17:15:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34B866B0093; Thu, 17 Oct 2024 17:15:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 15D2D6B008A for ; Thu, 17 Oct 2024 17:15:22 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9C043C13D8 for ; Thu, 17 Oct 2024 21:15:09 +0000 (UTC) X-FDA: 82684349412.20.3B5344A Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf15.hostedemail.com (Postfix) with ESMTP id D3834A000C for ; Thu, 17 Oct 2024 21:15:09 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b="Ch/ina8f"; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf15.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=1729199672; a=rsa-sha256; cv=none; b=ywPdyVvNqILXHF5sygu13tbNWfcVE9d5UyoAA9cWS3iu/HTWUq+Ni4VfjSoSQG6QVDs2Rb zet6jyXw16hJmCm/bWzZij3FhpVv6atuJZQWfd5TGMHe7mc1ykCf6d4RfQeZXDK3eI4M5r WETjhOwqEmaTnjBiH8uZrcX6JSWLtNE= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b="Ch/ina8f"; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf15.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=1729199671; 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=3ku7uHREd9TqwUoNgzm9qg5Yozv8tHKkG1t8H5hSVpQKEZVpX9QtmSg7/aqYReFmg5qXG3 r1+vneYkOWQ+aOAyIIMXoIKJNGCdGmiSAsFu8Ssvs9bT0tV7PFxGVQuaM6QV6TUmSgxdq6 nGVTyHHGuC77AlzsYzjmjF5KoRoD1Ps= 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=Ch/ina8fAml8InT0NVCX2DBY8h pa6eegyvu0qxYudH8yTysmj3p4gd31TtL9/xp3NxbgchJT+eo+GlC9YBVP3ABWpiH+glVwMbz65Cw xbelbkrCShVcpQluewnb3W2K1rRHvwayLGRPJCRV+41KO7Ia8Iy+SAdastYYvqgFwPcnswfaD6owN 7RgtrPBiqAdTnTaJQ/rAqvgXL3Yiy8W1Ym1HQJfsF8M3JpjFFrx6Lwd6e4WS9l/ydo7HHxqaErBbb BACW6ehubHrqCdeucIisxBtMssjQBfeHg9rNV8elevORxoa9M4yqSdFdtLyG0+11Bh7F4qP+UMK/g ZMN4WwbA==; Received: from [179.118.186.49] (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 1t1Xpj-00Bnlc-Cp; Thu, 17 Oct 2024 23:14:59 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 17 Oct 2024 18:14:14 -0300 Subject: [PATCH v7 4/9] unicode: Recreate utf8_parse_version() MIME-Version: 1.0 Message-Id: <20241017-tonyk-tmpfs-v7-4-a9c056f8391f@igalia.com> References: <20241017-tonyk-tmpfs-v7-0-a9c056f8391f@igalia.com> In-Reply-To: <20241017-tonyk-tmpfs-v7-0-a9c056f8391f@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-Queue-Id: D3834A000C X-Rspamd-Server: rspam01 X-Stat-Signature: ogk5krmpci6yaehdkhnttfz6d18dzp9e X-HE-Tag: 1729199709-760153 X-HE-Meta: U2FsdGVkX1/lCur+UZYE3b0ptdAN8b5oZ+n/3NJxvRtwNX1xIr/SMsgXdFY0UGFbQl0KkGZVfliaco9JTq4KdkgJBdbwdcn9eiXQNuW5vcufplWapsNlvEI0sda8r8aIxQRidvqj4WuKQhWJXF5u96//Oer+cUOjIQaUe5k2dHfDYIfG8XZORxl3jKWrqNnLD9i50uwar1TCVMdWr+GV/XV8VntpfG5js/yDR3qJt7hAiobzoHLX7OlU3vhBlPXlNjOrfvGNlMr9jRbxb6EioXmfI0cpgPUmsPdv71kvlXWhA90KFMV0vyeV6aY2X9tygseyZVXlzQSxRo7jNx4X6nFbpjfpF4PSgFkFWK7Vsbvypx6cEreRw7h4bcoPCpMcS+757zLGtYyXlihRDrUcvds2gVg2PtY9zHQmyoS2rU9J282eIomJS54sJiPpOYkPfPM5LgvvQg5sbchiWMG9YY1DnYwbV2j88JR+j9lsCrA6jHp0x41PLAgOxl3YKCatIbkIt4G6IGaS6K6aYC9/1luN+KHrJZVe6Ovw2hU6tJ7L2Lw4mckT/hlrKSdgim3Gs6503Fhab/gX8jL9YLbup7+YpRU31Y/uVVgOTozBt2Afg2y+28Qvb+omInfHP1VZDicNqz76/UbDVh5U9ovPB7rspSCVqtvHCQtg5ytRBLGxJ3M+RXMmXyLdscBYU+y417N1VX26U0vkrp+JL4QW6CtvFY3w0Q+sefCSXdJrS/vvjAt3ULIPuYP4CkGmfaAmzq4Njfdjjm2JJGVLS/KFzibm/pL/kQSfVkEGdMC2rL6hmFH7volMB0c+1bPQky8gznGJNHT5ZbQPhyA6hUKzt8G9eksVSSlb6aXdgZ2/Le1gpcoaYc0G/7ZttYsR3CatGoZCkOn9S+R2g9FMdSHfb738iRPCocXZDwiEolBAszO8mR/KfVjrpHiZSanxtLn27Aaaw+40MYD1ILRwZ70 qf+bbIuS Zckb5LE+a+LqYV4FYks3OMYJUIY/ge2kw+lmRd25n0cP3ySLjyTaD6Dy5NqTJgE+jsPOPz93Ocjeo7L1wsrfoXorQXkRl7zjyrCq8PIRkiZmgghQIlQeLngUAuy99l/xKJuGf5LjOS7vQMMZszMJhRzzTGTg5r8kGMg72aYoRSlKeapcYmvrInqPGooDK5HG0Wf2wZZoTVgExLohdUB+HSUl0Wz9ihLjNRo+iQyKC3lXnRX37frtkkZQQuh9BOV/XIYmBSqjww0stFsHRVl+3/7ig49kMFgZky/Ys5pAjpDJxoA+MlVvSK2UvQr+DD3RyyvvZpV9LVhqYpMjc40EvGxtYvXymklvS2NA3788sfING+5Tkl9V7/rYqMnX+2vSBsCqdNxl7mVeIvHd8ed+/JCV/3EppyVhgEZReqHrk3SBDev6eThF3Wjbo61vkd0eu3ClaMgFD+lDMo8c= 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 Thu Oct 17 21:14:15 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: 13840843 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 A0476D3C533 for ; Thu, 17 Oct 2024 21:15:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 369C36B0093; Thu, 17 Oct 2024 17:15:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 31AA56B0095; Thu, 17 Oct 2024 17:15:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1BAA26B0096; Thu, 17 Oct 2024 17:15:26 -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 F36716B0093 for ; Thu, 17 Oct 2024 17:15:25 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id EBA0E140363 for ; Thu, 17 Oct 2024 21:15:13 +0000 (UTC) X-FDA: 82684349790.19.213E03F Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf20.hostedemail.com (Postfix) with ESMTP id 948461C0012 for ; Thu, 17 Oct 2024 21:15:11 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=ZSU3viWE; 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=1729199530; 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=aKJMGqqg8ysmtiudHOn7uT8eJFcRURlMkiN4L56Qckc=; b=B1JqhLcQ+DeE9pvPEcHyMhOPhVkAuGLimBVOoqWA6kkWT6WZCA5pqE9Z6nGBytyuxOgdls 43WTw08VHXLq8pgIYUKRHe6upEkpekSfhPUrSSwXBPA5opNYaGi2q5XoCDTp3bZvHahxDs K+ERoU2QCZ/ei2mXGnJ7+KZ316DL5/E= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=ZSU3viWE; 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=1729199530; a=rsa-sha256; cv=none; b=yJb70zLlvvrM6O58CUR9EuY2wtH9t9PAZg3az06JjtjxQ0vk3YhF/McjZ2sMbT93Kr1Kzi vuxeFSdby1D/GD25z8e/yLJdbVlMmZPkm90EMMlc2s8PpIYvpg0gbhKy0b3k9pqt/LrKE0 1Qc/hVHKOCIlLiAkIU/mOK5LfGizv+8= 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=aKJMGqqg8ysmtiudHOn7uT8eJFcRURlMkiN4L56Qckc=; b=ZSU3viWEHOv4TQ3rGzE4Erk1QD W+mN+D1C2qbhbTnu60ta8qy5ip+a2dkEYa390eqEWeMNJx/vnfPeXypnY9OArnPxS7Au9NXfY5KR9 ldOBLy5YqGIUSsbKit3tgNPpXFdn+W0EccgUA4muWMNsv3hLGu53IZEq9Sp0avMykt0xq5X/S3hlk FG7E6uLKrE3hx6p5yvjOD+YSZRJm0egFSERtqS8FyqTV3fevHZC34WwdMG8VKVD51ZAbkd0FCDrvQ N9fLsK9RyfmEaaPb1EhGr9JjsBwn60cstu7Z1cjMA1T/EBDARmIwLlk8+rmeHcocA3whxP/tusFfp kTr4I4Ow==; Received: from [179.118.186.49] (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 1t1Xpn-00Bnlc-RU; Thu, 17 Oct 2024 23:15:04 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 17 Oct 2024 18:14:15 -0300 Subject: [PATCH v7 5/9] libfs: Export generic_ci_ dentry functions MIME-Version: 1.0 Message-Id: <20241017-tonyk-tmpfs-v7-5-a9c056f8391f@igalia.com> References: <20241017-tonyk-tmpfs-v7-0-a9c056f8391f@igalia.com> In-Reply-To: <20241017-tonyk-tmpfs-v7-0-a9c056f8391f@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?= X-Mailer: b4 0.14.2 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 948461C0012 X-Stat-Signature: 3c5j8q3zts1mkbp7sttrfw677etwtmk7 X-Rspam-User: X-HE-Tag: 1729199711-421594 X-HE-Meta: U2FsdGVkX18Yzg2hKINCITk/ChnURvjZiGUdhpSL37wsvap9OFI+Wkp2CuMGu3//l7ShqcX6k4p/WU3HGIOiwe7JeWWDWKpMeXk5X1gFF450EAQyKvxnnWyHdGQ/x7RV5SKsyzPyLeIJxEwOhZHJZwS0C4SlZDF7Sc5nM0p1Xhkv5NL1bG7N/tFc9Od/G1GNH/X1cxbWKNIOA5APyWtKQXh3qc74yMRN7LhSw6Ots8LnjV6NwpHiavh5hVKub+/E9pJcZfO2qORyaISeQrP95WjSbbK+7zc/UM2OaBKihCrqYgMSj2z6SdR0auPJixPORsLiICftGHGMSG9q4NPJZZjNVMnfheecn4iDVKyKsSSp/fuIt2o25qB4LSdlJEWosBEi1ymuTblXxNoA+/5Dofy35/0ZNzv9zhr/mxh/By+xYm247YXtr3kU0u8RVixsueOyS39pdF9IIfOjqlRtVVwYjMjE/+rrhCLdsP+d576dFA1X2183+9cewmUwKKfmG1z+uEjumFej/V6xXUDqLXcyFwdsyL3pdrjhzbtX9g4J4WKf1XVI8JvPCavvg230R/SJbKTspqf54vLSnc1OPnPoxNh6q+I1Y0VakQWWKgeiIJlUDx36d8zxe14GsIR4X8TAi79TG67p7ajmjv37VC+Avaajvy/9fmBaGV4Lsv30aJ2C7hCEnulOfOGHVluQOMtkvkwalGtA8jmmzb5haSYyRbiTeN3NW12pT+i1dEPiq4prbRJEeGif/vg0PksXqzUSptZRN1pwl10vJ47mFdJw7wgikVtmo1cmiJIvXyIwdbz1akpvJS/a8602VPM75Hv7Mzhk/hhSC/2d4EnSUNkz4Lq9y8hYASo/0aKLOXTwzzKIl9aAmuWP7aHvf2GalZwoqfWSJY5B0g7cmMdwOiRMR8qjOZhUxESi31tzyMX3LM9mNzYIMZjdb2fMgrNM63KVY9WYkcChhKzEW/A h7QBmDmx aGkB3FKwnkZg7slGz4kjkgJawK8UAjbkuNm9WFpq9B0q6bgS/cdnXPggyNSIk9TZjbnQII3rP4yoZ/m+B2Rz0kCJWA3RbWvfiqCXs+ggYjVE4w1vy7G4BpEfdgZK2AIWZ8KJHfhRwVinwo/PYQR65ihUBKkvfRnPh4VDzdWPH3sPIDb5OAaa0TP/aMfY3nM7E+QI3VeWT0zLbCqQ4dPUtJ9lv3jzGUL49qtjvUfq3o6+fsWMllS4Ww1KlfxWFyZpAptAAcC9dcJCkW3N1huMAEC1JlqN66t83PBxmg6ozUgnIoF61lfU7h9Njx/Mp8VrdOIPFAAgKa2D+lrOjMAVzIv7a+8TmIHEAcnbnd57aMowKYpZQCIMNub3Am1CXKK7z/mGjxf5uCtofkm+HmA5PCkh+Mhbk5NeJbmaYsmQRmlFcmQ9W9LjVK2+smpeora7tnuY9O9ioGlpisjk= 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`. Signed-off-by: André Almeida Reviewed-by: Gabriel Krisman Bertazi --- 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 Thu Oct 17 21:14: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: 13840844 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 DC4CAD3C538 for ; Thu, 17 Oct 2024 21:15:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 714646B0095; Thu, 17 Oct 2024 17:15:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C39A6B0096; Thu, 17 Oct 2024 17:15:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4CA0D6B0098; Thu, 17 Oct 2024 17:15:28 -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 1F8276B0095 for ; Thu, 17 Oct 2024 17:15:28 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0C67D8102F for ; Thu, 17 Oct 2024 21:15:18 +0000 (UTC) X-FDA: 82684350126.04.5B9CC69 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf10.hostedemail.com (Postfix) with ESMTP id 6454FC0011 for ; Thu, 17 Oct 2024 21:15:21 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=RfZ3pGR2; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf10.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=1729199607; a=rsa-sha256; cv=none; b=hzq3z7gppF1PpO/rMD0FBXLn6LYD0GTvMMAa15rC+HsNHFQWQRFEeSD7AeKgLcLSgiSNuJ h1LoUXrMA+zut7T3lTVxcCL2UQ6jjHOXSPfk/D0cbUhMfIl8UYYtGFOJzgrRdR/anefblt 584lhlLZ+k4FnycSZfTc5nrvjrWGkhs= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=RfZ3pGR2; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf10.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=1729199607; 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=9xemD8HNZy0B9hzKYpPdwz9hA2ZyaTo4FNpVrL7gd3A=; b=8ZK/FA61Tef0Tjv3fT9VJhccjichmRrYwN7GzTUf3IfcaOuEFEdUb7KCdFYlcTlelxiS5e rHnblHQefQYhMlc+nu+80pW0xn/yCw0aAuU3X0lREUWvqgBlnUgHjr4LE8TNE+8dQSoqbt UwaACtQzQxjoHOEINVdOjLSUetDUpMs= 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=9xemD8HNZy0B9hzKYpPdwz9hA2ZyaTo4FNpVrL7gd3A=; b=RfZ3pGR2yQfcTAwyqGWL+X+ahB fZAaNpJfv6HZjD97fx90GbDeHC7DJmlN8h6KXCqlOn8DmE8EaOSAF4XvKQ5YaoUhgl6StoEMOnh1S FIb/GiT+hCWM6MxJ1ZVv53kbgkRABT5X5fjc7B6vdcWZ6hq9wmFDc55R156xD9+fZXs2cnFdaLmOh a8nZME8mcqRuj8Gp1kdGuBzb7bxeXc5hVpMBKnIN0eAf/ecs3pFeWek6IKH0LRXh5kgZ8wX2pwZDJ xJdffzCYoYkuC7PWKFhs+pWVst1oLrVhieLqEktGEVVtc5ZaKUFVbSCb6gGM3nay4S6Eobk7jz6Ci oztKWfeg==; Received: from [179.118.186.49] (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 1t1Xps-00Bnlc-9o; Thu, 17 Oct 2024 23:15:08 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 17 Oct 2024 18:14:16 -0300 Subject: [PATCH v7 6/9] tmpfs: Add casefold lookup support MIME-Version: 1.0 Message-Id: <20241017-tonyk-tmpfs-v7-6-a9c056f8391f@igalia.com> References: <20241017-tonyk-tmpfs-v7-0-a9c056f8391f@igalia.com> In-Reply-To: <20241017-tonyk-tmpfs-v7-0-a9c056f8391f@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?= X-Mailer: b4 0.14.2 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 6454FC0011 X-Stat-Signature: uzme7bn1n5ipb68dyga5utzeu6nj6nzw X-Rspam-User: X-HE-Tag: 1729199721-772471 X-HE-Meta: U2FsdGVkX1/R8BtpfCnetcS2A5lNhXMVAHz0WinOkIJ7O6fxiSLAlCTa94+rX14/cEiCychB6D27tMIKdcb4xCej95+ggslLqADrhkAGBlGM77kfT9qhFLhSwAubPrFaJwNO0H1y4kRfZB5vHMd2ptL+d1/zB9Sd4NcYC/8iLRzKqtgu9gubpKfug2FpZfJ4agF4OXq8UhY1TaDFYBT6F5O9xumkGWL2FKr89cHXE+gg22MDXNAzzWkhfKPrfgGttrRnRzgF3fZXVZE3Eq18RIF4AuGIMtcLmtuPHyhiczIh7D/Kq9u5CfsJIYz/ushFbaiHxLCCH1GgYQCyX+oU5YiQpjNz++uk6zsRx6NpM6mLbmMown5lPWPMybUEXoIjYtUJHpTg16lvrZ0Z8sUbvyCoksrQ4w7PLmvfVDK/pCd4oYvybilGiwMLoZIip3fX6+H+IJjt+7C+b+XMJ1q5qA3ogBaFgBoxIhYO1vLarOttnuOw/4ayd+uYqBG6V5jZ/J7IsN+V/A3bW9EfxcDSylmPlkRatxXGqrV1iXG6IDNnqnY16H4k/gTs1ZuIvCTFZCwuR6VjUgQAAwLMD+wORsx8fv89Z0U+WCbMrG2EdkA3gfIvyrQG8IWcm1Sxx1c95J5gnyXAF1FhdkwQkQYiHLQydh9iptD4jAwsf0UT1KqSDrQF2QH7//+xcba9apwFW7L/vnFGEFAh5ZpqUYt6DgUver8l7IoBUz1XUjHLPA4ilmub1YAGPrngULVa1Xf9Lr5yWIG+pGphJReRjRpqRGYQLiwJLaEBKE1PYNnQx0uV1kRbaPYp/aAyj9XqhdNMSV10Hya0xkU/NC8K3kyOyz0EW02dett5UtW0me5dGrLvE+wgO+1rqY9IRuaU2VOTFFJClusWwyw886HwmPAWwj+6ZEWXFEL67tYHRGCa0oovRN+rN0szelqZ5MkYHkLzwl7zujLuKeBxbQn7eTm RLeGgjK8 eFfKYIWRBE9wqNescOCHF6Z6ohB2wySIdJxorE3uk0vXr3zBRX/poq9mggNg9ePar4htj1JESmJoA+2iSu4DRfwqxsBIvI4fuY3EO9asH8uJPSzxr8HhhqSyjDE13MptWoolYe67rbVvMrRAqW0SWmg95GyNdH6DsB7jIUTqQCznE8JXvKxgQY0fD58c4HmpqVWZIDjmCDKYxb5JG6eU7EHuPi/hw+BRwAmGyyttYCl4MvYmuHEo2w9susoj3Hu/szWyCpSr7c1r4BNbHpwQNRLypKGGTlrO+Id2jDxX1b0KCdNPpcJzXXOfpcbN9AY9E8ayTrbQgV+aZq2lC/1YwZd4xnQ== 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. Signed-off-by: André Almeida Reviewed-by: Gabriel Krisman Bertazi --- Changes from v7: - 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 | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 119 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 4f11b55063631976af81e4221c7366b768db6690..ea4eff41eef35c9c253092f39402db142baa741b 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,8 @@ struct shmem_options { bool noswap; unsigned short quota_types; struct shmem_quota_limits qlimits; + struct unicode_map *encoding; + bool strict_encoding; #define SHMEM_SEEN_BLOCKS 1 #define SHMEM_SEEN_INODES 2 #define SHMEM_SEEN_HUGE 4 @@ -3570,6 +3573,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); @@ -3589,7 +3595,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; @@ -3680,7 +3691,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; } @@ -3700,6 +3714,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; } @@ -3844,7 +3866,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; @@ -4197,6 +4222,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[] = { @@ -4228,9 +4256,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; @@ -4389,6 +4462,13 @@ 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: + ctx->strict_encoding = true; + break; } return 0; @@ -4618,6 +4698,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 @@ -4628,6 +4713,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; @@ -4662,9 +4755,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 (!ctx->encoding && ctx->strict_encoding) { + pr_err("tmpfs: strict_encoding option without encoding is forbidden\n"); + error = -EINVAL; + goto failed; + } + +#if IS_ENABLED(CONFIG_UNICODE) + 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; @@ -4938,6 +5047,8 @@ int shmem_init_fs_context(struct fs_context *fc) ctx->uid = current_fsuid(); ctx->gid = current_fsgid(); + ctx->encoding = NULL; + fc->fs_private = ctx; fc->ops = &shmem_fs_context_ops; return 0; From patchwork Thu Oct 17 21:14: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: 13840845 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 C4EB0D3C533 for ; Thu, 17 Oct 2024 21:15:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 565C16B0096; Thu, 17 Oct 2024 17:15:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 515CC6B0098; Thu, 17 Oct 2024 17:15:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 407736B0099; Thu, 17 Oct 2024 17:15:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 232EC6B0096 for ; Thu, 17 Oct 2024 17:15:33 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 8C7A012020D for ; Thu, 17 Oct 2024 21:15:22 +0000 (UTC) X-FDA: 82684350084.19.4F2B7AE Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf07.hostedemail.com (Postfix) with ESMTP id BE3A04000F for ; Thu, 17 Oct 2024 21:15:16 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=BfrFPtrw; 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=1729199585; 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=M158mrqvZp15Xip+FLGziOKd3tlqyv88nTB1oO59vBU=; b=VfeirAcwjXWMvTA3fj++wfVrHVUlhc9yKzyRwCmclqzkvQ9LqudBnaDfOqULZlivJ8gcQo HQ270UfiJcDs3Y/6gGomOSycXzg6OWXqi3yA5F11rj72ps39X14W5NIpLCL4EZwV+gvBlC n+9GiYcjNvDfX/yyQo6gWTP39uphrWo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729199585; a=rsa-sha256; cv=none; b=k7U/VE7jCNoVt3xTaFa1EbQBA04SwUXK0i/p9nesqPI01wV4Myi4bKMANsZ5PAWfpBqpcS rjvnjWp9NI6zMwvwwgmUCQ+uvaL55UtPTQdVhGUBq7YDeoMMCiDjFT2UIIcwrPEH9P84Zf fkZwjlAfsn6PZ4+TgfGY7mOPSSjBs3o= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=BfrFPtrw; 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 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=M158mrqvZp15Xip+FLGziOKd3tlqyv88nTB1oO59vBU=; b=BfrFPtrwxjB770vB6zSbk1PvnG CDFXS29qrDRxS9xlGnJvlhvrot8qlyg0iP/aue7DHub8FiNDvpgcimp4hLK5791W5ZZmRGspsaVzD uyNH6MhLBgoIKsQiBmkYmZQe+mmAl9n/Mrum2C5eJ/FlGIi+NrNRKS7uBamTnBz+i5OHv1o9Fmdhj JqOOSTHth4/Ct2U+y9lelQ1wQ8iTrtJTZ2zZk4xjSKwKiz71G5+pzvWJqc/bzWcnjw9lW9rqVrBlA WNjxYIYAloE140Ctu62PmHHFy7m9JoS3JEsGYEO+QAaTN8E5xFpdZQPzvo1bTd34BDg3a3i5SwaVS 0pUwz23w==; Received: from [179.118.186.49] (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 1t1Xpw-00Bnlc-Vh; Thu, 17 Oct 2024 23:15:13 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 17 Oct 2024 18:14:17 -0300 Subject: [PATCH v7 7/9] tmpfs: Add flag FS_CASEFOLD_FL support for tmpfs dirs MIME-Version: 1.0 Message-Id: <20241017-tonyk-tmpfs-v7-7-a9c056f8391f@igalia.com> References: <20241017-tonyk-tmpfs-v7-0-a9c056f8391f@igalia.com> In-Reply-To: <20241017-tonyk-tmpfs-v7-0-a9c056f8391f@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-Stat-Signature: d1m58k1xq7ufg77krppt48cx5fn45aty X-Rspamd-Queue-Id: BE3A04000F X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1729199716-207370 X-HE-Meta: U2FsdGVkX18MQ1bou0Bvukww+rNcuxOgBgsPCsGgV+YGeDYrPniZAwPQRrggTzO8oLO77ovtrJya2fpafG1RBrNa0xY7xnoQn/VqZFNNN1+6yg0HDVPM8ojCNJCvST7oruk1STByfcePeVrVzneVirNg0X/YpqrE/y1DH+XXuExsoWhEmDGLVwOjGgiRe85ls2zpF0GMKTCVruPuIBG8Y40vC5lY7CgNcbzZgesOb+L/Zq6yrqpZI7FE6lLMOIW7aNXybWGfxxHYHMW/WvHQ9ZGm6dK8A08kgXbV+sTSw8q7uGQt+4YCixoI9BC6uFh/1rAeJWrdRCISdvHfHoOsAzpXandiqA7bqzgPRB+5WvrmkRkae1juAZc+XU0sp2/MTb9zMQsAgm+jhepQnDaUWmEuQp14PSR8qh6Q6Cqmqu76PyStXmi2ZUyTtQaGZ+bQQxT1OMCu2i1Is251vHnFUbWNUlIMd3H7YCJKpZKO7FD2SiJfFyn9jn3XMziLYkcg4uszpSu6IjTIs9GNRfLghZrO57PhMfBdK2+Q94qZGQ0MMblhJOzxOAKKP7v1QfPFfixQ0/yBGK9DaDgsdUi9+XhIeiGBw8odv2o2b98Qfy5D73VmlNL6ptKRyJehXSjwxwY7PM586+X/LmOE9U1loV1tQGiz7O+9A+MKG157yLxp3T3yafK0alk8B1u8usCajkm5oVFCaVeRJthzHdWQcVoF+IUiaiKj19IOwcA+TqOc0UKt4kvhnt1c/SPsTesyr5vGpt+l4Pg/TeDz2DNZVUo2sg6JhZ+KTDYbE8U/oXOJOY23Ah7h2Gd7hBFepQgYUb/MNiQjg1K4tWaKIFv3BdOOIEGHAbpFgnBY9v4QeN1ILOMkSNYBsxribHxMGYuakwFH1SpdiLDe2ro8AcalQgvAQMTD7sbL0IAGdGVxRb8yB2Wz3YSEJ0XSBB6a6Tn1If4yBcreBkYB+2wjwMQ /g3sTyjl ANQB3Q2DVA2HZzYTSu/jiFAhij6P10iO/x4CJgJq1+qMdVzkHXSgTdppZb+B0N/Nw1b8d+4rJQ+CL2/c7J8uMzvGZlTBZF9CPCxiE3nYHP1FdPvMz55UI+0w1glf+6XZ95EdYOW6eRoJ0TyvFG+IJaks6JvZo8V6ltSZvGEzggBmftk9iBb+7POR09qBcNZsCYlW04hcsKtpmfLZARoWZ6W1YsYVcFuxd2XLqcqECBfnUIP8nfFlcmEEdFhVJ8B498WSRVNZbRh4nbxLuLlZ97CWPLqgHtpA37sRYU44XQG+fXz1fC5plgOQd/uhzL4vkmW46VbzYdk4ejX9+zu1DUvX3l/D8tccNp95vcVeHXedp71Eifzfk4hU0Ex4xVO6yTIUE9+kDytQjTMXm4aDuXFPpbjySvHphVjPOhkIZJbMFkNVUqiWJpx8mh/uqOUxHgyWPdkbUsielXfE= 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. Signed-off-by: André Almeida Reviewed-by: Gabriel Krisman Bertazi Reviewed-by: Gabriel Krisman Bertazi --- 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 ea4eff41eef35c9c253092f39402db142baa741b..8d206e492e7d51dad4bfe1b36426e0064b612dad 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2760,13 +2760,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; @@ -2777,10 +2826,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 @@ -2827,7 +2878,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); @@ -3934,16 +3985,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 Thu Oct 17 21:14: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: 13840846 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 DACB1D3C533 for ; Thu, 17 Oct 2024 21:15:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 714126B0098; Thu, 17 Oct 2024 17:15:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6EAB26B0099; Thu, 17 Oct 2024 17:15:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D96A6B009A; Thu, 17 Oct 2024 17:15:40 -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 41CBE6B0098 for ; Thu, 17 Oct 2024 17:15:40 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 432BA4038E for ; Thu, 17 Oct 2024 21:15:33 +0000 (UTC) X-FDA: 82684350546.24.3C3638A Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf28.hostedemail.com (Postfix) with ESMTP id 3A053C0024 for ; Thu, 17 Oct 2024 21:15:27 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=rFGh7F72; 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=1729199592; 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=3hvCbxaGpjuy/8mKuNk4raktjM7ym+WOJ0WuAMToJIY=; b=W/xlkFuu7iVn9r5TfOWoNoliIipuDAJMQmvfXqnefj0v3M2XL3rk2Xu2F3Q32qTdM/40mb RvaXoLg+NzFZXSFfKOP/vLI7K1Zsj4SoP+7JU9cwq4uqXkVmrRmXkJUA5SCDDobHsQXaJ8 rK03gz2TJORSu+pck3VVFusJc3ZGMfo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729199592; a=rsa-sha256; cv=none; b=4vMQ//hGcDGIx03iGfUBgPmJbLKiqizfZPg1u7uA43FiV0O5W6SOgnr15ZkE6UmjE/xCCy lsrfSsnMOvfNd+Ijuq6F8BTtXnu5g4AIWCCn1c9YmUh2wSWerlJZf5W6iHtM5//z7NZWx0 3IJ0jfh7sLtZ+w99xkWkeF/dvbtXnjk= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=rFGh7F72; 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: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=3hvCbxaGpjuy/8mKuNk4raktjM7ym+WOJ0WuAMToJIY=; b=rFGh7F72T1e2LF40VcDyS01cCo eV4JHySyjs8V6HuP9VsfgfvKDZh3qkUFZtoMb7CkheRjh7q6UNDjgaMG82BDMfsNIjW5mp8p7BkEh 0CCS2GT21AB9IQeU8qQfXuwCbR0gvwD2WFJbxDRYY7EMuaJBMb/TuIsYRRhXjNdVDtGa9K+g14j5+ xrzMm39McihVEhZ5FMOkh0iCo+cXaPKL830+q4wp8C7UOf3GM5iq8RQiWVXSfgSTAZ6Co/ZZNKqu9 gyHyH9ffFmul0YrTYklSBjL4CSzCkZYAHpKqpunTPyHDiVxxcmCprzkfYTm1zoo9ysubJzfMnx2ko 622Hqlsw==; Received: from [179.118.186.49] (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 1t1Xq1-00Bnlc-L9; Thu, 17 Oct 2024 23:15:17 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 17 Oct 2024 18:14:18 -0300 Subject: [PATCH v7 8/9] tmpfs: Expose filesystem features via sysfs MIME-Version: 1.0 Message-Id: <20241017-tonyk-tmpfs-v7-8-a9c056f8391f@igalia.com> References: <20241017-tonyk-tmpfs-v7-0-a9c056f8391f@igalia.com> In-Reply-To: <20241017-tonyk-tmpfs-v7-0-a9c056f8391f@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-Stat-Signature: 4jzoo7mkdx8gamojzdyj7dg7g9ymjwpx X-Rspamd-Queue-Id: 3A053C0024 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1729199727-980323 X-HE-Meta: U2FsdGVkX18L4OlZZa6snglbMnY9PsWTbGT8ACXrmnZuo9NjLHLqTaJasOXeyEfNnIoOXA1L4AeL22qad0+U4VJifmlgnIYHFoO0nnpoa20F9qUNijZ41f89kbSWXpgwGw/iLsItc/j9wuDMxo6K2FvE/OH1eYWmFOSSmy+sq9GBU9+VZherA8K4kFlVB8061ld17JjDOi/Jj7KUgKS0V/VO3dckLjFQjdKDgG6dyoOWAxdWIDZYI3w5dAeTT35amM91ZsaFOs5XJf2ghbH+VzfL1tj6812liaiPPHZERlevbgvZA/jMPexjCOWMEHw/oD1WpAvg53Th8P7nvU1hUYZXIzz65ghq9w+mAdfd+TM7E5FiSfNU8w0gKb4+z/qtzrjawSVjX0rytx+rvCN+U0XGeKuGogFkiwn1r4+vYLmaN61zbUTRt08gjY6uwDgGDwO5AJxIGirXfUb5hKcWogQJvwk4peCTt0lbr6H8PdxItFEwmAeZiHypbv/edTZqu9c1cW4vlR+mG1ULaTC8yx0Vjcg2+8XaoVbGVQhACxJyCLcX20Svi2IVUJ8H809iVELYiscOu6KR8bDsQUZY8Au8FIngjF7YHOkrsJGp/TQXuYLyDPSdrNhduqJWcqkTF4q1/UiXwJqHGTQkG9fp20mvuhFSgrmrioUviwlv8tfy5dYWxnSWkoaMw5IxTbGe8AP7Jtf+ulJqxoncDGD92J0SU5dsshfwTnK4XrJFqzjU58CMCm3m5HLV3cVUkoYv+tMQDwIniDuUBK8OuQ3WjJeX6DDQARfS8gbV6LeUmBIPGvUhGX+itYPuomNKDgSysCb0lyKnBoW30cKoaCHLhFs9CndyXRhYsx9lX047McdXX8Md+eVJq3piQ1+/ViEKntT6N1HWxHLlwOyyTyKc3aNEzPlDQFacLnBxlOteEpc3Ak2YQfqBlW0WhHBAyPsgGmJuO7JxDA3ddm0y4Tu +IWoq4YC oq+w4c37dTLtHfQhQ2+6rVBF2w0uUfA/xleh4Hf9RuoRg6P8OstvPq6F0NHEMtxG2tz/L7wGoFxSV7+Ki+VVXtGJQp8VELYyxJXVh2kVMCoIUtzBZFm0JkFCNNF2A+h9dq8umsVesRvZC+Agy6q4HH5TFk3Ir6vS+P2K3Nnmvk00iuQFD3o5h5Q+ODHyQcJz9znlDSF14bXOmdKALfSBDYzz7ZRCqzi3OK+8lUYph0zYa6csVBdNzfZmra7tkK6zUH8b5Lcz6qHRtfYzR1sHMyVi3HHHbxuq+Y1iCLhfGMVik+ve+OaqUl6OLXMqAjI1Mon9RRLNFCsw+uizK6FNSnIQiVxkmWtRp89y3O0Ia2lwjFYUxqIMAYNZ0UVhEqEGoj5ycW+V6WRGOXbqaF4l0hcF5iK/spxHFC0M+ 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 8d206e492e7d51dad4bfe1b36426e0064b612dad..7bd7ca5777af70c5a226daa20970781c638e34ef 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -5543,3 +5543,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 Thu Oct 17 21:14: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: 13840847 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 416AED3C537 for ; Thu, 17 Oct 2024 21:15:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CDFF76B0099; Thu, 17 Oct 2024 17:15:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C903A6B009A; Thu, 17 Oct 2024 17:15:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B57316B009C; Thu, 17 Oct 2024 17:15:44 -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 91FD06B0099 for ; Thu, 17 Oct 2024 17:15:44 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 66AE0A1652 for ; Thu, 17 Oct 2024 21:15:23 +0000 (UTC) X-FDA: 82684350714.10.1DD15F9 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf29.hostedemail.com (Postfix) with ESMTP id C99BB120004 for ; Thu, 17 Oct 2024 21:15:28 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=A+F90mfJ; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf29.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=1729199694; a=rsa-sha256; cv=none; b=Gb7tuaPratbgl36qcT/hnJkYqpDVNjPhmJAfpz3RpZLc1jrtT7FAZs5fdg/o/jMzA6xirJ oprRBtQdz8dT95SeKMtpDWF0M2NnkH0Prg7oUHbxqv2vciH4SHjdA7VdiPhJU5EdjP0tT0 0Oe+D+M/7TgBvhPlMt/a1oXcSyC+Eps= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=A+F90mfJ; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf29.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=1729199694; 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=MO38/TKDXEZfYM/HH5HvDp3/o+h1cffvB2kBOci8370=; b=TlULCguqNz01sowdjVIkSeoyCiVW7jqKg7N/q8fO2wjMiGcTAJiuePOuHZNFXVeoBSreDV a0+L8dofkp7ES7f9yDluMKNE3PcV0CBHk2Upn/fGntLkkDSCnqXjKvksVxNkCsiGj9K5X9 F4vm3CwC2yPCvT8XptjFQ4acnMNRjiQ= 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=MO38/TKDXEZfYM/HH5HvDp3/o+h1cffvB2kBOci8370=; b=A+F90mfJn2DhR3fQwiK4jTFAF/ FhERPkrg6outZi2Sj16a9rxBBdca2QwgpSjNqnlcmcbPyoV08juBTQiQM2dRM7OajJnH3xBa/VKKE TFwClC01rw7yGaQ394Qnm+9pdwuoceVeVitXMWHQ8Pzp6WhIdCuI4hObaPaQSDPEfBIaVqJLydvwo qOAIbOFHrVOZTvRIlKgQOalrosv5fjPvR5tKFwpiQF/oPGnw4Ppwc5oxm3tCrtZesvyEIcvuHI++j epMZ8mq7SgEr9V2sodvnqsvYWBoJmjcDoegF5mu0Bu31PPraIFhLs+OS2eK5QlvCpQ75995oDZkKI TjtlSmSQ==; Received: from [179.118.186.49] (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 1t1Xq6-00Bnlc-Ae; Thu, 17 Oct 2024 23:15:22 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 17 Oct 2024 18:14:19 -0300 Subject: [PATCH v7 9/9] docs: tmpfs: Add casefold options MIME-Version: 1.0 Message-Id: <20241017-tonyk-tmpfs-v7-9-a9c056f8391f@igalia.com> References: <20241017-tonyk-tmpfs-v7-0-a9c056f8391f@igalia.com> In-Reply-To: <20241017-tonyk-tmpfs-v7-0-a9c056f8391f@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-Queue-Id: C99BB120004 X-Rspamd-Server: rspam01 X-Stat-Signature: tcimph5hfzu3qog4phhn3fst3zqoxroq X-HE-Tag: 1729199728-971045 X-HE-Meta: U2FsdGVkX18jnbZTtAl2AJvFwS4t5Al/PPrjLjYpL/pHtWGgdxfTncLACJhq/LzIv1Lc2A2aTYTjOJSvO90U/sXTVUQ1zo2PONb+nexCDQRuxPTGfW536bSx4CvqzugfSB5dPKh2NBDRI9UG3XFK9KQyZx/U0/8jBKOlGWtC0IXMfX3BZRoefHYjOCBvlgdGn1ynym83i1nvLzEj5OGj6dO9bSHL3Y+UkY6PNuBJuzjanmFhzrprtZmRl5gXQ5escj5ZBBrpFXtZCFvW/d/0FJS3wGWemRfiGWHANPdVYQiQVNWpZatDLdgzncGyCC+p6jqzNVKrO1fWZaaibSdmOp9Ogz06eItxyQzG6bA7ADAGcJCycKUoLax4LJdN5xZSCkS7fhYbf7l1aJ50VtW5U2QF/Clt0st9trnKyldEA5K0tSIP/bjG5ZCwSoIcVhgLEvWG+dC2xzaG8sQoII68M81vyBcKIvyHquWVMm0LUSwr87zizDWmeWAKu2D91/17dkj0mJNZx6Nqmd3bDmmMRagSSDLw2BQJXRNc6BRbRiFWwelsA6PVCPCskn8M4nOdtCsinSXqrDXmuXmRu7A4PnGGPk5Eh0h5QIWkwcubhCb5kNhb14gRh+ZbuaqeUVEtfpEFxaD/YIMDYChCTDGuuCDrOM5rdUsOchy4Mxhbt7/V+G4+0KrBmRV3Grjdk/i3+Sh53PYr+7V9YON2O4GPCrh9tTK57mzfYgJRXRuP/DsjkWT65s+/p/E83LrBK3SDpcF/tA2UXRKfZjJT9lF23vLkcSLjEPBMC9IaCPYsaM41PAxLjta8z00F0mayAwwEUXdxp9XM6bpxheH6akXRC0J62VMOO/gqiT3PoDy2LJvXOZXnCImhCLqt4ggGstiqks7/vepDlmI0QAuxv97nh/foeWDx3GbBhv7fzFZnmkjiDhYA5vdm1gTpPJg4ycacNWsHoZmoLyQ21xlrZ6S jZEhGn8I FVH4qI+5l60N2vQQoXtO6Av/hjVrksex8gekExHl42t4Uif3icVD2gUoq4P+7A6CvgpSLdQRTlU/uwrB3uL2stRqgDng6/kJsAXIHnHiMQjwkhJZH1TXZaY+GAJYSDCMaBu1AOabqJh7rfC15x/1xvg0pSvo+kQK/fKjfMUwQoRcxbyIH5zxcDoAtAY3s+ttMTYOSH4kVqP1OQ6ZgADG8YC873Wui5AHoaOaaZ2oenJVHRc/IUSS/I7yGEe3Pk1/wlHXYiiAqqV2OdTIGHLFQ79efnOhDTmqPdStME1bCsv3q00J8lNhnwRkwCIEP87qg1FWOk6bxzj552DlbESk9QIZU1fMq4koC0RQI2cnszDbntKkm/q7oNOthBBN9pEbH8crfz7SQvTyZrfugffnZ4Qfy9zry+bDdn9jnP88pZpfCQzRKUiMoN8Loog== 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. Signed-off-by: André Almeida Reviewed-by: Gabriel Krisman Bertazi Reviewed-by: Randy Dunlap --- 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..0385310f225808f55483413f2c69d3b6dc1b9913 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 +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