From patchwork Fri Jan 31 22:24:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 13955949 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 12348C0218F for ; Fri, 31 Jan 2025 22:25:12 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1tdzRm-0004S9-42; Fri, 31 Jan 2025 22:25:10 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tdzRk-0004Rt-9J for linux-f2fs-devel@lists.sourceforge.net; Fri, 31 Jan 2025 22:25:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=juG8nUdV0WyyYnlPmmsUCrmKv5b3xnKpXZDvL3+zs6A=; b=AtDC/VUS7YKwWvN4LP3wV6EJ3u ybMTJslnkSw4X1AkYYvWhPbl39e+Z8Z9hE/7q1OxKl3GRAAbuzFP67WFcwkHPwb1d4j7nwPKhq6D8 UN6QoI7vBzj/oiv0hK7Uw3Lje7KhPE18hbM/sMsx5cnRve+/sdK1yN8TfMB6fco9mNIw=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=juG8nUdV0WyyYnlPmmsUCrmKv5b3xnKpXZDvL3+zs6A=; b=d HmYkYh5y9T1KpzrVdRkwYTznX6sg0hNJsi1cp3wk7jwBu5Hvu9wWZkV+fNSdSfCQD8HkWHQZHcVja XXuclrlWE5VJg0L422utXAbap8hPPhopnRifi1uZvHsU8jrpiaFMNH8hc2sUugxo2S/cTFM1QJ74t LVW+l0nOE7DqFObc=; Received: from dfw.source.kernel.org ([139.178.84.217]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1tdzRj-0003d8-KB for linux-f2fs-devel@lists.sourceforge.net; Fri, 31 Jan 2025 22:25:08 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 47B1E5C634D for ; Fri, 31 Jan 2025 22:24:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D9109C4CED1; Fri, 31 Jan 2025 22:25:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738362302; bh=onDCTihKWJH6F+H8IdhFe7TFdJkEjG+vwnD/wYojOBQ=; h=From:To:Cc:Subject:Date:From; b=VxVh/1OnEZtTWaN5CCIGEU4ar79eHlsqhbmSAdxi5H1j6wTDaHACBcaFzfVqHY9x6 dSurFgTcM5AbVcoUHpgRH4PGoKxwjmJpVmojwt7umDY4Kxl5tydMyxGCP3DHFZXeOS qyYJVCXjyxQgojV59OTi38LHng2xAMRgpF3oZSgzgS6MxzC3DyzZA+di7z9AdPpzKn g7fiPvCNTA6sJVtwlgMQUOd3oCr/xEKBHgGgvkgK+dwDVNXi5P4UV481nQ2NE+MsSu UoRl29X9bJ+5D2gsuldtf/UCi6DukMeGcdivUClEEy/EgrrkRFFOIju1C1eSZHLO+w ajjRlg8G/2TTw== To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Date: Fri, 31 Jan 2025 22:24:56 +0000 Message-ID: <20250131222457.1634039-1-jaegeuk@kernel.org> X-Mailer: git-send-email 2.48.1.362.g079036d154-goog MIME-Version: 1.0 X-Headers-End: 1tdzRj-0003d8-KB Subject: [f2fs-dev] [PATCH 1/2] f2fs: don't kobject_put in the error case X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jaegeuk Kim via Linux-f2fs-devel From: Jaegeuk Kim Reply-To: Jaegeuk Kim Cc: Jaegeuk Kim Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Fix a wrong kobject_put in the error path. Signed-off-by: Jaegeuk Kim --- fs/f2fs/sysfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index d15c68b28952..001e97cd0a96 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -1605,7 +1605,7 @@ int __init f2fs_init_sysfs(void) ret = kobject_init_and_add(&f2fs_feat, &f2fs_feat_ktype, NULL, "features"); if (ret) - goto put_kobject; + goto unregister_out; f2fs_proc_root = proc_mkdir("fs/f2fs", NULL); if (!f2fs_proc_root) { @@ -1616,6 +1616,7 @@ int __init f2fs_init_sysfs(void) return 0; put_kobject: kobject_put(&f2fs_feat); +unregister_out: kset_unregister(&f2fs_kset); return ret; } From patchwork Fri Jan 31 22:24:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jaegeuk Kim X-Patchwork-Id: 13955950 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7E709C02194 for ; Fri, 31 Jan 2025 22:25:19 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1tdzRv-0003de-MZ; Fri, 31 Jan 2025 22:25:19 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tdzRu-0003dY-IB for linux-f2fs-devel@lists.sourceforge.net; Fri, 31 Jan 2025 22:25:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: 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=7kq0+C6CqyFHJx/YySgBHOYWNcRvmV/Fg4JyHamy6is=; b=c/e3vzNHZfe1IlmfKsBAJnhEIt zvlREjEKUatuqyBTIrk1I1BLZoFmF8kTlGYWwavSAP9m5UmO1N9hFLP1bjQdD2VVRI7cz8Wvutvx6 aNach8KV8NOxBTbB9TuNemcBOA9qFbTvflaApF2MHVAtVtjF5ZJxxqg3FR7N8E8yZYbA=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=7kq0+C6CqyFHJx/YySgBHOYWNcRvmV/Fg4JyHamy6is=; b=F03MxGcR91PZxaplWcFMZr0S2B kXIqT2irl4f4cUUsm58jumUiv8JHq2Lw11gvADBveqZHDwasd0+a0yNJeyqmnUVwrI4p1mg852wVB K8AR8ZanJcZsGAIiSUH2b0BJjKQmQSwQJdl03Gw4V3Li4RWx+eCQRobXrMgTXrnWXTH8=; Received: from nyc.source.kernel.org ([147.75.193.91]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1tdzRs-0003dd-W3 for linux-f2fs-devel@lists.sourceforge.net; Fri, 31 Jan 2025 22:25:17 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id BAE2AA41FB6 for ; Fri, 31 Jan 2025 22:23:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE22BC4CED1; Fri, 31 Jan 2025 22:25:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738362306; bh=sFFU7C1MzuogcM5wOGc++NVm3alLfLou2/czRdP08Bg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MdjLNYDuy3w5w8H4jJ9Smxyk/5V98BhSy0J9Go5yG4129fsJ8zOPbFf4D/8o8d7U8 1Tzd36ACHEXN2XtmG1YNMjr4/pwI4PaQAyWlfVWHftip9WEHywVmXmHkVtmKLkHS7/ /dYzpcw5QFVTQqxhfIkTFdX8URo/HDqCflvOBAvD2iznulDiBNdPfaihEpzQGU09Af TvDR4oGOPqx3zlkDk5yUt0hdHW4xR9acsHpZWRJcH3uZLMlN3Y4sVeEsWUPf19dwfF s7kLP9ovHILbEqlidpTZA7ST+YnL1ZdqwP37NJovSNKJ3eI1aH+0n0UAJwB1rHrm6j hPZg9zbuDbC3A== To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Date: Fri, 31 Jan 2025 22:24:57 +0000 Message-ID: <20250131222457.1634039-2-jaegeuk@kernel.org> X-Mailer: git-send-email 2.48.1.362.g079036d154-goog In-Reply-To: <20250131222457.1634039-1-jaegeuk@kernel.org> References: <20250131222457.1634039-1-jaegeuk@kernel.org> MIME-Version: 1.0 X-Headers-End: 1tdzRs-0003dd-W3 Subject: [f2fs-dev] [PATCH 2/2] f2fs: introduce f2fs_base_attr for global sysfs entries X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jaegeuk Kim via Linux-f2fs-devel From: Jaegeuk Kim Reply-To: Jaegeuk Kim Cc: Jaegeuk Kim Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net In /sys/fs/f2fs/features, there's no f2fs_sb_info, so let's avoid to get the pointer. Signed-off-by: Jaegeuk Kim --- fs/f2fs/sysfs.c | 74 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 22 deletions(-) diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 001e97cd0a96..4bd7b17a20c8 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -61,6 +61,12 @@ struct f2fs_attr { int id; }; +struct f2fs_base_attr { + struct attribute attr; + ssize_t (*show)(struct f2fs_base_attr *a, char *buf); + ssize_t (*store)(struct f2fs_base_attr *a, const char *buf, size_t len); +}; + static ssize_t f2fs_sbi_show(struct f2fs_attr *a, struct f2fs_sb_info *sbi, char *buf); @@ -862,6 +868,25 @@ static void f2fs_sb_release(struct kobject *kobj) complete(&sbi->s_kobj_unregister); } +static ssize_t f2fs_base_attr_show(struct kobject *kobj, + struct attribute *attr, char *buf) +{ + struct f2fs_base_attr *a = container_of(attr, + struct f2fs_base_attr, attr); + + return a->show ? a->show(a, buf) : 0; +} + +static ssize_t f2fs_base_attr_store(struct kobject *kobj, + struct attribute *attr, + const char *buf, size_t len) +{ + struct f2fs_base_attr *a = container_of(attr, + struct f2fs_base_attr, attr); + + return a->store ? a->store(a, buf, len) : 0; +} + /* * Note that there are three feature list entries: * 1) /sys/fs/f2fs/features @@ -880,14 +905,13 @@ static void f2fs_sb_release(struct kobject *kobj) * please add new on-disk feature in this list only. * - ref. F2FS_SB_FEATURE_RO_ATTR() */ -static ssize_t f2fs_feature_show(struct f2fs_attr *a, - struct f2fs_sb_info *sbi, char *buf) +static ssize_t f2fs_feature_show(struct f2fs_base_attr *a, char *buf) { return sysfs_emit(buf, "supported\n"); } #define F2FS_FEATURE_RO_ATTR(_name) \ -static struct f2fs_attr f2fs_attr_##_name = { \ +static struct f2fs_base_attr f2fs_base_attr_##_name = { \ .attr = {.name = __stringify(_name), .mode = 0444 }, \ .show = f2fs_feature_show, \ } @@ -1256,37 +1280,38 @@ static struct attribute *f2fs_attrs[] = { }; ATTRIBUTE_GROUPS(f2fs); +#define BASE_ATTR_LIST(name) (&f2fs_base_attr_##name.attr) static struct attribute *f2fs_feat_attrs[] = { #ifdef CONFIG_FS_ENCRYPTION - ATTR_LIST(encryption), - ATTR_LIST(test_dummy_encryption_v2), + BASE_ATTR_LIST(encryption), + BASE_ATTR_LIST(test_dummy_encryption_v2), #if IS_ENABLED(CONFIG_UNICODE) - ATTR_LIST(encrypted_casefold), + BASE_ATTR_LIST(encrypted_casefold), #endif #endif /* CONFIG_FS_ENCRYPTION */ #ifdef CONFIG_BLK_DEV_ZONED - ATTR_LIST(block_zoned), + BASE_ATTR_LIST(block_zoned), #endif - ATTR_LIST(atomic_write), - ATTR_LIST(extra_attr), - ATTR_LIST(project_quota), - ATTR_LIST(inode_checksum), - ATTR_LIST(flexible_inline_xattr), - ATTR_LIST(quota_ino), - ATTR_LIST(inode_crtime), - ATTR_LIST(lost_found), + BASE_ATTR_LIST(atomic_write), + BASE_ATTR_LIST(extra_attr), + BASE_ATTR_LIST(project_quota), + BASE_ATTR_LIST(inode_checksum), + BASE_ATTR_LIST(flexible_inline_xattr), + BASE_ATTR_LIST(quota_ino), + BASE_ATTR_LIST(inode_crtime), + BASE_ATTR_LIST(lost_found), #ifdef CONFIG_FS_VERITY - ATTR_LIST(verity), + BASE_ATTR_LIST(verity), #endif - ATTR_LIST(sb_checksum), + BASE_ATTR_LIST(sb_checksum), #if IS_ENABLED(CONFIG_UNICODE) - ATTR_LIST(casefold), + BASE_ATTR_LIST(casefold), #endif - ATTR_LIST(readonly), + BASE_ATTR_LIST(readonly), #ifdef CONFIG_F2FS_FS_COMPRESSION - ATTR_LIST(compression), + BASE_ATTR_LIST(compression), #endif - ATTR_LIST(pin_file), + BASE_ATTR_LIST(pin_file), NULL, }; ATTRIBUTE_GROUPS(f2fs_feat); @@ -1362,9 +1387,14 @@ static struct kset f2fs_kset = { .kobj = {.ktype = &f2fs_ktype}, }; +static const struct sysfs_ops f2fs_feat_attr_ops = { + .show = f2fs_base_attr_show, + .store = f2fs_base_attr_store, +}; + static const struct kobj_type f2fs_feat_ktype = { .default_groups = f2fs_feat_groups, - .sysfs_ops = &f2fs_attr_ops, + .sysfs_ops = &f2fs_feat_attr_ops, }; static struct kobject f2fs_feat = {