From patchwork Wed Sep 11 14:44:53 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: 13800718 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 2AA57EE49BC for ; Wed, 11 Sep 2024 14:45:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D4AF6940021; Wed, 11 Sep 2024 10:45:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B5C71940052; Wed, 11 Sep 2024 10:45:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 986DE940021; Wed, 11 Sep 2024 10:45:33 -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 683FE940050 for ; Wed, 11 Sep 2024 10:45:33 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1AFBB1618BE for ; Wed, 11 Sep 2024 14:45:33 +0000 (UTC) X-FDA: 82552730946.11.748EC0D Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf07.hostedemail.com (Postfix) with ESMTP id 693A540010 for ; Wed, 11 Sep 2024 14:45:31 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=TvzCw0sR; 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726065927; a=rsa-sha256; cv=none; b=TxkENuLhfbCOIwR26HfKdU+bUgHA5wZDMdE8BhMIgjzoEJYKd8xU7hssqhK1py78LUT4eW rGjFphHWUh4116lk+yjjH2GpHbFlWdVRmk0RXaRf/MHuPevQlUtiIJOzoRRjnXp/+YTW3k BeRKcRl/829pVMYNg9aDYbN0SMkjvGQ= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=TvzCw0sR; 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=1726065927; 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=h3G2XLqID4r09rjc35sdSginc1+HQQOMXWwkAOpIqMQ=; b=bklxKbI0LrGkvFDglUVW13cxr6cQG8db3xQRW2IHCDf8eCDDFQEv2UQXdQrCCb7zBvjgq9 In4/OR6HbHVcC9Wpj/ObTrKC5la5eo1bIoF2ln0SabLu1xA3XKUnrAq6scTVq9c+cEIhP2 ScxWtEO2tbpAe6Pupo7BnPWPOD7cGGE= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=h3G2XLqID4r09rjc35sdSginc1+HQQOMXWwkAOpIqMQ=; b=TvzCw0sR6HZM4aA4GH3FuRWYVI Px1BmzDY56FJAszk+GMHqk6MfhKr9AEhgBV6FEg9nSClLKdbWiQL8W1gw2pGA0XM0I2cafcQTMa2a mQImN7F+fHAec/ZSZtxFLaf8Wwxk6UxtKbGW1nWSQb59kGyGHtUL0cDVy7ISICVNfg63Ul2RkokT/ N4wTFu2Cw67udkHhRhTtzMmsu0D1cV7XEPHq9WhsvDx+fQ9Rk6CGeWlPhh17D7Ca9aXtNgQQZRDn7 Di0uygBcmjjmwtUXmwrtrGH9LguZ1wuQ6mutHL0QktiGfRSTDSL/LddnC/W4PrlubNkwUJWZ3hW2V j8C6emTg==; Received: from [177.172.122.98] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1soOap-00CTwi-PH; Wed, 11 Sep 2024 16:45:16 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= , Gabriel Krisman Bertazi Subject: [PATCH v4 01/10] libfs: Create the helper function generic_ci_validate_strict_name() Date: Wed, 11 Sep 2024 11:44:53 -0300 Message-ID: <20240911144502.115260-2-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911144502.115260-1-andrealmeid@igalia.com> References: <20240911144502.115260-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: diffehn48yop41y9hh1pad3wnnznc4bm X-Rspamd-Queue-Id: 693A540010 X-Rspamd-Server: rspam02 X-HE-Tag: 1726065931-957640 X-HE-Meta: U2FsdGVkX1/tpYa2nPYW/7ZJyHIWQ5sGhw2tERf4V1NFknRQiTHux01vR5X9cBJzVSNA1H/kizfNZEi3babKUZfEAVVZESmsvG9l1bWuI/WzhO8X/bOoyfBQQqmNNwjsgDZBc1pdASrVqMKU80wChqYefTUTm5KzFZWglDOCnr/zlHh8CP71KLdtYSAldwOu4k8eHBClZOLLlVIpQckC9DEMyYkLdNKB1Ykv20L7OrJ0ZDFremYfhZzOeW52OWzgz9XWM7rrAumcXWaTPedW2NUP6YINqhpLKbpdfAqaf1lTODkjbioqX9AmnLGG1BwVnHN/rzPCrjhapR/MPtmNEzn1qb+j3sZIRYKy0pYAT7mizT4Fd0kRxYeXTS9k0mwY7nuDVconq5uwd6TEoiUE32dsYDADhzVnQ8GgYLhA+4dH5WzM3/TWoTPxcDASxs3eUQ0NoTyVGj+ZlqzVP3odO6mHV2wE4YUDevQEUnzDOkq5S//BJVw294HZEtFxnT/MgJtjyrNxTHYTBkakxeZn2Mw9dJcHSqBJvRWllx8HcukLMtQyvVcFJ2mdT6Iv93MD3yAP8Jsy6begALYotfesQrqB/JoxILQqlaeAqwOxb4oP5NzMRAdMGjuL86FP8BUegGDgaSBl/X0j9zsgWACla9boC9tz6GPP5QKKdo/ozrG8wWPz1lVyqS6KYrNbYgbij6tBcZ24X7CY2/O8KUFe00ukgwF9mdJGsNVrXs6SmIjfG0NqRuUzT0BcwppUTDgL4KIbM01HpWX2FpMua6n24rSTTxRMBwaX2HyUdb+TkZIMSBnEsP2mivGD+8yoMZawjIEobhu49UmeSjqjosRQO+C+aGGcClMMaAgfDZEIjrUHI8fXSPa7wPmuidN5RcuMAD8viPhVAS7a+6T4eU1z10bvIRHyDCmRpWzmYdII2uKDCGOLa97pJ8qR+kB3682oxwgPNmWOjNzjz83y0RY FWGlSSjx t92CVcino+kG2GmB7Xip6pbubWuVSw97a+pX23Dv41FU5qW9dZyKUVyYkbaW9xJs8rC8FlpCXYH0YBNrxp9rTDXtfCeYpJnpdyzmWh6XuL3v//PX6Xoo2iHiiwtfsFMTdpFfNqjZpzTfQa3Jq256sSVnm4VqbBQaBnA1hpeySuh93shFsXnJ6STpKgNl0nOhmKKj6e4iXWwzf5Vjmbr75xNLQi129MfmuBn5oAm/GxppKZCWHmLdtX8s8iSpQ+pI+IHk1EZXu4hhBjM+7d+4l0mwQB2Q/F/WrBn07wLX/U3Ky3N9TA4dVJb3A65VostkQVuqaLCVMEuOS1hd820l2dA25seZPO8LeNoMwOgWXivqOU6w= 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 v2: - Moved function to libfs and adpated its name - Wrapped at 72 chars column - Decomposed the big if (...) to be more clear --- fs/libfs.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/fs.h | 1 + 2 files changed, 39 insertions(+) diff --git a/fs/libfs.c b/fs/libfs.c index 8aa34870449f..99fb36b48708 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1928,6 +1928,44 @@ int generic_ci_match(const struct inode *parent, return !res; } EXPORT_SYMBOL(generic_ci_match); + +/** + * 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. + */ +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); +} +EXPORT_SYMBOL(generic_ci_validate_strict_name); #endif #ifdef CONFIG_FS_ENCRYPTION diff --git a/include/linux/fs.h b/include/linux/fs.h index fd34b5755c0b..937142950dfe 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3385,6 +3385,7 @@ extern int generic_ci_match(const struct inode *parent, const struct qstr *name, const struct qstr *folded_name, const u8 *de_name, u32 de_name_len); +bool generic_ci_validate_strict_name(struct inode *dir, struct qstr *name); static inline bool sb_has_encoding(const struct super_block *sb) { From patchwork Wed Sep 11 14:44:54 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: 13800717 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 60529EE49BD for ; Wed, 11 Sep 2024 14:45:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A231D940050; Wed, 11 Sep 2024 10:45:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 913D3940053; Wed, 11 Sep 2024 10:45:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 65231940021; Wed, 11 Sep 2024 10:45:33 -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 44629940050 for ; Wed, 11 Sep 2024 10:45:33 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F1E64AAB79 for ; Wed, 11 Sep 2024 14:45:32 +0000 (UTC) X-FDA: 82552730904.02.EDADE16 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf01.hostedemail.com (Postfix) with ESMTP id 498454000F for ; Wed, 11 Sep 2024 14:45:31 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=d3GntHFk; 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=1726065878; a=rsa-sha256; cv=none; b=mvYQxatPXwxGBV6NN22nEj8JIaJRSYw+FF2yDsvIRW95zN3cnKrnUnWwv0meZvFjNJ/jkw wqWHVFtF2pHtqs3KYl0sQpzLOMmXSqzAvFmTThnST+ySEHDah38FDaJTBGzXdrBqzLUJ20 DPSN2p8dJXNAr+/+DpUSB8Nid8p5V1k= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=d3GntHFk; 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=1726065878; 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=kxZabVtRIbsH5N40Gr/wp92cNKF1pfI7iuz0Er/EL18=; b=m1znbnzDp+9N3l6cQDSdaBX5CkYX2bxStfu25tC2VDc7K8j2PZptH7RnVB1JD/j6uCLOCr RC0rwM+q3tL4AZThurCLYBskDFuz5r3AebNe0PMVuX7jOHgaOUn1W6yNmmw2DPiIX4AmGF 5zg+/qeLi/9VasrXgscxiDd9nYOgcoo= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=kxZabVtRIbsH5N40Gr/wp92cNKF1pfI7iuz0Er/EL18=; b=d3GntHFkdbbMSCXQUNBp91ixBf 9OIUngs6Lz8HspCHitoMhM+6/l/YsLELRFGnW2P9DblIt558GwmqgnJGce4qp6WHDmuG86C5POYVV Bl5v5DEh2FEO70Vymnl9a/tI3/1xWfCgIybnnSHuPd74+4vWpGjFuxoo6gvobs+wc0hgznp0Jc9DS 2lTOaJ5cRQQwanvW74I+p5hOUYaoDu7HS0Jwx0055qobygH786E/npE4xaeuZNpnXhtAwPpGRMsog Ok13crqzkBfgGFCSmzuMbx4DjIQAQTYQZpXBatIclfY56U2TN45aNkHqbXaOi7dD4qTiHYo3mkWE8 wI1XTxgg==; Received: from [177.172.122.98] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1soOau-00CTwi-4M; Wed, 11 Sep 2024 16:45:20 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= , Gabriel Krisman Bertazi Subject: [PATCH v4 02/10] ext4: Use generic_ci_validate_strict_name helper Date: Wed, 11 Sep 2024 11:44:54 -0300 Message-ID: <20240911144502.115260-3-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911144502.115260-1-andrealmeid@igalia.com> References: <20240911144502.115260-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Stat-Signature: fcfy83t9okpfdsiag4tahqwspsmrtu9z X-Rspamd-Queue-Id: 498454000F X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1726065931-291726 X-HE-Meta: U2FsdGVkX19jXAg46ANLZKTQ9wJFA5dIWGgZVAcaxxDDct/PvkMYYmc0RV5iVGC5WwibbDuO3k87nYcIDtiUUuvKThhyQavibXxDP5LBCabgwvnTQChrwBf+XzYqX5AOgGuyljnAylDN5Cr7PiFT0UJCg3vtLd7DhD1tZWRhD9fttep3XFk7Y11/7YynA0TJ19YX6lww7XNBE/yFx8PZnAoXlR6LuiRwE6CybyCqv1WHl07V6efP5M93AOoK8TMlDSLT04wCdKFChDUozPDKV4VYTgUp/EH2Jqlb+7CCfXOYP6/e+vvhpcubW104J+rufu9WMTryJyxmIx3UGSfcfewHBErueHiII3YF07byN7K0xfWpKVzsD3S7DuLqMnx73ElAX+hlKAAAM87EC3ga0GePOkBXBh9IQQwxqcNLAEf1ds2nZEq533xXtGDo/EBqeThfMv1p8s2v/wsCAkjT/kXbOD31Vrio7M1uAnuOXXEz6uVun+nTOiOqPfFHERC2mm6wVOgidoxvokeiYH64sAi4NJlVemuhvzlGbxi2INuLp10GGD7pVBNL8qN3se2FUFs4462FgVYqkV0ag1u/+FPFSeNs0pLIQY6EWzlC0i8+mO3vpr8g2UpD3nVuIKnERsz3P34v6h4jnBi+jTO1g236WFgqFN9DO3zfpT6aQk5w4UmTBI2nsqoZxGQq7kjjakBHyvW3BHtzXdC148lGmuXZjUxV2MFa6QCZHIklehGIAem1wMy2qzcs+tvo4koDijOIQOyN7vfMqB+ggpyIIz+pL+qhwWKSbFT8T6FbbkRThS8J6B9mVDmHBAc5C7BmaFsUcFgVWe9k2I0Wsm3bq8Mtt4TwG68JSC32lnCVuO3sV/uYQEO8wIWDjJ5O9XaMlUmkEWS+f40BfLYLuQfGbBGGOzZ6hs4KrwYMQsTa6OB3Zavx/aA5kTCLJr/SkyTyQc6C9Dij6IFaH3jUbfz HyVQ8zFi FsKDvJeIV7TZ471uW3nr+v6SOUyMuZKNeh6yTfCT7b1x4goEoen0qlKJhPQGZZFqTgmg3VdMgwLRKOBPKp5RkCxqGeQktPnzys7bGLR53Et9m3thVH2lIYHL3j9VoBFeKeJt1jeQca+Kl6rnNcSgc28lYFOf+6LVnGZa4pUKPk56grK6DUL2MjtWHO7ypv5OoiiB/R3oIv9ZzlXVKrBHAxGRYP3rccFE0PqQ+RddFqXh1tNN5lh/ukLRtpd+STa98JJo8jsiAwkfxs+lTpNLUPHRbNhceBM9VBVtuJpEB6X1XuLfrGfi424mrig7bf+HDlr7B8eH9jnzImjHqQp8yuqGJwf5mZRFCy+/rHu+OiIQiZMfaPOo3H4Iug1t0al5VICU3 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 --- fs/ext4/namei.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 6a95713f9193..beca80e70b0c 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -2394,8 +2394,7 @@ static int ext4_add_entry(handle_t *handle, struct dentry *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 From patchwork Wed Sep 11 14:44:55 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: 13800719 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 91F9BEE49BE for ; Wed, 11 Sep 2024 14:45:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3E45C940052; Wed, 11 Sep 2024 10:45:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3936E940053; Wed, 11 Sep 2024 10:45:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 20DC5940052; Wed, 11 Sep 2024 10:45:34 -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 F2CF6940053 for ; Wed, 11 Sep 2024 10:45:33 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A9F421A148C for ; Wed, 11 Sep 2024 14:45:33 +0000 (UTC) X-FDA: 82552730946.22.D3831D7 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf09.hostedemail.com (Postfix) with ESMTP id F292E140013 for ; Wed, 11 Sep 2024 14:45:31 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=mL80uITq; spf=pass (imf09.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com; dmarc=pass (policy=none) header.from=igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726065828; 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=WN3J9Ey5243Buto3KVkQAnNnAuXnNzeuNPoBKu1Uxzk=; b=iI4iIV8E0ejDPqhOAyA+ad0wLb+UVI9bcdWj8iErL9QaChCNVhrRuAfzjcjnc264cXgd9O gaURb3k9IDOgYH/HjhcjWBw36ZLGhU8wB91hGQEfOlDhr1yxcedf31Cmitakxb/2MHbDFD Lj/XaM0oW/LQZaumKIi1XKBhVlHs/Ug= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726065828; a=rsa-sha256; cv=none; b=OCdzyeya66VWZq2pXof2wuLVSmX6iMQ1795sge0f3jglbboO9BCDm4Zo3oQ/jv2gjSd038 mweuUxTaIWWCSsQCba2EMVglisXPFUn1QMKre9QiILG2f83pZlawvoGAzhsLX7N14Vyf88 3OQ5USo2PqS+YchPaNE1mBZekEeDW58= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=mL80uITq; spf=pass (imf09.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com; dmarc=pass (policy=none) header.from=igalia.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=WN3J9Ey5243Buto3KVkQAnNnAuXnNzeuNPoBKu1Uxzk=; b=mL80uITqrstdF/YOk+k9aSonku pXo5DDt06puEPHzWWm9fxQlUUhbeyg1ua0cn56u0HI5O0R2+eVN3TMcCfmpONscPwSMntpWPX+52K jT+CxL9RyLFn4NI0o3CNt/2y9revtz7hXPKfb7sD54PF/d2PJOcjE/oUxmbFbuirS1uxn5vrHN8gU tLXxQ8L/rc57Kf+IpTunNBFBtWr3rp88g10exMPPRHM0bYkPLh3DhC6NgDEeefO3LdsDZT7uw1tbp 31DW/eEiPk1KLMosg20VA+XJpE3X598rr/3orHXs0/woYyja/KIVxOQ3dPtyVOlXtTh185I5y92tx f2LiS5cA==; Received: from [177.172.122.98] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1soOay-00CTwi-8f; Wed, 11 Sep 2024 16:45:24 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= Subject: [PATCH v4 03/10] unicode: Recreate utf8_parse_version() Date: Wed, 11 Sep 2024 11:44:55 -0300 Message-ID: <20240911144502.115260-4-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911144502.115260-1-andrealmeid@igalia.com> References: <20240911144502.115260-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: F292E140013 X-Stat-Signature: u7a5jkyq7bmt8mbro3uk7y9q8cy6h761 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1726065931-399033 X-HE-Meta: U2FsdGVkX1+oC3p+2HW+f3yD4/+pebY8F73sMJvp3Eg5rTCGLYE07bd0ED28GtxCDZrBsDvFSlJSjg3PBrMyVNbOFtwdFiCK/Hu7khbm2izIcK8+xFeOEPSpRhhwR4GHvsT0fACu+QK7iuFnxrjyBq6nL1P9KjBxrEsRUJXoJACaWciWqvdKac2EMh7uwhddkRV+GsKs/8vBuEFvwm5M/SL7e/X8BJ/40ZAq0rE9+jNp8fzNPoOue67DxzqR6B3IIaRltLU2Bs9xX7ZnXXYFHWTsGbgVfRqc0Hp5LUEbxJnREa14S9c2eTftDafz+8yJlnkfAzpmOcy1lNSPUajKrgTEJRxcAL49yWW5hJ7ccsOC9Eq1mcwDnhIm1i4zFqcphD9dBcGwIpqdT/fF4/FDAxKAJNQvtxXDMxX8l6u2b+/NEZUaPcapY1W5Y9A3/V+WkS19M7aaLsTvS7PbTGtqX5H+14VDjgVUpFqzzsc2OQgnF210SfSzEjpFkmZhcwEkXOIrqBlIH3LGg4G5tXdP1bU0D/pMiW8XymCB+3WYbDtdhQdlerILLKtDkWbUmA9txjDtKyKVqqGSAJyJiXzdteIcLR7bl70G2qxMr7R6gLb/4QcdX5Vln3dhxdOuIS1H8qCodGP9JTlyn4y+frMBouElx/QfZgmalqzqEi2IFQ4tgVg7Dbi4jUgYsZIn5PtHRFmWxH6d6pR9M0ZyFhtz7ZgE9mpMX3qCYVhDRnhNWvoZHpNKHhKjnFo79pU+jCBErNibTJ6Fm8Dl6C1F4j9J3Dmv2l3ugbGEWg4BbRIp88XZAEXwHc5Zs5t0XYi9BCqi7B/J7bQEd0KD65P98McLFe8sG/eRBjlwDHnF9otnuSOLYL9K7YqPQegfIhRDghQLPAZpPyfkR9iFiJtMslF8PwftxPaSE4Wwh7E33gBrUpyk84+MIz4TUvPPesCG/PlZ9bkjA2dJNqyNX+/i2Ps D4RuSzlk lxVptUIzt8JIhdz4u/3d/g5mshga1wrdiPKMcg3Y54GqhJyZUCs82KcO+heTZs9KhrDEDxuNV9mWKzB/jRWwvVKqrsgPvkxoGgnIaSje3gHw+vXvRAHXLMhLYap9U3gufLF4dlK+/vZZN5i+EuqUzbc+rIGx9Qbktr4W8gZ9dgARz9u+2toDdqWFPXrnVYPjW2FPtIpepYg8I7fmoYu3a1eX7pPv6fcpYiXoqPmn/BcF4klTkA9w0CrVqNpFP7wv1fjFErAeeR1igdbZ2F62mBnlNrh1DPFPviS5aKg6tUZMAyGUcqSJirMGZdzHPb27CzSMDtwB2F9z23RoghY2Ok76/4d2YphGlk985N755TRZjFQmlc7rRFnfOr5SN46t0SjAP X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: All filesystems that currently support UTF-8 casefold can fetch the UTF-8 version from the filesystem metadata stored on disk. They can get the data stored and directly match it to a integer, so they can skip the string parsing step, which motivated the removal of this function in the first place. However, for tmpfs, the only way to tell the kernel which UTF-8 version we are about to use is via mount options, using a string. Re-introduce utf8_parse_version() to be used by tmpfs. This version differs from the original by skipping the intermediate step of copying the version string to an auxiliary string before calling match_token(). This versions calls match_token() in the argument string. The paramenters are simpler now as well. utf8_parse_version() was created by 9d53690f0d4 ("unicode: implement higher level API for string handling") and later removed by 49bd03cc7e9 ("unicode: pass a UNICODE_AGE() tripple to utf8_load"). Signed-off-by: André Almeida Reviewed-by: Theodore Ts'o Reviewed-by: Gabriel Krisman Bertazi --- Changes from v3: - Return version on the return value, instead of returning version at function args. --- fs/unicode/utf8-core.c | 26 ++++++++++++++++++++++++++ include/linux/unicode.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/fs/unicode/utf8-core.c b/fs/unicode/utf8-core.c index 0400824ef493..6fc9ab8667e6 100644 --- a/fs/unicode/utf8-core.c +++ b/fs/unicode/utf8-core.c @@ -214,3 +214,29 @@ void utf8_unload(struct unicode_map *um) } EXPORT_SYMBOL(utf8_unload); +/** + * utf8_parse_version - Parse a UTF-8 version number from a string + * + * @version: input string + * + * Returns the parsed version on success, negative code on error + */ +int utf8_parse_version(char *version) +{ + substring_t args[3]; + unsigned int maj, min, rev; + static const struct match_token token[] = { + {1, "%d.%d.%d"}, + {0, NULL} + }; + + if (match_token(version, token, args) != 1) + return -EINVAL; + + if (match_int(&args[0], &maj) || match_int(&args[1], &min) || + match_int(&args[2], &rev)) + return -EINVAL; + + return UNICODE_AGE(maj, min, rev); +} +EXPORT_SYMBOL(utf8_parse_version); diff --git a/include/linux/unicode.h b/include/linux/unicode.h index 4d39e6e11a95..12face04c763 100644 --- a/include/linux/unicode.h +++ b/include/linux/unicode.h @@ -76,4 +76,6 @@ int utf8_casefold_hash(const struct unicode_map *um, const void *salt, struct unicode_map *utf8_load(unsigned int version); void utf8_unload(struct unicode_map *um); +int utf8_parse_version(char *version); + #endif /* _LINUX_UNICODE_H */ From patchwork Wed Sep 11 14:44:56 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: 13800720 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 3CBF5EE49BC for ; Wed, 11 Sep 2024 14:45:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6A513940054; Wed, 11 Sep 2024 10:45:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 65641940053; Wed, 11 Sep 2024 10:45:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4800E940054; Wed, 11 Sep 2024 10:45:38 -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 22151940053 for ; Wed, 11 Sep 2024 10:45:38 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B297912138A for ; Wed, 11 Sep 2024 14:45:37 +0000 (UTC) X-FDA: 82552731114.16.8B5A9AF Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf29.hostedemail.com (Postfix) with ESMTP id 0793F120016 for ; Wed, 11 Sep 2024 14:45:35 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=RNPzzW+J; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf29.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726065851; a=rsa-sha256; cv=none; b=CkWbgFMQdvrdj7sLh7syyX1SlHf60LZAx4GGgCrMTzZ6w54Bbyu6S+r6o0GGe9Q8BTWI/K UNyYouCGu425MA8qDhcQ0kdfoUFzgPg1EtYecdn0AAE35uKlCVpo40gjgKv7PYblUwicu6 XXg6Zbr2rg71zGwoi5qixmNzLBAqeLo= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=RNPzzW+J; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf29.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726065851; 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=Q0CxLvnub6YNgaQNFMUQs5iJpolg9jiEm0ayfVoTv18=; b=mSoptj0bo99UZ01auzoqFV4xFnUCevuD5N8RkyMc7r2n8ftSgtbEHBQINTG+ZvQJej8ZRS 3l0M9hR89U2gGKVR9cdzdg9KjME3PCkXU2StuXPES3xE7j7aDrH70dBfaoRndKlbss/fgm X2w0e0G5k0M+zjVTDR+CxJYN8pbSCn8= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=Q0CxLvnub6YNgaQNFMUQs5iJpolg9jiEm0ayfVoTv18=; b=RNPzzW+J6Gy+V7B4nSX+XG52Pv mrTDmizb56Ty4IzYaIyjxAFQgOgdRKJYM34xOv64sr9PVV8kbabW76/oWNPdm+0Utqhh8sC/OQg0W 3lpoSGCXhe49JKsQv9lsQ2jUmNmuNjG69npKt6k5TV3g8MgJRHJQ4/JypQs9EOwcifkjLK0WGwQD7 unLC+UxtoDo0VewnbYj9oeiZuVk0XYwqxOpBp/PAcGGjmWRLy4kv0p7EwJztZazVs8KS10o7mNeoY TvngTO0It3S6tzFVn0hNSiHadP8T0DQxncgAiTK4LF8Qf7QA1rBFVhbKsOh25JVczfyokdbHftNMA Xp8oLGxQ==; Received: from [177.172.122.98] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1soOb2-00CTwi-L9; Wed, 11 Sep 2024 16:45:29 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= , Gabriel Krisman Bertazi Subject: [PATCH v4 04/10] unicode: Export latest available UTF-8 version number Date: Wed, 11 Sep 2024 11:44:56 -0300 Message-ID: <20240911144502.115260-5-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911144502.115260-1-andrealmeid@igalia.com> References: <20240911144502.115260-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 0793F120016 X-Stat-Signature: 1t9g98tthyd154wwsu47icn15ag8c8h4 X-Rspam-User: X-HE-Tag: 1726065935-107613 X-HE-Meta: U2FsdGVkX1/t9Mx7xKhAGqCiEGK0tdK7uQ7yKME/Uioa4yLTFNWl+HGWE7VLgAJwvnKjok3QYt1KDrJnsrUSQM0642kfQgQl5bhwA6xMgGxGjccMkje2TbLCJ6i49tksS2bWQCwiuUFazX8YslSvKFvZgDc8pg9U+XN00rmRPSVyb4Spq3u638A/GZBNLnuGfV0UUroVX8A7XXCEcLmCf9BBMU/pjgqcBuiHZK9xi/xiplbMZBU22eL30YrluIkFoDDCi/RLXit3KmbpSrxV/FwTmf+oQ11oEzhh7DBJbstQbDa+nrJHhvm0i30TTmtD+zQJ7sXmPL6KLVRaCHKIp9zZB9t4XrTCOhmLbUdYPQ8BI14NM6qGq6L004W6NIC3IUhgXKwRKP0Kw57dbl1i9+ifghpkxMg6YDT29/9PkNG9dtPAbhUBvX5tI2cMlmihfJ7ITsOVVmooN74VU8X5rXtgQdfwxw+ziJbukYudz+o3uoszNmSwMF1MEuR8fKBXm+4ROAv4y5oDFEqb9zUCURBxZ1139C7v2jAGJfdtsz6oc/7+BeQg9q+onfLf6qKA/EjmGYtbGBCvxCbXrljc0csrwu+4krH8eOv3hgbcLBL+2h+lQrlHpornBigoI4MlMs8ZIG93A+WjFkMtXhfJ7azagnr5sjXfP5GC2KN847Yg3JmdYM7T0h+xy7RUFJvoZRU9LIWgCpk1T/cE3WilZsHmONSHKx5NaKmK4mNS5swrMn9TCYw0tcWixJ2AoT+aBQE+W5CvlMC9HyN+FWFcY+t1Q8bjwY2v5ETlNkHqeG46kCyG+EyvEYraTd2rMQAjl1zGxlU29eU9YThfbrCr0KzP3GJOOx+6JSARd2Djpp73gSy4n8aiddMqH1rCD31MK5ok1RO4BfbiBNgb111Rw497F2EaLarA+oDPHvc7TXHWbPRA9cWiM+XoPV2l81IW9NsGzDFzS5qNxzzb0W1 52QFaiZ3 Irh9EzR48CeIjWbcTlidgTH4GZexLUXGPhVjVYwq+A/+h5gBOyVHDfeCxGCq9GCFS1UcKVmSASuuQqM3wBeo7DA49voWjQKPzphBYHdj1Jw1uGNTMam535QmcbYYbd/ujVCbTylViwaeqFDjSi5QydPkE6I8D/tPIzoiaC+XoSHKoNduYBiKKrvgZotAxJ4zBsoY7H6kO7Y8KNzEp0M0EhuToAoqaUR3Sh5CCbyA25K1AYii7u6NqmyfmsksXAFHx6fnlaUlxBgwmy8yUxAD4CCVBFW824uc721dJf/Ep7zgB9Nh0moWAjvc0Bj3Mf6Syb7zOc3/pX9hVnPc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Export latest available UTF-8 version number so filesystems can easily load the newest one. Signed-off-by: André Almeida Acked-by: Gabriel Krisman Bertazi --- fs/unicode/utf8-selftest.c | 3 --- include/linux/unicode.h | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/unicode/utf8-selftest.c b/fs/unicode/utf8-selftest.c index 600e15efe9ed..5ddaf27b21a6 100644 --- a/fs/unicode/utf8-selftest.c +++ b/fs/unicode/utf8-selftest.c @@ -17,9 +17,6 @@ static unsigned int failed_tests; static unsigned int total_tests; -/* Tests will be based on this version. */ -#define UTF8_LATEST UNICODE_AGE(12, 1, 0) - #define _test(cond, func, line, fmt, ...) do { \ total_tests++; \ if (!cond) { \ diff --git a/include/linux/unicode.h b/include/linux/unicode.h index 12face04c763..5e6b212a2aed 100644 --- a/include/linux/unicode.h +++ b/include/linux/unicode.h @@ -16,6 +16,8 @@ struct utf8data_table; ((unsigned int)(MIN) << UNICODE_MIN_SHIFT) | \ ((unsigned int)(REV))) +#define UTF8_LATEST UNICODE_AGE(12, 1, 0) + static inline u8 unicode_major(unsigned int age) { return (age >> UNICODE_MAJ_SHIFT) & 0xff; From patchwork Wed Sep 11 14:44:57 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: 13800721 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 8A75AEE49BD for ; Wed, 11 Sep 2024 14:45:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 82A0F940055; Wed, 11 Sep 2024 10:45:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D8D8940053; Wed, 11 Sep 2024 10:45:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 67A20940055; Wed, 11 Sep 2024 10:45:42 -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 4B409940053 for ; Wed, 11 Sep 2024 10:45:42 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id F2B2C141545 for ; Wed, 11 Sep 2024 14:45:41 +0000 (UTC) X-FDA: 82552731282.24.25A0E08 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf18.hostedemail.com (Postfix) with ESMTP id 306731C000C for ; Wed, 11 Sep 2024 14:45:39 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=JM3ErL2m; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf18.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=1726065855; a=rsa-sha256; cv=none; b=gJVMx2wHqdWX/ajcYXarvYhpQXa+hwBicAMX21b5kNwAnQhy6f+W5/1Gy5hdT6gfN0wZ9J 7e4EkQdFXsx+N/K169ahYTlOMAGwvkXMZ6S5zJY1n/YMVjUkGP/SNsqLbTw0sViGHz5Anq Z1m6OKRfPGh1imZhuqwhOd+l2jfTpAU= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=JM3ErL2m; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf18.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=1726065855; 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=3FFQIAuGvH/0A1mPCgj4xlU1M+Y3nXSW60dESGxKvsQ=; b=B6LpWd5S8ziLMyFyAN6RMN9RwaxQdN36um2BO26O+NTMXfrsCG7tksuRSl1hZJ6LhRnp8P OeJkmtpFXDSfelgiwEheWvwxPsmx4CBtpXI7oYmcLuoNxQ6kHn47LMeJvcU/Pc4WJ1Yz/v E5bBL1idmKBCnrJ3RXyMnAAU+7qig1M= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=3FFQIAuGvH/0A1mPCgj4xlU1M+Y3nXSW60dESGxKvsQ=; b=JM3ErL2mdbpqkr+KcUJ1aszMzB jLUIm09KwRkExt16iFaCVWUoYp+LQYa1M8VbtDybGticsjAqAlWcY2NjwguRMr8P3SiiqOT+fbESB 3KQTsCcWkDhdfP0wvYJ9Vge/dkxu7H24NfFYEYPIZmMHqhv7hW80CTFZQ94DizqdnAvx9ruoU02MG tAc2qt6fQ24oNqy7UUU6FxcXymXkkPUVxqlCjU9lrA6CjR+R7J546lGLArpOb7MISi5m+tQyBPemd +KDsSJsXEv+xrk2OD2lZ2WZpAziErf0cxqXrKqtZLXWYgrIq8V+vCRArNAZnX0WkvFBZKEqQJk5Ih m6IL6OTw==; Received: from [177.172.122.98] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1soOb6-00CTwi-Pc; Wed, 11 Sep 2024 16:45:33 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= Subject: [PATCH v4 05/10] libfs: Check for casefold dirs on simple_lookup() Date: Wed, 11 Sep 2024 11:44:57 -0300 Message-ID: <20240911144502.115260-6-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911144502.115260-1-andrealmeid@igalia.com> References: <20240911144502.115260-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 306731C000C X-Stat-Signature: 5unyd95t76jq1pu1fk951q3dgfazonkm X-Rspam-User: X-HE-Tag: 1726065939-351 X-HE-Meta: U2FsdGVkX18ReA7smVEcxyQgG7PECbNI/0cB4jbxoc4YTFyci6cpBO+VFozYtI8ZxwOaQPLbWSFD8CGKXeJSoFhzL+bDATJfoq2foSMj7BBv+IQiaoIkyxTopWfo2Nbg35UPOMPPg8874/u7EyIDupYq2tkUya1CSyOFWZ58vhzglGwoYpB8EN9zLHB7zlyU8z7ehFtwrl7r5Y4BA3aPESJzKMhRLbv6e7OVw25UXaLxrKU30wpjaTa+BdIJ0niGM1HlOPoeF8wFry19D1Dxt/3GgMVLAG+Vkw6w7YIfw4wA3nxyebGPYWBcPL+l2JAiVM/l7RVAOM8Hafrayw6ZdK0Ul6fHbQ5sI2lZSVvii0ENucqpCyassNLf5REem/dEheUN0A7N8wBz656l1qmLWYo3GaO4EIR70ktKuP/FpKsWfKUaCLDYdo5p+nVd6R0c4oMhBcEPdBmQgGWXpUSpmP9XZEnKg/FMCCg5xVKJyeajupC9/ozWRcrDkapSudUsaoo8Zwd/Bm7wN/MIEf5VoVgoCdGIu5ofXHh4GfM1U0woLPsiw9FL1mFYH7owljNaVGEfcXA8fxLUKdTE2f+2is5t9cjqnyZCr33xj+t6T+w+Hxov6/BNPqkVPMUE0ZRdvT+7nCdncg/Phvdmc6U9u37TNNObGwwTxmwdpCTi/czFpMN0Os1/vx8KNzjV5PVndMlyhJCnH/jbq1fLC+AHYVK9TSHn5JvRGacg1uxB4xCQvb7AH5Q8K6ure15EMfrwJ1+Ak8Trb5ivvcpnvyLBefXHmUbA+guoZb5oc69+/b5InHNjaP/f7fiuIyiL4sN0wZ7I7a406gL9WbxjCTagH22EdT/8VtJBEZNeOKg7iPRU0NljbgwvNIU8p6yrWkHViA/BNBktKKFrhUbBvYAsCMgh2gn/bEqPUBTPsO6bfr4Ec+FGeimQqiv4lnRbXLyP/mEGYfaVhjYP+mNM7hm 8Nx0uIgV /eNoRLxvnatEpVqEl5zcwiV4IbXX2BVk0yDNxzVXGJK9loOmgMt9GbfqakdQM/ezPeTjUuDtpFKsnZcm7LF/9S0eAHF3iMpK2DPEsfMHTiC+dx53lalat9gfwqbWYqnNkEBVfBQc1uHT57MmSPadZCpp9BMvdWH2BjMs2gkrsyRRskUTAMjxDCvqPslxFOA4LP3oQ46FRsl07rQDsEyMBdlIITAJWVESIO0E/HWR+KIq+WOTeD6q66ysZuUD5SJQyh24Dx1ZWqTmN63t/sANF8c8siOgeQZOaOkk3hepxC3SglipaXuKoc2kwtzEjZtg1NCm0UZ9SDxiplKwFMhks2uvyreRWKv7+pL50cJEe2KSngoU= 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: 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 --- fs/libfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/libfs.c b/fs/libfs.c index 99fb36b48708..838524314b1b 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; } From patchwork Wed Sep 11 14:44:58 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: 13800722 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 D112DEE49BE for ; Wed, 11 Sep 2024 14:45:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7DBE1940056; Wed, 11 Sep 2024 10:45:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 78AE2940053; Wed, 11 Sep 2024 10:45:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 604D3940056; Wed, 11 Sep 2024 10:45:46 -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 38D09940053 for ; Wed, 11 Sep 2024 10:45:46 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E156DC1393 for ; Wed, 11 Sep 2024 14:45:45 +0000 (UTC) X-FDA: 82552731450.20.481E4A9 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf12.hostedemail.com (Postfix) with ESMTP id 418B94000C for ; Wed, 11 Sep 2024 14:45:44 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=hxJKefRG; spf=pass (imf12.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=1726065839; 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=B86Pw1ckCkywr9gzf5gk+joWfc2NDawEVXulB0pNBG0=; b=1WvTESpaw9P/jBoDn+gfIfWi/kHFQlR37rtX6kwrKupYZUpHz+VbttZHd38CE89Dh0Zhqe 4YVB7xRbcEXW86nEi7NFDgOZLjD94evT5oXoMcq2+8SphKrcBQIIWSd3dPWIkXNitwf/fU M7ENRRlViHz0Bh6aJXappPd97nUa8DI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726065839; a=rsa-sha256; cv=none; b=yY03NFTQro/Y1DYwimNDx85n79N6DnjZKSHWzQCZWu7II1fOXIEia4L1UemeyUC9fXd1cL VXdjUVCh4xLujxoFYwcdckcW2ZemInL5r+2uWl3kSH5Bcs22xnIKLJFsQtfu+P4AiM7X4B WZK7zu3GtZQkNq7eaQZl25YnAYvMvAk= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=hxJKefRG; spf=pass (imf12.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com; dmarc=pass (policy=none) header.from=igalia.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=B86Pw1ckCkywr9gzf5gk+joWfc2NDawEVXulB0pNBG0=; b=hxJKefRG1tjyLL745br9iC9O4A jcfqv+LNEBW2FgL9bLdQh841tBi7M1XJNljoL/h+w6JBZ4Qt7AHX2JQ3fILqb1kKkXydBhzZ0f/Zf 5lQTd/bh6iYANTNNqdkhLdBaM1zx9cBpMHpmQyGAudyPYwWKf8+nLNLqCBhQrnDelY7LcUOoRIzx6 3CVm4GH7tvWsHOn94OzODUu0C3KhOEYk153KyDh4Nh/wRDk6L28h0fmMeYJaL4Fbpp3iM0xX4PfBy gNWVKo1x38q654U/6UwewxkbF/8tDNc93lckRXHV2U0om76pxlBisCcYgv+MdbVwlRUe67gK3SZVA HSnuoh7Q==; Received: from [177.172.122.98] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1soObA-00CTwi-UH; Wed, 11 Sep 2024 16:45:37 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= Subject: [PATCH v4 06/10] libfs: Export generic_ci_ dentry functions Date: Wed, 11 Sep 2024 11:44:58 -0300 Message-ID: <20240911144502.115260-7-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911144502.115260-1-andrealmeid@igalia.com> References: <20240911144502.115260-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Stat-Signature: kafjbeznj69jwdi1kjb1er9t47syeh88 X-Rspamd-Queue-Id: 418B94000C X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1726065944-133884 X-HE-Meta: U2FsdGVkX1/XiSRufMwic4hh7aaTwjTIpsbZbpwDA0t/3crg1fukSLkes262JUwSsv95NctPUVL3UMgaxEIXLxrf7ThnC7uFgDbWlvmatdK4Tzb6AdD7xq6xwKhvF7bTHD3+2xn5TZ795KY/OiOPqdpJzrtZvQS5zr26FsslchHyfIFJAU5GNOfc+1mGx4z+exLwGFaKX/rZFaxshqhAViLE4iYb2EihTxBrL2yFegXjclieRo0bRn9C1Mj4SoAgriOYar0KswQe4iLcXarS19yK2akCfpoIO8AmWaGL2c4u0FnrlgNrinD6FwsYoawzZmlZgEGxwppmmk1rCtyz6WNPTcXLtmndVZgmmesuGYYOkkRs9ihuDYZaAy5YYeqIF3ylUNDxuryI1WDg6xQqwY7zR2KDPUTyXA995kxlBThnp8lzwvS5SuDsdhCUxi9/vb56j22mzSGVAi+HiqxdMMAneUlrK0RVkj7KgMEMIzOj+JmqVpUYwpiTzKYtkx2Q5U7L2rE5WnYfSqERa/CXiQKpPOLHV2zW3YUhGJ0aL9eQGczDomB0w1I++95SzWTraJn6E8pTrsGKGDTE0g0Hl2mOvFMUOlyTkcoJtL61j2YdL7sWWLhylX6AhEsaABVOxMX26viQgiqo5kMvvFYMmMk6C5eNOi8PzoFeCFII/aDsnN3FCmntv2q7iBHk+y25+lyw1I5uXxMBcRcWa/mcBIeysQonGKIVs/0Au57xSLljhuppS0FQ4ySQ4Ln3r5dMPgInT+YPZtNgdjGGN9efc64F4CDc6JstUNH+89imdH9DzC41VbpYdKytvq7EovnL9T+OhHZg7c6WjJgY+NvRuVf6CmkIdSEyKX0Cs0jwsj4Qo0qhjon8K+f2qfI4Y96a6J4NPm1121vchgaT4zYSEXOhs3+wnDsB31IbFk7I/uR0KnLnJRaRhX7obb6ON9b59ccAJvbQvIiCHw15vZA uaIV0jk8 ILVEn1i9GcSLiLoqKTv6sP5yaL3+T3ptO5u0OiZKe7icBAuj+xdtrSufyxmP7tvY3Ezgb9hlm3zBeqCAMhFOohHiAb3+vzuthxw0iGAl4YxyZ7kKNoO5lLCIsLBSd9sEMioznh4AJ40oKTSObqSyqkKp0eoA7y52SiiRzGjD2QPhIvnBGFwaPRb8Krms2sNiyP2hKz+b2bMZmSA2M35NVQ4qdW9GdWBK82UunDu4vggwDao85JBt0aohDPN8oWQOgIHeCz5ObZLZ0KOzAtvK062+qji+XQIQlQlsIfyZTwW99ZallRICgb4y9ZrujI7oBroDP4wqGaynDlf5NB4zI6iYg/wwgEVB6NGKJR119zoSqleE= 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 v3: - New patch --- fs/libfs.c | 8 +++++--- include/linux/fs.h | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/fs/libfs.c b/fs/libfs.c index 838524314b1b..c09254ecdcdd 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1783,8 +1783,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; @@ -1827,6 +1827,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 @@ -1835,7 +1836,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; @@ -1850,6 +1851,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 937142950dfe..4cd86d36c03d 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3386,6 +3386,9 @@ extern int generic_ci_match(const struct inode *parent, const struct qstr *folded_name, const u8 *de_name, u32 de_name_len); bool generic_ci_validate_strict_name(struct inode *dir, struct qstr *name); +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); static inline bool sb_has_encoding(const struct super_block *sb) { From patchwork Wed Sep 11 14:44:59 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: 13800723 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 94CEFEE49BD for ; Wed, 11 Sep 2024 14:45:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2845F940057; Wed, 11 Sep 2024 10:45:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 23416940053; Wed, 11 Sep 2024 10:45:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0FB18940057; Wed, 11 Sep 2024 10:45:51 -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 E5DA8940053 for ; Wed, 11 Sep 2024 10:45:50 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A2A3F813DB for ; Wed, 11 Sep 2024 14:45:50 +0000 (UTC) X-FDA: 82552731660.30.C036626 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf10.hostedemail.com (Postfix) with ESMTP id CEB4FC0014 for ; Wed, 11 Sep 2024 14:45:48 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=FmEHDMG7; spf=pass (imf10.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=1726065896; a=rsa-sha256; cv=none; b=jFne7o3FirVNjibiu+YBxPgitf7cBx7SgAVQwMVl8lxNR9id+6xsbalvGp24nUrnPH3l4A XYf41tszr81zoyTkj+OZS55wQjTE75HmlajVhCCwRtzfzP8kCXNW1bwaHpe5IsmrmXnqKV WU/L7Z474tloAdsvOk1CLNAQdzNQ7TY= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=FmEHDMG7; spf=pass (imf10.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=1726065896; 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=kMwi9DgjI7/4v55ZzZscrcyDvk5lH8JPPPnq5o6cGm4=; b=jGoBhdM0yuu8bNIDD/85FML9fCDFtJDjf5X8zzv15F7Unj1+H8jvcobozh8/z743wJHmgA W/5h9Bj5a14oDO/6gAdomR5NZNaq//+oQgvMCIsm2mVWkaNxpyrHUOxAUKiVRFMf3SLYIp 1fS46bhXzhVZSW+y4XcA51gcR+adqP4= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=kMwi9DgjI7/4v55ZzZscrcyDvk5lH8JPPPnq5o6cGm4=; b=FmEHDMG7eXG0TEGGUg8tka63zK RnKBDbAXjJqpfqHBUAcPugh2cNDiWQ0po9F4c3IwIaT0Jc7gVNacP6mCQMf0yPKzqfOQfZs8IwGmv 5iKwUQQ775VWfdLlDKuT6Z/eLOdkST79naFS28AUdk0lxUjvDxginAYs5OSVEdu59EGsUO3p1PGc4 va4ORflAzosENoLy71Jw4KuKkR3poXZC93u7SrvFwMV4keO9skIW6nHStCFY8bzfBXa9kgw2HAH9g zHoxIJKJhA+iQm3bu4SUKXKDLIeymG7T13PVtH9ZYRNy2ITJsW3PtqXN/cYB6B1jGyyovMLfOo4dV uj/VJYow==; Received: from [177.172.122.98] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1soObF-00CTwi-2s; Wed, 11 Sep 2024 16:45:41 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= Subject: [PATCH v4 07/10] tmpfs: Add casefold lookup support Date: Wed, 11 Sep 2024 11:44:59 -0300 Message-ID: <20240911144502.115260-8-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911144502.115260-1-andrealmeid@igalia.com> References: <20240911144502.115260-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Stat-Signature: beuuzjdd8xunkefnot6bqgjecqimu96e X-Rspamd-Queue-Id: CEB4FC0014 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1726065948-894576 X-HE-Meta: U2FsdGVkX1+5wGHvQspiXOGJ43DAFSVRchTe4RYn517epPyOCmudpEd6I5EmHdobcd+46GZX7ZNHbmTNonHO2/OMtJMh6bXn5KDJeTqDpWJnZPitTgOfy+cEaCFTgzGARKlYsyVQ6fdjwYQszq5EiVcryXtD5l2pss1YyqtS1zN9gk5gJAbAM1aFbRqn8/cVsAyKGEbNAqdfN0w+N/yW+/FLlh7CgM4DrL5Fd/WF1uQbT+T0X70ZX/0Q1s/xW/EWLGjy5nO4FBbQBW5V5L7kIunT/q74XThLYuTlk6inJWC4yLN/aGLZtlzpInJOqKU/NCcss0ZS+rOWlUh1L5H7hezCxXoNuFr3idmYP+fY8hNmSHnVlQnV+hxNpU4Ut4ixIGEAP8S7jCuxLKLvSoougwRoOVUSRRUhtWpXlKG/JIn6+ZqxtAJwNuMx0GnmCfm/xLl3eGJbl/7WXhDVsR8uYAXQL8mbG9ZzZdZiW4MFz8J/wXGxYCZuO4NEmTuDBeNbUAOCa7f5wg3y1y0HaAWBt5XJ6SL4QZ8RVOyrI9gPnS8jb5IOu91UwDUzD+ixkui822fARB8L7Ntlxk8Y2vcT9xm6hVaIHkr9hTT6zKANn1/jgXEaILOq++LU8snmqVKdDCppywKpZ9kby005YuocY91zKW5XHNAJaT9t1bKoQ112FRbQaO7GH/JnUlSAadiFEGwkK48UzFqczaCQF3a4lLIBwZwYovItCQ0zpGyKYkGwWheUl9eYXsONb2c2olDuLhxYfPXo5iJ8GRYiSct2DxoXCY8rCa1u51kmYl/2gVeLsSM9RC710tHEV129ZRQ+yV7DGHYmcovimUB41dn5bRSUIFcwYPMVp7lyYibfOTE7ygr8gBL5gK95HiTx0MvYg/RhZSWUhe6pajGMPiz6vVXKN3VG/uHQ4uyM2vlEFXQ4q0yLs2OCxu8zMuDZp0U4XDnRjgcUbYDU6g8tg3J 3BxCDsMQ GGMGMZPvGSUHg5s5EZCoxGyZYg53DGPFsifNbrAVQz6lBlWX58gj3yIXuyRfmP9A+8AZHB4wXVlJuUAlLrmiVPu+HLxbBmKs80k6BJJW1n0elZUuJ7J8EJ3mwPphxN9mtKqEc5zLlabFywQ3U07RVX57ggeZKFPITgUH9EsbyLQi7QYiPJf4gRtM9bwz45GN3U5QqBWORvBnzDhnw4ocPiGfAxu7zI49JWIj6P6ZpXEGbN7LDJuIqB7cymQNQf0dY6RRQqG5ST8SXsRrZzYPKr48CWQb9t1vMqyq4A0IcEJ3zhtZOSJbpVMcJ+en2nw7WcGaBtuQwTBUCzd4= 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. Signed-off-by: André Almeida --- 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 --- mm/shmem.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 115 insertions(+), 4 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 5a77acf6ac6a..4fde63596ab3 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -40,6 +40,8 @@ #include #include #include +#include +#include #include "swap.h" static struct vfsmount *shm_mnt __ro_after_init; @@ -123,6 +125,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 @@ -3427,6 +3431,10 @@ shmem_mknod(struct mnt_idmap *idmap, struct inode *dir, if (IS_ERR(inode)) return PTR_ERR(inode); + if (IS_ENABLED(CONFIG_UNICODE) && + !generic_ci_validate_strict_name(dir, &dentry->d_name)) + return -EINVAL; + error = simple_acl_create(dir, inode); if (error) goto out_iput; @@ -3442,7 +3450,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; @@ -3533,7 +3546,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; } @@ -3553,6 +3569,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; } @@ -3697,7 +3721,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; @@ -4050,6 +4077,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[] = { @@ -4081,9 +4111,53 @@ 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; @@ -4242,6 +4316,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; @@ -4471,6 +4552,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 @@ -4481,6 +4567,17 @@ static void shmem_put_super(struct super_block *sb) sb->s_fs_info = NULL; } +#if IS_ENABLED(CONFIG_UNICODE) +static const struct dentry_operations shmem_ci_dentry_ops = { + .d_hash = generic_ci_d_hash, + .d_compare = generic_ci_d_compare, +#ifdef CONFIG_FS_ENCRYPTION + .d_revalidate = fscrypt_d_revalidate, +#endif + .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; @@ -4515,9 +4612,21 @@ static int shmem_fill_super(struct super_block *sb, struct fs_context *fc) } sb->s_export_op = &shmem_export_ops; sb->s_flags |= SB_NOSEC | SB_I_VERSION; + +#if IS_ENABLED(CONFIG_UNICODE) + if (ctx->encoding) { + 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; + } #else - sb->s_flags |= SB_NOUSER; + sb->s_d_op = &simple_dentry_operations; #endif + +#else + sb->s_flags |= SB_NOUSER; +#endif /* CONFIG_TMPFS */ sbinfo->max_blocks = ctx->blocks; sbinfo->max_inodes = ctx->inodes; sbinfo->free_ispace = sbinfo->max_inodes * BOGO_INODE_SIZE; @@ -4791,6 +4900,8 @@ int shmem_init_fs_context(struct fs_context *fc) ctx->uid = current_fsuid(); ctx->gid = current_fsgid(); + ctx->encoding = NULL; + fc->fs_private = ctx; fc->ops = &shmem_fs_context_ops; return 0; From patchwork Wed Sep 11 14:45:00 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: 13800724 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 075DBEE49BD for ; Wed, 11 Sep 2024 14:45:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 939DE940058; Wed, 11 Sep 2024 10:45:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8EAE2940053; Wed, 11 Sep 2024 10:45:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B1E7940058; Wed, 11 Sep 2024 10:45:55 -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 57D02940053 for ; Wed, 11 Sep 2024 10:45:55 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 0FA20417C5 for ; Wed, 11 Sep 2024 14:45:55 +0000 (UTC) X-FDA: 82552731870.30.D88D645 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf08.hostedemail.com (Postfix) with ESMTP id 3F6D0160021 for ; Wed, 11 Sep 2024 14:45:53 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=A7Dg7fX5; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf08.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726065925; a=rsa-sha256; cv=none; b=57iKxn/I/fqUpYc2nlLx4ev5eFWxfU66Mry9SVdcFgS0wA0T+aSW1FZDfMwOe81TWkEq/c mjXyzQIhwcsM+Nxal4/EOkL3A/h1gUCV9OYZgdTMfokWyNrK+SBUtSRPagarvjJjHx9vKu sIQ7JBAq8121+SIIYlfXupbcSH9IMJY= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=A7Dg7fX5; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf08.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726065925; 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=pWMEhCsmENMz2YxsCsMAnt8xrE5QYXGLyTRuCLCRswY=; b=X1IgP9/Nvl7fiNSkkV/TZN2vkN2v9m8RpaFZyyL7uZ/oj1WYbzO0mB0lPuiqD6creGhi3a 3rcQx7eOIpUDBsFr4XwSWeTXmdYuDNEXC8s4SXBcjvA8uVl8g0GFh49AG28K4METFGWrkl EutsRK1iRKovM02oGQUKrWEQy99fbNc= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=pWMEhCsmENMz2YxsCsMAnt8xrE5QYXGLyTRuCLCRswY=; b=A7Dg7fX5KbF29tj/ZUs7s1d8xF LoxB0wt7OWD8cD2bQkKQ6V+iZ+jAqU19nbtnKGvoTUunl0XyHT1UeJyM4KPnPIYCzQ0CkkuBtYJXa dALijuXnTc9DQl9TmwyAdwExS8sEjAKLN4mHvjmVHpEKJ2FkIjycdHCqWCHMqGIKL4d6zdbvpyPDF 2uepRXkz3ah0siPKv5m14Ad3246xMxJCIU5UlL3zZrLFbHgFXz+brqy3forjWy47mLkofoc3P+gN2 vG0fJs7j4lty9DDtMyOeYrXfG3j0RqJ7miKvVKihcaDQwaXfFPIwVdLEKJvrJYs2hDM6s2li2bFv0 cVRIaV0A==; Received: from [177.172.122.98] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1soObJ-00CTwi-FK; Wed, 11 Sep 2024 16:45:45 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= Subject: [PATCH v4 08/10] tmpfs: Add flag FS_CASEFOLD_FL support for tmpfs dirs Date: Wed, 11 Sep 2024 11:45:00 -0300 Message-ID: <20240911144502.115260-9-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911144502.115260-1-andrealmeid@igalia.com> References: <20240911144502.115260-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 3F6D0160021 X-Rspamd-Server: rspam01 X-Stat-Signature: ctmbm8riz3uzmhthnqyyme91rzgqub3z X-HE-Tag: 1726065952-521691 X-HE-Meta: U2FsdGVkX1//CV4vS6xwsIcLt3iWZYpY3UVZ3IAmgLnB5sZP9c/PgdeFYQDGd1+I60qkvX92lDB+eUiTsA8WNo9j/Gpdvhq1X4+UE3cc7f2rbZvc4b4HbPmJSAR1OxY0ZCCOyWXCLCzLVHdlW8cpPfH45yfGRMlJwx4uutXXv6Ufud4Dl+od0rXC0o72g9Jrqv5tNErkLwssJ4zDlwseTMkk8Tqhj+Qd9qyUrg1zOz7B8iwThOGVfP5GlRNVB26jkQM2Zho75W3fhpM41wdf0cHKFuem11myC8q57ECgiu8v/M3kx/Eh33rpc3OSDHjVyqVsWeYNtiLGjx6onddzB0PfGcItKAoatq3+BhpYEhxH+rQ5kfGxIKzLCTWhE9LDQeE4n6Vn+hQ+/QDGfitnpvXgZG9F2/RMlCLgEXG/8RHZVEiANXswe20EsgJeox5H4inqxmjSpYBDJBFGifYisp6TP4iCeOVuwPDreCTRLEVlnsnJeVFQ8D/jcudmLW/oK4mr8bE9QQ09lb96+yVCxEX0f0akgjyU2q9ojau+S9N8JwltZPTtPJWuCLUV4HlmW16U+Uv7mAKEw9qsv4Jeg5ILHc2b2Hh3+dZ5VUOKCWD3XEdZtv5A/HLkmzTmFw7TTxF0tXvWiX800f8mimT+dqk796M0OmJEVfmDcNADjkxTTbvCF+qCnRaNdf8zJ6HpUMWeHqbCtWoLVSAWq3udHBiJyVd1VH16rNUzLCpOJwakElHutqUERlVPCt631egNZsGcSVmADo+PonLjDXqwAkUzhevTvWFdZRq6dPwp/bm4f6vFSS9OIpX2KZdkMaJ47pCpyxSpsbnoSTQ1H6fwCxWuGwBRDMB8OoHeVrEvjncGuvQeELPT/ZfmefddATs9cFrGxwkUrxJJXu8AtuhFCi1/HZAQPID2jlwcquB2JGQUPqsS98HCRScRneZBLd+AC37xBlUuWzH6m0XFCPm 0/uv+up6 XwwVS0oMaikZ9eciwEPwlJP1qlNPzThOpT7itRVENrupqsjlh0j7Hn3RUU8vQ9VMujqS8iqELwU5tdPZnQPRkFTdzLQTaTMmCnIFN7ML4S0TD38u4Oz234wTl1QnmyugKqPJSOpBf8Zw/NLFnPxot7/xqg6c3uy3Iv1yFqFqo4u3gY2Hti6qT1kHy7lrOqAqeF8ZyNQjViqOXWz3NcvociA73mQCY9HCwymX8ak6dtjYynf5IkFnM1Ms3eoDCJCSCvbKQcrN4Q66pROboQxtatdi4n8mkORIKDg+vgcGQ7qEXxtJkX/ptv5xY02BwKsF5KU2HfOkEXUiJYcL/BIVW6xQbAVZmuuHQHMFPNNeME1v0Cjs= 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 1d06b1e5408a..8367ca2b99d9 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 4fde63596ab3..fc0e0cd46146 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2613,13 +2613,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; @@ -2630,10 +2679,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 @@ -2680,7 +2731,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); @@ -3789,16 +3840,23 @@ static int shmem_fileattr_set(struct mnt_idmap *idmap, { struct inode *inode = d_inode(dentry); struct shmem_inode_info *info = SHMEM_I(inode); + int ret, flags; if (fileattr_has_fsx(fa)) return -EOPNOTSUPP; if (fa->flags & ~SHMEM_FL_USER_MODIFIABLE) return -EOPNOTSUPP; - info->fsflags = (info->fsflags & ~SHMEM_FL_USER_MODIFIABLE) | + flags = (info->fsflags & ~SHMEM_FL_USER_MODIFIABLE) | (fa->flags & SHMEM_FL_USER_MODIFIABLE); - shmem_set_inode_flags(inode, info->fsflags); + ret = shmem_set_inode_flags(inode, flags, dentry); + + if (ret) + return ret; + + info->fsflags = flags; + inode_set_ctime_current(inode); inode_inc_iversion(inode); return 0; From patchwork Wed Sep 11 14:45:01 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: 13800725 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 67182EE49BD for ; Wed, 11 Sep 2024 14:45:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9249940059; Wed, 11 Sep 2024 10:45:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E4180940053; Wed, 11 Sep 2024 10:45:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D09BD940059; Wed, 11 Sep 2024 10:45:58 -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 B0EC1940053 for ; Wed, 11 Sep 2024 10:45:58 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 59BA91A1324 for ; Wed, 11 Sep 2024 14:45:58 +0000 (UTC) X-FDA: 82552731996.27.B5F2067 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf04.hostedemail.com (Postfix) with ESMTP id A96384000E for ; Wed, 11 Sep 2024 14:45:56 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=ViLjtovm; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf04.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=1726065880; a=rsa-sha256; cv=none; b=JaE+4COBX+yRuJJ9hnIjgWb8rc2lmK80A3vs4DA1wQ7Mw6fzQOkvj4685FAXtIBaNRItUG K9xDUgtkrwwOv2+wBWHusJ3uNom7BEiPyg/Mh1y15737L8M8FquGCJJmbiJNHQwet+gC2W 8S2DKhvZX2jpWNCFv4ud7AyYrTLAMkQ= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=ViLjtovm; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf04.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=1726065880; 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=pK8srYuw9wrv3ZwJYkO0PSANkqjQtOsAR4zsFhEgnYA=; b=EwP4R4Zgo6dXAbMzzMggfLuHVflu9PfQuB+U2LvQphCr8htIZC+7eL6GzVT7wbZs/YJ4Dq tHFTdPAc7USaem7i/10xmCnSsqlfN2w3EpFvJnegdQrrl9VwWKBeV241/qFcSRh6LYEUSV 5P4YHw9RlXi+IsfJ/tQhvydFIN6mIjY= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=pK8srYuw9wrv3ZwJYkO0PSANkqjQtOsAR4zsFhEgnYA=; b=ViLjtovm9+jx46z9NAxTCgvkry 83+J+2uzaaR+6xtpgGNpGwxlNqYrbscclmySVeWUNc4M5x0NRA9qyA3DeINjEBW6m0KO3tqeFh1i9 WVU+dRvo8ovMdPLU+s07ZLsiMEvkNgpR2DVKPAwbjco4llsIwnDSbT+IAW7LNf7sn/JRDex/60WoS t9QbIB8RcRheSXc21NUKmn5X2NUGj2746kiav+LMMSeb5OWIpr5kXyTG9rnVDMOTMC9VnwYgdExG+ GNBUguE2FMSA4DwzRxkh0QSnSeH36bJdhW6Y0TkedAwpFRhEQymVXoLOoRVglEoMMJnJjyC4EeR8n NBePUPYA==; Received: from [177.172.122.98] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1soObN-00CTwi-Jj; Wed, 11 Sep 2024 16:45:50 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= Subject: [PATCH v4 09/10] tmpfs: Expose filesystem features via sysfs Date: Wed, 11 Sep 2024 11:45:01 -0300 Message-ID: <20240911144502.115260-10-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911144502.115260-1-andrealmeid@igalia.com> References: <20240911144502.115260-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: A96384000E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: j9iwztotsjsg8jwmctshm5p91nazjg63 X-HE-Tag: 1726065956-47197 X-HE-Meta: U2FsdGVkX1+lF7nM2idEM0eaXPrXx/KIZYlIvNIbJNmjnupXQ2PXIA0uchIq2At4hwoviIlTuYpfvnJMr6dPp13sOfFqNPClqUg85xYoIrgsEfo3sc5BYSRPLfitLqNFKexaXa3Zf1q+mbSNtmVhQX9BFAnDUx7F79ZTBdSrk4zfHOFFtAVejwtwWYISzlCWuwZJMUWJdue8lqZ2M4u63LY2OZiqONO7DoIh8qTn//fQLaeTDJ1EoxPJ4wffep7IQnoKKfgTk5wQDa5jz0RGbHXCmoq1rORn6G8Bgah2UPnshjQUiL1YYay4wkESLeckSJjpGMvvZ3K1rK3Zkc1MwY6Poiu0q4MGPTBGfzzhPGPtV2gAPXiKBWXf5wuKObbSEm3vfA2JRExDaNjJlScsFh5ug2qUIALCSbifabhTU67b5Jc5uG2nQuBONpxK/JO1cQ/ZIUMKNH7UXs6RV6iSzoePyi2rjawN/pl3lixbfwHb8+wyVBUmDY2rFALsZzVGefts3ouF/RYw9UxhmSbJSMBKLnNFT32CIfwok+DS8SOqlaKVbQv0xh11G9RBVyVKagLlNA5VjPGSO2cqfXq2wK7R0nuXJmOYAu/HpHf7BqTwG6H48fXnxreHB1c0vpBbGmu/HyKnBpQ9pm6b31wW5YAvYhi5e9DrqvYJRvrvJpk/MCqjjVRpI3Z31ildzuaHheX4hg1kAcTSqSm5v6tTQ4qE5R1J/vsnS9DYnw/2Uh2wItqu0N70hcaxEsILXGMyRDtbF2nD0vsFe6IkyFFn2uCcZa14tuY67hO/AK7QNTKjtnTBbBi5vpLyQnLw3e2wjH/C8pDXM4EUYKsE4pRJJMJxUUfAwUEJ9ZyrVFgW19D8uhc+tdrcP/Kgby3Q2t98hi+tjEldNatfeqtC+HjJgQLTS5iNSK+wgy4l7zPBhf6zuFRBVJ0XdRQZIvRWu+UNbnEp5nM1NIqdcMaC8+R qo534Md7 XLl54UNeTDq65flRvDZbUWIIO/Tj//P0yPwHFDeTOL5DSVZZChChC2mdpX4EyKNgx3UaB2aarUz/Y1VJFb7cBdbrM40uw478/MjotEC0uwOcwcO3m+7kd3DgpmsNKaXlGJcuBks/Mi33qpFJpP+U4O42uNsszL+CxihsC+JHHyqOg2AiU5DBSFslu+4KBJnxkO7keIes1CprbepJHIPoJb6hbjLlDUN8jj228PaWrxNU3AAapyqA071t7dlEz89zs0W9752AtNE08ghLXqJ1d7SaOZuILb9MNbKm1KTslt1/I6QlhQGakQjG30SfyaqAj8Kp+D381icW7pE4= 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 fc0e0cd46146..7e7e2461a314 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -5401,3 +5401,40 @@ struct page *shmem_read_mapping_page_gfp(struct address_space *mapping, return page; } EXPORT_SYMBOL_GPL(shmem_read_mapping_page_gfp); + +#if defined(CONFIG_SYSFS) && defined(CONFIG_TMPFS) +#if IS_ENABLED(CONFIG_UNICODE) +static DEVICE_STRING_ATTR_RO(casefold, 0444, "supported"); +#endif + +static struct attribute *tmpfs_attributes[] = { +#if IS_ENABLED(CONFIG_UNICODE) + &dev_attr_casefold.attr.attr, +#endif + NULL +}; + +static const struct attribute_group tmpfs_attribute_group = { + .attrs = tmpfs_attributes, + .name = "features" +}; + +static struct kobject *tmpfs_kobj; + +static int __init tmpfs_sysfs_init(void) +{ + int ret; + + tmpfs_kobj = kobject_create_and_add("tmpfs", fs_kobj); + if (!tmpfs_kobj) + return -ENOMEM; + + ret = sysfs_create_group(tmpfs_kobj, &tmpfs_attribute_group); + if (ret) + kobject_put(tmpfs_kobj); + + return ret; +} + +fs_initcall(tmpfs_sysfs_init); +#endif /* CONFIG_SYSFS && CONFIG_TMPFS */ From patchwork Wed Sep 11 14:45:02 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: 13800726 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 C1BD8EE49BC for ; Wed, 11 Sep 2024 14:46:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 56B0C94005A; Wed, 11 Sep 2024 10:46:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 540EF940053; Wed, 11 Sep 2024 10:46:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4305E94005A; Wed, 11 Sep 2024 10:46:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 262A2940053 for ; Wed, 11 Sep 2024 10:46:03 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A1C6640AA9 for ; Wed, 11 Sep 2024 14:46:02 +0000 (UTC) X-FDA: 82552732164.19.FFC1027 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf25.hostedemail.com (Postfix) with ESMTP id D9BFEA0020 for ; Wed, 11 Sep 2024 14:46:00 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b="f8TRd/op"; 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=1726065956; a=rsa-sha256; cv=none; b=d8RN4ek15/6mtB3495iziJZPUKo3SdA8yEwaWxFBL/7H2/cHk5MYZ6+m4gufff5VrzcanS 2b/TL4sT/dVc3B6aDe3FyYqYOmLWRPop6EBq5uVOTdz6PzHtzQKcIb5jGd9x+4QQIknzjw 8ecp3NbrPDOBBBpBwk4fv2qUP5Z6MWM= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b="f8TRd/op"; 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=1726065956; 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=ZrWTg49UzMkjH8qd8vKX5SzyF13hb+rnSQKtHmhmDkI=; b=2Qwqu+rqw0QjcmpXQJrrb7huqoMIzDW0zaoZL5BlD1fQ7n3QAwrMPk0FLjjmbarpu6zWre molpgoFWdFubucamuTBw6q/6R986WlelDCb37Uumaig/NK9qgb8XWNcNSYGsaNgJTk4HWi VyarGwaOamE2/1Op7ow18FBGVyV4uYA= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=ZrWTg49UzMkjH8qd8vKX5SzyF13hb+rnSQKtHmhmDkI=; b=f8TRd/opCrY9v2ZjWMMp83cRTL K8o057bdo7X+rtob6NwPA+uNCqwDbmAUYFeIZd6ShwqIRTBRRgq/TkNEG8FpwNDUl61n13XXNjRfo L/wvYEiBYcPJ275FTVs6AoJ1R55b4O7yXher5u36fgakVeVl/A7tEmS9ahsG3H6xcgbgthySTSrHD ba2x2Az6gGYRk9WHA/sB3qy5rbduq6QgwF4cZ8zD/lxKMxVreJwGZlG/NwU11Rd1vUKu3jJBjYuXr ChfM17dfstrvbewzcKEifKQ2ILLXzPsc4Hz+qOEnh6qBLVhaLiAi76y5NeURt73wDP7P0pLjMh4ZC apRs/NMA==; Received: from [177.172.122.98] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1soObR-00CTwi-OM; Wed, 11 Sep 2024 16:45:54 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= Subject: [PATCH v4 10/10] docs: tmpfs: Add casefold options Date: Wed, 11 Sep 2024 11:45:02 -0300 Message-ID: <20240911144502.115260-11-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911144502.115260-1-andrealmeid@igalia.com> References: <20240911144502.115260-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: gp33cptem3mda683exrisgzds58hm4r6 X-Rspamd-Queue-Id: D9BFEA0020 X-Rspamd-Server: rspam02 X-HE-Tag: 1726065960-304234 X-HE-Meta: U2FsdGVkX18VWwjBlrxFTh8trnYqYP67c1mAEyZv75OJNluHnZ4FSTcQV0EpCs5ZeRsYkrjsmcx8B/XNk9kmyRiK3AScaAQBXubmiiDZiftd2QTo6IOdcMMv1QSR922OBaJbgeTL0OeSqPE1zza9qYeuSrUe4d0LDX2rYzt3UNuKZ8AT7Wat79UpgdJjA0Sn/3ylwBa6s5sjbwBtvWiiUAwrmb048GyRZ4ri8oR2WdzqkamKHdWNlk7wBTNZ+7bnFK4/rehJ7WKgZy9ztAzwEQ+FfM5+yZAKGxU5w2TIDxUv8ja431lBgnGcPXH4vu2MmgEeE0lh33xz7Td//+ql4FZU6YQY9KTg+rX+HmW12HB57/2cxAV4Kv8Yv4LJOEQK74p12q7JFbFugzhzv7zQ7JV4L0yUHqDIPusZ+pcXcKf3xjex/u1IHX2tj8ZR1/QHeK3qelOXnQPO3A/QfDKgTa32/F/uU+PaV8CTTc5KB84RrwYH81hmISJO1FO7/Q3KczqYh3L1nVpakEYluqgzhnzUxzjhyht9GzPBUH/lS+BALAVeRqWu6Mj73uuA2JWUWZ+ElOejGfhW58JERDhH1lbyjlxjKlrVE+jt/ijeJGDUKJljGZB5QHrgRDCfffJcQ/5OaHugbHnp5F2ttoNvCFSBCjT1sPsCV0lO6CGGuSTSv05Cudcs2AA99u/neOlZkl9P94KaNbPVRDhf0Sv6/pq0eCe5wAPet9HC+bNMYl4u5D1jZJEgTqODkOx0OL8VcqNDczOh6Pe5zgBej2OPHSlgTcZLNAcEwxnT1iRAMDhq3Y3KmvTaPfkuJyIXPtsqLxDSbrW6I+UYYjkvzYgGoKI4zEvimj2N5QWzLx6iGne2imlH2P6IN1rKyrnZP4cVS2OjfmkPcBrw53xiE0wgRssTjtQ3thj1nJGsz2MYrHOVOTTJU7LENSypmZeRMp6BT3AOZYFo1nN00KVI1Z6 uRvwv2p6 qhZaIqHm3ZnyIufWxtVQX9CAjj3WXJvITVwp7scoQWHW4q5QLnkGVz1L7bcQf/BAK9Fmn9umCWgreh4cm/dpkBCY8ih9TIyfImNasWphE24dShTWH5W+zhIQIEKC/wUYa545Gjbj1s5BT4VTBk85Xogh0p6ky16IbEaHe8IrYAMegbCE8dtiTxndwLjAS4PFSEHqyH/EL44+SsqXyUewxA9Yp1EsTUNn94V2IQahw/WbxGNwvWuMQyulMObE405i+7aGgbPG8FYgamMvNpnHM6NZs0S0wevY/zlGp2kFs4D5hCtqpGlhubofOBirYplvPbu31QA+yBmRtcbzu8EdWUwrN8DTDPxVtjkoJ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Document mounting options for casefold support in tmpfs. Signed-off-by: André Almeida Reviewed-by: Gabriel Krisman Bertazi --- Changes from v3: - Rewrote note about "this doesn't enable casefold by default" (Krisman) --- Documentation/filesystems/tmpfs.rst | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Documentation/filesystems/tmpfs.rst b/Documentation/filesystems/tmpfs.rst index 56a26c843dbe..f72fcc0baef3 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 will 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