From patchwork Fri Nov 1 16:42:49 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: 13859592 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 28C67E6F06E for ; Fri, 1 Nov 2024 16:43:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AC2A06B0085; Fri, 1 Nov 2024 12:43:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A72966B0088; Fri, 1 Nov 2024 12:43:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 911EC6B0089; Fri, 1 Nov 2024 12:43:27 -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 740206B0085 for ; Fri, 1 Nov 2024 12:43:27 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 1E431120A31 for ; Fri, 1 Nov 2024 16:43:27 +0000 (UTC) X-FDA: 82738095930.21.C0B9677 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf21.hostedemail.com (Postfix) with ESMTP id 6C3A81C000A for ; Fri, 1 Nov 2024 16:42:31 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=dNs6y88V; spf=pass (imf21.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=1730479323; 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=8swRcMqa/BS2pXAGjnNhVyXxuHalIiMIO71jJmsFBEs=; b=Q72kIJq/cr31S+a0LjaXlzlgRyyLtBHGjixze4b2caeepxLd49c4QtTjqhQr+IL8oX04ZS UdvuBrss2c2sg4su3VurWaAYp50GRjnvW4VCa7PtbQ3+rN5TKpk4/yMo6kmyfnso4dM9UU OCDEBimG/Sy7FNnQAGyZEsU21wOiCec= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730479323; a=rsa-sha256; cv=none; b=bU71QJXxDry7dTtfhgTJeGKfBP7DEkPnDeZJrVGp4vbPXW8/9/4dw2Cgc9ZZ+ILG7nNbpc Y9+kYSlSHD8KKjrx17dK/yoVbrp7GFxzbfqBKEZ0kHwlba3jySJKo4SQnSIqb/oReDJZE/ dztzfZQa2oelZdQ5rRhZsz3+hDPtCX4= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=dNs6y88V; spf=pass (imf21.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=8swRcMqa/BS2pXAGjnNhVyXxuHalIiMIO71jJmsFBEs=; b=dNs6y88V3Dp060LB2jwGQ42+XE aWYX1YU5LJCoxMADvt2/KdnVdLavBZNQQILvGyY94ejMp9bE6JQgXj7LU1esE8v/j6PcIjfFN2IFD TwYEhaPWyK7KZxPgqiR/taMupeNQSJ0sexhpttnS9M6pTBg/g6Z0rTevV9Xz5lMZ6Zo6EYqZP5kSl Y+MzYdD9Aq+ZPn/JVDu6c1VXbwFipB3kStIeax1qQiIWirUy3SPlI+Drz30PxLWsPvm2lKHKequgv GSb+WpsNI0LbdZSh2uDbTI4MfCWs9+yfMiEgDdQewanxooCxFLUhIFHuK9v6DygPiodpdldb+rz+m dLB8XqYw==; Received: from [189.78.222.89] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1t6uk2-000V2F-QD; Fri, 01 Nov 2024 17:43:19 +0100 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org, Stephen Rothwell , Nathan Chancellor Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Theodore Ts'o , =?utf-8?q?Andr=C3=A9_Almeida?= Subject: [PATCH v2 1/3] libfs: Fix kernel-doc warning in generic_ci_validate_strict_name Date: Fri, 1 Nov 2024 13:42:49 -0300 Message-ID: <20241101164251.327884-2-andrealmeid@igalia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241101164251.327884-1-andrealmeid@igalia.com> References: <20241101164251.327884-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Stat-Signature: 4gnu5nfq7wb5syh1u7k4wq5tzfrfebks X-Rspamd-Queue-Id: 6C3A81C000A X-Rspam-User: X-HE-Tag: 1730479351-571947 X-HE-Meta: U2FsdGVkX18nNkPf824lM8wVNwpgsotn1ZhBSp/G9/2fgVEjeAylzOryH+w45M8GnL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Y9faMeFTirjPyVXvH/62gFe1VW/tLYwPievS0TimE1vE4Jo+D4YLRt2kV0lHByB2T5jfM4xc54BhCMO1U/4Nw5/vh2yY7tgkRRyO3SRCLCZat1cEumoVrjX6Oi2P6bWRsh9ewqrTU8SNC9rES4rsPwBGJQ73xMGTdE7BGU8XxMVnND9FyKHtHUJonP5fWxRk6AZU/CXjmaqNgPhCV3MWSBDwc/66XDg+ykRWk9WwYZVDwI22x1kEh87op6aGdTCspIh8HekqKFNjn2KWdsV8Ki1IOnNBT4xG+YIv+/tY2z4Wy/Fr7kP3RLaicwvSRWPJlQ== 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: Fix the indentation of the return values from generic_ci_validate_strict_name() to properly render the comment and to address a `make htmldocs` warning: Documentation/filesystems/api-summary:14: include/linux/fs.h:3504: WARNING: Bullet list ends without a blank line; unexpected unindent. Fixes: 0e152beb5aa1 ("libfs: Create the helper function generic_ci_validate_strict_name()") Reported-by: Stephen Rothwell Closes: https://lore.kernel.org/lkml/20241030162435.05425f60@canb.auug.org.au/ Signed-off-by: André Almeida --- include/linux/fs.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 3b279f60e48f..b562a161e2ee 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3499,12 +3499,12 @@ int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, * @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 + * * 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. + * 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) { From patchwork Fri Nov 1 16:42:50 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: 13859593 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 E2D12E6F06C for ; Fri, 1 Nov 2024 16:43:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7DA9E6B0088; Fri, 1 Nov 2024 12:43:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 78B886B0089; Fri, 1 Nov 2024 12:43:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 679926B008C; Fri, 1 Nov 2024 12:43:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4C8356B0088 for ; Fri, 1 Nov 2024 12:43:34 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D6EC4ABC05 for ; Fri, 1 Nov 2024 16:43:33 +0000 (UTC) X-FDA: 82738096266.26.4174C22 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf01.hostedemail.com (Postfix) with ESMTP id E48DF40019 for ; Fri, 1 Nov 2024 16:43:09 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=czU4tOPy; 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=1730479196; 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=s2zJ3ZAsAPQ0E9uJzi8hgSgBj9U5Eh/vvFyC13/+d5w=; b=OTgebYvxeH+KsLAQp/CLvS6VBc1Tb4T6Q/igJ64ipaBhINJHyR0rODOeOwJh5XuGxb6aAq dORL/YrNQ4oT+KaPo9DZauBII2+kTC53qx8CJHYWqH6nfGUYYfYlvboSLShmLBISU3z9M9 6s7wCi7wG/8dF41AapE6NSRz9ijM4FI= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=czU4tOPy; 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=1730479196; a=rsa-sha256; cv=none; b=DLz90bVo4oN/lYZ7SOCdF85nQiIcn6Z5Wnkb6qmekOMPvlpqVI1mtnVpvb9Phw7XdGoGJe NTqlWe52nLMxBkkvUnDupNWtIYBh1F9OgZgtL1QAuPPT1bJGHSN1ukUzoxZbYaZlWABAcu Pt17C8svYsAMLzEF11MCnCpXSsqsaVY= 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=s2zJ3ZAsAPQ0E9uJzi8hgSgBj9U5Eh/vvFyC13/+d5w=; b=czU4tOPy9JPLZZs+bxemSdZzV5 /rpbQSDGQENcIJBnYPji0JLIMHGJzmvhFqnTK1JRE6WCUHznLbk8ETVJUw+hCSb9kvFQ+5x80idPV bQi67u3Fnc41GYhvnpoKVp5qVUc+kHXfTp3SdwXUTlBqHlcTLvMTtLFbI/LVhZVAyD+CkECEoSKXG Hmk7nI9g8d4OhUhZ7/0uR0o1VPaljl8ssXLel3QvOXM1A+rQQ+3LenzA89PdfAl2WOXpK3KzvQwJi Icdy2puxLfCgC/mhKhtRDGmsRSaUP1VeNViyZye0EVUWcKR1+X9koKub9NY/exwJyTDK6cX8Gy/gh bjhTsZyA==; Received: from [189.78.222.89] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1t6uk7-000V2F-1g; Fri, 01 Nov 2024 17:43:23 +0100 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org, Stephen Rothwell , Nathan Chancellor Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Theodore Ts'o , =?utf-8?q?Andr=C3=A9_Almeida?= Subject: [PATCH v2 2/3] tmpfs: Fix type for sysfs' casefold attribute Date: Fri, 1 Nov 2024 13:42:50 -0300 Message-ID: <20241101164251.327884-3-andrealmeid@igalia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241101164251.327884-1-andrealmeid@igalia.com> References: <20241101164251.327884-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E48DF40019 X-Stat-Signature: h3dqsamy754rzutisww8rgptdfhdmpyd X-Rspam-User: X-HE-Tag: 1730479389-687895 X-HE-Meta: U2FsdGVkX1/+Axh0UhK/h0BTj1Ws/pWmjwa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DqfsYhBlucoRp56x627pkOXKaR7lvQXoCSZXlygi6dOnJ9e3tuJCWz/ZS7kYZnT07r8Lo6KPimZ3La77GvIpgFxA+NtZviSHDHaSb9/2/LbhE5P+H5i1luCEnTf0UT3kax+Lzz6JCRuQTb7fjK4qifDSfubzm3Uf80Ka5Sep0nfmOmxcoAP7MJCtW8HqRH/ound8sZpyJoi0nIhWKiXIzS8OypkNHHgRGUPUE 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: DEVICE_STRING_ATTR_RO should be only used by device drivers since it relies on `struct device` to use device_show_string() function. Using this with non device code led to a kCFI violation: > cat /sys/fs/tmpfs/features/casefold [ 70.558496] CFI failure at kobj_attr_show+0x2c/0x4c (target: device_show_string+0x0/0x38; expected type: 0xc527b809) Like the other filesystems, fix this by manually declaring the attribute using kobj_attribute() and writing a proper show() function. Also, leave macros for anyone that need to expand tmpfs sysfs' with more attributes. Fixes: 5132f08bd332 ("tmpfs: Expose filesystem features via sysfs") Reported-by: Nathan Chancellor Closes: https://lore.kernel.org/lkml/20241031051822.GA2947788@thelio-3990X/ Signed-off-by: André Almeida Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor --- mm/shmem.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index b86f526a1cb1..6038e1d11987 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -5548,13 +5548,38 @@ struct page *shmem_read_mapping_page_gfp(struct address_space *mapping, EXPORT_SYMBOL_GPL(shmem_read_mapping_page_gfp); #if defined(CONFIG_SYSFS) && defined(CONFIG_TMPFS) + +#define __INIT_KOBJ_ATTR(_name, _mode, _show, _store) \ +{ \ + .attr = { .name = __stringify(_name), .mode = _mode }, \ + .show = _show, \ + .store = _store, \ +} + +#define TMPFS_ATTR_W(_name, _store) \ + static struct kobj_attribute tmpfs_attr_##_name = \ + __INIT_KOBJ_ATTR(_name, 0200, NULL, _store) + +#define TMPFS_ATTR_RW(_name, _show, _store) \ + static struct kobj_attribute tmpfs_attr_##_name = \ + __INIT_KOBJ_ATTR(_name, 0644, _show, _store) + +#define TMPFS_ATTR_RO(_name, _show) \ + static struct kobj_attribute tmpfs_attr_##_name = \ + __INIT_KOBJ_ATTR(_name, 0444, _show, NULL) + #if IS_ENABLED(CONFIG_UNICODE) -static DEVICE_STRING_ATTR_RO(casefold, 0444, "supported"); +static ssize_t casefold_show(struct kobject *kobj, struct kobj_attribute *a, + char *buf) +{ + return sysfs_emit(buf, "supported\n"); +} +TMPFS_ATTR_RO(casefold, casefold_show); #endif static struct attribute *tmpfs_attributes[] = { #if IS_ENABLED(CONFIG_UNICODE) - &dev_attr_casefold.attr.attr, + &tmpfs_attr_casefold.attr, #endif NULL }; From patchwork Fri Nov 1 16:42:51 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: 13859594 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 A1123E6F06E for ; Fri, 1 Nov 2024 16:43:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 394F06B0089; Fri, 1 Nov 2024 12:43:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3467D6B008C; Fri, 1 Nov 2024 12:43:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E6356B0093; Fri, 1 Nov 2024 12:43:36 -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 02F7E6B0089 for ; Fri, 1 Nov 2024 12:43:35 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id ACAFD80A96 for ; Fri, 1 Nov 2024 16:43:35 +0000 (UTC) X-FDA: 82738096350.23.D7E64E4 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf09.hostedemail.com (Postfix) with ESMTP id 19BE414001A for ; Fri, 1 Nov 2024 16:43:13 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=pn87DnAX; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf09.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=1730479357; a=rsa-sha256; cv=none; b=Dp7FndQo9SJ1+/8zx6Ryk9iP8As4DCXry4dxfxugMh8w9fx/dUrZqdJw7TvGUThO4rTblP pHM/Jk7bf+1HIS26BAv0owz6UoP5odjyGWqE8o44xZtD/UH+iLpzHESrneg2Kjf7YweZ9l CCFPf2HgWPTZBBEgyU2ot8hDyHD1vZw= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=pn87DnAX; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf09.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=1730479357; 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=1Ftxs1X2bzMP8j6QK8gh+paXxKWIM0HgFnEN8ePS9Tc=; b=RuEYvRd+2Xo+LvWBEFs2y9X454Lq860a6w1l9zk5g0ymDjUj/6lEjeIDKugg6xA+C1aCgP fz0B4DxeCtsB3D5sd5AvndNZfQSqEufR/GBiQVHIKvu5bXmyljG8ik0GcwbF7ROeoixvei ir9OSQCrqn4gFW3E1dBX0v71JM5ONdU= 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=1Ftxs1X2bzMP8j6QK8gh+paXxKWIM0HgFnEN8ePS9Tc=; b=pn87DnAXiqTKqX3MhKegErUZj5 8fCM7W1FYVlDWFulKMj228VX/ZFBQhPW4JdWHiNJiwft3+OKS2uzZ38b0zQkfN7UDdR63V5WJmxNJ 0cosR6SaUcOAmBfdPq5JkJzMoDj8rmyXRxm5n8gdLhSHxkpUdnkxrjNy6F6WQp+T9Hq942V7HLV3C riIgfxGS/lJw0g3kwhnuyvJbZ219OKN0jbsI4l8TPLXRXOdfFlve7BfHTYfALrHsT8CTepBHlg3m+ +N3x4S5N5bDYQV3qfkogt58NtqJQWVUwatzywOpDBtCpGXtluXxG07xA2u0cIp2s8qwApichjWNIj cvwLKPEQ==; Received: from [189.78.222.89] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1t6ukB-000V2F-9N; Fri, 01 Nov 2024 17:43:27 +0100 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org, Stephen Rothwell , Nathan Chancellor Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Theodore Ts'o , =?utf-8?q?Andr=C3=A9_Almeida?= Subject: [PATCH v2 3/3] tmpfs: Initialize sysfs during tmpfs init Date: Fri, 1 Nov 2024 13:42:51 -0300 Message-ID: <20241101164251.327884-4-andrealmeid@igalia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241101164251.327884-1-andrealmeid@igalia.com> References: <20241101164251.327884-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 19BE414001A X-Rspamd-Server: rspam11 X-Stat-Signature: bgg5a6u5uuqwudddg3uxp8ehsa7fw6mr X-HE-Tag: 1730479393-979514 X-HE-Meta: U2FsdGVkX18ieDKsSN5yoBLrA7gng5ZmUpojI3s80spU1nGzSOn6orLBpj9xPZTGVnJI2Lp6FMLqhGoV41Gpqi5F0V2XXvshSTSMoqtGZIw8K1kONl694btqz9T2BXzETOyM1YLZZ5SzUO6gs+CNSCFrpqIGn+sckpVgrO3oIbaCaFEMUIqEWLMmbMvJzQQU07p+AVAlXnWBmah6h5WEYdH+0DI4O6PN7gKS61gfNvYer8XaN+4ekcFIRNc/2EoGPs9yPTwOGPfN3oSUOnMQKzzyHZXxlBHSz49RGd49qEostevVq00gDhgT5BTs9tOuo8QouMQDVTMgYOJ9BAe7KjGs+ds3NQEW709vuGDS53i2fL0WY9Qi7jSn8zbNjy1z7hKNKAE9pdeIY/o61pAGLDK86vTQT52utLkTpvq2g3USVs18QLi52SSC4cF77EErd9zPQ5Dq8i8wl34LwgfVHcVl6RLlyHj9KdM4J+4GbO8ePOYKRiFFkCz9EceSrPU1cf3XWjbMq5fqb+NHLGVMb2UJ8I8zh1Hxt8ED21py/MCPWrJg+qgVlThbcyPbX1gIZpMEOqF5ZLhjcoKFJ7owxvZ7O3fRIHqGoc5x8ZUCiAoorRtxBJY0Qiwi+Z+DL9Pmy56wcx3AK3nf506qEcp8/HfLZ48lEb/j0pFOS89sQjdjyAnp4l0fn2K9X6A6PDgWoVbE/9a3jfB1hRL+/L9xWd6USpsiwycw890nWpERiWtfe8xNKDV+F8gt4DVVeIc1oyM1rYBPYMA+vyPSow3rP5I/gXznznqRwJ4qVgCQl/VGC+zSwWfcxkps2DkUGi3xKEybojvmSzDXUr4B9gewkWwBv1KiDm1uY78gOarCHxfqzucEZjox2MpOsmtcYbVWmbysWK/YZAvpMioY2Ckri5PmX/KXzywRVBXrylcoh9l/2kXfUzbj5oNCB1ISP/rVWf0WFQt8Pmr25q4t6/u A0noAIaz aG6VpJd3TrNoyrK8gSBCtqFzcUIHoTrw7R9/QIjhSt5kCGxKAnljd69Lerk9aMMA/a+LxldOcbvtNtUfBm9nv2J70N+imS3RpQviKjQFw2ZHvkybFAwieDwpU+sY/br7koZsylN0PCzaCvW4KjTN+/fTTNy4tyVG5x4GvzjDe0ar2JAOZ13vZsiQpxn0MD8PDvrKQCPFzNsaNfCtEiKVFGCVlAbeuo2pJfP3D+KRV+y6XBw3fdN9T44zJ70NrC87os3q4eeF3qxX3oJdF1i7wsirhPJd/6sV5oc1YpAT+uwUkx27SguNJOVxz4NBdhsyIXF7jVHnGf42X92Y= 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: Instead of using fs_initcall(), initialize sysfs with the rest of the filesystem. This is the right way to do it because otherwise any error during tmpfs_sysfs_init() would get silently ignored. It's also useful if tmpfs' sysfs ever need to display runtime information. Signed-off-by: André Almeida --- Changes from v1: - Fixed ifdef guard for tmpfs_sysfs_init() --- mm/shmem.c | 130 ++++++++++++++++++++++++++++------------------------- 1 file changed, 68 insertions(+), 62 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 6038e1d11987..a5355cf9443c 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -5126,6 +5126,66 @@ static struct file_system_type shmem_fs_type = { .fs_flags = FS_USERNS_MOUNT | FS_ALLOW_IDMAP | FS_MGTIME, }; +#if defined(CONFIG_SYSFS) && defined(CONFIG_TMPFS) + +#define __INIT_KOBJ_ATTR(_name, _mode, _show, _store) \ +{ \ + .attr = { .name = __stringify(_name), .mode = _mode }, \ + .show = _show, \ + .store = _store, \ +} + +#define TMPFS_ATTR_W(_name, _store) \ + static struct kobj_attribute tmpfs_attr_##_name = \ + __INIT_KOBJ_ATTR(_name, 0200, NULL, _store) + +#define TMPFS_ATTR_RW(_name, _show, _store) \ + static struct kobj_attribute tmpfs_attr_##_name = \ + __INIT_KOBJ_ATTR(_name, 0644, _show, _store) + +#define TMPFS_ATTR_RO(_name, _show) \ + static struct kobj_attribute tmpfs_attr_##_name = \ + __INIT_KOBJ_ATTR(_name, 0444, _show, NULL) + +#if IS_ENABLED(CONFIG_UNICODE) +static ssize_t casefold_show(struct kobject *kobj, struct kobj_attribute *a, + char *buf) +{ + return sysfs_emit(buf, "supported\n"); +} +TMPFS_ATTR_RO(casefold, casefold_show); +#endif + +static struct attribute *tmpfs_attributes[] = { +#if IS_ENABLED(CONFIG_UNICODE) + &tmpfs_attr_casefold.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; +} +#endif /* CONFIG_SYSFS && CONFIG_TMPFS */ + void __init shmem_init(void) { int error; @@ -5149,6 +5209,14 @@ void __init shmem_init(void) goto out1; } +#if defined(CONFIG_SYSFS) && defined(CONFIG_TMPFS) + error = tmpfs_sysfs_init(); + if (error) { + pr_err("Could not init tmpfs sysfs\n"); + goto out1; + } +#endif + #ifdef CONFIG_TRANSPARENT_HUGEPAGE if (has_transparent_hugepage() && shmem_huge > SHMEM_HUGE_DENY) SHMEM_SB(shm_mnt->mnt_sb)->huge = shmem_huge; @@ -5546,65 +5614,3 @@ 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) - -#define __INIT_KOBJ_ATTR(_name, _mode, _show, _store) \ -{ \ - .attr = { .name = __stringify(_name), .mode = _mode }, \ - .show = _show, \ - .store = _store, \ -} - -#define TMPFS_ATTR_W(_name, _store) \ - static struct kobj_attribute tmpfs_attr_##_name = \ - __INIT_KOBJ_ATTR(_name, 0200, NULL, _store) - -#define TMPFS_ATTR_RW(_name, _show, _store) \ - static struct kobj_attribute tmpfs_attr_##_name = \ - __INIT_KOBJ_ATTR(_name, 0644, _show, _store) - -#define TMPFS_ATTR_RO(_name, _show) \ - static struct kobj_attribute tmpfs_attr_##_name = \ - __INIT_KOBJ_ATTR(_name, 0444, _show, NULL) - -#if IS_ENABLED(CONFIG_UNICODE) -static ssize_t casefold_show(struct kobject *kobj, struct kobj_attribute *a, - char *buf) -{ - return sysfs_emit(buf, "supported\n"); -} -TMPFS_ATTR_RO(casefold, casefold_show); -#endif - -static struct attribute *tmpfs_attributes[] = { -#if IS_ENABLED(CONFIG_UNICODE) - &tmpfs_attr_casefold.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 */