From patchwork Fri Nov 1 01:37:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 13858588 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 10C96E67494 for ; Fri, 1 Nov 2024 01:38:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B9CF6B00A2; Thu, 31 Oct 2024 21:38:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 291606B00A5; Thu, 31 Oct 2024 21:38:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 131EA6B00A6; Thu, 31 Oct 2024 21:38:10 -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 E9D046B00A5 for ; Thu, 31 Oct 2024 21:38:09 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 6A4001A19E0 for ; Fri, 1 Nov 2024 01:38:09 +0000 (UTC) X-FDA: 82735815246.14.4E52654 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf14.hostedemail.com (Postfix) with ESMTP id 8F478100011 for ; Fri, 1 Nov 2024 01:37:36 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=F29RFp4N; spf=pass (imf14.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=1730425006; 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=hp5kpbwvaILYgIy2Fimx7HPe/HPYumwLw3G9mZHE6LiciY4K04kwU+FYv5pWeaMtlsZlWl wiO9A415apkFEDV4yxcw7mn/GmfBX0xw/iz6kpdkp550AwP+IgurIYUCvNvKpB1ARBVXj9 21wQ/KuNbaR5iOXvyHrFlTSATS4aZe0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730425006; a=rsa-sha256; cv=none; b=nUDtpNukrIlciPJs195K1X7FItHwQ+dRe7YlDYfpdCQwubdY1nOjGtfjtKfpv2SEOy4sZd 1EipxmXrCc2OAo1hD2OQuo5UQW4n8uxlQkW+IESwlAa+UG2hOnZFssIWNA2ynsSP7s5y/2 aTQ/Me77uH95p1PoV1EqzNYYaRTpC5M= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=F29RFp4N; spf=pass (imf14.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=F29RFp4N0vPj0s1J5QEIiOahhJ XtmstjmkH5wGBzWkqKIEA2OND/3xKxCb9IEFo6qCWlDuQUR5ousxHS8g3uJENfHud0qXvl4NTrPCN dviD8nbyefB44gJh9xemI7cUIggGvtLvhYX89M6abblhgPv8kDkh4tN9Haq95WNrpI8zaTZWKj6ly SuhaBPbLcCtIVKQG7cgniiwSRd+pSEpfxhAWMKAzuEMOUBvk0ZXR9HEhnLn6jEL6eDElGjGeLFRKI f7liZadXemfK5Ip7WLRt8d4nYTXsQ3hkFzmReoEDsMG/+k+wlw3DF5/yoqIOwXTnl9gQLak28w572 LDDltqDg==; 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 1t6gbq-000G0m-O1; Fri, 01 Nov 2024 02:37:55 +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 1/3] libfs: Fix kernel-doc warning in generic_ci_validate_strict_name Date: Thu, 31 Oct 2024 22:37:39 -0300 Message-ID: <20241101013741.295792-2-andrealmeid@igalia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241101013741.295792-1-andrealmeid@igalia.com> References: <20241101013741.295792-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Stat-Signature: igieco7wj1mo6yqgxqmhwjbseffxp59q X-Rspamd-Queue-Id: 8F478100011 X-Rspam-User: X-HE-Tag: 1730425056-448469 X-HE-Meta: U2FsdGVkX1+LG0KGNVqe/KcFX7teeSNTT408TkqDFZQ6FXznjmawL8VzfjorVBJKICYxkbToO3wnVEg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q+Fg8mhcCFNHpykgQfN6htPelfL4F06fc78pPR5/k69MdP03HuJmn0sX2EPP8M3sxFJ8jhL+YwuRHpbfseO+z2QDfiB6rXkkwP+/pp03Ik4HT86NkoVKEhNfYEuys+cQ5R4o42/Rdh2Lh9LLekv+6eh8+9Zxx7GNpBPCfJcfYQFaDWbDD5jkwY/OM914PE4a31ip7UfzFsFmHrXxlPoqlEMpd6GOCAptwq1V927wPutLShcM/CYRSAEWEdN26hBmyibjK1lPQ/EEBbbI7yszJJEUmwKRf+RZHtgLw== 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 01:37:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 13858589 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 01324E67493 for ; Fri, 1 Nov 2024 01:38:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C7B96B009E; Thu, 31 Oct 2024 21:38:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 578566B009F; Thu, 31 Oct 2024 21:38:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3CB8B6B00A5; Thu, 31 Oct 2024 21:38:12 -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 1FAA86B009E for ; Thu, 31 Oct 2024 21:38:12 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C514D41AA1 for ; Fri, 1 Nov 2024 01:38:11 +0000 (UTC) X-FDA: 82735814952.05.12E179B Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf10.hostedemail.com (Postfix) with ESMTP id D1CB8C0007 for ; Fri, 1 Nov 2024 01:37:57 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=rSsUgbSb; 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=1730424874; 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=QXcbpwTTq6N974MuejeNHJ9xQ2vu2gRxnquK0VwfKiM=; b=sZA0GZBpGPaF//YWXOjQk/Hi/3zujw/3UW3hyUf3vlOS2wCklA2dyiHByYn0WTMEEam2P+ E1bz8oRpXBBaEBjQg7HYGZi0EQ/5vR40LGza+ucLVRwyMgA1TLXXr9yqZFMdCi6ZTOt2kb NWRYDLEmdybxuXUvShbFbIBevl42+hw= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=rSsUgbSb; 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=1730424874; a=rsa-sha256; cv=none; b=6I9w4dDgV7xXOj1mVg83HtfXx+lMiAfKklM7kf9iu7ECWvOqn3rOjn57R0+IG9doFlFLow irNEn8a+b1dCTq653Db84F0YhwjMZ0Jf0gvHqjPDEXKoM2VBONv45aiCK6HXRUra5tMOi1 MPHSRWgD56uD+70NPk6SK8F35r1SlM0= 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=QXcbpwTTq6N974MuejeNHJ9xQ2vu2gRxnquK0VwfKiM=; b=rSsUgbSbSkaGXZl2Nm0F3ZzIbh AsSs1pLZiilNWolJ0Ng/HkCRkTwnkQLW9ZdhOtdOBVFNuPI8HjhXpwBWRgrI5/SaVZat03DoIaYV4 uQrEZDBZ0N7tKgeKg3dtxC8JLbPmjfg2Fv5wL6LaCfy0TvL/Z6JszwJE7xsdjdsz9MQNEnlet/5iD cCuzVvwTvT6Vue9CJF/41cIz5pwqd7+GjifCk09VKnfRQOAorR8yfP8d+cHSnQmgBPutzEkAfJcrS IWQIM7j6PEHXGBBBtRCZ1oC7wpbHOqiNnawjK6epVIU1MKto1arXU5WH4jxQijvopmHnkJTscuu/l sFLOwJYw==; 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 1t6gbu-000G0m-VI; Fri, 01 Nov 2024 02:37:59 +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 2/3] tmpfs: Fix type for sysfs' casefold attribute Date: Thu, 31 Oct 2024 22:37:40 -0300 Message-ID: <20241101013741.295792-3-andrealmeid@igalia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241101013741.295792-1-andrealmeid@igalia.com> References: <20241101013741.295792-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D1CB8C0007 X-Stat-Signature: f91n457yson4jnqwog3xt6txp4s4g8xw X-Rspam-User: X-HE-Tag: 1730425077-490617 X-HE-Meta: U2FsdGVkX18biqN3P+PV8ZTxyS4ZlPxqg+B1Qh0qprJiNAKe5WRKRCRog19LzzFgxI4qqr7ztB/O/78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h7BQT9qbokOEWLZI1dyZDcQvN07d1pOANzRL1nASO/312oVESX3DKbxmPsWdPUEap69NnVqk6EMXMhJVaERV47GErpV/HcNkUMG3ifIMg2zfE47efhW27bpUORqjpwIzYxRUjJBLhy73X7ALEZXzy+Ppt4wgdHEBZO4UUtxb1XDWjKAIux1 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 (as seen in fs/btrfs/sysfs.c). 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 01:37:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 13858590 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 68D01E67495 for ; Fri, 1 Nov 2024 01:38:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 79FA56B00A7; Thu, 31 Oct 2024 21:38:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6FEA26B00A8; Thu, 31 Oct 2024 21:38:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5C5F16B00A9; Thu, 31 Oct 2024 21:38:15 -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 3EF3B6B00A7 for ; Thu, 31 Oct 2024 21:38:15 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id BD0E5140D28 for ; Fri, 1 Nov 2024 01:38:14 +0000 (UTC) X-FDA: 82735815456.28.59A742A Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf17.hostedemail.com (Postfix) with ESMTP id C184340012 for ; Fri, 1 Nov 2024 01:37:51 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=P7renoAq; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf17.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=1730425037; a=rsa-sha256; cv=none; b=HRTlFSsMqQUGkabld4Kdk5FYXzzYNXv3VDH6jjOFZhYBKrOJyuXP7QrF9DpiCsNMBWv2AC +/WW8N+AOjVaJnczcLaIHa+LRSV0ymd1uYk41/6v13W5rbcTM5Hy/AtCez+5+IjvLJ5h2/ wtgPvNJHFO2gPtsv8y04sPAhlBthz6o= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=P7renoAq; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf17.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=1730425037; 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=k/VHsL4n8pERS64P5NHMSQf1JEBAuX2jkWl5gqjSdQw=; b=NxvileDyXbMc5sgz7gVjh6w+8qruNt0gCo5s51r8hfT64Or1PTqpZeY1Nt0wMV2WdhV0fe Fe4g6CzBKPkJ2y7htcPNltfHA0lN7YjCxWfDw4tft61Wh+12X7IHNHt8fK01pKOIeqcm2y X7aM2/Vn2qtS+boq5ZZXuF2Nd5FyNIQ= 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=k/VHsL4n8pERS64P5NHMSQf1JEBAuX2jkWl5gqjSdQw=; b=P7renoAq/Nj0A3/1vK6ktV09ha 0YPhZg8HwiIH7CYXUUh3/A5MNQ8peqcpFMAQzX/AeCLfbjuEzmFgJVHu/96iSWH7NzooTvRg94Tgo gIA4OKIxxushW8a3C2javH97VxijDClm2UDI+7+h6tooabgWxwmMY4L95Iu7KPgb4n6zy+grPFKAJ jrobxJOCpsjclHQsYboorxe67fkiNuMVAibvI85AqDGo0dsG/jwhSKuCiPzDa4Ao/GdKNM1hV4iMx iYd5PCsCI5aajLgFHt5PEIYKOPQwMOGxLWeDQ8udu/X3kUaZQdrd/6wtKNvk/FvYXi7WddYan2D4x 2jm6T2oA==; 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 1t6gbz-000G0m-6J; Fri, 01 Nov 2024 02:38:03 +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 3/3] tmpfs: Initialize sysfs during tmpfs init Date: Thu, 31 Oct 2024 22:37:41 -0300 Message-ID: <20241101013741.295792-4-andrealmeid@igalia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241101013741.295792-1-andrealmeid@igalia.com> References: <20241101013741.295792-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: C184340012 X-Rspamd-Server: rspam01 X-Stat-Signature: 6wdy3c5ytrauxi5sctuqs4pgxeto7p1w X-HE-Tag: 1730425071-726672 X-HE-Meta: U2FsdGVkX1/ZPuCKF9m65zOZk8JyGZ8WtOq4f7RsFUqIhdMUvFHl4lvQz2Nh1nI+2EBeuvH7LXormxQQD3dPo9soUpPlaQHjW8qocygqldfLklwE+cJC7i53maXPbqouWVb0RY+dJ7lHqr9K0kaAHtemUHTAyjE60iIz18IuDEMCnLiT5CKPmAlJ9E4bbFYsjVhfKBGdEZovx4rmd82rKzBun/jIjCTQp9y4Zs5oFfsQz1yf07Ww4eZKQceXJzKUf4SWCcAaovBlrX8ZNTggWGqBvqrBrcRSpZ2mhd1af6zY+74Xk/cyDWGmZTX5ZuFdx+XI3ig518cV5fTIbDnXgFGQqDVqObr7j8CJkPhDakiA710TRnRZ20X4pEAgAnlvaLIEUGtgtxPHj/yf2FFbmn5YnZfMwYGmzksT5BVHe87mFc9COC6EaKO8VyqZhUSxPpHIKMneaKO75q/yTuaZWE+fsgvPYlFe9W/TEJ/sTyRykFhMUCkqLLUcBEviRXQA0B7gTnmOGy/aew9oCEvPmCEDQqMSWR/mqZP6+bwouV58aYE0H+fjstkbiYVOJ0swclmor9f2+3xQlB9L9FhaYM8PHAI7/lu7H4jMXtUaf3CcM9waTHw3LAXzfaTigXfKwdzioSJ3Zt6zOAWJbWaWXJe2OmiyfTuuRnEQfSnm1vMB8ryQ86bQm+gNXBllMRGGOjvfDbKKVc45TxfWqag2cqKdUyyhRH5NI08i33XzGJju/4a02CaxEEr/D208eusVy593/YBvEtKpPy6HCC+BjU4KSsaNeuJogTOokN4sTO1DEMKUatCgcWKuspmTPXrysX3Fhv1k+3A7LC3bGOmjo+fnoZDuFY1+2QEkuv73FKRaDL0qeahbJ2I6AX14LMlahrVKD+Zkto5c7CcsMcERHPjaeb2GwfFl66SQe+/amaz/fO5gyo+SEBGQ131F9ax31fSSU4Cw3X0x9DgfsJ9 8/atup2C 3yPZL5MSVw/QK4apAyJ0yFAvJL14PNH7+8H4jX7Q3crfRMlxww+ln+7bN8QKwZQW8tgNmqlAS8vNKFqYHopaOv0+0ppynWqHj/UhWPG7bMk6+Ha33gi4N1bYRiY7Cx8ubMfstEBvyBQeONx5+2+d5F6Db5cDi/hjbixOEuaScdYamS9HOgOq7uOgXy35jM093N0XejZMgO+nh5OUGpR1ZZpseXPESqtZdgxOwFCQ2poZ5QwtiL+p89Wu6OR6Ch1THuk6AS5WeaWynmGSGTCqg48jzH1sHQyJcLXy647n6YXxAulI/OsUahJ4+PxabUU9++NxdUmp+adxKM5w= 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 --- mm/shmem.c | 130 ++++++++++++++++++++++++++++------------------------- 1 file changed, 68 insertions(+), 62 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 6038e1d11987..8ff2f619f531 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; } +#ifdef CONFIG_SYSFS + 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 */