From patchwork Thu Oct 10 19:39: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: 13830981 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 0606BD24441 for ; Thu, 10 Oct 2024 19:41:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 101EF6B0085; Thu, 10 Oct 2024 15:41:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0636E6B0088; Thu, 10 Oct 2024 15:41:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E03B96B0089; Thu, 10 Oct 2024 15:41:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id BBFFA6B0088 for ; Thu, 10 Oct 2024 15:41:26 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D8ABC1404C0 for ; Thu, 10 Oct 2024 19:41:22 +0000 (UTC) X-FDA: 82658711772.05.5B87A58 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf01.hostedemail.com (Postfix) with ESMTP id C802940009 for ; Thu, 10 Oct 2024 19:41:22 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=X8S1N0Lp; spf=pass (imf01.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=1728589215; 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=NLs7GtCp2W3Q9BJj11jchN0o8DALdgxfm9oDq7oy5Jo=; b=WIUKO5r4LHCyME0vGOx0n9aicuX0DgAR/dbOQV7g/cDO1xTm4mz9itgn2+c92eUym2ui3u OaGu5B6XbnKqAqe0F6B5e7L4dQHicwIEGv6J3y8QwfwsbtYKx4RPT25icBpMrS9lS6OFOK Wp/9fBR9lQGHhbnAN4F1XoDhDeN2LaE= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=X8S1N0Lp; spf=pass (imf01.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=1728589215; a=rsa-sha256; cv=none; b=ROT2CXjwvd0ljVbEP7DlqDefkuXVRkf/HSSn9CTcsGAOZvohVCrG1mmLpIwT0vl0DD4zTn 1kNw+hkE0YaTXkKhGyJsqu39O2KevFAtjiSN+tkF+vZI2cyu+yNeq760e2OFIfd5REpOJ2 /W63gaF2CCWm61ISmo+U0Cd7OT0g5/8= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=NLs7GtCp2W3Q9BJj11jchN0o8DALdgxfm9oDq7oy5Jo=; b=X8S1N0LpSdVrFfoMMTr4JRID9A usIaeMrHVxAVjFJBb2AK4GNiyTBV4x5SRhvlw9IFWSL4BXL20ibxP0wBPGsDMx8ZxbzWLLYawSzXl n865ySfXiZWFn5xpx0Ar4u6LKyEPTfxffuXC2tCDBUxJTBbNa9ejWANGB3DcMMT6zZDC1R/V1GkzY Yhf26hMFiDfuFRbx8qwJYVmOne6p7Fv3cf0Xd8m2C2mbdcIG+OUAJzxmupZco1LmN09TUemRbtxA3 s+efEWDmAHQISCeBmfL8AXqAgA6lCU0vtAJNAYwyQaQfyTibZKAXpE2UHnops8Ep0fxDa0w93804g ne7zyLFA==; Received: from [187.57.199.212] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1syz1y-007SHz-LR; Thu, 10 Oct 2024 21:41:02 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 10 Oct 2024 16:39:36 -0300 Subject: [PATCH v6 01/10] libfs: Create the helper function generic_ci_validate_strict_name() MIME-Version: 1.0 Message-Id: <20241010-tonyk-tmpfs-v6-1-79f0ae02e4c8@igalia.com> References: <20241010-tonyk-tmpfs-v6-0-79f0ae02e4c8@igalia.com> In-Reply-To: <20241010-tonyk-tmpfs-v6-0-79f0ae02e4c8@igalia.com> To: Gabriel Krisman Bertazi , Alexander Viro , Christian Brauner , Jan Kara , Theodore Ts'o , Andreas Dilger , Hugh Dickins , Andrew Morton , Jonathan Corbet , smcv@collabora.com Cc: kernel-dev@igalia.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, Gabriel Krisman Bertazi , =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.14.2 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: C802940009 X-Stat-Signature: w7xbmq7rqa6itchmfb3ie1n8epdesbz6 X-HE-Tag: 1728589282-450697 X-HE-Meta: U2FsdGVkX18bwrV0kTSuQ9JhLD4HHWMzEp9dnrj0MwktnAUK1VKHyzVLsYsYz0xTJ505lVOf0PLkoW4bgTbECVeQTsm/qf9l/oAyyE86kVJKo0rVNq9Wsm+9GuXORBVxp6vlHKbkEwL+xT0R2GBUKu3pXV0Su2+VwdIO6sGjNBob+Puq6+BsNmoB3wj28ert17MVJFn68oOQpGloe/DXiAmI8xJzlbnyt8Ta9Na//hpTYU8XwWaGTJRAl5eQI5mbZvW9bO4SQM94B57bEEqPSrPpJeIxAOI7aRwGeO5HVBB7dAbMQqVPW+pPRYJRZBQlQlfTLXblDfC8ElXh9mVBlJQRp2KgrMauqVZoy+6UHPpini0hwK5hH95WZG2bNx9WVwmuk0VRR9oGnHCHVdeyEEnxNAdo4szjfgpvPPAAj1Wl38rjmSYKu3OgWo506d7y0Nm1er80Uc7dc6fQ8TRb+GJv9ArLhgoz3uxcy00tfxR058gcQaCT2qZbwI8iDPEBxa/3MF2MZx5YL29csMdUzuKHfnNyNV2U+3tGmpxi7RHImPZnlOwAAHlOzFyuaQpOA/R8NMiJF/OPsF0wwwVBXkje3NGYMnn2oZRZPnFTWDKLuA4KwZQZyalQ+AUBZH/VVDWS1oYPyGLJxV4O1X9oLqu4foW5cuJJuUgsgf3LzOfE/ndPTsl/M/Y8dYbc1lryW2WdVtXqRCirwYC/X0Vc0fqMB8CwdgtpJAk9hJfsXLTuQDXS8CWev4ximbIWtZmclPeEGy03T0rcDeVJAbLx2/Ln48dCcSyB5+SyzZWEdz45FFo6Lq3zhg8yzl/jrzdtWfPUllESZFzbsHApg7hpymsCo9QuOSJ2VmPR1qm1/ik1/rgoa65fK23JwKTMIHB2sOLnWtKubkZ0LDD7mwNPTL9FcA6a4dvbLtWyWnUObJ12qT0NCpKJbFUpwzRDmJriRjuo8Lp0S2bHERT7B5m HHOK2QrO 8VhobOABuh0VRHBgZqZPEr8cX6q704q+Ai31JGqeccitoczpIXOs6hH0tuEXI938hItv/YyPu023qS+IOQ0mGsMlzBlEkeZDVhtlN7JrWH4Up0O8dyCT/ckBMfNqq3zJ2Ykw0U8BlLJ8UatFm/klev1DfupXMDzUyG2Kq5LZSTe++FQVXnmBSzHEYz4Z4knzCTHbB68Sdeca+dzOB+b9J2g0ra/I11pyvae+ic0Rriz1My2x4YEPsRLhQ3ahHDUAKlIfnlN5DkrLdvgM12miw5mXBzVyUZgPFw+ZEVMfCMO1RKUd2l88MHdgxJA1IbZv9cAy/K7r01XTYZj4LivmkAnvVoqj+MifAviFCQVcAjDZWr08nYQfIN6LnCjX/iLDSOXqnT5f+HftuJrjzIJS+AAXHCyL7N/57SBzw+8wna5waSqM= 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 3559446279c152c70b7f1f3e0154f6e66a5aba33..9b232aee4cd6ad8dce64370db0111bd25d3fedfa 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -3456,6 +3457,50 @@ extern int generic_ci_match(const struct inode *parent, const struct qstr *folded_name, const u8 *de_name, u32 de_name_len); +#if IS_ENABLED(CONFIG_UNICODE) +/** + * generic_ci_validate_strict_name - Check if a given name is suitable + * for a directory + * + * This functions checks if the proposed filename is valid for the + * parent directory. That means that only valid UTF-8 filenames will be + * accepted for casefold directories from filesystems created with the + * strict encoding flag. That also means that any name will be + * accepted for directories that doesn't have casefold enabled, or + * aren't being strict with the encoding. + * + * @dir: inode of the directory where the new file will be created + * @name: name of the new file + * + * Return: + * * True if the filename is suitable for this directory. It can be + * true if a given name is not suitable for a strict encoding + * directory, but the directory being used isn't strict + * * False if the filename isn't suitable for this directory. This only + * happens when a directory is casefolded and the filesystem is strict + * about its encoding. + */ +static inline bool generic_ci_validate_strict_name(struct inode *dir, struct qstr *name) +{ + if (!IS_CASEFOLDED(dir) || !sb_has_strict_encoding(dir->i_sb)) + return true; + + /* + * A casefold dir must have a encoding set, unless the filesystem + * is corrupted + */ + if (WARN_ON_ONCE(!dir->i_sb->s_encoding)) + return true; + + return utf8_validate(dir->i_sb->s_encoding, name); +} +#else +static inline bool generic_ci_validate_strict_name(struct inode *dir, struct qstr *name) +{ + return true; +} +#endif + static inline bool sb_has_encoding(const struct super_block *sb) { #if IS_ENABLED(CONFIG_UNICODE) From patchwork Thu Oct 10 19:39: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: 13830979 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 CF6DFD24442 for ; Thu, 10 Oct 2024 19:41:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C59B6B0082; Thu, 10 Oct 2024 15:41:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1743F6B0083; Thu, 10 Oct 2024 15:41:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0631A6B0085; Thu, 10 Oct 2024 15:41:25 -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 DC4216B0082 for ; Thu, 10 Oct 2024 15:41:25 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D01411404C0 for ; Thu, 10 Oct 2024 19:41:21 +0000 (UTC) X-FDA: 82658711730.20.3F0736E Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf22.hostedemail.com (Postfix) with ESMTP id DE41EC000B for ; Thu, 10 Oct 2024 19:41:21 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=DWh5LAbu; 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=1728589214; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=sdXGjKgs/rhRe8l19F01/brI44jeC/ablpb8vlTIOo4=; b=jR1lyXZ4w0GwPfWWz+RyoG6YPDgIl2bHzNky2/5K8cicaeE11Q+U3vxixw7rav9I+MZqEO BOBxxBeqpAYvG2h1ErF42wL0YBrA0f9bhTsr8IzN2WAvRhFZKqqZiXqG0/jaY5zAdiQiog n+xLCIaFR0/XuW+QcXpJn6Zc+ToHwNA= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=DWh5LAbu; 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=1728589214; a=rsa-sha256; cv=none; b=Z7dZiK841HI2kpXU3Bh8CgtZntyh1twPJwjNCPwmcOKBq0ouE5ITLmyzFpTdjzgW9gAZ9Z FdzV5mdF3vaWTf/mNDqrZsdUlIaSDkSr151aO6vUSN31pOsgfrKyb4QxC5l4bDO9+9aWIP AlOqNGgHObMahCWS/2xto1YlA1I5TFk= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=sdXGjKgs/rhRe8l19F01/brI44jeC/ablpb8vlTIOo4=; b=DWh5LAbuzvrFfI8q3pnduTIg0s RXIu8j3fHbDuSLBLGVQsUPFVBhbhX9XL5iBvP0PfwDrJpJFWYfbEJJVexYEcByIq/md6nNcVKO9VX lsEGXuYGUFtfvKdlEHpZGscyOON7IxJcGXhF17P3W5tmsZwb8RUgSusxruV+oi4LkGgHCkmPPbGO8 toQDAbyZixKMWnkXBYJx5F2P/77DtFxkskUlpuuhpUJ6NN3nDwuPfGlPeasXsW1TNA9yWA2wCscvs KypErmDLlSXacL7q+CPiTmQjQ2JHvTXQVrlp872EyvNHKj14nv+tAAmtcgWIgRvQHzjJaNWBDg/ci 07QFXuew==; Received: from [187.57.199.212] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1syz23-007SHz-7a; Thu, 10 Oct 2024 21:41:07 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 10 Oct 2024 16:39:37 -0300 Subject: [PATCH v6 02/10] ext4: Use generic_ci_validate_strict_name helper MIME-Version: 1.0 Message-Id: <20241010-tonyk-tmpfs-v6-2-79f0ae02e4c8@igalia.com> References: <20241010-tonyk-tmpfs-v6-0-79f0ae02e4c8@igalia.com> In-Reply-To: <20241010-tonyk-tmpfs-v6-0-79f0ae02e4c8@igalia.com> To: Gabriel Krisman Bertazi , Alexander Viro , Christian Brauner , Jan Kara , Theodore Ts'o , Andreas Dilger , Hugh Dickins , Andrew Morton , Jonathan Corbet , smcv@collabora.com Cc: kernel-dev@igalia.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, Gabriel Krisman Bertazi , =?utf-8?q?Andr=C3=A9_Almeida?= X-Mailer: b4 0.14.2 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: DE41EC000B X-Stat-Signature: q8bc8b9faz3x7kfkgmuar5wdfep663g7 X-HE-Tag: 1728589281-885341 X-HE-Meta: U2FsdGVkX1/a+BcjmFyXy2pPq7L31oNkvBqsKG9VByrnkjF3mBpdQRorwc3Bzq2iBl01ZHjzAHSpubDxEKOwnyhn2ZkzqRDP2nj8SFUv8LwNMJKzoIAHww2GVHoaMg9psYo6eshX8Tj3cBWy14jwvvVf5Ugj1uAgngbOp+CP6l6Am6kv4h54OhHXpKfHZfVCC0MpEAzlgPmIPca18rH5HXfQD34Cmgltl2NuBWoWfcYzR3aykf43ZNLIC3TKr7A3QfcYvUeiyIumSaPSj7H4pJIAYvKyNZppyIG47tAvkhq10FsKwijY14DPFLK6oZJaVtZ14WQBKvC7CoQpQZJi7+C73DArZB6trbTAHl4Lv4jNIkRsQ3o+sgwCkTevWY0blX0am7/smSmcAWgStowrQWikowzdU3+pGeXt/9fUmAmtUnUJyoyNKIkAxkPKI6z7a9TPR+Cjwig/wgoXjZlJW6zsf8BZqs5uPgUJd1S4+YVc0gl2JwkpccUAdHdmBtoCcewVeWiMEhLoradamE9KrmsVOQi7w3w9mdqym0uZFwhum3YDDX7IR6nj8KEotYHXXIGdMiw8igNF906gy5nJ45UtmF5oHMsbn0xoQM62eFLqp75EgEZzsH0vX1ULbKiVwLdfu+biqqMzE+8AERSz7XYON+SQq7s2CYVt2rnriisY0odMtmdbhp0DkXcUF6Ca/buO0BXy48nQOC27+pYYuK9wLBNVs+wwYrG1NTzcV+SR0JitUdhcojzO6ntO7MkTqAIHCmuRK2pDbXVfzpvMCZKPQEnx4y/aFuXk6SgDbL06wVYm/zGMjbkFagb22Lw1idFmjRvISfPxlXIWmq6KJa17cxqchM/2cJWRUngD5aaJWxZFFeIB21HWRswFnTnxlR8Q/Tc0gRkuuyYmBIRowwCIWWdr5KWeOIgkcA/PvYsJvpgHquCl5XzN4jDeFqzI1H4z7joD5BkYMAz7o4X KDtOZmT4 0dFpo6zqAnXbf5hABcMee9/U5vqZ+TiFZcvKdnQxlduVEqDiDfYSUYj8AVbIxZzYYNJ2Uf+Dnd3nLzRZQ0v91My3WJsBcJoAWEEfe7OXx8w0u1gJ9fFflzu8DRqdn3PlhC0jd2mxzxm6gYyugxMu4aF7hS0qxT292ynZAzJTswAAmHlFIWmr6jGYd6ES6drxgyj5kjE1hm0q9FDdrfKA6NobyCwFehiScqtbtdnUwBJI5N3p/K0VXu7LvCMQ7A27TsYJigigZh1gi/8bHo3hD6IfVB712UB/8ki+Ql9c1V4ETWYBiGgr+gClXjqZm6nJ3ziOSwGkwNwgQviTG7VlaL3nEjk9NrKErYIyZ73WczehGYf91ASIJJeQ4xIPAaziHyCm6 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Use the helper function to check the requirements for casefold directories using strict encoding. Suggested-by: Gabriel Krisman Bertazi Signed-off-by: André Almeida Acked-by: Theodore Ts'o Reviewed-by: Gabriel Krisman Bertazi --- Changes from v4: - Now we can drop the if IS_ENABLED() guard --- fs/ext4/namei.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 790db7eac6c2ad5e1790e363e4ac273162e35013..612ccbeb493b8d901c123221ef6573457193dd16 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -2395,11 +2395,8 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry, if (fscrypt_is_nokey_name(dentry)) return -ENOKEY; -#if IS_ENABLED(CONFIG_UNICODE) - if (sb_has_strict_encoding(sb) && IS_CASEFOLDED(dir) && - utf8_validate(sb->s_encoding, &dentry->d_name)) + if (!generic_ci_validate_strict_name(dir, &dentry->d_name)) return -EINVAL; -#endif retval = ext4_fname_setup_filename(dir, &dentry->d_name, 0, &fname); if (retval) From patchwork Thu Oct 10 19:39: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: 13830982 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 73FD1D24442 for ; Thu, 10 Oct 2024 19:41:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C15F6B0088; Thu, 10 Oct 2024 15:41:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 372FF6B0089; Thu, 10 Oct 2024 15:41:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2120C6B008A; Thu, 10 Oct 2024 15:41: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 00AE86B0088 for ; Thu, 10 Oct 2024 15:41:30 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 54149804A7 for ; Thu, 10 Oct 2024 19:41:27 +0000 (UTC) X-FDA: 82658711940.22.A0D0D00 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf15.hostedemail.com (Postfix) with ESMTP id 4A0F9A0009 for ; Thu, 10 Oct 2024 19:41:27 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=JscOpjLC; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf15.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728589244; a=rsa-sha256; cv=none; b=T4uEM06R8MYzHlnqUb6Ia3bH6BGW9xHaT6/HjBheFsP51ZSoG2k6j15LknvsX19oVw+PfB Okzh/sQ7Rcb3Dp2JTDirSHdKfbhkcvcJQTPk/8YUnzaNykUM67+dyF88S5qMxFZ/Rkd4Ea UPffOew3+342tOtC9aT9CQ7jNCdKPzw= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=JscOpjLC; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf15.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728589244; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=hhDlIiM2rMTHaWInpW6Q+AoMhFTJClxESMUDFdoVjOU=; b=H4+WSB0Yk6f/6qr4PRQHnmAb5QeGEeaf2RDjJmFNKvjUPh+F9v2n+4swT4Zk+/6pZueWdy t7WniasOmzHZfe1YZUBaTBiM6meQu3wYuCDhwx2Sxm/BpJefHlZTvYvN2SvuEyswkv40nm MkoRUEfWAFbEamF4RbGNdVxKprwA09Q= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=hhDlIiM2rMTHaWInpW6Q+AoMhFTJClxESMUDFdoVjOU=; b=JscOpjLCcDAbWr+y72BNgPbFuT YFffuCfFxjs6RPw7PX+MxgkAyxRSQEaucgc/5WtOLfUHuenuf4pgFNElvM3fOxGP1DFhqC35aoHCx Ov0V/eXe5I0g9YO7VY2It9HBYn85ZVn2LrOzoxgFLj19k5/yFH9Jl41GoX5ZJfrHRqEBtxv4pcMic 67rBjBCnMcnzYBK4rO48DMznqloTqrgwAV9KR1x0daA67b3mZiInkxDgCQ2ByNCNCoG+/J+KYQnpT og0jUep8IQm8/pzZ3bZ5nFan0FK46EBCtJo01dhQUaPwhfWdqEBHXzClxUvjp4yZYMR/dOAp3HLql toZs0oOw==; Received: from [187.57.199.212] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1syz27-007SHz-Q3; Thu, 10 Oct 2024 21:41:12 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 10 Oct 2024 16:39:38 -0300 Subject: [PATCH v6 03/10] unicode: Export latest available UTF-8 version number MIME-Version: 1.0 Message-Id: <20241010-tonyk-tmpfs-v6-3-79f0ae02e4c8@igalia.com> References: <20241010-tonyk-tmpfs-v6-0-79f0ae02e4c8@igalia.com> In-Reply-To: <20241010-tonyk-tmpfs-v6-0-79f0ae02e4c8@igalia.com> To: Gabriel Krisman Bertazi , Alexander Viro , Christian Brauner , Jan Kara , Theodore Ts'o , Andreas Dilger , Hugh Dickins , Andrew Morton , Jonathan Corbet , smcv@collabora.com Cc: kernel-dev@igalia.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, =?utf-8?q?Andr=C3=A9_Almeid?= =?utf-8?q?a?= , Gabriel Krisman Bertazi X-Mailer: b4 0.14.2 X-Rspam-User: X-Rspamd-Queue-Id: 4A0F9A0009 X-Rspamd-Server: rspam01 X-Stat-Signature: my9mf4i9pb9c4paow3inxharqh43b68k X-HE-Tag: 1728589287-368337 X-HE-Meta: U2FsdGVkX18oIOq2vqj2c5TmATSESKP+0PBPLuxN5XyGEUJEbVQm/Ie2vVLq+KidH6PTJyaX/9PpFD8B4fpPuky6/U++ZWYIrXOhgvUsrKY1uwKdch80vwIW4izU7NkPOOHg2uNVwjYGwmyuU9LOvDsJs7nObV9iIe0paI4D5cYI91+fzQT3IV/JSel6R9OVMT/wV3HYrXY1IN/TOQoYFZ6AAdLY7D+MT1cxp8oo7p+bnof3+hrrRsRvAqINm7nCm8Zn3etVke6CmFmOAwqkZ0hufJLbEyiFA42SoEY22Vcre/l0YAr9Ne2AnTJRwsF2O8ezOBA2wHEmArQPQ/UIVLukH1DrdnPBJqU8cpNMXNZ0RwN5AO+iNIThdL+aLKeSAej/2OF1vgtTbFt0HrjTYtLh7QDKLcPp3K+LokMrSOl9MQ8m2hnD8eM0Y8nm0EaR5v6Vgls0r+zDfYolWov88B+VNxF467JfCyXowFLYcz5aJnUUPwPjkhcJPbxmDh60yPXBRpSGPyOyvnYFfGT4/jp1tbSRbXb0sB3bqQqKvugaEf9CHI9cNA/0/KcMORsxYMd7zwfYxfunpy35cKneKnqXCX2WJZzmXKMEs/Z2p9bX1T6GIVB9wO/JVDx9sTXgVUOuFef8lRY8cJ/rL4IrE90LhwC5RNr4iOHb9u/TOaDjgTa5zELXiEqO8cMmj7FRffz/hLiaP9HQQMGOYMBOuXCpYv5hOh0fgMWuZF4vR1+zPRa+Vo5C4vI6HBSTZPVXVhdD6/+yGrxHgxAMdS2Te0oqEEtqRDWkRecEY4qBiMyK4bDGaL1UIWBFN1VvhHJzycGw6Q/PobXuyPGSIlGkhaJyS1zBaEgEz13CuyotolHM1Jhm/a4WnY1QRuiPYoEgQ0Orw+fDizy86QZiS9Rw8BLNx1fib4a2NRUtAeRtIJ79IW8qHnfPFYtgHix3c8jtkI+J5lBwyXxf84zcPUo idDHzecW BfWQLuXZs07jBIa+G4jr5Ly3K5c5luTUdlVxLA5ZOUNIu/1jLgCG3nt7JiEfoKqVXp7O7qM/Rjn+YhIkbpEjjC45PukcpSWYPn19zwIligr5wg6Onag1/gt0d/1zZQhiLOjn8tRm4kTjNECjJt0mhzvN6iAMTD7uIhaia6omKuT49AIctu6vD6RQBwcW4Qd+c7J1fOx7JWZ0ebuCRdJx0w5zqjzWkq6hJ7WlG+C3VS4qDvdZysM8NiSl3oNwvQu/HS3Fz1cbns/TB7hPOmy6ApC0pBO543hBYtpEIClurOiZoDZ2TYBADV5cpKNes4ExOn5hidqXAI+faHyA= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Export latest available UTF-8 version number so filesystems can easily load the newest one. Signed-off-by: André Almeida Acked-by: Gabriel Krisman Bertazi --- fs/unicode/utf8-selftest.c | 3 --- include/linux/unicode.h | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/unicode/utf8-selftest.c b/fs/unicode/utf8-selftest.c index 600e15efe9edfdf6d04cecd162e84f1f5a59c5e1..5ddaf27b21a6543770917d5a837e86e12eee0b81 100644 --- a/fs/unicode/utf8-selftest.c +++ b/fs/unicode/utf8-selftest.c @@ -17,9 +17,6 @@ static unsigned int failed_tests; static unsigned int total_tests; -/* Tests will be based on this version. */ -#define UTF8_LATEST UNICODE_AGE(12, 1, 0) - #define _test(cond, func, line, fmt, ...) do { \ total_tests++; \ if (!cond) { \ diff --git a/include/linux/unicode.h b/include/linux/unicode.h index 4d39e6e11a950c76f78d775fd6f351296f3d7d53..0c0ab04e84ee80227f9390ad0498f21a7ab7d34b 100644 --- a/include/linux/unicode.h +++ b/include/linux/unicode.h @@ -16,6 +16,8 @@ struct utf8data_table; ((unsigned int)(MIN) << UNICODE_MIN_SHIFT) | \ ((unsigned int)(REV))) +#define UTF8_LATEST UNICODE_AGE(12, 1, 0) + static inline u8 unicode_major(unsigned int age) { return (age >> UNICODE_MAJ_SHIFT) & 0xff; From patchwork Thu Oct 10 19:39: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: 13830983 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 CBBF7D24447 for ; Thu, 10 Oct 2024 19:41:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2AF5F6B0089; Thu, 10 Oct 2024 15:41:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 261786B008A; Thu, 10 Oct 2024 15:41:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1028C6B008C; Thu, 10 Oct 2024 15:41:32 -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 E3B396B0089 for ; Thu, 10 Oct 2024 15:41:31 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 561F31A046A for ; Thu, 10 Oct 2024 19:41:25 +0000 (UTC) X-FDA: 82658711982.21.484314E Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf07.hostedemail.com (Postfix) with ESMTP id 789904000E for ; Thu, 10 Oct 2024 19:41:27 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=DAwZ5BTr; 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=1728589138; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xvtpXgeaP5+3Qey4SeTiBPWN2JmcKdnKWOsB+lrnGJo=; b=U8MuxS9hRY8PT2j0fweP/Mxx5ntKviWVYKOJtD1VageOK6kTJv7IYqzQO6rZlCu0IjNA7w ad10ASzmFNVWdRJciEMStLp8Rp6Ty/m8oq28H6261Di9fRe/01+TmP5pcyocuHzV1YKzIq IwwqDG3URQOpALPb5EGP2aFzWQbLtzs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728589138; a=rsa-sha256; cv=none; b=szLM0ugTZGRKhaNBsPwBeJBkBdaQBN5R3h52QXy97W9ghr97ChLhIvXVNF7g05QLTNXITf w2eG22qHErMYnfwISDXgfOAMeO6jsjkF3x9W2Fn5JpC1zKIWsMucK9ALak1UCkr1w1LA9Z X1BMMryY6FkYkpquq4UG8vxlpdg1G+k= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=DAwZ5BTr; 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=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=xvtpXgeaP5+3Qey4SeTiBPWN2JmcKdnKWOsB+lrnGJo=; b=DAwZ5BTrIxiW5InqyottPfBJ6H GOXT5VcX3s+KAchFmfi/4sOsDev0Nd6Wjml60PP2IP+OqHdXhJsk3obIdbu9VBk5Uo0ud+8+MVW4O qQecqteTmktYmhDBsFkHZqESd8rZ3wofZeMJTkXdN4AFjU95K4g3H7rz3YGMqRFj3W8PTPGMtkKHP N3Sr7D900/vDB9fM/xwTYhr32dyJiEBcmxx//4MIPAkAN2Dm5A1sT9lL4o0+NDjmbNT62tfUSJVvq kaj1lZQkAIhaY2L2XYTzy3A4uck3TW56R9Lu1Rpw+bmoUBUTy032CVfBydcIb0tO2eTES/dkAeyf/ VGG7orQQ==; Received: from [187.57.199.212] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1syz2C-007SHz-CH; Thu, 10 Oct 2024 21:41:16 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 10 Oct 2024 16:39:39 -0300 Subject: [PATCH v6 04/10] unicode: Recreate utf8_parse_version() MIME-Version: 1.0 Message-Id: <20241010-tonyk-tmpfs-v6-4-79f0ae02e4c8@igalia.com> References: <20241010-tonyk-tmpfs-v6-0-79f0ae02e4c8@igalia.com> In-Reply-To: <20241010-tonyk-tmpfs-v6-0-79f0ae02e4c8@igalia.com> To: Gabriel Krisman Bertazi , Alexander Viro , Christian Brauner , Jan Kara , Theodore Ts'o , Andreas Dilger , Hugh Dickins , Andrew Morton , Jonathan Corbet , smcv@collabora.com Cc: kernel-dev@igalia.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, =?utf-8?q?Andr=C3=A9_Almeid?= =?utf-8?q?a?= , Gabriel Krisman Bertazi X-Mailer: b4 0.14.2 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 789904000E X-Stat-Signature: d3xi3jkt6ddfa19do4odja6wtnbz1hrg X-Rspam-User: X-HE-Tag: 1728589287-267855 X-HE-Meta: U2FsdGVkX19RkGUqeZthOZ8Ul7arvWkK8Kd7Ldk2NoeZVn084m6E8VElfeBfrn5gZUPFIkj0SzZ2XiqhJ1dh09nDrYOIx972hThfaBC2uzTyRcyDmNaJBm0OmbJs2wqpT/4+qKPnSR982imt/QVFcspGqPd8bImSUslGyc3Dcr88xbYAtrl7ajN3hhl4w2bji7Eqgzw/6A7Mmtx0hqDKKWs3b7MCukznikVEyxhI3JNbCfo415OSDtZ+HyNJmSTe1kOE4O6zJHMyhBxOIhlsFM9hO3k3i8SmuG+WcxIVs0/bRbOMib5m3lisq11B3LjTEIlHuCbQA0+bEXHadl/fIb7XpSNDsw9QiCJQFfNwgCe7Mzk156uJXl52d+ySDbYI50l23U8rC8jKQtA373XiudX33PAftMNQb/MuxGfjqjWM0sfDVlYAT+fXFqy+UEOScU0uUQLnPAAXNFr9sF4WvbyUnvtajYkqtxlEBxmrUmpyKVaChhxOk/SDYGjKCzLXEKHpq0JNyd5cwMa64EmicaS9JQcJId+69WGacGp9h1wdDT2X0OWkTeK4iwJkDBigvYeq18hRZ65Z9qCDF0WY+MNdPXFblkveXw6Ms98ol9F6Q6X9Q2mxaYIUimRrd6ZgilTGNMfI7cVAlaW2LkIPYssR2plD3yoyiXE83SRbVzXTwCZQTbeqjjVW+rmZdZk6UBLXOvPAtgLZn9/D2tLlAfEVr4o4qQZdUluSnhbgBv+wNwAgGnCRpZTsuM+WmmubKh4qQ/ve4zx7qKE+Dtnf4Fv+Kw1YopOGMLBzBJi0lMwR0jWTyQCTwEvhV9dUzXUN3YQopnjF01/Y2+V7rk4vof9zmeRg39nZcc/+hwCFZn6kRSScYqMZYD2ULCxl/l9K5iX3mtaUTcPkdM+hYRGSF84tpT11LS9X/fuMkVnDq+/jTR6OpulrdKDQa6IpEP5WQB+bdrsZuULY5p9qLe/ RnjVw07G 5q2sq2JhRnrf/kcRuIYhL1A6LiHDjPr7Oayar/SRAHlt3fPhnc/PQGJeMGT8HjKnVXW2+B1GFoZWYCGLHYGd8DVLrqgdmX5Mw7C9Tx2uUW2Cou6hHlvjgwxnk8AEHR3jzuT/Fb0r5zfxeP+pdpYCvfwoyjCFFjRl7avxUwKlHCNDsfJbxzHNY+rNhrbRxO6JUNHaTpvXX2vH9X9J+/esYI2WpDHOmzSN7fLVjy5yWvQDByCLWgL0OejgECu5d5Q+9/loYza2fNxh6r5MYjnTeThxC2tJXp36hjnFiP058zthLbTzMQ3J4PVmT3bD6S/CNXsOb27fBOzRngFdJdrlsPrzXefIEDXAn432koRa8inAFJ7UFwwxA7d0h++NsGz8/+D1q X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: All filesystems that currently support UTF-8 casefold can fetch the UTF-8 version from the filesystem metadata stored on disk. They can get the data stored and directly match it to a integer, so they can skip the string parsing step, which motivated the removal of this function in the first place. However, for tmpfs, the only way to tell the kernel which UTF-8 version we are about to use is via mount options, using a string. Re-introduce utf8_parse_version() to be used by tmpfs. This version differs from the original by skipping the intermediate step of copying the version string to an auxiliary string before calling match_token(). This versions calls match_token() in the argument string. The paramenters are simpler now as well. utf8_parse_version() was created by 9d53690f0d4 ("unicode: implement higher level API for string handling") and later removed by 49bd03cc7e9 ("unicode: pass a UNICODE_AGE() tripple to utf8_load"). Signed-off-by: André Almeida Reviewed-by: Theodore Ts'o Reviewed-by: Gabriel Krisman Bertazi --- Changes from v3: - Return version on the return value, instead of returning version at function args. --- fs/unicode/utf8-core.c | 26 ++++++++++++++++++++++++++ include/linux/unicode.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/fs/unicode/utf8-core.c b/fs/unicode/utf8-core.c index 8395066341a437d0c20d6ab49b0a022eac7eec5c..7f7cb14e01ce8aa87d14dffdd767f63a90cf11f7 100644 --- a/fs/unicode/utf8-core.c +++ b/fs/unicode/utf8-core.c @@ -214,3 +214,29 @@ void utf8_unload(struct unicode_map *um) } EXPORT_SYMBOL(utf8_unload); +/** + * utf8_parse_version - Parse a UTF-8 version number from a string + * + * @version: input string + * + * Returns the parsed version on success, negative code on error + */ +int utf8_parse_version(char *version) +{ + substring_t args[3]; + unsigned int maj, min, rev; + static const struct match_token token[] = { + {1, "%d.%d.%d"}, + {0, NULL} + }; + + if (match_token(version, token, args) != 1) + return -EINVAL; + + if (match_int(&args[0], &maj) || match_int(&args[1], &min) || + match_int(&args[2], &rev)) + return -EINVAL; + + return UNICODE_AGE(maj, min, rev); +} +EXPORT_SYMBOL(utf8_parse_version); diff --git a/include/linux/unicode.h b/include/linux/unicode.h index 0c0ab04e84ee80227f9390ad0498f21a7ab7d34b..5e6b212a2aedab7ebf4363083339f4c5e9b82f8f 100644 --- a/include/linux/unicode.h +++ b/include/linux/unicode.h @@ -78,4 +78,6 @@ int utf8_casefold_hash(const struct unicode_map *um, const void *salt, struct unicode_map *utf8_load(unsigned int version); void utf8_unload(struct unicode_map *um); +int utf8_parse_version(char *version); + #endif /* _LINUX_UNICODE_H */ From patchwork Thu Oct 10 19:39: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: 13830984 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 2DBF2D24442 for ; Thu, 10 Oct 2024 19:41:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A61F6B008A; Thu, 10 Oct 2024 15:41:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 657476B008C; Thu, 10 Oct 2024 15:41:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 520C36B0092; Thu, 10 Oct 2024 15:41:37 -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 316796B008A for ; Thu, 10 Oct 2024 15:41:37 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D87551C4C0A for ; Thu, 10 Oct 2024 19:41:32 +0000 (UTC) X-FDA: 82658712192.15.A80B7E3 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf25.hostedemail.com (Postfix) with ESMTP id 4729BA000F for ; Thu, 10 Oct 2024 19:41:34 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b="e/wI86TS"; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf25.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=1728589193; a=rsa-sha256; cv=none; b=rxqXXiSj0hP5V8kFsLdEGz94JiBlNuvVnheua3b1yRoba14r21PHyF3f9GuvO+2Eonj9fH eYf8kNHcLP3uqxoQJwgMfl9Yg0jqJw69/tPRCsVXIUx9qSFrGDszSuMxTA678qith5R9O9 Pg0ZMsYKPRzoBWKD5ExSbPO/vfOfkbc= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b="e/wI86TS"; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf25.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=1728589193; 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=Yy1QkMBVz1rUhANkqZgd4aZpMCC+lFeHbVpyTkY8ZcE=; b=W3MjzcbY0aqxIm6Zpe/vLMcPeBAe2IFDqVjv4u4A18y5pjRaAMN1RhtU+NBUTJWH9vqreD ewB0UKsURdbpYpXkdUO8yJoNyV/fGIRF1JpKxOOA8MgPnmRQrqGdKxT7fZlLzxuNtiouGk fhnC36xcsM3R/iIWYY0I+aL5cJu9d+I= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Yy1QkMBVz1rUhANkqZgd4aZpMCC+lFeHbVpyTkY8ZcE=; b=e/wI86TS/CqLCywlrfiwkp1WUs HM/n+0gxZKeHi6CUJE4brwibgsgjJv5gT74ZYWGrFkXmIbYetmTe+Pc4o0xdsLaAhndFe+gcNyVKK QiVos7aFwQEM+FSpqTj8Zw/DYljmlNx5FvTjoIHE2/I7FmHETd2nrohp+eDgPu3LlFycnJEd+xb9Y P8MLfHz15A6Enve05fWqu+ysOgEIA7H3fypmIMubJzoyA3rnyc6TVbrx/FT911lZmvvVViVyOW2cY y8+7EkHtdx05Gskguah8myRuScZEEYfuFa5XTIKIrBUZ+wzJvwHLIoV+SDzmC2ia5jTs5Brqcyot+ qlMLVCxw==; Received: from [187.57.199.212] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1syz2G-007SHz-Nk; Thu, 10 Oct 2024 21:41:20 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 10 Oct 2024 16:39:40 -0300 Subject: [PATCH v6 05/10] libfs: Export generic_ci_ dentry functions MIME-Version: 1.0 Message-Id: <20241010-tonyk-tmpfs-v6-5-79f0ae02e4c8@igalia.com> References: <20241010-tonyk-tmpfs-v6-0-79f0ae02e4c8@igalia.com> In-Reply-To: <20241010-tonyk-tmpfs-v6-0-79f0ae02e4c8@igalia.com> To: Gabriel Krisman Bertazi , Alexander Viro , Christian Brauner , Jan Kara , Theodore Ts'o , Andreas Dilger , Hugh Dickins , Andrew Morton , Jonathan Corbet , smcv@collabora.com Cc: kernel-dev@igalia.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, =?utf-8?q?Andr=C3=A9_Almeid?= =?utf-8?q?a?= X-Mailer: b4 0.14.2 X-Rspamd-Queue-Id: 4729BA000F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: r6wyqhisb78qqee18qs39rt4xy17roic X-HE-Tag: 1728589294-603602 X-HE-Meta: U2FsdGVkX1/3ASL3icOCuXKQwMdiyb/oRvm1E1dHo+SMXTBwNKfMXhQbBdc0Iw7w16066yJi+113HZx6u1OJrIDHOu0d3gbrxY3Se7GJ0URmpdE+Xq0gyzbShMnqs35ynXpB9nw3NCP/tJNS682/hxYRENOUQq06DvWxDog3DAuMO3j0HLXSb0zTYzJKPpJsKfI4FIRfYpwLYeKt+Ac5lJC6wtTAjlMlbox53DKCBDxzSINKl8r9aR084Z2YMSLcXI9/V87c8tCsAvaWEQCkbfvJd2Lh7jdGBfgcgsAqNJ5U0N6kZ4Cqyynlr1jHAb73Q0+OQkJbAunPELyqJuUqQPyFpSnklRQ+4RF3eoqalMFkZe5LWl0uEMsS8AauRPOzhc84gVS4xHXBKAmPVk2aQONZ8NMsnSNfJO8NwuY0JhjaCiVdEi3BuHW6xHOOJyl76CwMkeGfy7ZUgN/Yg/BfC93Yv/OHIaNdI3fS3GXX4U7j0ihZuk9N+uhxne0QsBrsRyvq3Q3UFV4fk6sDUzPt82JilA5MgJg2I3toghW1WLlFq+jQt0KLtoY/cRlV8TQhlmpo9Vw1HC/A/MR1Djf3fYgFkzEEV2PTUrVYcE6er6pILXAiizSiPMr7NF3i7SBarTqKHDX6Q37pjU1MBwUt8Z7iohkXOcNLZwogOhLm3gPynKidBRH8h2gt2RXOV+MxDsBCZB04HYejHSpAhDlb4AC6h+W7/9Xsm8mL7grZhrnf69ZPBnnYWfCrPzoJ9jT24eKJ/SJMAvGQwO++DuPpdy64OjiwnTivRAaXRnhazMnadLp1+S8FyBZxAQP9uHgxy6rBPwvBahQ4smo4pSwYbm50z2HZI9Jm4AQLcVvmnKfentwSv6KNOT5WLvktPxmOCxktXd0+c2sl1z8OGOMtA5wrLNNQTNpg0jZeP2cyLnzEsZHIl665hBP2kWY3SuLxUTB6zpaHVvaO7ZlZqt0 RJGaHPdx MSHNdkDk52BFDfe0ACUCl++1DHECa3WKwdr88PmBZu6Wu8BfS9ilO8YSH3Qikdgf9hO57ngtj7vCaZC06Ge9jwbsfYrpRKirrXTYmhLlR2RL2AOsGvpfJfemCHz7nnGntX+0pYEepRIQRdxxqkuEgIk2hho6FB2QWteezVSXmZ6n0bHBVbBdlQGWQBvdYbWaGHc2rQrda7hE2ZwZn/QIdIL0TCvWMS5ZfbZOV8cM8B2daH+eajjmnMR1IDgb3WfTTkvJ/Pp3JWVSFDdXsKVDUDYK5VYkD1JxeSGlttkwbpBCpjZHLqsPGG4Mncqdhi3B9RkONI1fkGZxKK8VurfCwzKBmAdg2YW95ODd7Hr/tp0cbUQRQLoP5anM2WlZThwE06sCp 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 46966fd8bcf9f042e85d0b66134e59fbef83abfd..7b290404c5f9901010ada2f921a214dbc94eb5fa 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1791,8 +1791,8 @@ bool is_empty_dir_inode(struct inode *inode) * * Return: 0 if names match, 1 if mismatch, or -ERRNO */ -static int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, - const char *str, const struct qstr *name) +int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, + const char *str, const struct qstr *name) { const struct dentry *parent; const struct inode *dir; @@ -1835,6 +1835,7 @@ static int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, return utf8_strncasecmp(dentry->d_sb->s_encoding, name, &qstr); } +EXPORT_SYMBOL(generic_ci_d_compare); /** * generic_ci_d_hash - generic d_hash implementation for casefolding filesystems @@ -1843,7 +1844,7 @@ static int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, * * Return: 0 if hash was successful or unchanged, and -EINVAL on error */ -static int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str) +int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str) { const struct inode *dir = READ_ONCE(dentry->d_inode); struct super_block *sb = dentry->d_sb; @@ -1858,6 +1859,7 @@ static int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str) return -EINVAL; return 0; } +EXPORT_SYMBOL(generic_ci_d_hash); static const struct dentry_operations generic_ci_dentry_ops = { .d_hash = generic_ci_d_hash, diff --git a/include/linux/fs.h b/include/linux/fs.h index 9b232aee4cd6ad8dce64370db0111bd25d3fedfa..21e183e5041ed029bf47fda018f44b20bcdd4389 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3458,6 +3458,10 @@ extern int generic_ci_match(const struct inode *parent, const u8 *de_name, u32 de_name_len); #if IS_ENABLED(CONFIG_UNICODE) +int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str); +int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, + const char *str, const struct qstr *name); + /** * generic_ci_validate_strict_name - Check if a given name is suitable * for a directory From patchwork Thu Oct 10 19:39: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: 13830985 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 BFB7DD24447 for ; Thu, 10 Oct 2024 19:41:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A03246B008C; Thu, 10 Oct 2024 15:41:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B5546B0092; Thu, 10 Oct 2024 15:41:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 87A1F6B0093; Thu, 10 Oct 2024 15:41:39 -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 66E896B008C for ; Thu, 10 Oct 2024 15:41:39 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B3E851A0752 for ; Thu, 10 Oct 2024 19:41:32 +0000 (UTC) X-FDA: 82658712318.07.72BF2E3 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf05.hostedemail.com (Postfix) with ESMTP id 9A439100009 for ; Thu, 10 Oct 2024 19:41:34 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=gdw40U8C; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf05.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=1728589253; a=rsa-sha256; cv=none; b=ekj2updKnffiamWI5/R3VQDRsLEXnuJVJeaCJSMOCJzscIYQ/JmG1nrBBRqezoQNFkcWsr hkQ/gkLGOK0HKwnhXGJt1nBEY2x389d4kpjqrDNQkGEJw7WRJM2SILAe5TJdRstFyqh7g6 ZW/FcpoZD/A8f5BX/pMWaCiZAkd8z50= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=gdw40U8C; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf05.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=1728589253; 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=VzXfvIbzNG0CSJ+bJDRaQbQX3trBLicfbCXoWczurs8=; b=y7S9y6/Cd9nBcHiQ15bKOdi3ZS+Dmaqx8DGkN7+ncRH6rBiIOTYgDTWAjbxHci8JN2AEbz UgaQtit40CXcC25RVq6LhIAFUwITSkZdvp4YyQPHq3E7kHYrCZe6RELKuTcI3kfa7Z/Plz NDVjLblMEdcNs/jfqGtbk458ntK0EG4= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=VzXfvIbzNG0CSJ+bJDRaQbQX3trBLicfbCXoWczurs8=; b=gdw40U8ClqfhBNEr1zvH72DVze ei/o8WrtCUhyyOBxKWaOESNuBIM15Dnar7hBW/4EIqTwb3xfHTvvKWmrM2jcJ07SSqrWCnGhcMuBx OmZnI/kmTHDgMBqxOIfkFRPIzYBe3ay0VysEQqATyKPnMrZZok+8Xz8bZU+BNhlmao9bUfyzRFnLP endEIXVlclO+Q7IRSMHMCELHso5NIZpycJLpRgV5mpZcA+dKJjSR034h4SHkPxDTO2djEpcuoHZ0R 4bktloCNris/aaWJCEljs72STAPAvtsHs8m9TCIEPvUEf2qdj3rvIqXVgF1iELs23iWDjQ14rgrGA sBZ9+Ctw==; Received: from [187.57.199.212] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1syz2L-007SHz-30; Thu, 10 Oct 2024 21:41:25 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 10 Oct 2024 16:39:41 -0300 Subject: [PATCH v6 06/10] tmpfs: Always set simple_dentry_operations as dentry ops MIME-Version: 1.0 Message-Id: <20241010-tonyk-tmpfs-v6-6-79f0ae02e4c8@igalia.com> References: <20241010-tonyk-tmpfs-v6-0-79f0ae02e4c8@igalia.com> In-Reply-To: <20241010-tonyk-tmpfs-v6-0-79f0ae02e4c8@igalia.com> To: Gabriel Krisman Bertazi , Alexander Viro , Christian Brauner , Jan Kara , Theodore Ts'o , Andreas Dilger , Hugh Dickins , Andrew Morton , Jonathan Corbet , smcv@collabora.com Cc: kernel-dev@igalia.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, =?utf-8?q?Andr=C3=A9_Almeid?= =?utf-8?q?a?= X-Mailer: b4 0.14.2 X-Rspam-User: X-Rspamd-Queue-Id: 9A439100009 X-Rspamd-Server: rspam01 X-Stat-Signature: 9gxsnqdxt5m7qsbcwkofo5ego7z3xdxt X-HE-Tag: 1728589294-613052 X-HE-Meta: U2FsdGVkX19i8CHYHFB1CzYsLrlE8ty1tk5vduc6mkPF+TitFLe+UoUSaMMYQWQJ+eT6MrCBI8bkpiPBu2FE/6NBr0MF7y+l5yMtpQkSud8hzr1vxiUEa0IgcFFdK8+FCVK6mD6CaI6V+6wWoZZcis5ZVNQDxuAjLJe75Ban6CzSOZMvVlW6xVoBA/plIHl8ttyiA7cBOA1Rn5hqdHq4RJy69Yi1b1WR8OFg4YiYKq88x277035HGJKaUdjDfk+adPOXfgNxOipZ+K5b16ee2gyc08JOsFzSyYio5ESGzxyHBxH6dYykvmHhbtyd5dGul5qUkYr1L0d+HWzV4i62WFYM2iVa0UpTZ5aam2uWOrs3BIj8+xvVqzAUGTctdd3UjDg2JEVFwakg0s+7t3VzjUd7IR+gPOqyt55uoLg4JbvI7Gd6mzzZDRt5Bf77CB2w0OiVjkj80CYAzcd8ltq4Zsw4sOAIPGmk1a4VIkzTbiaCYvVbWZldYyJcUhY76U9zIY4XirtHzvCJ+njyFraA+HVuOKARgXusaYiM+X5LcYNDMQKmOhTqtBYQdgEEtvRtIvVGhjlV+hrwd+45c9oIjykntY7bDVWcrcXKB04k7dDNXMAI4iyFjTN1/X0b5Binspc+3LufiMj6Qw1GFzkP/tWBd9KzwpvCBSvhyFMI7Cy7YvwrzNlCM0Y5WaVv8d8c5fzkiJNi0wx4Cyl0dwVCHQJr2rmzNh5DfufpezoDRDcCJB3Icsevc9aaUfR0mVOB63wAS1l8PfPY5G3bB+nKLUHwEMVn5PCevVUnlvs/ouZ4/AmyzubnBnwj9IMjvkNSQZwPcvgHsJbGAvGlTpqHLjB42XqOsZtVJmFGDdYTOXn+rZgdGz6M2xKCAHfLcd/8JlcbLrv3Rb2pWguYRUxommdD1nvMiNH3UBmEXQkGgmKEktu0lk1qoZZNjf2GMVD5+/fD6pMe9giNex7Vt8I /7fdPU30 ciYb3Ff0FjNh00780Lt/yNLwWF/Dcztt2yk/fSJqidjwLYM4jAKFvVOeSpQZPvY/3l9v6gYJP4lf57YTOuh4olj5aX0TBVZCekmTTPIqx75HQH86gAjBDJoPhKv1854g8TZ7iNyauxMTftpKVp5bjEMsabEVsEaZlsUOJSWk8ebZs8JqtvEX/TRfptlfi1NsD/NE2f/QNia4AOxkUGLEV6+u6Wc/7VQ4ts0qyyY0LutCsk+MHtHhREqB3jQIWJEzuwlXQzfHgdjYhFIwymdbvwG6vg7RuN46kP8YvT3BPqKOKrY4yOaPn2FcXIbaMJKiXzi1W9Hki5ejY5Gi65SUzKLS/PJETCOTec1dgLBQjzaAdABV4H5VU+7JCHHsgSiW+QrGE 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 4f11b55063631976af81e4221c7366b768db6690..162d68784309bdfb8772aa9ba3ccc360780395fd 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 Thu Oct 10 19:39: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: 13830986 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 AB432D24442 for ; Thu, 10 Oct 2024 19:41:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 40E536B0092; Thu, 10 Oct 2024 15:41:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3BDC16B0093; Thu, 10 Oct 2024 15:41:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 25EFC6B0095; Thu, 10 Oct 2024 15:41:46 -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 0760B6B0092 for ; Thu, 10 Oct 2024 15:41:46 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 5EFBE1A0767 for ; Thu, 10 Oct 2024 19:41:39 +0000 (UTC) X-FDA: 82658712570.23.DD78A7E Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf15.hostedemail.com (Postfix) with ESMTP id 62C67A001B for ; Thu, 10 Oct 2024 19:41:42 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=gE5p1QiS; spf=pass (imf15.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=1728589166; 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=XHdi9hQBqFVnhv7IC8o5GpggjJLpirJi3kfx0QcBzok=; b=xI+6vDhtOqO5wAdPlfSW5coerteStfoRRHYA3JKFMXlPVQSTndx5D6Vqk1+9Ze1r9XyFtD 2VRXjBrUkjXhjp7b8NtGpjqrM510kU5yZ8s9sCZAKTRp1nlgypQYhq1rY1XVa0W4hZ7Bbw GW79erKeZiQYutzsemaMHNTNCf8lHFo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728589166; a=rsa-sha256; cv=none; b=JTakdk0dnHXcFVlAZPxVgOVkjg5p8tZTQAIttY+EMmbQU8mOkeL9By5ekkQOuhMSyPKhe3 i2uS13x2b4qcywB8YJSbhrFZKGgySkLOOmZKiTeKkyuL2pyEHCM6DnLAzeSzV9uG1K7zfk qhCc3tqn7zrLch6t12vPNUE3iat02Uo= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=gE5p1QiS; spf=pass (imf15.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com; dmarc=pass (policy=none) header.from=igalia.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=XHdi9hQBqFVnhv7IC8o5GpggjJLpirJi3kfx0QcBzok=; b=gE5p1QiSfllJwSdRlI3HsbrVUd dtP0npquWm+YKdZfvs/6gWGWPskTAFQ0ggKlYH/6lq/Wmw/PQFwprLaLQUb9BmkeX2+dlJDVpcQnB wJISy6+Mp6uah+0j5yKvfVDEFFqfW7Kp5af+e7ihAxw7sLH5frwf1pEVByIb3C3jTxeDkYm+6NBPo +UtMCfWckcf+Y9QTYIY/tAFlWTz/34RtQWZGRQfCNzBN8Rj83qbenVje5NjDZo/w327yh+GXUYsLR VFvkutrJUSo6HOh5NfvCXk46jwOVvfH3fOrIWvCzDAmCQ6AW1azHAPTUha3yKGhj0FlA7UlxAg+hP /J3MwBZQ==; Received: from [187.57.199.212] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1syz2P-007SHz-ER; Thu, 10 Oct 2024 21:41:29 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 10 Oct 2024 16:39:42 -0300 Subject: [PATCH v6 07/10] tmpfs: Add casefold lookup support MIME-Version: 1.0 Message-Id: <20241010-tonyk-tmpfs-v6-7-79f0ae02e4c8@igalia.com> References: <20241010-tonyk-tmpfs-v6-0-79f0ae02e4c8@igalia.com> In-Reply-To: <20241010-tonyk-tmpfs-v6-0-79f0ae02e4c8@igalia.com> To: Gabriel Krisman Bertazi , Alexander Viro , Christian Brauner , Jan Kara , Theodore Ts'o , Andreas Dilger , Hugh Dickins , Andrew Morton , Jonathan Corbet , smcv@collabora.com Cc: kernel-dev@igalia.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, =?utf-8?q?Andr=C3=A9_Almeid?= =?utf-8?q?a?= X-Mailer: b4 0.14.2 X-Stat-Signature: ynpfdwyiefz6nprrcekg8smsug6ym4y4 X-Rspamd-Queue-Id: 62C67A001B X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1728589302-254262 X-HE-Meta: U2FsdGVkX1+/sEydocVrWGJHcJmMFwdzP3jvjHRa3cCGGeV/o513QqIrhiMAj4ybUg6oeutQoPtIhBFKeyHT7Q5K5Cv4G27E2F1MY+IKZCUordneXqsKpTmiX103txmFiZmNopU60DS8wJHHrHNjqNik1hhLUrGO+5eTaP13hkX4IlUw67EpKLLOSg7Tn7kJxMr9fqr0G9xG3o8tIZH9LaHvrTnUUT73U9VUwXlgn0c0SC/B/d8+4HMMd/a3wo8sNuePS1LzI1ve1LAReKQTCTJUSf2jOjHM93uSiglrhrruPdnP4S8ssVMeyBPLieU1k4AQehL4NTCIcxY6D6NiF5Y3eAXEZlAMsaT0hnKcnRpVTmdMxMHDiUFTLdJDf0GH/FNqBlhn2pth3ZSIuG5NY9FGC4Oo8MDIJEFPGHFOlOEY7aXFIzf6LMKoEDFeUyeapv1qXg0rRJbRDmKci0Qh8dWoxLe9mZmiYZG4rWKQ5tGxI+o4UMWkvJp1cjItpeESlh30mxAw0CForVzmUlWLDEcIJVyEZTAfshNoopr8cf3cqGRlMtkCzhRPRDGMBfd7sz/M04ZFj5A3ie6bBX+RiITRv6AlkHgHoypsswuj4/RUDPsL0IIocS2EazavVDh1BdAGAdRzJyQ6MTHqdnsozDxrRMHTElEiQywLULkg0gRXmntQIs+W1/iU8a8uQ7tCQZUg/AZaAS+A9MIOWZl5VCYnxjLFbPRCnEvFVS32c/Dk7wrewWVP83xkx2zsjdaLI8CPp5HRQCsGB/x2+n7tGXNtyxPUh4u9K8euvqs/gFmdw5YzrHlCqTD12lsifLRpQczegbmAHA9cL4+53UR+RqMHT1Yq3LtycuilhoGT3vPXRg/8zeFKP0ggNMccRP/JotP+CSL6E1hARSGB3hPUbmPnMPpiyF56QjR+2nuSrHjBcfv6Gjj8lCtW3z18kBGKbX7fVSXECwocm0yi7gv HfBPfeov YQc8CvI/LdCtxyPESJEi/ZiLiygUpvCDL62yZiB7RnIhKMy4mHTeE/DLYbbv/BUKQiiLhF3vE2aTTAWe8ZOxccCPBkHn9Ui//HRGaT2DwamlvI48bZuBNThObm/mo7zG/5/mLOuRHrE784QU9NUEBaVHyy3uMmMP/+noXhFaJjs433pQ5vw90qMcYnXtfs+E6ST3u+RiGiXnoNjbFbeLJhNNnficYgc840OXAbyu8HSiGCe08fA5sAIyKOPfNdHeUkkX1cG9pxPOCi0/7SwaHUy/M/8S6bxYjDnKUTHAr/cYwkvqhggJ+ro/4c880/tSW1HnHwxqYr63/ztjkoEKQ8+Bmjg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Enable casefold lookup in tmpfs, based on the encoding defined by userspace. That means that instead of comparing byte per byte a file name, it compares to a case-insensitive equivalent of the Unicode string. * Dcache handling There's a special need when dealing with case-insensitive dentries. First of all, we currently invalidated every negative casefold dentries. That happens because currently VFS code has no proper support to deal with that, giving that it could incorrectly reuse a previous filename for a new file that has a casefold match. For instance, this could happen: $ mkdir DIR $ rm -r DIR $ mkdir dir $ ls DIR/ And would be perceived as inconsistency from userspace point of view, because even that we match files in a case-insensitive manner, we still honor whatever is the initial filename. Along with that, tmpfs stores only the first equivalent name dentry used in the dcache, preventing duplications of dentries in the dcache. The d_compare() version for casefold files uses a normalized string, so the filename under lookup will be compared to another normalized string for the existing file, achieving a casefolded lookup. * Enabling casefold via mount options Most filesystems have their data stored in disk, so casefold option need to be enabled when building a filesystem on a device (via mkfs). However, as tmpfs is a RAM backed filesystem, there's no disk information and thus no mkfs to store information about casefold. For tmpfs, create casefold options for mounting. Userspace can then enable casefold support for a mount point using: $ mount -t tmpfs -o casefold=utf8-12.1.0 fs_name mount_dir/ Userspace must set what Unicode standard is aiming to. The available options depends on what the kernel Unicode subsystem supports. And for strict encoding: $ mount -t tmpfs -o casefold=utf8-12.1.0,strict_encoding fs_name mount_dir/ Strict encoding means that tmpfs will refuse to create invalid UTF-8 sequences. When this option is not enabled, any invalid sequence will be treated as an opaque byte sequence, ignoring the encoding thus not being able to be looked up in a case-insensitive way. * Check for casefold dirs on simple_lookup() On simple_lookup(), do not create dentries for casefold directories. Currently, VFS does not support case-insensitive negative dentries and can create inconsistencies in the filesystem. Prevent such dentries to being created in the first place. Signed-off-by: André Almeida Reviewed-by: Gabriel Krisman Bertazi --- Changes from 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 7b290404c5f9901010ada2f921a214dbc94eb5fa..a168ece5cc61b74114f537f5b7b8a07f2d48b2aa 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -77,6 +77,10 @@ struct dentry *simple_lookup(struct inode *dir, struct dentry *dentry, unsigned return ERR_PTR(-ENAMETOOLONG); if (!dentry->d_sb->s_d_op) d_set_d_op(dentry, &simple_dentry_operations); + + if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) + return NULL; + d_add(dentry, NULL); return NULL; } diff --git a/mm/shmem.c b/mm/shmem.c index 162d68784309bdfb8772aa9ba3ccc360780395fd..935e824990799d927098fd88ebaba384a6284f42 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) && defined(CONFIG_TMPFS) +static const struct dentry_operations shmem_ci_dentry_ops = { + .d_hash = generic_ci_d_hash, + .d_compare = generic_ci_d_compare, + .d_delete = always_delete_dentry, +}; +#endif + static int shmem_fill_super(struct super_block *sb, struct fs_context *fc) { struct shmem_options *ctx = fc->fs_private; @@ -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 Thu Oct 10 19:39: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: 13830987 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 9F249D24448 for ; Thu, 10 Oct 2024 19:41:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 34BC06B0093; Thu, 10 Oct 2024 15:41:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FC426B0095; Thu, 10 Oct 2024 15:41:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 14F626B0096; Thu, 10 Oct 2024 15:41:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E9A456B0093 for ; Thu, 10 Oct 2024 15:41:48 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 33EAB1206C4 for ; Thu, 10 Oct 2024 19:41:45 +0000 (UTC) X-FDA: 82658712696.01.C710678 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf27.hostedemail.com (Postfix) with ESMTP id 5D8974000E for ; Thu, 10 Oct 2024 19:41:45 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=ngCP2OSX; spf=pass (imf27.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=1728589168; 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=zoE4RPJrEfLVHReDLgphj31bDW38mEz4OTwqDqkwzOs=; b=7YUGge3zvCbP+4HGOavWJmn+5iZwiCO1shG6wqsMnMCZrmuLqqdNeTH2yn/yFdOBrhKmRb eRWViAmRlP6W3wYvMfp8zrG9HCTqMrtMyZcgFf0n1hLDn6B+TUX4zMDyVIRLxX3s5L6BKB HzgoVbiqVlE2ZQbff/OSTEeYpDpY+JI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728589168; a=rsa-sha256; cv=none; b=xyU3x6KAzW74+iRpTPc5qoJJUVRaz2O97kJQk06cx/wBCQ6Iy7RdTPI+LzGRvopUiIIWv5 s73i310Urh8s8LGbg28UA3Ck3WmQ/7X4dAOS56aOluSL4tW5amiaqW7qaZNOjub54uEgYL z5cYm0CNJE2zR45x54KEuxYGSAjG3P4= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=ngCP2OSX; spf=pass (imf27.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com; dmarc=pass (policy=none) header.from=igalia.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=zoE4RPJrEfLVHReDLgphj31bDW38mEz4OTwqDqkwzOs=; b=ngCP2OSX3FyNez4PeGc6ilBYL2 VlvK0I+D6Vcx+oGjksNEOCAIhEsf2nmAeZ6yfNK0Xu7/OpLkbI9Ac8nl6cNsqLtwmiswOrnpbZ2gx qRLfHMUjuD1+lZ2yw3QPaZihs6cBD8JMFMVYgy6dvePodtMpof9Lx2cUBBFAsDX6KBRfeezxCmL5w S1dqfODKlVQn4QfZu47oIzYvKG0NwX/M1PCPVIyMbt4JPKJFsJcGhP1hNWgnn8Rnl5AfJcl1zk0uP s7whR7pHza136ZA/Y237m8Ul3amIqkqzFuST69DUr1vzeyb1T1+6Guvd38NpahdTd81nZP1a6LLnk Z7xNHMtg==; Received: from [187.57.199.212] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1syz2U-007SHz-0k; Thu, 10 Oct 2024 21:41:34 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 10 Oct 2024 16:39:43 -0300 Subject: [PATCH v6 08/10] tmpfs: Add flag FS_CASEFOLD_FL support for tmpfs dirs MIME-Version: 1.0 Message-Id: <20241010-tonyk-tmpfs-v6-8-79f0ae02e4c8@igalia.com> References: <20241010-tonyk-tmpfs-v6-0-79f0ae02e4c8@igalia.com> In-Reply-To: <20241010-tonyk-tmpfs-v6-0-79f0ae02e4c8@igalia.com> To: Gabriel Krisman Bertazi , Alexander Viro , Christian Brauner , Jan Kara , Theodore Ts'o , Andreas Dilger , Hugh Dickins , Andrew Morton , Jonathan Corbet , smcv@collabora.com Cc: kernel-dev@igalia.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, =?utf-8?q?Andr=C3=A9_Almeid?= =?utf-8?q?a?= , Gabriel Krisman Bertazi X-Mailer: b4 0.14.2 X-Stat-Signature: fzrkub8sdsjqb1aiqknpkz378bbw4qj9 X-Rspamd-Queue-Id: 5D8974000E X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1728589305-784517 X-HE-Meta: U2FsdGVkX1+Ev5IjSaQ7YhfVS0ve0lu9unCkyYWQIALaHF3/YQ+VyDaCIwMeIfy8Wb+0nkxRqvjEOBBD4gw+u71KS7hBOaQ6/cYdF6A10OSPgX13b2g1WTFIon7mZZ4Yrk4giQBXU2d0WO7yLL1OskwcotfE0vXmWfvPv47b8GvxcKM5TuiC4dhED4v13vHeUZwvg1XzG1TKMDVaeHSTABJRGh8+oyhvwStBMlzkium8FsI4u+qxaIr76lX9UggdrUIbi+QgjnHo5hpm+mGOSWSHPiKmoRmUB1/GMX5RdYNLBmDxA4rkoJiGYAdHUJIEWGs6saM2POU5sIhnkDFqKIwWl1WQCFE9Bxth1XFUiKKLgTMr/8tMpgk9W7pD7djDqtk7P7jfqIZUc3k/VwTQsrtHf1vAzwg2RR3pYn3/MNcZVwLV3+7JoQmARFjhgflKoqFyK/Whpb6YYSTlSbUu8E2d+hbUOwof1W+E+L+ZHaq3eo+nAQd3bn0dxzsKj/GeJASgDIVNce7Wtut9GRPCkTNh66FmBLcbGXbgKb4ytb710vsArfE8zwRmZdNb+L2I1eD7XkO3kPtLDh7a/LyAhJHMt/P3UCBaCJOf0phLVTtqwknVBJCm6g2jfh0V6gB1jtpKhRVqQyYp+k3pzRR2yEVEyp1Dpzq+DhT1QhqV7MBgoJbbwfDHo5CjXIIuSxa6cL2FFoSN6cnGokVTn0ZXejgjjlXbnXs6KN13tm6ofrI//m7VU0t/VxDEaUqrwodKEYJb3onrxdDaE5JQZTU5Wlaacj3fXgBRYh7C96ZU3Xrdib4Yxb+1lzBS+QY8x0zr7dUELSG4jFwCGSqgPQFVjUAl5v6KKXKHPa5cfNPvruDbrLmfUKfv6y/EUSOGl1bVDFBwSL7mR1OKV3nK3Sx/ENMC/kQEv0PWewCA4gzgUs5vdVlgWdohD2sSV37ZIj9pGB2blAyGXEoUDfKppZW yLSt1v88 qtXMnwpm5gk57NNuXoEpHdAqStO1Zz/Ef1yl0kb88xG9N0SU9t7+FFGvHbwsPVX1wNUevDQ2osI9g7ZoGlM0j9U+sQyFdtk78YexQfVs4fZPxFS3mPETaaZchV7Yl1JkAFLpthNoSf480opqvscBVlzpo0eklf5MtzlHYtDn822u5Gcz5DVAKOkaD5kC7a73Y21bJ28vgatTiwTnNICL7rQFzl6U698obE4op0QV53x2eDSYbs4ygmGu6uDaLhm63i1YFUHl4wOenI6EoBSJ1xJC1tuQwrMoIavu8AOGcMlz04GSTJDa9oF3bzmRroW/1048YZwSTCGvh+xZCYYlQ2U4jmaYF9vtlNyfIr/8bZm9Uv8zQ8kI+8JJ1oUYVZjtS0h+c 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 515a9a6a3c6f82c55952d821887514217a6a00d1..018da28c01e7d71b8fb00bfb23c000248c8a83f4 100644 --- a/include/linux/shmem_fs.h +++ b/include/linux/shmem_fs.h @@ -42,10 +42,10 @@ struct shmem_inode_info { struct inode vfs_inode; }; -#define SHMEM_FL_USER_VISIBLE FS_FL_USER_VISIBLE +#define SHMEM_FL_USER_VISIBLE (FS_FL_USER_VISIBLE | FS_CASEFOLD_FL) #define SHMEM_FL_USER_MODIFIABLE \ - (FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NODUMP_FL | FS_NOATIME_FL) -#define SHMEM_FL_INHERITED (FS_NODUMP_FL | FS_NOATIME_FL) + (FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NODUMP_FL | FS_NOATIME_FL | FS_CASEFOLD_FL) +#define SHMEM_FL_INHERITED (FS_NODUMP_FL | FS_NOATIME_FL | FS_CASEFOLD_FL) struct shmem_quota_limits { qsize_t usrquota_bhardlimit; /* Default user quota block hard limit */ diff --git a/mm/shmem.c b/mm/shmem.c index 935e824990799d927098fd88ebaba384a6284f42..1c130a7d58ff3a4f5f920374414f9e7a29347ed9 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2760,13 +2760,62 @@ static int shmem_file_open(struct inode *inode, struct file *file) #ifdef CONFIG_TMPFS_XATTR static int shmem_initxattrs(struct inode *, const struct xattr *, void *); +#if IS_ENABLED(CONFIG_UNICODE) +/* + * shmem_inode_casefold_flags - Deal with casefold file attribute flag + * + * The casefold file attribute needs some special checks. I can just be added to + * an empty dir, and can't be removed from a non-empty dir. + */ +static int shmem_inode_casefold_flags(struct inode *inode, unsigned int fsflags, + struct dentry *dentry, unsigned int *i_flags) +{ + unsigned int old = inode->i_flags; + struct super_block *sb = inode->i_sb; + + if (fsflags & FS_CASEFOLD_FL) { + if (!(old & S_CASEFOLD)) { + if (!sb->s_encoding) + return -EOPNOTSUPP; + + if (!S_ISDIR(inode->i_mode)) + return -ENOTDIR; + + if (dentry && !simple_empty(dentry)) + return -ENOTEMPTY; + } + + *i_flags = *i_flags | S_CASEFOLD; + } else if (old & S_CASEFOLD) { + if (dentry && !simple_empty(dentry)) + return -ENOTEMPTY; + } + + return 0; +} +#else +static int shmem_inode_casefold_flags(struct inode *inode, unsigned int fsflags, + struct dentry *dentry, unsigned int *i_flags) +{ + if (fsflags & FS_CASEFOLD_FL) + return -EOPNOTSUPP; + + return 0; +} +#endif + /* * chattr's fsflags are unrelated to extended attributes, * but tmpfs has chosen to enable them under the same config option. */ -static void shmem_set_inode_flags(struct inode *inode, unsigned int fsflags) +static int shmem_set_inode_flags(struct inode *inode, unsigned int fsflags, struct dentry *dentry) { unsigned int i_flags = 0; + int ret; + + ret = shmem_inode_casefold_flags(inode, fsflags, dentry, &i_flags); + if (ret) + return ret; if (fsflags & FS_NOATIME_FL) i_flags |= S_NOATIME; @@ -2777,10 +2826,12 @@ static void shmem_set_inode_flags(struct inode *inode, unsigned int fsflags) /* * But FS_NODUMP_FL does not require any action in i_flags. */ - inode_set_flags(inode, i_flags, S_NOATIME | S_APPEND | S_IMMUTABLE); + inode_set_flags(inode, i_flags, S_NOATIME | S_APPEND | S_IMMUTABLE | S_CASEFOLD); + + return 0; } #else -static void shmem_set_inode_flags(struct inode *inode, unsigned int fsflags) +static void shmem_set_inode_flags(struct inode *inode, unsigned int fsflags, struct dentry *dentry) { } #define shmem_initxattrs NULL @@ -2827,7 +2878,7 @@ static struct inode *__shmem_get_inode(struct mnt_idmap *idmap, info->fsflags = (dir == NULL) ? 0 : SHMEM_I(dir)->fsflags & SHMEM_FL_INHERITED; if (info->fsflags) - shmem_set_inode_flags(inode, info->fsflags); + shmem_set_inode_flags(inode, info->fsflags, NULL); INIT_LIST_HEAD(&info->shrinklist); INIT_LIST_HEAD(&info->swaplist); simple_xattrs_init(&info->xattrs); @@ -3934,16 +3985,23 @@ static int shmem_fileattr_set(struct mnt_idmap *idmap, { struct inode *inode = d_inode(dentry); struct shmem_inode_info *info = SHMEM_I(inode); + int ret, flags; if (fileattr_has_fsx(fa)) return -EOPNOTSUPP; if (fa->flags & ~SHMEM_FL_USER_MODIFIABLE) return -EOPNOTSUPP; - info->fsflags = (info->fsflags & ~SHMEM_FL_USER_MODIFIABLE) | + flags = (info->fsflags & ~SHMEM_FL_USER_MODIFIABLE) | (fa->flags & SHMEM_FL_USER_MODIFIABLE); - shmem_set_inode_flags(inode, info->fsflags); + ret = shmem_set_inode_flags(inode, flags, dentry); + + if (ret) + return ret; + + info->fsflags = flags; + inode_set_ctime_current(inode); inode_inc_iversion(inode); return 0; From patchwork Thu Oct 10 19:39: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: 13830988 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 A665FD24447 for ; Thu, 10 Oct 2024 19:41:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C07C6B0095; Thu, 10 Oct 2024 15:41:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 322696B0096; Thu, 10 Oct 2024 15:41:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 211E56B0098; Thu, 10 Oct 2024 15:41:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id F3CBD6B0095 for ; Thu, 10 Oct 2024 15:41:52 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 88CC880738 for ; Thu, 10 Oct 2024 19:41:49 +0000 (UTC) X-FDA: 82658712864.23.8BB19AE Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf11.hostedemail.com (Postfix) with ESMTP id BA8A84001E for ; Thu, 10 Oct 2024 19:41:49 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b="X6en/DE+"; 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=1728589173; 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=PVI2yOyAN/UHNCWVPw7UlxKiOm9A/KNT9EdQ/TMvelI=; b=OOeX2/dZW+dNqI8JOc0z+AewRiXGtNkrsHml1ETOyJfpk/HBCBzd5vBmbdMNzQ8ceCOGrs b2Cgh3OpJZOeBPQ3yqWXecMYffcmNC9s2xah1xq3Nz5g7A19z1jGe4voh0nECuYg+fUini AVVFxBq7zzxsf8xolD+bVnjOn8Kf7vI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728589173; a=rsa-sha256; cv=none; b=NOQa/epHEMjLZBvmgzr05AGqkoC7da6EPvJG54T7b4J17xzwTFzR0ElmIrj4askJLd/pKY tHL4+7kRZNZ39SjzcsS5jrK2UmmHCz5RqvRip+qkB43usJ0hpoVRnO6GDoJ4yre06ZpfxV FDxhuqwgWWED3LF4vrXQdW9S7C/Q+1k= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b="X6en/DE+"; 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 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=PVI2yOyAN/UHNCWVPw7UlxKiOm9A/KNT9EdQ/TMvelI=; b=X6en/DE+BvgjfVsX7s/4m3ZAOI 9JKyGbPjruDT4Cgi76g0Ltw6bLkYySyicttEMYiglcq6d+oj8vdyF3avkASdHGZhNHLDWNDeF2eSf s0bVUQP5Wg0LBbAA0Gz4BONeWHHH6AnD1k081SIsMvAqacrP3gG8U+97JuFOZT6jnsqqjPBGyb+9x KeVYaDKvz3pHSxPLuvAKB7Q/Z4/LUERI7Dtqwwzs9SlVH5WNOAZ9hqGgnJONGyWaYWPgg4zJdfLTF qszQ5+E23RkLLoSeoJP/elIl5zM4LB2ObH+RPG3zd8cuVdkn7vuMaROuHB5FCl+Y/hnY9I8gPJnsc m8owllnQ==; Received: from [187.57.199.212] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1syz2Y-007SHz-JF; Thu, 10 Oct 2024 21:41:38 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 10 Oct 2024 16:39:44 -0300 Subject: [PATCH v6 09/10] tmpfs: Expose filesystem features via sysfs MIME-Version: 1.0 Message-Id: <20241010-tonyk-tmpfs-v6-9-79f0ae02e4c8@igalia.com> References: <20241010-tonyk-tmpfs-v6-0-79f0ae02e4c8@igalia.com> In-Reply-To: <20241010-tonyk-tmpfs-v6-0-79f0ae02e4c8@igalia.com> To: Gabriel Krisman Bertazi , Alexander Viro , Christian Brauner , Jan Kara , Theodore Ts'o , Andreas Dilger , Hugh Dickins , Andrew Morton , Jonathan Corbet , smcv@collabora.com Cc: kernel-dev@igalia.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, =?utf-8?q?Andr=C3=A9_Almeid?= =?utf-8?q?a?= , Gabriel Krisman Bertazi X-Mailer: b4 0.14.2 X-Stat-Signature: 9poaoqwjno6soury1pkde9d788qhbp1e X-Rspamd-Queue-Id: BA8A84001E X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1728589309-261285 X-HE-Meta: U2FsdGVkX19vox0vldo5K/FOjKJgScdiSuzQqA+8p4/xQqyby7dULm4I51U5+P4M4r3Q2dslDeAD16NOB0g5PFvIJy9euS2SIStGvOTk7rPytnK7ErOm9oyeqUk7AKZ3qUBt4jan0oz6GOk4be+912wJMH4euLB926rVQ8EOMZr569MKcL9u+SvFpJ9iBGmy4uKFx+YPAPSqd4Elcp0OCHZbkx01+YAToXcNKZiAiVETcRrzHnzfJczcPJU1UbNUpcO12AgnL8Zw7ZVJna37SHW3TNnlgA+jlm5GZ7WF1fb9xQIySDgX34VANG6EjDnFWtp5/jrv5WVQLr+YR+7h7izuHN+tk0Y6niS7k34sNTvWnZ8yS2usFddwIgnO7YvKg4k80Sk6qs2mvvddGzZOCwY/SKtRPw6ESaIyaBYpZbCr3zfHptSkCMK8aC/QITRsv5+dDk+ulmc+WDuLYDp2J/DUJFPIuYyPolFpKLGYE4GXVKCcqsndyjpiqufX6JoP9mrPp4tptfPTe3WHj4T+XtbUhailpe7f1W4dAa8ITG1k6Z6L+4B2JS7Ostq9mhjvXxIKgVwYUQH31mS9cbVqUY0hryfkM4+tP2Fsxash9aIDh5GAVKFew4Y5biyfG7Z0RYtG5ct98G5Ib5tBcpqmxahJje52za7F/MKJsLgw6of5sbXepfUHEjEKJQ4vz9CM6kVxZMKDUx16iL+anML1lPiwqYOOqatrXa6DroaJNYvlk9/8xcYQ/E41jgU0SyfQ7m5PlOv1ncdpVX1erYss63MoCeL95/gydnnKDoB365cn2IA+bJM/PnHa9D8zuhkzyHVcG7hum7h8FzQe3oqLY9lowWTMPtkDOcHRlt+833yHAfo76lc1v2cNLP1cCXnZYYClZYvGTCk2h/Au5CLOVkjBBMAafYkTJ+Fokuxap9RwbJo4t6HKfroEkkzcW8ocRNtFYAM/ifHQh+vwZlT TgYyMv1Q yERhvB7xrRqn1zvx73uJIL9adtYX9EZsBlqfEM3Uh0sTxZ56qG2lkXLQRqbJcsWKQpaf8xgYofpD4BZJ1nbtNDtlyXoONfYJjhu9TNGuBjuDyEtyIUEME9PR4WY2Rv3U3oe3kNtkji5JN9qBkdsapmkJftfsjE52cg0NLbRMbX9N1T6JDi3JTdHmEnOhhpXUnbMWiayO7JlZB9mL4tRMWqykbI0XwxRhkEy6K9mQaROea5yPM8O9yEc1mYppa3TQyzEP1MZDXqZKKAH/dPlroFt7x/7RYq9paLgPwNCHeWZlzhcWjplgUlbSNRO/qedmkG+mAgagf8mmCwBI= 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 1c130a7d58ff3a4f5f920374414f9e7a29347ed9..eb1ea1f3b37cf7a4a11c3d11ad3f70ebb0e48d07 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -5543,3 +5543,40 @@ struct page *shmem_read_mapping_page_gfp(struct address_space *mapping, return page; } EXPORT_SYMBOL_GPL(shmem_read_mapping_page_gfp); + +#if defined(CONFIG_SYSFS) && defined(CONFIG_TMPFS) +#if IS_ENABLED(CONFIG_UNICODE) +static DEVICE_STRING_ATTR_RO(casefold, 0444, "supported"); +#endif + +static struct attribute *tmpfs_attributes[] = { +#if IS_ENABLED(CONFIG_UNICODE) + &dev_attr_casefold.attr.attr, +#endif + NULL +}; + +static const struct attribute_group tmpfs_attribute_group = { + .attrs = tmpfs_attributes, + .name = "features" +}; + +static struct kobject *tmpfs_kobj; + +static int __init tmpfs_sysfs_init(void) +{ + int ret; + + tmpfs_kobj = kobject_create_and_add("tmpfs", fs_kobj); + if (!tmpfs_kobj) + return -ENOMEM; + + ret = sysfs_create_group(tmpfs_kobj, &tmpfs_attribute_group); + if (ret) + kobject_put(tmpfs_kobj); + + return ret; +} + +fs_initcall(tmpfs_sysfs_init); +#endif /* CONFIG_SYSFS && CONFIG_TMPFS */ From patchwork Thu Oct 10 19:39:45 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: 13830989 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 348A8D24447 for ; Thu, 10 Oct 2024 19:41:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C4B4B6B0096; Thu, 10 Oct 2024 15:41:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BFBFC6B0098; Thu, 10 Oct 2024 15:41:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AEA806B0099; Thu, 10 Oct 2024 15:41:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 911196B0096 for ; Thu, 10 Oct 2024 15:41:58 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 31AAA8092F for ; Thu, 10 Oct 2024 19:41:55 +0000 (UTC) X-FDA: 82658713116.27.2DCBDAB Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf23.hostedemail.com (Postfix) with ESMTP id C3B3A140026 for ; Thu, 10 Oct 2024 19:41:55 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=QviYkYoZ; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf23.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728589204; a=rsa-sha256; cv=none; b=1DRS/nMzWhUv+nuybN25EzxuW0edyZFwhmJknE97YXTVyWC9lQ3L6VFmJ+IaKQkSBKnKlP zG4rCJUd8eLoLBh0oosrlWJDH3ZS0pIk/eMfQlRv0O05rlBO3r/r+lQX1zB7Ey0cw5GkC7 e10hHwNUFtN8TuUjx98gPSfBwndtKgA= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=QviYkYoZ; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf23.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728589204; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=MO38/TKDXEZfYM/HH5HvDp3/o+h1cffvB2kBOci8370=; b=OSmPalamF9b7abhjKGlLtJ0fUV8run4UbL1KEqlQNSYeymcVA67O/dISyHg/EuWnSu2VlP vE8eQqqyIxYPGK0oZqFWg8PAls+5IuUjkR44Sy+R0rZ7aHyQFvLgyfI+VINaMtCErmj7VP Oy3HENLLIMQuOgcbCWj/Puh4IX9zvFM= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=MO38/TKDXEZfYM/HH5HvDp3/o+h1cffvB2kBOci8370=; b=QviYkYoZfsrN9cX7rTubnq98UU 7LyTxBOAopZwqqGYcT0V6e+Q7BQ/Dr35uDEh4j7FjWja0wRFY8+dIs2zKg+VX8ftdZIBv19sl3aWT 8uRNDIcbA9EWiIytTjGgBDR4NmXyimdqgJwM6O7/5n3dRZXLZ2ecQ4DxGKmhrS5hSPKT8GpcSZWUj PWia/6xhppkTkKyrUtKdblHmaPN9BviQZ2BvK3zAknjjxgdGDds3/5r+VT79DrY3kwaLu5RDY4n5m l3bGuz6Ulehzjs+fE3jAQVzYLHhOMAP7kNs6J1zEx+xYKeVVUIEoOIAUEZJX2E8iTEuo/jAX0y/L/ o1tSV/3w==; Received: from [187.57.199.212] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1syz2d-007SHz-5Z; Thu, 10 Oct 2024 21:41:43 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Thu, 10 Oct 2024 16:39:45 -0300 Subject: [PATCH v6 10/10] docs: tmpfs: Add casefold options MIME-Version: 1.0 Message-Id: <20241010-tonyk-tmpfs-v6-10-79f0ae02e4c8@igalia.com> References: <20241010-tonyk-tmpfs-v6-0-79f0ae02e4c8@igalia.com> In-Reply-To: <20241010-tonyk-tmpfs-v6-0-79f0ae02e4c8@igalia.com> To: Gabriel Krisman Bertazi , Alexander Viro , Christian Brauner , Jan Kara , Theodore Ts'o , Andreas Dilger , Hugh Dickins , Andrew Morton , Jonathan Corbet , smcv@collabora.com Cc: kernel-dev@igalia.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, =?utf-8?q?Andr=C3=A9_Almeid?= =?utf-8?q?a?= , Gabriel Krisman Bertazi X-Mailer: b4 0.14.2 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: C3B3A140026 X-Stat-Signature: bztfjacgcpa7qhhfmhmwz4eyhfg5q1fs X-Rspam-User: X-HE-Tag: 1728589315-348516 X-HE-Meta: U2FsdGVkX18/RG6yBnSF8hY3hMJXo1Xf1FETyHUx5vTxdBFfB3fuVisLCmNRJ+KwmQtxrw/dbvawjDX8UsNjFLK/WHq6QraeiYA+En5HQybVuMO73JSQ1561pHt6oEnDQBEAUYr7Vd2OjjMnDqS7VIL6vGCJPMpneQaH7vPwf04wrs5h44ji9iYU1UZfhao/Y7+qoA94P2JctLZyZuw2vDcSA6ZfefSJWhZ4zuzO+v5dG78FXRrq4aI7KzCECQbyN8dKBvPbbCXBWfND99L2433h38z+qnd4sxCt0EFT4TAuS3iEiWQiULdg/5U+YhcxahqszBUQIWSy7YBQ4oVmj/nGyC8chV3p8TyMM2q5mTqtckQb1enQg5QBUzCjHK1iLIi48z83yDTuF/QVYmTmAKgNYyiMX3VmV0cEdQV4JeYEzcXP5/t6LlR3oJ/6+MNjohNS0kHDIMp2X87kGqGIdR6SfdCcLkkH/mMgB5SXhkXVeeJpx5D5MN420yW0pp5SI3xTBCqGQpiJDSNMBrnTmUGyprxJmjV3rC71d3n/PsE0dq0k/a083LA/uxRpVGHnqdjJUU9WGvvVL3RPatmKSHrTs11raJh1cBsDA7o6cQkIhvcCCjCeunVPVPraV7fqNQnmHR+DIAIcU87lt0ZfPHfu/8zU4TaMsjBM0irIAVGclh/fUjjEwl+T7FEMF2oneWrkmr6TT0ZkwQs5zOjDYzl67J+5EoWQ2DNV3Rp9ckE2hrHO7iqSW7wSQNnBOnkDAcimAgjv2MsYWrAzc46LA+xdYEO/MJyyPpZk/17QF8aUOfqgl5Zoq045XVVRzNSfq0+EpTiQtgBB47xlUCjxN2mU2JZjUZnhBfhJq0AQYbbvi9SNhZGPhLhMUPxeLhQBK2AjrzNIbrySpsJM/vZWySFblUJY0aKeP3HEzAltxhAmT8w4NDPkwrnhSN9wTDgQVUUCUdlyU62u+5E3Gt4 sCNBm+lV olrq7Cy2Q8EvT/yvjTAlK6zFtE9EzmqhOmK21A64KlU4pCW8oYCrZAkEPHyl3dA7eEwvjsKC9Jo0ZCYUxxMbIqQjVeWzLzdgHIm5xBxigHY3AaeWOt1VGW0J5g/Wy+Wz0PbWr5IDj+3PTvNqIzeJLr8gMQ5YTcSVnWFADy1/DOR9cS6/h9sKhTH46UOr20iZfeGpOrFy6xTHCpeYk+mCvXcOQ6jOxUU2we1tXDTYmYcCW8WqPoY8cLzyUiyIFJu51PGB9Pk/Q/UFDn/XoKxdI6LFHS57nk2bOXgj/O2NrlN03E7jfGptK+eLI+Hiv9JluW6UZsGodsKe2/Ad59biV7ft/nd3ZFqtEBpY/94a8qlN4mns= 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 56a26c843dbe964086503dda9b4e8066a1242d72..0385310f225808f55483413f2c69d3b6dc1b9913 100644 --- a/Documentation/filesystems/tmpfs.rst +++ b/Documentation/filesystems/tmpfs.rst @@ -241,6 +241,28 @@ So 'mount -t tmpfs -o size=10G,nr_inodes=10k,mode=700 tmpfs /mytmpfs' will give you tmpfs instance on /mytmpfs which can allocate 10GB RAM/SWAP in 10240 inodes and it is only accessible by root. +tmpfs has the following mounting options for case-insensitive lookup support: + +================= ============================================================== +casefold Enable casefold support at this mount point using the given + argument as the encoding standard. Currently only UTF-8 + encodings are supported. If no argument is used, it will load + the latest UTF-8 encoding available. +strict_encoding Enable strict encoding at this mount point (disabled by + default). In this mode, the filesystem refuses to create file + and directory with names containing invalid UTF-8 characters. +================= ============================================================== + +This option doesn't render the entire filesystem case-insensitive. One needs to +still set the casefold flag per directory, by flipping +F attribute in an empty +directory. Nevertheless, new directories will inherit the attribute. The +mountpoint itself cannot be made case-insensitive. + +Example:: + + $ mount -t tmpfs -o casefold=utf8-12.1.0,strict_encoding fs_name /mytmpfs + $ mount -t tmpfs -o casefold fs_name /mytmpfs + :Author: Christoph Rohland , 1.12.01 @@ -250,3 +272,5 @@ RAM/SWAP in 10240 inodes and it is only accessible by root. KOSAKI Motohiro, 16 Mar 2010 :Updated: Chris Down, 13 July 2020 +:Updated: + André Almeida, 23 Aug 2024