From patchwork Wed Oct 2 23:44:35 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: 13820554 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 C2FCBCF8548 for ; Wed, 2 Oct 2024 23:45:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 41FEF6B00CE; Wed, 2 Oct 2024 19:45:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CF926B0125; Wed, 2 Oct 2024 19:45:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2707D6B00E6; Wed, 2 Oct 2024 19:45:16 -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 EE0DD6B04E8 for ; Wed, 2 Oct 2024 19:45:15 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 94A7B1A099D for ; Wed, 2 Oct 2024 23:45:15 +0000 (UTC) X-FDA: 82630295790.16.801D542 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf07.hostedemail.com (Postfix) with ESMTP id B71754000B for ; Wed, 2 Oct 2024 23:45:12 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=aFc7Mb1H; 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=1727912648; 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=Y8QDzI/AINMwYgFuy4R/IREoIrpywxbZXblB5AdDFcw=; b=kSMYcUKvbs6j9ca4uXQIrChB7qz6WnQTsjh5SPtfO7YGBnYTUIlYBkdNwdpre/A0e01+30 hj6OQJtHYZocd7tgQBC/uo2MEpVF8lfnJEpQ58yk82twGArUQd8sRrCPxIdoFFFSV7xORO 4drYZus9DPyq0+W3ymQj3DkGVUFCcSY= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=aFc7Mb1H; 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=1727912648; a=rsa-sha256; cv=none; b=zi7ZUTq9Xc2di5cCG3i7VxwZtCGVRFJSc6oWCMDVcsXM7h3ocOFPuJeXoNXiojMBiwH5SJ vOlwpQfW+id744rZd/OjospTrt9qrckN5Q5SXBOwNBCV1s7/8QcUAuc38VCGoClYSW0mr2 SaVCl0zqv2VcH0NvdD1BTPaVaQmUbfs= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Y8QDzI/AINMwYgFuy4R/IREoIrpywxbZXblB5AdDFcw=; b=aFc7Mb1HSQlbH0FXXlc1YsbKdF OZD65SM+Mo9xLxyEBrZUjzuHCCkRsZcBFJYLdQlKwdRX6nWq0w6esff57g7fqherOH8YuTk/Ost1I MI5DF3mAGvO4fodymwddk7xTPROZmALyoPPx4GX8GMtxBfNe6NQnqxLTUICHA3fuLjd14/LosDiAH an2uWrZtQFDjpoR+7iy4UR4FQ+0BmINEzIOpELXgGGsF8Pb1kAG/2mPbfUeYlwphCN9FwOpNZp2SY g8rT81v0k5CwfMJtLdPaFf6qxEgZIn5jEowDq9ZdmiMlRlCg4j+hhgQHvYsQ/JS8K174GH9+q36lD n7m+wA/w==; Received: from [187.57.199.212] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1sw91j-0045tc-71; Thu, 03 Oct 2024 01:45:03 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= , Gabriel Krisman Bertazi Subject: [PATCH v5 01/10] libfs: Create the helper function generic_ci_validate_strict_name() Date: Wed, 2 Oct 2024 20:44:35 -0300 Message-ID: <20241002234444.398367-2-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241002234444.398367-1-andrealmeid@igalia.com> References: <20241002234444.398367-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: B71754000B X-Stat-Signature: enddannuuj4oppfonp8iy9g7b1cyud8f X-HE-Tag: 1727912712-285292 X-HE-Meta: U2FsdGVkX1/1HhTTTUGyczUtgpZl4hiblMA0u3zoNPTy12fcniQeLX8XqNOs6V+dP6sAebkSzzZwmSpZBiEurHzgDqt3q8HmXLu4tV0DhcdBnIfwyWjczDx+nxwF5raUkToGulv64H2x77g+vQhVfMgTKS+xfDPSZGxUmpvRWPtZ8yfLbCXQvKbTYJow7RFCG0LFUhYCGx6G6eSMCmjUPsPWWSAQ8DCDD9Pws7E/2IZ7hCK5I2j/MzhUi7FrJo8+O2f/zVWPZZvIdFwIa9sniqnsX0d9cdhqJjxXp9vrFpwbbJUKwV2BqVTdnKTXPeLmoh8TSQjPb9GATk6pb3Vy/8LqP5CwdAWc90TdsZ7Yg4/3BEch7omhkLe/ROwp4lQCP7AaBJHyx1/1VhVJ9PKQnSAJqxVGeTdQF8sTgWHqXlJwO6lGPGQ99S2eiH1zTuJQaDY1v2EChxjWxJPH+21bMTFsMH2DVTgSiPHVuiHGvVZwPeBC7lJpHh8EuUkHlZjxNBoNjka7++MTfGdEwhOMOtyzqVdQLGc6IJFgAZHJAH0M/P3O0YJusdOR1gU8naO3DXyfPN8n6eNwBYT/HZT6tTWtqNX+VCQIF7Poej0SQLveAk1QYNNGaFmHZENfH4EhwsFMCWQckBSEvfF+31o66m+Bdad5eSEwQ+euoRRcftsJnAxUtIcCemMFkMZ2siaxPmYLX8jF3h5kDO+Vbp+A2KVlOuPxOzMUxkDJZxwwR+WDdg+qv0ZNQ7Pwsc2ppCSs/BsWN2V2oSE9hyUv1a0TbxbcmHX/grvbm+PrzTHXMw4z8qb6oyoMJJHo3yNGQ1M7WpHxAtzkPoiO6p3E+WFGJcEHzLBpG+d5XPzo1c3jqQCghwa+kR6zAlbaT7E1WWLvWQeaDlMch/uDU4mDE2VgZbS3B4cV8JAa3m2+OhisbR2Smaa0K1aO2WNkZcTxHUbX4TbbYdGey2d+CIcNm/j tgf4E65O e+R5zLmEuHzIn57wNFH/S6bkvPzbbT01b6MtUrW7oAy89O8wHcsoXMUq34vc9a1c6V17IS5i3xIVYQ46VkseHQhRk/sa6D7AsxuZFfv67SIbnlHUpg36VOsoRagvgLY8CBoJrEj+WneT33fdHAHGbC4fP+896U0SIc0g/QkaDeCIM2ByBxgVgf9fLszgBZZIrn9bWCXS4aLEuSZ7pB4BWrsGDZh9eOgeRbtbCaQCDKXkXeIyKwIUzMy/ttGWxL+8RRz1qqlf4ZN2x9Kqtn24CsmDO9nBM+koNAOZwj+MnuEzGSJV4/aKzD4DCfJ2DtBlLhnTf9Q3sPTIERlEwzJef3z8Tuq+Hldtbpom4raojPPUfAlRY8NGiSfwLO4GhgTKLCSSSPIBmDjsks8pEO2bXyljf8y/3aAgnwn6e 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 --- 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 e3c603d01337..9a5d38fc3b67 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -3451,6 +3452,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 Wed Oct 2 23:44:36 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: 13820555 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 098A8CF8548 for ; Wed, 2 Oct 2024 23:45:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A5956B0478; Wed, 2 Oct 2024 19:45:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 927496B0479; Wed, 2 Oct 2024 19:45:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 753086B0477; Wed, 2 Oct 2024 19:45:18 -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 3EC836B0473 for ; Wed, 2 Oct 2024 19:45:18 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id C2C82C04A5 for ; Wed, 2 Oct 2024 23:45:17 +0000 (UTC) X-FDA: 82630295874.04.FBBE41E Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf18.hostedemail.com (Postfix) with ESMTP id 1466F1C0009 for ; Wed, 2 Oct 2024 23:45:15 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b="R/1/uZzI"; spf=pass (imf18.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=1727912676; 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=KXLeYwW1OCCqt0oK34O4XtdDejRlj8zSL51Jo9mqNzY=; b=IgZoCWX6WRn+P44wc6BXneMuvLQg4x9iZf/CtUhglZFth+FxVc/IJaWKWDiZjHMm8yaos+ J0kiMT1VvUjP866z3zYVBSha36LEHW2kj264IRsER7LGnqxlRmm84dAFTEuTSATEn1b4+s Sy+2ymHOF+Tp6VNNeqpPp5rNkBf1iV4= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b="R/1/uZzI"; spf=pass (imf18.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=1727912676; a=rsa-sha256; cv=none; b=xPbFP5ZLx7k34StOz6bNzr61Egrw5I3zb6OZYo2qCc4TGVlrQ3B8bxkB6oHsW02OeLrmY4 NUgQome8YDFGuKxoBE6ulP5Jg2zl//Seqf0ZiRTL+XNudVAqZnR+VZsY8lTnZC92F5C2bQ 7vp3btv9LKQYBnP2Wtxa3Yivx20jrAo= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=KXLeYwW1OCCqt0oK34O4XtdDejRlj8zSL51Jo9mqNzY=; b=R/1/uZzI/kIq1MfL9Fyep64GAN DThJRyI7liLrxMsvDeAcg6HQv1z1Ydktk7c41UBYpBb6SSjONTsurzcfgayHZg7l7w6+BjRbv/xAB DP9pG7AKa2oReMvwGx3Ae/uX5AKWeV05+AoQUggMbeWFPoDkmlcVfWpYsFaMa3OwMQjNTvfCwzdOE 6tsFAE3ox7EsCugi/yvjLSJJ61mXHnko8SZzbTqWkIZ0CedMr0cb++XzjBjmNJpsZKc+zHVEKrJwr qyPVsw23JHhXUalI88GbHqQ7nkbaKLJMo8FDotp3h3zqxex+/7qTO7s0gmVWqRuJUFpMaIuwnKqgj G864n8bA==; Received: from [187.57.199.212] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1sw91n-0045tc-JV; Thu, 03 Oct 2024 01:45:08 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= , Gabriel Krisman Bertazi Subject: [PATCH v5 02/10] ext4: Use generic_ci_validate_strict_name helper Date: Wed, 2 Oct 2024 20:44:36 -0300 Message-ID: <20241002234444.398367-3-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241002234444.398367-1-andrealmeid@igalia.com> References: <20241002234444.398367-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 868qi1e39xr9q5orywqejpudtr8ypyjr X-Rspamd-Queue-Id: 1466F1C0009 X-Rspamd-Server: rspam11 X-HE-Tag: 1727912715-473347 X-HE-Meta: U2FsdGVkX18qhnIEi+k36/SgD46oMyS+U5D1MgZCar6Rfa1yhp9ukLAvQMGEhJuFtz8hm1hZIqF3tiKg+5n2CxsW1pMhObkxPZw0AxSqCO+8ydh0bUnRlTNSBhOIPLbDO0TuiovUI/wL+pUbmhU0vjabHc8daBZ4HspBQxMM+ZM9MiOllEggcCyMmFUXurM8LAkanyiRQ1AWlRlLwXvtokbDi/ItiRkhe2lX5VUwjR+jI4dE0cYXsZVPDsEpjk9BSly07eJn2eg8b6z+VI1xd5897r7TwrwQmNSZNSVAukyz8dUoZTMJZxQBqqkExnEsO9k+DZk+ZFHa1yuwYX959RhnKiWC+XwVeN2H8d7kJ0lMu599a+MlALOOrwZEMGa7AKf3LH8Lc9FyAiS99jRYR3OpyNEsujZQAx8o881lj+I8YRkxqnwuC6b4t+707KFL7yO1GCniyhMeIo/4brBZTpvoPA2uWg++2BI5TX1X/JWtZqGxkzxjQ4wa6D7kHE6OEplzZgcs57F5kW8vu239/RSlpYIukg/iJiJJ6ySa0OBs5H4PXVXzmd1UXG6Yr35ZhYsO+uhtlQ2AQKeVNSsuJNkIKk+AkgdlQPhWCUZCUxAqREdvvmcc+u9FGxsloxZb6aaNfVgoyquQRJ8O1amks91Jca1bRi0r7q77x1638kbUaGVnnlRnXUMK/bdMfoNhCOYN3KRQyg1Xg/9qnswRYWAo5gTFbrBZmYQ9r3oLMbYEC4qVYe9nBd/0qUIuA6vrsKAeT7/0hJ3chqA7HhA5hfxvYWBNM8HHAArfpp6N2b8DsesyL+iPo66jbpnR+AqjZLB38ZCWDsYlnguyE+oUPNcHruZBWwjjEQlZNDAaqIniyj8zGH/qq8ng0KZVOpV8hVK6649XpLs8hnGChXrskr9RmbTG/1zebSRD8IOlyDyL5x2+FvGMmDIyqjcGTcRq9wBT9pFCyCWki5vtweA 3yt7+nai 6MWivpklNKKMVrPSxVmqN4iz74Uyl6YjPnfa498N3y7fky1qnb6/Bq4/ICkznqOm/9/LAVdAW9hpCAOCwG+p8CfLf4OEMBKFTFkSrinHEEJcp05nN+6fxZ22rCVbm7wWG49jCg+uFIQKcD6LYUgOO/KXcVaBka3KB9BuMHkMYpPREfwaQQC0v4dsvpPuG/yQlu+3BNGuBfvYbvJInHpW+zF2/umyigVJQVyy9GSvThdFzkGYfU127DHIo23JKulKLVAF64WFCxZ0f3TyRcq6jWRAhzKwJlnbk0Nwx6rhZs2JlIo7V+ga8E6Q+ghlHAReOMOBnu2j1C9aAlJ8D2CNQ3SEcznZy0iWdcnAug0CZfaSg5S+t3KaVJq8BvGAL+xL6xZqt 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 790db7eac6c2..612ccbeb493b 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 Wed Oct 2 23:44:37 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: 13820556 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 D1AF0CF8547 for ; Wed, 2 Oct 2024 23:45:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E0AA06B04EA; Wed, 2 Oct 2024 19:45:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DBB046B04EB; Wed, 2 Oct 2024 19:45:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5DC46B04EC; Wed, 2 Oct 2024 19:45:21 -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 934BC6B04EA for ; Wed, 2 Oct 2024 19:45:21 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 394ACA0B87 for ; Wed, 2 Oct 2024 23:45:21 +0000 (UTC) X-FDA: 82630296042.03.F111BE1 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf23.hostedemail.com (Postfix) with ESMTP id 7BAD1140018 for ; Wed, 2 Oct 2024 23:45:19 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=UgzBQREk; 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=1727912591; 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=DalQc9ZFDkAEv3Wa+zRkk2ZJ5+lE2Yk2pdRycpfio0A=; b=ymwTj6L2PYz5qNlet+i5PMBQwue8FwG3iB6Ex26s6rdPVGUVK3S5tIl3rJ++pbJNU5C9tn jGYmJJiDpj3kJ/NYFOgMO9Wl1jLyeUCTVBAMFqFBiJZ3nsttSXJOsnSWzGl2fAo1ZHub5a EBIAFlKcCsoi0/GobzWuyAsXGe/p7iA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727912591; a=rsa-sha256; cv=none; b=AvybZBPMTbs5gH3ePLyJSMwkKU063cAsqafxQDGke4nISsY/2WXUsuMZvpl0XBS5efmtY6 LpGMpbLRTf+fI2QByLaJaZCXUKd6SmRoSjkYEp+4BDQX6krchqgDpF9bNutMogdGFlt1FT EIlPDCrTRV+zUL/VoXIZbAz7lolzhmI= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=UgzBQREk; 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=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=DalQc9ZFDkAEv3Wa+zRkk2ZJ5+lE2Yk2pdRycpfio0A=; b=UgzBQREksyY9Nb2Y5xXzTaqlbk yogZnCArPZAn08oPQZEdWPUNmG8pl5ZtM0j4iy5+XcdiKQeVPztN7tOaXFDXSHiDH1W3nSydxyKD9 TxqluSZz/becVnaml0eECIvj0UHDLW9LB78cePc0ddHXzgGqjJyxW6mVViMMfYDoR9qTF67iOKwqU nk+aRiWIdAQx++IsD/G9JXyzVFa+wE1aoGe2qG3FklV22U9GHo/U2OPbM8crVUe/wE8jYMtPWJqXO td8xWsu3H/xoWO1GM3zXOqrsz3hzBXpQMiDgDQK9PH9um02ltAp2yQt8JlswIlCaloNLF+5eIyei4 +YJl6+kg==; Received: from [187.57.199.212] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1sw91r-0045tc-Vt; Thu, 03 Oct 2024 01:45:12 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= , Gabriel Krisman Bertazi Subject: [PATCH v5 03/10] unicode: Export latest available UTF-8 version number Date: Wed, 2 Oct 2024 20:44:37 -0300 Message-ID: <20241002234444.398367-4-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241002234444.398367-1-andrealmeid@igalia.com> References: <20241002234444.398367-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7BAD1140018 X-Stat-Signature: bk5jmmmk7edokzoqb8crymkbcikp943u X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1727912719-493697 X-HE-Meta: U2FsdGVkX19gVDiz07zsPNMFqWCiKXMsyynM7fiw7BpwC2MM0B8vBI1J4Diog8bJ8kOCaKCVMx5BiaFKcQFMMsJPrxIIPUONOm6UFRoKl80qJXOV/0vIPQH/UNV7wX65T1sdpEnBWgqz2sADLin1qP4QSEGIEd1ACSRnS3hs/otl1InqsWjn68Y/FvGXzA+soqAa/ygjhujqWBGGRj68u24u4h4G/M/DaQ/0GqmxyW3GRxNGopdK8WwhxhrzLnFmm4u3NeFskIn4TECsVTSsrfmqfZVWHUnYhUbniBnJO+dBUwYNMRTsIPkrvKh2Ikzbmo/9E24jZz5Kaann1K8AGZXJ3yHsvR/vTUV0DQfK2DbKyk60JKTo90SLR9gBzfZX0OX5rUxUIWSDoq2Zz8gNAqsctOtIjm6wL9p8kwFVEt+jA5dbpeK96ixVygJBGPNlLigxLnb5AC4cz1ZcVL1qOLnrKYgVNs3Z092jfQULGKI87uKvF/8R35Ac9EahwIvSBcoXqF7NrA4wwYXN9cxfpOiYKISX87svT3KJFuiUqBAL/a8CNFChEcrCHksORFiYUwqeqLlN6WTUQ3+0mr4bmSagveVG2xVDX7+/z47iuAXCwN99dAMLeglADnkpbTgwYoqelZmnP9q7BwRTYCb68PKK8njXFVk5oM2UZIwJFwQ+PytnQc2YZ/306JjHiLVqMon+MxHsDqZU5F+3l5lX6tMkS9kloVy1hYfI7YNeK4PtddS1SD7G+MtLb8GT93chgNoDnUPakhjDAO3ucX2RsZ6dUsq9gC/T8Ywxsj4wM1ERe8sTADLfQZHTumD/yKY0OvYQn0oQEhr+iWz33+YHRhcOztgKNfa7PBwW6Rhem72hN/Ksf0McsR96GZ8jkHyydN/zaJWmw7klDo9RVnmmQ56ELsTtdUBQZJ77RH5ZPsPt86Sd5c0CPiPzk+/yeyVrRQwyAry/yTdH79qbx7w ONbp7coY dzAm1fL0U/YYJFCewUhEvqzonPOOaP41yL1HK02yL/+qv2G/zyz8+MV05JC21mJ/tGMQcASX7Psnt4yHh+KRIhUqnUb3tLX5E3gCkMpgN6uLaz/0uIAjWR601WTJS/gEC4mrc+xU9zA8q8gXmn5TQ9VzqtLJ16rZzg5YHShsldq4Z2AR8x3H8E4VGWoX4qrbWUpEFbeTfyxjLxDcjvH3l4lZfEDUmzOam0o0BCZ8zdXAVYW7MxiE4r0M0SCGv7QH8hpaBF0aMeeVGX+Ra2Aav0OkP1OoDFXkNZYCT1+Yi2M6dD3kTfJibFHmqOCXaaq6TEsHnreFHTWZuuUA= 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 600e15efe9ed..5ddaf27b21a6 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 4d39e6e11a95..0c0ab04e84ee 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 Wed Oct 2 23:44:38 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: 13820557 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 15546CF8547 for ; Wed, 2 Oct 2024 23:45:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A87846B04EB; Wed, 2 Oct 2024 19:45:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A37D96B04EC; Wed, 2 Oct 2024 19:45:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9006C6B04ED; Wed, 2 Oct 2024 19:45:26 -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 67DE56B04EB for ; Wed, 2 Oct 2024 19:45:26 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 0E64B140C5C for ; Wed, 2 Oct 2024 23:45:26 +0000 (UTC) X-FDA: 82630296252.11.7D94622 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf08.hostedemail.com (Postfix) with ESMTP id 5C14116001C for ; Wed, 2 Oct 2024 23:45:24 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=rEN9q944; spf=pass (imf08.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=1727912553; 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=HCbVqueHUmSSCcT+A2gsLYEdLj0anlbi7vfWbqjQz7g=; b=gutwd4V1TBJkkEdGYQzYjgORtBy376QgGdpMQwFiudlJlT/hUDZU0A7D8kJzU1tQwRX1Xt S1AMC+goAaGBjgA4apUowJR9jtgVAMrddBM2Bi56Zi1PraeNRmJyL5gpgFnp9p9mHcu+Hx XsRz0kPmli9QUQJr3QiTsWtfbCDo11c= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=rEN9q944; spf=pass (imf08.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=1727912553; a=rsa-sha256; cv=none; b=lltAnJkAyahWqEZ4F+LGpsiANYLDobKyNk6263/WlUI3f1Sx9amyMKBf4vYDI5ciCPvnPs X5pcqDaS9iLNIDxbk41gSYJsgUFtZMW0o0sAows/pw4Tkqt1UiOYvvY2hrHAIAjkMpuC/0 cvl7JSXD+Iaxi6kxQWsdqYOlMIseQtc= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=HCbVqueHUmSSCcT+A2gsLYEdLj0anlbi7vfWbqjQz7g=; b=rEN9q9445fHCa6+Cu5k/ZNfA6l rUVf5HN05YiPW6LBeSVDHVW4yadCX1//v6PcFQTA/Mu90qZhR7Kx2QsPMNbrNzyHSUt4N8NcoKeY7 WDaRV9YyJxmiKIQKzgH4Tqf6xY2PfLxyrL1xu+3E+lHnOktCjoFwrwW0u+T+Dm6IIp3tyD2xekUbA ppP90YeCpxXhbXEgPg7bO0JT0sxAzzCV9SfZH9N9JKBfMt7feJ+oUh9ehxpd5ETYEhNy9ULePV+4s oCrLHrmwF0ZREkJLY1US/OZkYXFek93sSO42K+dxBJIzW+OHd0L33CVG8dyiqCs0qBtz3j5HTqmPQ O0FJJMEQ==; Received: from [187.57.199.212] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1sw91w-0045tc-Bz; Thu, 03 Oct 2024 01:45:16 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= , Gabriel Krisman Bertazi Subject: [PATCH v5 04/10] unicode: Recreate utf8_parse_version() Date: Wed, 2 Oct 2024 20:44:38 -0300 Message-ID: <20241002234444.398367-5-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241002234444.398367-1-andrealmeid@igalia.com> References: <20241002234444.398367-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 5C14116001C X-Stat-Signature: wh3kq74197wkwkwb6n6nog8huc7boum9 X-Rspam-User: X-HE-Tag: 1727912724-382732 X-HE-Meta: U2FsdGVkX19mBzmV4Vawp4lZ2IcO6hoTahu+BDbIiM5jzvN4tK0o4tTMh3iVD3Fv8jcprqg20tXD4JrZtQ9Cu35UxOEH87Gz42JJ4x3a3noL9cVNXZK8nPVhneWjogibRghmDaRDMnaAk1gSPIf4DkseZx1ht2Xyj4rrf95phN08r4WlyMN9KXi1OHaDseunWw9+g2wHzYvqWQ5zB0FMRcuzOBCRw7lBmNGoQHgTeDtFVLqGQadDQo+hNiAKLIKC7yRFGDXdo6lHdRLbfxDeJOmxYfX8lRP4lUmF1/NjQ/0FZySRkfilWfjqePF/9xfVdHljS/w8chTR+OVUBf0agt246rjV3sqaBnT3gLQHDw6sQB7wlzwAma2gNi9R6h1RoJV/+rqgrtIyf3WOxH+MKgegpu+VAut2Qk1Mu+gp1njOusps048TGXmjl0AtVSqeoG3g26PRgRh3na03bMIRkwpx2rGOFzRQZVcQZ1TKqWw2tLZeEaXZXdxuy2gm1ERnZX15cusoWlEdrD2CWGDokHyXppHiMIqx4YEIVB6shbRIt3rj//i029JognJxZ4xsCwYIUIHhFeAiduulzxOgD/WQGvlVmWd1lCOD9u3dBQYw39v9FvsQtohsNirwUBMh98WRCzF4iWCmwYt3m1AlIuOU8tIyP+5klstOp0hafz3p3Xz7DJQXyaqq48UCj0Zz9a0phRF3FM3KgrMr3MbSNfthFbtBI/vNF4FkJ77aSjW/PveXEm0cZ0VAishp4rFCPwuA8zEV67DjKrAoDzUAgKKSlR0L7GReQSWbieon/AdCxA7Sbc9fEHVPRGSVi2j7i1836p+UDj2sy8ZtaZbi7hneDIs6dPatEs/6lXaNS1VUg1Q2w5bLSPlFsWv6JtcPfFoa+ko5X/4+Neq3BvjULlanlyFOU8HH+ZABqQztkF/wU/9A5YTv6Oq8d4g2vRlBx5mwu0h45DgzfI5YDj5 LwxE4Ro1 HWsS0koVo7+gtCmYJbPm9Xc9lUHPl6ITEISfboHTvCvF+M9gTyaFa/YfiXKnuSozwDc3OEnCNQuvuD8P2wkEvuUdsTCt22cI0tAfA+EcxRs3xH62o/tp3UPfoIrprwLh5UBIXnSYNfRgwuXsuyeEXBwN+PN9iVSHlfFkEZweWj7nqMLMv5YRDB3TTQt6zslNVrBNd/cxB0AMh7YrXdD6A3ONQdakhwiyY+o7fCOtUmLsXX+o7FyoYOWbgvtR2f7RNtWoJxblSZz6RXGxyLHCHr5Q4dPBt6TpNzNlNSUGwt5E1lHCPG/2JDCsnXfXl+5wxGMQmjeVGJVU6enbXBE5Asy6HWlAf7nyGHFA3Cbl2HGIlihwIW/N8s+wO5WUVnSqm39Ta 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 0400824ef493..6fc9ab8667e6 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 0c0ab04e84ee..5e6b212a2aed 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 Wed Oct 2 23:44:39 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: 13820558 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 A2E7ECF8547 for ; Wed, 2 Oct 2024 23:45:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 382AE6B04EC; Wed, 2 Oct 2024 19:45:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3330C6B04ED; Wed, 2 Oct 2024 19:45:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FB4A6B04EE; Wed, 2 Oct 2024 19:45:31 -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 EC0CD6B04EC for ; Wed, 2 Oct 2024 19:45:30 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 626911C6DEF for ; Wed, 2 Oct 2024 23:45:30 +0000 (UTC) X-FDA: 82630296420.10.31B5C57 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf11.hostedemail.com (Postfix) with ESMTP id AC1DF40018 for ; Wed, 2 Oct 2024 23:45:28 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=GRS0ZU4D; spf=pass (imf11.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=1727912663; 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=AQXk6ztfHTUQteq8elPhWhUuCISghcvWoGYTPvw/Cw8=; b=y2QmNKWM6o5ibIkcPzmKhI4N6YqXBQSRqfaDWQQyUPW9QgrTYYSh39wV54U57uy1nTNpbm DlfsX2yi00Isog0qpZd7t2qDXeV2WTiWagLbioE0+WcHSnLnHlO+JZjAnliSCfUSg4Z1DZ E8hClfGFC5AyGa/YoxGq7wo53Yviqjk= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=GRS0ZU4D; spf=pass (imf11.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=1727912663; a=rsa-sha256; cv=none; b=IMma49UVprFd1liL++sqIzfeXEBByMmFyJkmuFo4n/x+veWCbIY2jN3LnmSpw5PH1OC6mm nq79fr+3tR8zXRVXzhSK2HddlRI3971cfEk1LrYhEemjJbdvLwka7PTVYSF8APrP3p617y yeETA1Wiu6RZbK8iR9qkAMRH5NTh9WA= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=AQXk6ztfHTUQteq8elPhWhUuCISghcvWoGYTPvw/Cw8=; b=GRS0ZU4D/LbdgGtJz8RqDet2I/ kBSmua98CNEkx9YC1kQqu5FoWtonv8v6mjKUDDc+4jt2vUVc3H6KfulRVGlmnmc77P+HgeXkffCxc ylDiVRu9Ko+fcofddOY/MotK4SzHmfX/qso/QhYfbjx+NngmuqyXbkJsJKWcizQVxvqWLiSXbitLm 7N5QOFhclCGI2g2TRhiPKOVDDFSHwO19js7JLFOv+9TrSrB6I5oA81S9Gzs6k2x9duS/K3VXWggQY rjF7yM0fWEyE+RAq7rdWWkODzySa7GRoaOxdV0lHMyk6n0mrrCOHOXnjiIU+96+GbfoKG8yqtGoj/ 1ycf+wPA==; Received: from [187.57.199.212] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1sw920-0045tc-HW; Thu, 03 Oct 2024 01:45:20 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= Subject: [PATCH v5 05/10] libfs: Export generic_ci_ dentry functions Date: Wed, 2 Oct 2024 20:44:39 -0300 Message-ID: <20241002234444.398367-6-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241002234444.398367-1-andrealmeid@igalia.com> References: <20241002234444.398367-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: AC1DF40018 X-Stat-Signature: hmw836xxd59b6k4xps15qhxi18toabuu X-HE-Tag: 1727912728-717067 X-HE-Meta: U2FsdGVkX1+IunSG068Mdh5HmytQy7R2VfA7iF/qu9cclNaGBwBxzvYZ/JQwbFjZpjWmJ06z8wNvBldjxe3//bYk0eDPmjorAAQJX7GV4g1DzFFfNSHPKGJJtwmEBSiMEoZ/tC8VRDt+GGzHsLJzIkVFK459r/ydzAtfcK/VfOyGS/igQ7Kfc/lpF320xvmaabWdH/szY2K0xyizT1YNmrX/K4Y2fmKLvQAxBD2H9VZL9TVd+ChmuUuFK/lfk44WjmiQxhSAcP+QkYy5U5vwqzrkyH/CN+/IKTJPHWdlFlq98tf4bWQAqNPUc1b2aee5GIDO2O95Xaondq2TV0XgczL2mXyaN1EGSnj8JYaJWDlQ9Yk0a2UebKvO1/+81oOW+76ZC37oLlRZCCGnO0h7hA8bPFwoGx0uazfOhQvudJ0ixXwLlwgXum9Sl64nEOU/L3QOQVJVLAE3uJUDlArJdQG2cVW2Y8GBqnNDeik2BB8HDuh9QmKrnlzyCblbzO/JD55KfK9eQTiMqtsyFMhWTAiGp8RuE7Gg1KBfpPITh2v+GuIzkS1DQNa99qqAylZhFZM2espGt4b8zEmqtj9y3MB38snsqyL/3PF6eaZQRk9pcmYgVfvsJqAfU+UQZgaNtDClT3bkwgOtpeHkdoMRf6AoEpv1O2rzxfpE5V4A4VTFy48IjDEureSOs2exCFqvFAaXLSGGlKS1B05VcVm+iLwfUzLn/2EeEqweGsZIZPahtCsQ+Vqvfmy9U7UAzalEnbJiOv2oDfyKwd5T3PB704wc72nTemAljLJpbcl7/M9TqBVY7GYYBfGgZKN+WqpSOv5QDlYWqWUctt4c7SuXWNhc8V137K2ftlFlsSCPFAuZYihkt85jUwjClkOoj5rmcnQoKHjpHqMIMdYo6qT4BsxJliYHL86YXHBL/9Xb3GrH5GBTJIfMVrqXIEg/ZNeeJQStgW7BQTI6SyDVpDf 7a48j2ht jl5iVvK0OVjZOdajVDNh7BAblDzjN+F3x7TIk4SfnZ7ER8dXnx1cLbHrYPduwzF8vN/Jm/H5f5Eqg6FlQTz0l9gEqwFfcPhuN3qp5sMgZ0REfZibtgmXK2Vn78hH7jaHWok8SZARNIKNOg5VMH/1zK0tK4rOnTzOGPQ9oFsCPMvB+MJH9Ft5286kzEB2KZVljv/oceV9VvuBgWDlDcDzsHgJYCn2w+yTfCnrKJT7XiG7Kkl8TQqbsz5uUu38aTHXWypArBo6UNaYGuVe6gY8e6Qw24tsJSfyJ0LVddylKx6gk/+6arw1fJRgjJu04uJJyzRP4g6wrXiyF5Wsd012Y5qzInlKZp/c7jm62O1AtMF9oMWjlsQpAyY46hTuoB3rpzmY9 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 --- 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 46966fd8bcf9..7b290404c5f9 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 9a5d38fc3b67..400d070d9a9b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3453,6 +3453,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 Wed Oct 2 23:44:40 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: 13820559 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 62767CF8547 for ; Wed, 2 Oct 2024 23:45:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA61D6B04ED; Wed, 2 Oct 2024 19:45:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E57046B04EE; Wed, 2 Oct 2024 19:45:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D1EB06B04EF; Wed, 2 Oct 2024 19:45:34 -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 AC6BC6B04ED for ; Wed, 2 Oct 2024 19:45:34 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 4E457C0ADA for ; Wed, 2 Oct 2024 23:45:34 +0000 (UTC) X-FDA: 82630296588.20.DA204BC Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf23.hostedemail.com (Postfix) with ESMTP id 9FAC214000E for ; Wed, 2 Oct 2024 23:45:32 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=bka5vrt0; 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727912667; a=rsa-sha256; cv=none; b=hQf2NVIb+zAmXtdthzO22Ou1xKF/S+Brb4jCY1cYTRJQH4oDeH0uCdNDvN+/vXjBkkoJme L0mUhwFiUNmErAABqr8l3V5UFHZLfckOO5h/gmgFJOKOZggMkyKy38I0Zik3+zdjxtYYdE MoxBtdT4xrpJ9Owp0sJDZkfldsnyqZw= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=bka5vrt0; 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=1727912667; 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=Quu0dtbQ9E+zFuEMK6MzcOIEYam2pR7bqkVHBNP4Z1M=; b=5T1m8tWsJGG6y9c7hNsPUGKNHl6mHucnR6zpqQ3rjeTT+s23OS5TZCGXMnBRdvJwim4pSg CJ6fHLie3rOQ5bi730c6PHvj5m9Tmm/dAYz81hZqOzJdSijieXKKc+9BY2DMZfAYy6Haco YsimSg9Wi/RukyeK48hI0tUatEwfpyM= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Quu0dtbQ9E+zFuEMK6MzcOIEYam2pR7bqkVHBNP4Z1M=; b=bka5vrt0u16euP1xIhWZ/Kg1wh ar8IE3EbJsB3viwk03hqbcr4jQJ2jK9Xd6LueY/9eMGT++ho5OGh5/nR0NfR5aDwNNIoORZs/tzPz xFCknGIhr9MWfGMTi7ksYaVVUUNTC7KXm0a4Ifde3cNKpmNSRYxCGMWk/4ECZlxRe2NbGewsG7ttU t9jE5ElARxyxdq15MgdjrRrqqiW5cAx8boixraK6bpaUw1r/5E6uO6yzCTq45C4dbRy9hfU7qwsMV CmUkUxxnREwLcSVoSqLD/1vhksx9xUx1OfIaSteNU0kxODerKgSU6VvcJH3wt1Syiovvb9s8Zj6NQ rIR49aAA==; Received: from [187.57.199.212] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1sw924-0045tc-N1; Thu, 03 Oct 2024 01:45:25 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= Subject: [PATCH v5 06/10] tmpfs: Always set simple_dentry_operations as dentry ops Date: Wed, 2 Oct 2024 20:44:40 -0300 Message-ID: <20241002234444.398367-7-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241002234444.398367-1-andrealmeid@igalia.com> References: <20241002234444.398367-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Stat-Signature: z1zrmix1zkxagm177t7pirgy43t9jyju X-Rspamd-Queue-Id: 9FAC214000E X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1727912732-937301 X-HE-Meta: U2FsdGVkX184eTw1XkvJV/y8ei2H90rbK0wSqraZgQJYyvBKEjy3/Q4rcIwBTZIZcO3K7wHwjPROLM0C4Sg100gxqfVdiolkANEYXvxbxOrVly3xgTSlnjl+o0X/4dmBEbF7kKWbQpBY2qaEdmr4WG3YkkhI8OrBvCvBVc7D82UkAAi2+Vju2/H0ORnSBa+SW6Oclaycz+PtlNVUwD67n+e373jpziTL8H6ZaTRV0qtbPhCcV85nroKaegrgEnYtKCrW3BKGxow3FdaPbn45j1kLb1XrMesJx1+ICW1TOmKlVWPOcxm40FmhFVfX5NmMxw0k0JOYwFSochJtXkvx9ega59LtHQSr7zgg1DS6fKU+tLbWc6EvUYA35oedaO3Yb5haDqQzyzzXQaL/2zRZ+r5mRrC7e43DbeiMJbvf5nkVE4X3nZ0qBYImSkb+SKK7ifrocmfT2c/SxQ+BCsSsry1bB7oHnOKbrDZwqZPIzO/AF6HGTiOvJaM0NHOqiaBpvqgfYjSR3uKluqLEjC2Wmf3lPdvm3TU9lUc6Lj/eP76/a4MIlJo/JSzR5HmyEk7vOy9qjMVbrIC4zQrMMzO4qYsU2cwcpYaPU14irwkGgpexUWaK+zuQ5GJYpL7Ybu/okAceHVykB2XqlJnhQss4Yho/fu+9uV+zfj76ojzM6HpEiLyJK7JdVkW+qRyHXHyyG5GQejP3aNE/lmERTLD1y9pTesoGrHLPElqwg9QaGuWwubgVtrielSAEOlnxOz19nunotGZ90W/SQ6sjWmbKCprX/YjZmdkn4hJJlnIOBiSH7Q0EdPv5MdA+LOHOjymmmqXTpXB1okt39UEhXhtuhbd78PpGUSCtMoxxFwLZ5n9r9w8W3W2sLvyg0R6nqHOtKI+QnhpbhnmyyRQ5hVikreN21Ty42cF1L9OFQlm87At5xSb7QW4VvvZRRH8KwAPfE1WVoUuzOB9/2FK+BYg ZJaxQqZb rKegUv7NY000gVW0jo7v2gMgRDDihtP5HsY7a9yK0bYset3/3jm1+on40Uznz1yavnIahql8bqo6DGXuAycI7TbBqUNSejfzaAigWsGOHapr9tIjoVXRisiHuepGjfBzuR7+MACNnVWdXiVxYkMmk+lniFBu0LiS25jTEPeRKKEC//VODX4OI0nvOxms6e3/xrxMhsrepGY+UO+m/gwx7ytHkbPfjY8gzBtboTOzudf3PbI1jAxaCKUAuNRgLITzyfwQVs15p/EuJjhe8ae6FkvTa1RNcVAVdxIoh9vKoc7EHiVm10ohvrBllGjeA9qS0QW8RRL/pE6ceRytIreErsw0OUMlHtAlEeVeJED9Ra9B7rWI4qCJvlmiRRCtlVbNng8yW 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: Set simple_dentry_operations as the superblock dentry ops, so all tmpfs dentries can inherit it. Signed-off-by: André Almeida --- mm/shmem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/shmem.c b/mm/shmem.c index 4f11b5506363..162d68784309 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -4662,6 +4662,8 @@ 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; + + sb->s_d_op = &simple_dentry_operations; #else sb->s_flags |= SB_NOUSER; #endif From patchwork Wed Oct 2 23:44:41 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: 13820560 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 D2121CF8547 for ; Wed, 2 Oct 2024 23:45:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6B8606B0499; Wed, 2 Oct 2024 19:45:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 66A336B04EF; Wed, 2 Oct 2024 19:45:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4946C6B0499; Wed, 2 Oct 2024 19:45:39 -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 1B99F6B0495 for ; Wed, 2 Oct 2024 19:45:39 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B8FDAC0B11 for ; Wed, 2 Oct 2024 23:45:38 +0000 (UTC) X-FDA: 82630296756.07.FFF8451 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf22.hostedemail.com (Postfix) with ESMTP id E608BC0015 for ; Wed, 2 Oct 2024 23:45:36 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=WQXH2dH+; spf=pass (imf22.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=1727912672; 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=a44X2hLHZHM6OEDMyxUHO1xVlMNMtLmqduY2AzXe0HA=; b=0RMnpwzwr8kkd5GmVJU4sx8OZgeqcp+3I8FOanATe89NEpsOm/rOvzG5YV5Llrg9cBccOu 9m20YsF3zQKp08nvZv1siP3ocX5CWH9cFbTw+VOU9SOdcOqtbA2XjNOUaYdIMPnQN9+n7u aJ8qtPsAlQLU+Cx61Ny2l8tmlDlVuUc= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=WQXH2dH+; spf=pass (imf22.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=1727912672; a=rsa-sha256; cv=none; b=WTY/khsv0hBJ1zPaOmfX7LYctFcm9RFy8QylRBN3t/jXC2H6UB/BeCYyyYow4wm1Jc3zKS jmck/kIcQ+SU46k0/Vl6yvWwAmN105w3yhVcMx4jrJ+X31JgFeWykQedTbzIh59OILZyZx YsVvDiQfXYeNMcCajWQDHCfOntxjI8c= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=a44X2hLHZHM6OEDMyxUHO1xVlMNMtLmqduY2AzXe0HA=; b=WQXH2dH+S1J9YIo6G0O001t96K J5FiSqTRu2ts8uBrtgp7+vm3sVcL9rJDY2x0K3cGx0tLF2Ft8sN50OJWFJcCUMEIb4ihwv8K83qM8 j0xJsAd3Soy2U8p9+uTvqu3je5yS0dTvCMbNI+a0qCv2RdNc5vMRf6HUKVi7/9AFPRAH6VhN0jVsU 06lFGMoUusQhHd11deSJT7hrzmEnZL0BuygM2JU6jq00BJlXr+cHiH/H0A6DWH+/ytKWn8tcGTkLp oibfaKgYymHDk8q/Q2s0PJDOYvePUNM2Xc0QJkgrTVO4pWIvjc/5WtudxD3RCYRa9sS5UDJwtuCdV YOAVB09g==; Received: from [187.57.199.212] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1sw928-0045tc-SR; Thu, 03 Oct 2024 01:45:29 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= Subject: [PATCH v5 07/10] tmpfs: Add casefold lookup support Date: Wed, 2 Oct 2024 20:44:41 -0300 Message-ID: <20241002234444.398367-8-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241002234444.398367-1-andrealmeid@igalia.com> References: <20241002234444.398367-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: E608BC0015 X-Stat-Signature: msmrefun73q5sd6ukmgah9xuk35u3xbe X-HE-Tag: 1727912736-296399 X-HE-Meta: U2FsdGVkX1+5RKPubTQO/jTSGW5yIewjoTcHgQ2SWGIVuSZcsx29hvQ+fxmbAQDPY5GpuuK2JjGrxs+R4VVLFYqsHBQd8zNTz2WvNOabMf80xRia/uR7R9OaW9+jZYNVllfpdJTK4x/RwcIyveoVtxqAS5p1CXprCXo0tDp4n7jpndXBvshsEA8tw8cvE+2qQJkRohpD7vnkijc/+bUmhcprkzn7wo7P4BKQ/noG2p9KbmHyIjQfdqookE+Ox4rrsFHuoUrLhcmB4K2WAIUGco5r4WvPYkzAibQUD0L1L+fdqLSn0bo+te6ovY8yD6GNH3zeg2fMGLQftGnPutWZNH4wYMyYGpe1AFffLbDQbJSVxT1SgH8p+72ka7VnRcQLbooye2jFbRVHpW4EdOiQtMiB341VzB/7jiSKS7Nw+S5IUVlAHumZ8vHcAlV3lDaoPNZoEFYiKN5Tg8Q07WztHdEKiMpIUqSiol7OAGkysFb+kO0ia1n3v88TvtKiOKyQGg2XQl12FzeE0v7QsWZONOJpYt9UcGewKRq7lMjk/uiHH4/7zGMnql1ekPKHJpURGR6s+G0tbNjSFO8gdV+jlonCTu2+2iNzp6ei4UoMYBorQqoju+HLVm62GbJUxHkwhC5D+8dVkJcJvDYWO4OOn9YJEzo896K8CFxYWSILOYu/1FhWZcZ43EGesKYcoqWGvI24r0FdX5YjfJEOXg9wO0LZY75m8NqbPAaCV1NTpt6lCg/cH7aXvBI1ijwwdE9cfUYm6ag7bV1Bkrikex7S9w9Nilbxd5VgbIZfYCzw1K7xff6aIA4goPBJ4bLI9vp9lq8xhXbxopr8KWJYavS96U/eaYyMP0FMb9cS6iMhL/FLU+yZdw10nQU/rHRe4gwskiyxfIjGG1nX5/w7HrsXGX9jfr1hSlb3AGlbur0quLm9BZfwJvPCBABhhDxeqMpGTBJupIaoWddyLEbjCI2 Y3tbXGLa NaHELwqf9tT7qTmg90YtjUhuEuh7xqLPFv/5V8Gp0oV5AYXapM3rkAvp5ZXYNEaFFUg1ZaYD03TwjuHXQmypw94vowOfbReBVBhUX/1n061Or+vWdzgAmHX41TpFbPcz5V6FYwSwy2RUAOvsSoVJrYXcE/uTx411I6FN8PsqLI5kfH2oXkcYOJNzyOH7voPW7v1RRDoh2liZPGp78O4yb5AH71o7+xbm1ITgraEnsXf4xDiW7y76VjiyDsPKt55Ic7eEtvps5OHl5YKsRwvPKZH2geyral33FDrGqjFMXVQKJcYRH6gu+ElvBCAZYLsCZeACSpmCEoYBV+xY= 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 --- 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, 118 insertions(+), 5 deletions(-) diff --git a/fs/libfs.c b/fs/libfs.c index 7b290404c5f9..a168ece5cc61 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 162d68784309..3c8c7b34632a 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 @@ -3574,6 +3577,9 @@ shmem_mknod(struct mnt_idmap *idmap, struct inode *dir, if (IS_ERR(inode)) return PTR_ERR(inode); + if (!generic_ci_validate_strict_name(dir, &dentry->d_name)) + return -EINVAL; + error = simple_acl_create(dir, inode); if (error) goto out_iput; @@ -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) +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; @@ -4663,10 +4756,24 @@ 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; - sb->s_d_op = &simple_dentry_operations; + 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; @@ -4940,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 Wed Oct 2 23:44:42 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: 13820561 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 3C79BCF8547 for ; Wed, 2 Oct 2024 23:45:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C0E306B04E7; Wed, 2 Oct 2024 19:45:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BBEAE6B04EF; Wed, 2 Oct 2024 19:45:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A5FB96B04F0; Wed, 2 Oct 2024 19:45:43 -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 8065C6B04E7 for ; Wed, 2 Oct 2024 19:45:43 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2EFA7140BD8 for ; Wed, 2 Oct 2024 23:45:43 +0000 (UTC) X-FDA: 82630296966.11.01554AB Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf07.hostedemail.com (Postfix) with ESMTP id 8784B4000A for ; Wed, 2 Oct 2024 23:45:41 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=S3porjiK; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf07.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=1727912599; 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=QytpkEJz2P1dJL+CmfxoJi8346LIRFv339Bsa+p1XKQ=; b=eXDh8v7/S00Cr1HDUGhC6hztTE+xDz3fnYEsk33ih6KiqMxrgnGZKaM2o59RqqPocNNjEG jOR+WpMj8Sv1TROGH9OBxS8ffq/KMzavDPDctW+WG0yZx6HsvXfTyQ8c9GvqYd0kX7dlrV Ts6S6yU4JpJN6DH0h8dQRV8zj5rZSGo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1727912599; a=rsa-sha256; cv=none; b=C5jEaf9dm6qs4iaVZiYVNPshtPDtSm03rebfCSgHcL+8JE6krb+lxloE0kwzsr1MjY/nSu 84CWY1vJ7Go0/R7kQBnRcMF78DER72ESvgzG9P2bC9dkRKMRu4uF5s/l5eaK2dh7C5W6Pf +5lZCp0+pG1bo7/IYJpgKKmga2QW5FU= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=S3porjiK; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf07.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=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=QytpkEJz2P1dJL+CmfxoJi8346LIRFv339Bsa+p1XKQ=; b=S3porjiKB8j1yc1P13gIqYyX/u 7PmSf6enyYqUSXaev5M2yurMA9//3IHYmZFL5hQ8Tl+aU1b5nDWsh6QW0POaCoR4JQTLD+jPpIE5I VfJYHblM+8f7loAVsR0hBj6degYp9N+sBHcRgqVXTChMkEOYB8stu7o5x0uZwfti8kRtYo8P5hOgM eLQrWem3+Rh9e+YodNjfn+z7wVKQc7DDFggSevcgRQ1moW8XNTc/dhyCYkyGFlOyZLiHSKJR15j6v 0xMZOcXyrKWkkB6VaAFCxvLVOS0ug0/gRrBnlnlOz9XlKAt/lIpekWGhqHK0geEG5g80+EXaDABwB wEyThyVQ==; Received: from [187.57.199.212] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1sw92D-0045tc-FT; Thu, 03 Oct 2024 01:45:33 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= , Gabriel Krisman Bertazi Subject: [PATCH v5 08/10] tmpfs: Add flag FS_CASEFOLD_FL support for tmpfs dirs Date: Wed, 2 Oct 2024 20:44:42 -0300 Message-ID: <20241002234444.398367-9-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241002234444.398367-1-andrealmeid@igalia.com> References: <20241002234444.398367-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 8784B4000A X-Stat-Signature: npriq3brgi6p6im437ubz7jzku91fcmp X-Rspam-User: X-HE-Tag: 1727912741-590733 X-HE-Meta: U2FsdGVkX1+9iQ3qr9RdAndOYmTPMS1U02nuPWDyXYhFahQ4x2vYwoiofDb1RBhCYgIe9hifp7h5vlieD2gADeMMAeqVoP67bs0bjl7MrbzGf/RM9CqyFMt8fq9KsUgFjzgDFi5HyIxtmgDl5u9UW+RD6h1fFi85NpetI/VvNwHv2PAGkedwI7PxTdTQCDycFJNvpHnYHDH19iAj935mgZr50vVFY+IDiE9QZHWFKW40EmfwH4jeBwJRE2xPewOGLksNcbV5TVj5bnC8lza2MRWMpe+B8yPkCFV9gHgQvUze8r8FrTXBio7QhCJu3eqDRcbvcX3fdZ9nPE5Mdug0U8MFp9OlTJ55PELhA1xMnpej+ALLdb+vTDueCzYNVyHNBEP2G5RRLcB3emgJk+yNxnH+QhBA5SUiZVIhPgwQRXPCucdUSkQ/Y0sI4U4xFB0790g+0I+ECKrjAd8lRaRsILPVysdg8atCI2vXOSYy9ZuhVwUfQD9MXm4AFK/fEGu8W4jISInq0qw6iYG9SbQOP9Rff/isbNWXK6Cxsjpa4w0xEIo8aE3qdvVFVP+9f7/e3Xvw/D2lwaa//tMkZElKyzE76d/vvQwiATC7YwkU7Xr9gAkaydpYR4pMtn0vyknOuO8cUkydHUofd83J4sT+qJWwRVy1FslrQsdyM+RItuLW6NazMrlxNeLYFXQGEem+9jAqoBaTE85YAvGFncGMG4TRAo3p6YL8MQP0odzd2U3Yzi4Cw4Dh7uGs6OF0VOdxpbmNItgSdatRNBt1VFTZlI79xO9WxeABQxQmu29S8Gyx/vLZaiqr01aAIcvBHerObNstGEWutwyPtV/izC7Ejpz670YmP/U9/ze7kLbucMtbOCnW1b0IG1LpU64wny8edc2VSQPqLZqAf72XhSViBq76xFI53jUrTMbsO9UM5pq0k7oTHlWfiHuiEQEk0FKN+WY3XZ66yqvWtEhabCE 8ftVjZnU 5U9LgXuR2G8jidkDEuePYfh80uUPuHaS7LmyvVi2W8tDGuZdp6Fk9rInQ+O/DnObOTODvO8w3i4HSMPU7U4YVaiuFa6xutJlHnbRaMrCQXQsRhCDivlq8b7r2oB7zyZBtL+t1X7l4H4dFwAwr6o46IkAaZ8rrJZ5GPMSaLPw9++uScNeL+0GedJdWOyAMWer8Enq16GHlZ5nIGJLVDIH9k6fviD73JvV/dqz36diDRzZMr4qPT7DWjOxi66s7GaHe0oXF9wqHLBYTW/UklyUuAveJWXSdBCw1MCgDROMAbYx9MPkneNnu1n4ZIRgHI31h+lMheycarWCtsyIVHK58rMOTC4MexkukRIb0EH524slDZmEhix7I2rnjzBe0nSGrgUkv 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 --- 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 515a9a6a3c6f..018da28c01e7 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 3c8c7b34632a..f07b446b3c98 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 Wed Oct 2 23:44:43 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: 13820562 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 671DECF8547 for ; Wed, 2 Oct 2024 23:45:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF5126B04EF; Wed, 2 Oct 2024 19:45:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EA6E96B04F0; Wed, 2 Oct 2024 19:45:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D94D46B04F1; Wed, 2 Oct 2024 19:45:47 -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 AB97E6B04EF for ; Wed, 2 Oct 2024 19:45:47 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 5324AA0C83 for ; Wed, 2 Oct 2024 23:45:47 +0000 (UTC) X-FDA: 82630297134.12.E567536 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf08.hostedemail.com (Postfix) with ESMTP id AAF0416001B for ; Wed, 2 Oct 2024 23:45:45 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=YUXfIqOm; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf08.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=1727912641; a=rsa-sha256; cv=none; b=mreUxZ5m+Aja49h+9cYvwvraVID7jNRnoLEDuLka7TY66WwcyXNWraOq5aKtGYqBLsJw2o lpMn8NjVl0Y1VlBJmw6FPszWlNzi6N3gu49HWlkgUCr85zEQKB97aqeJ1jdHxQxXTQ6PTe hn78dFhsRZtANd6Ts+iMngMoqPBnBT4= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=YUXfIqOm; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf08.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=1727912641; 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=IRPMd0h51YpQUBbAAX/wcuH0ZmexRZTVdCGmfxXJDJ4=; b=q5blj9ap2OKWd9esJzwz6ioF6wm8JSI4aJWJFDsi1hW65jYk6SMw/n/R1dpQfWyYKdywA8 92WyTFY2NY85gDzFs0y3pmmbNPcJC0lbnNdPHBk39FqTPgnlRsE+nrwspil1vI6bCmAYIy BfYgie7U0eUtam7lZ6qjDGly6vuHZ0s= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=IRPMd0h51YpQUBbAAX/wcuH0ZmexRZTVdCGmfxXJDJ4=; b=YUXfIqOmAm+ugm/XutADfo8KPq 852FMkqLH0SDzwTuLviY9XWwuciBiWB4uZfTdN24lUwGI3iZLz9ztLI4yr4ZiyMOkqajRybBp4+6Y ZVNOj6EVyZdjf3mfra9zlRHjbxVuwh3/Z7v79gNubJXqRoQVGVoJi+XcDsmWWGpHG+/pqElH1cuGD jlrxW7RXb3rlOqzNOGq7INMOtQuN2U3xQ1Qpt7V/+XV7ntd24CXQJgXdwHF2fo2xTS1t0RNn6ugun BmWFAlzoQECJH/X4J4E+FfadeI5VAdDMnKrk+E24N09A1HfCdwjjM2faNC5hDeOKzLCKd6vGLTVVO pnqUI3LQ==; Received: from [187.57.199.212] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1sw92H-0045tc-Rv; Thu, 03 Oct 2024 01:45:38 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= , Gabriel Krisman Bertazi Subject: [PATCH v5 09/10] tmpfs: Expose filesystem features via sysfs Date: Wed, 2 Oct 2024 20:44:43 -0300 Message-ID: <20241002234444.398367-10-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241002234444.398367-1-andrealmeid@igalia.com> References: <20241002234444.398367-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: AAF0416001B X-Stat-Signature: tosnyd8z9yesdh9ctsz494dyrhw7ece8 X-Rspam-User: X-HE-Tag: 1727912745-892108 X-HE-Meta: U2FsdGVkX1/ejMOIB/0ZZnhcJPiS5E0x4WF+U8ANhkFl+rOCeHEJdXa1PWXNFWAPW5BT4oH7lyOQqXjn/4sxZKFyGmtT1knxMQriFP7AM1gJGYO+0oiMIc2OBk6Ren4zNufSSDCRF002sF5tSylRRZG4pSjZPNZkgtG2Xy3fEMNH/ovgiVDB1d/S8fTU3LbWNqaJbjypR76GLKlGmfPDyEx1otd7/Q+11r/4/baaw3yGWlJSRwTjGtUu8y2dQBIij6K3Prn16hWkSBdeHLCUGSDHCyla7vqPkg6bMn1piw6c52m8N9/Bv0JvSZoydvt9l9ZY3j8oTGANeKmMte/ibrzmZdu0afHvhdXtoUZP1daCSp0YvxsYpWo74D+kHvyhZTY/8d/XkJgRCeSHmWBkSu9MY71v4YyN5EKdMqd3xor2vEhkkMfELL0MXcFjIgWl/5zNsXbg+SufqUquXh2CsYVJxqB02SwuHcSwJdlCLIrQEND7f7SYmMZitj348owmNoQqrpynbRHqSH+tC5ptT3Nns3pYztVIRAJsfIhzH+LYMDuILzcg2oMrs8gbEfD1kL0Yst5FXuXhfi1uJA62amSILRLXHRU3qP2yQUHdDPuuLjxhnpcsFBz7pZ4JDxSe+0MdPHl5whWpCRTglil1bskR7Fkdxmnu3RSwhZHt4fj9UTqRPT7gum6G1JQkGD5VcMEbIxJJAPQr3AO98gssP7FGb4kFpUFMFldzki1Vpcj2CV7wA08MxbjbsNu+OppjkUOp/iWgOAH82F4q06/G8ofksVB6PEgRpTCXlus5F1drMgYKZ8rhyUTDjUmoh3CDGQJpYTAPC9YqUqoJ+4hpf7X476CqChQaX3cWyS6H4sPImDTMglALEuf0Xg0Sg5reLQYsh4Ut9f7lXYEJ1u1dKNiP8gbSx/0j/+M/PHRUHN4mt4Qtsz2kmy7bnH9OM1tO3Xst1HIopErziZ7ea1G rwhsK+mN py8d7ufsy5f7/qpw894HrQ0kZo2eErwJqzMmIvREI1ufo4w2a+TMHfMSz9ECEMkXSXWAZS3M3oP6rFzRJdypw9aXphV8apPnqyMpNalai3jIIvN1lcb5PdTEV1lwrVm9Sv1HJtsqo7UBEDV0qoX/LnQkTtnL/NRNOZM2iceZExa9f/dUC5UaHItZ8OVNewvrqkVHQbwqBuaZsEXqXDfEG89qDHAXNdROyUfW+SbWHeAyxQ57PDGHnC1GYcSRT6rwMKVX9vhHVR0Wr2m8FgY81eoIQjV1GQPllpmE5Zzv2dSMTqGrlHIjfWBAWZ/TzfXKGf0h05z3/e+HvcjU= 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 f07b446b3c98..007123019d1c 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 Wed Oct 2 23:44:44 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: 13820563 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 2CA74CF8549 for ; Wed, 2 Oct 2024 23:45:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AFD256B02AD; Wed, 2 Oct 2024 19:45:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AAD276B02B0; Wed, 2 Oct 2024 19:45:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 976FF6B02AD; Wed, 2 Oct 2024 19:45:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 63A376B013C for ; Wed, 2 Oct 2024 19:45:52 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id F1DC4A0C68 for ; Wed, 2 Oct 2024 23:45:51 +0000 (UTC) X-FDA: 82630297302.21.D190905 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf06.hostedemail.com (Postfix) with ESMTP id 54EE1180004 for ; Wed, 2 Oct 2024 23:45:50 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=JUOKNPWp; spf=pass (imf06.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=1727912684; a=rsa-sha256; cv=none; b=zeSW/6iFAbK7L6bz2j3dtVDLNkheW/5NwtlmGr7fBy+LXxT2IPGGOk9WEe3lxyiQ0qpTmb 0dJETmDcS6s8EtVrAnaTINwtBE0M78/hxH59D1H3sPtWMO6G2pTuEr8D2vTW2NZ9/9T1Ko Hi6yLXoUim+DqWQUGJ8AFnLP7QQ31MU= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=JUOKNPWp; spf=pass (imf06.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=1727912684; 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=bm71yghG5LmMPzMX6MAemKlkSPoby82wgR5jHJ9lUOc=; b=1LKpnC3lfOmv+5ZhkBCqsw3GpxSE+2P6eJy49qQgO6D1B3Qf+SpIfBVJP7cwWUMBXgxUJp HX1+s4iRKr33tsVMGb0dGmUcWZim/EKyUf0697UIlLAFblj6eTq462E3L7RhrxBEFhue17 Cd19CnhDR1ctDWkk33vAHRt43Xxm3SE= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=bm71yghG5LmMPzMX6MAemKlkSPoby82wgR5jHJ9lUOc=; b=JUOKNPWprVahbSaKyzgJmNEx3M oddv6lJOok+SD7V/VPr5KC+WOTyqzaNMHoygRYybFzuPmkQvSGabEroPITqAbrEqUoJLlbjmakWUX hoScsaL4uMDdYEijrIvsiQxlnzqY7xACli8TttrH8Yy/LF94oWJWS2PtftPR4qaWqGqRuvnnoWKy3 CntcYbyf3l+Z1irHv4S9UUt56wM37QvLpNIzei5pCPOpcDRWjuKox8OWO+LkUUs5Jp6TfYQ/A9P8G lGJTtTypJdsTL+JjpHdQkscGbV7p2UgehaMyGB0lGLtg9M8SyPMKkkCBd3EK5zQbwnJ3SKKQIc/Yi eB2wDhuQ==; Received: from [187.57.199.212] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1sw92M-0045tc-81; Thu, 03 Oct 2024 01:45:42 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= , Gabriel Krisman Bertazi Subject: [PATCH v5 10/10] docs: tmpfs: Add casefold options Date: Wed, 2 Oct 2024 20:44:44 -0300 Message-ID: <20241002234444.398367-11-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241002234444.398367-1-andrealmeid@igalia.com> References: <20241002234444.398367-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Stat-Signature: hhjqz5aam3dg6rb5x3qddznkjqt1bm56 X-Rspamd-Queue-Id: 54EE1180004 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1727912750-801630 X-HE-Meta: U2FsdGVkX193GUKk6Lz2v5Ph+QyHbLZbQ7vPdCdS0c+wbMQZpLs0RqVB+V/SN6EVoHFpFsP+zBBUT2KHUqQHSKBpWRUyLgagArdyla0lRC2SkhZxELX1kJ/+KgYJBfpd5YrsYCEnnMyLq7DhHEVavyW2k8WSwcerYm+3MvebFCZkKArHU4yqcwM0ufKhVA/n3IdXJV712ci40mrSqIHUPliGZOQb4fZtDYsXI39ofVb/aZ/7rR/Inzl6sdahn2VPqzoios30hXLGapBHSg5hPxTDeUeT3ui6eyG+r2BNnvvYkd4frAAuEKt2dFXvJ+q41mjOymk3kg30go//HHYLMBosPIVIz03FHVArQHa/cMi5cyvgpzdouMvVllGK5PzdLXEzO7A4tlFs+Y+XxJr9N1tS78wfiSUdjHRlCVO+yW5StRl7wGSYoVf9mplddLbLtQbKam8rQbUPmR45QIzS3yHkR2mnHM80MSBbsiwvMTOzaQ2JzmjVaRW8tvs00v1zkdwA+6fl5DJQQkA+xuuhioTXiTQTiGpDzN/DxoFFirc6D/3gsitMqdpjRczqeK6m5UKV9I4t+s5gDrJZufcaO3tbQn7/ukhvHvvj7ejv0xixtkw41jRpLPOag8ffGXWEUpXqShdwA9BJBHZmamM+DFX+6QJ7ABC+gHGiBdxJeLdN0GbC303405ghuxihpSY2i9hPZaTcQKkOwml7UwtDEDjcVL9LMC0aIBLbstOg5ZpbQKF1wsI7Tc3TK5lbsJ0rGjVGixfHpB4iLG7d2jo7Wmh/vVp8HDEC/+ga/tgIxC5Pt+YPWEZCq32395XK5bpQTC+e7mYGi3Q3ixdM1X7gMmsGnKyWL4oYNuhLCpm/iQixilEaPZc4lfPdvLUcnvKjWcehn4uegjQRiNrFnipJHy2kLzPTy+WvLI3mdG4a/neOCkHogjpTTotrHxQA4m0QKQtT7DIyqF+YtjQY24r 5ehfxtwg IZ5jhsjiqzyBux1vueUrbCnb8a2scE/qluE9vtgBlsMFEovqRBPx1QbGEPJQt9UupdCMSlJiGM4QZNHfwpLcecQRgp0L9vVSmVpkuiRIwfGQVKi6UbF2hSF8n7nrIB+M0aKj6QrOhO5ZN3UaGLQeYKSAT5lGEgdes13P/iNVRVbgt4epn8eEVeU1E9C9MlxXnuES8UxI9K4itJrgUIIY/LH+4MYI3r2nGvvXY9HZ9KJ+nprAb4JyH9AbdYpZTuynG2yq1nE0IYTMN33TiW3xXl5bmCbjS5V4qkQttxxKx/+I3TiLDVsPM3Qw9CUYBfIHJGYt5JHCPxZA+PlnMgBR69ByBAXvS5oJrRz9I 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 --- 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 56a26c843dbe..0385310f2258 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