From nobody Thu Apr 2 15:02:20 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C23F3C6FA82 for ; Thu, 22 Sep 2022 15:31:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232128AbiIVPbf (ORCPT ); Thu, 22 Sep 2022 11:31:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229802AbiIVPbY (ORCPT ); Thu, 22 Sep 2022 11:31:24 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E59BFB317; Thu, 22 Sep 2022 08:31:23 -0700 (PDT) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MYK0C3gL3zWgvF; Thu, 22 Sep 2022 23:27:23 +0800 (CST) Received: from kwepemm600015.china.huawei.com (7.193.23.52) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 22 Sep 2022 23:31:20 +0800 Received: from huawei.com (10.175.101.6) by kwepemm600015.china.huawei.com (7.193.23.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 22 Sep 2022 23:31:19 +0800 From: ChenXiaoSong To: , CC: , , , , Subject: [PATCH 1/5] nfsd: use DEFINE_PROC_SHOW_ATTRIBUTE to define nfsd_proc_ops Date: Fri, 23 Sep 2022 00:31:52 +0800 Message-ID: <20220922163156.2027440-2-chenxiaosong2@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220922163156.2027440-1-chenxiaosong2@huawei.com> References: <20220922163156.2027440-1-chenxiaosong2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600015.china.huawei.com (7.193.23.52) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use DEFINE_PROC_SHOW_ATTRIBUTE helper macro to simplify the code. Signed-off-by: ChenXiaoSong --- fs/nfsd/stats.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/fs/nfsd/stats.c b/fs/nfsd/stats.c index a8c5a02a84f0..777e24e5da33 100644 --- a/fs/nfsd/stats.c +++ b/fs/nfsd/stats.c @@ -32,7 +32,7 @@ struct svc_stat nfsd_svcstats =3D { .program =3D &nfsd_program, }; =20 -static int nfsd_proc_show(struct seq_file *seq, void *v) +static int nfsd_show(struct seq_file *seq, void *v) { int i; =20 @@ -72,17 +72,7 @@ static int nfsd_proc_show(struct seq_file *seq, void *v) return 0; } =20 -static int nfsd_proc_open(struct inode *inode, struct file *file) -{ - return single_open(file, nfsd_proc_show, NULL); -} - -static const struct proc_ops nfsd_proc_ops =3D { - .proc_open =3D nfsd_proc_open, - .proc_read =3D seq_read, - .proc_lseek =3D seq_lseek, - .proc_release =3D single_release, -}; +DEFINE_PROC_SHOW_ATTRIBUTE(nfsd); =20 int nfsd_percpu_counters_init(struct percpu_counter counters[], int num) { --=20 2.31.1 From nobody Thu Apr 2 15:02:20 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EF42C54EE9 for ; Thu, 22 Sep 2022 15:31:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231222AbiIVPbi (ORCPT ); Thu, 22 Sep 2022 11:31:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231578AbiIVPbZ (ORCPT ); Thu, 22 Sep 2022 11:31:25 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2760AFB32F; Thu, 22 Sep 2022 08:31:23 -0700 (PDT) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MYK005TQ0zlXN8; Thu, 22 Sep 2022 23:27:12 +0800 (CST) Received: from kwepemm600015.china.huawei.com (7.193.23.52) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 22 Sep 2022 23:31:21 +0800 Received: from huawei.com (10.175.101.6) by kwepemm600015.china.huawei.com (7.193.23.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 22 Sep 2022 23:31:20 +0800 From: ChenXiaoSong To: , CC: , , , , Subject: [PATCH 2/5] nfsd: use DEFINE_SHOW_ATTRIBUTE to define export_features_fops and supported_enctypes_fops Date: Fri, 23 Sep 2022 00:31:53 +0800 Message-ID: <20220922163156.2027440-3-chenxiaosong2@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220922163156.2027440-1-chenxiaosong2@huawei.com> References: <20220922163156.2027440-1-chenxiaosong2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600015.china.huawei.com (7.193.23.52) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use DEFINE_SHOW_ATTRIBUTE helper macro to simplify the code. Signed-off-by: ChenXiaoSong --- fs/nfsd/nfsctl.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 917fa1892fd2..51360d0bf424 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -185,17 +185,7 @@ static int export_features_show(struct seq_file *m, vo= id *v) return 0; } =20 -static int export_features_open(struct inode *inode, struct file *file) -{ - return single_open(file, export_features_show, NULL); -} - -static const struct file_operations export_features_operations =3D { - .open =3D export_features_open, - .read =3D seq_read, - .llseek =3D seq_lseek, - .release =3D single_release, -}; +DEFINE_SHOW_ATTRIBUTE(export_features); =20 #if defined(CONFIG_SUNRPC_GSS) || defined(CONFIG_SUNRPC_GSS_MODULE) static int supported_enctypes_show(struct seq_file *m, void *v) @@ -204,17 +194,7 @@ static int supported_enctypes_show(struct seq_file *m,= void *v) return 0; } =20 -static int supported_enctypes_open(struct inode *inode, struct file *file) -{ - return single_open(file, supported_enctypes_show, NULL); -} - -static const struct file_operations supported_enctypes_ops =3D { - .open =3D supported_enctypes_open, - .read =3D seq_read, - .llseek =3D seq_lseek, - .release =3D single_release, -}; +DEFINE_SHOW_ATTRIBUTE(supported_enctypes); #endif /* CONFIG_SUNRPC_GSS or CONFIG_SUNRPC_GSS_MODULE */ =20 static const struct file_operations pool_stats_operations =3D { @@ -1365,7 +1345,7 @@ static int nfsd_fill_super(struct super_block *sb, st= ruct fs_context *fc) /* Per-export io stats use same ops as exports file */ [NFSD_Export_Stats] =3D {"export_stats", &exports_nfsd_operations, S_IRU= GO}, [NFSD_Export_features] =3D {"export_features", - &export_features_operations, S_IRUGO}, + &export_features_fops, S_IRUGO}, [NFSD_FO_UnlockIP] =3D {"unlock_ip", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_FO_UnlockFS] =3D {"unlock_filesystem", @@ -1381,7 +1361,7 @@ static int nfsd_fill_super(struct super_block *sb, st= ruct fs_context *fc) [NFSD_MaxConnections] =3D {"max_connections", &transaction_ops, S_IWUSR|= S_IRUGO}, [NFSD_Filecache] =3D {"filecache", &filecache_ops, S_IRUGO}, #if defined(CONFIG_SUNRPC_GSS) || defined(CONFIG_SUNRPC_GSS_MODULE) - [NFSD_SupportedEnctypes] =3D {"supported_krb5_enctypes", &supported_enct= ypes_ops, S_IRUGO}, + [NFSD_SupportedEnctypes] =3D {"supported_krb5_enctypes", &supported_enct= ypes_fops, S_IRUGO}, #endif /* CONFIG_SUNRPC_GSS or CONFIG_SUNRPC_GSS_MODULE */ #ifdef CONFIG_NFSD_V4 [NFSD_Leasetime] =3D {"nfsv4leasetime", &transaction_ops, S_IWUSR|S_IRUS= R}, --=20 2.31.1 From nobody Thu Apr 2 15:02:20 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 075E8C6FA82 for ; Thu, 22 Sep 2022 15:31:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232136AbiIVPbl (ORCPT ); Thu, 22 Sep 2022 11:31:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231990AbiIVPb0 (ORCPT ); Thu, 22 Sep 2022 11:31:26 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24F47FB330; Thu, 22 Sep 2022 08:31:24 -0700 (PDT) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MYK013XH9zlXMy; Thu, 22 Sep 2022 23:27:13 +0800 (CST) Received: from kwepemm600015.china.huawei.com (7.193.23.52) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 22 Sep 2022 23:31:22 +0800 Received: from huawei.com (10.175.101.6) by kwepemm600015.china.huawei.com (7.193.23.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 22 Sep 2022 23:31:21 +0800 From: ChenXiaoSong To: , CC: , , , , Subject: [PATCH 3/5] nfsd: use DEFINE_SHOW_ATTRIBUTE to define client_info_fops Date: Fri, 23 Sep 2022 00:31:54 +0800 Message-ID: <20220922163156.2027440-4-chenxiaosong2@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220922163156.2027440-1-chenxiaosong2@huawei.com> References: <20220922163156.2027440-1-chenxiaosong2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600015.china.huawei.com (7.193.23.52) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use DEFINE_SHOW_ATTRIBUTE helper macro to simplify the code. inode is converted from seq_file->file instead of seq_file->private in client_info_show(). Signed-off-by: ChenXiaoSong --- fs/nfsd/nfs4state.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index c5d199d7e6b4..4017721a04c7 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -2478,7 +2478,7 @@ static const char *cb_state2str(int state) =20 static int client_info_show(struct seq_file *m, void *v) { - struct inode *inode =3D m->private; + struct inode *inode =3D file_inode(m->file); struct nfs4_client *clp; u64 clid; =20 @@ -2518,17 +2518,7 @@ static int client_info_show(struct seq_file *m, void= *v) return 0; } =20 -static int client_info_open(struct inode *inode, struct file *file) -{ - return single_open(file, client_info_show, inode); -} - -static const struct file_operations client_info_fops =3D { - .open =3D client_info_open, - .read =3D seq_read, - .llseek =3D seq_lseek, - .release =3D single_release, -}; +DEFINE_SHOW_ATTRIBUTE(client_info); =20 static void *states_start(struct seq_file *s, loff_t *pos) __acquires(&clp->cl_lock) --=20 2.31.1 From nobody Thu Apr 2 15:02:20 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44BFFC54EE9 for ; Thu, 22 Sep 2022 15:31:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231293AbiIVPbo (ORCPT ); Thu, 22 Sep 2022 11:31:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232112AbiIVPb2 (ORCPT ); Thu, 22 Sep 2022 11:31:28 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60728FB311; Thu, 22 Sep 2022 08:31:25 -0700 (PDT) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4MYK2J1TMgzHq0J; Thu, 22 Sep 2022 23:29:12 +0800 (CST) Received: from kwepemm600015.china.huawei.com (7.193.23.52) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 22 Sep 2022 23:31:22 +0800 Received: from huawei.com (10.175.101.6) by kwepemm600015.china.huawei.com (7.193.23.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 22 Sep 2022 23:31:22 +0800 From: ChenXiaoSong To: , CC: , , , , Subject: [PATCH 4/5] nfsd: use DEFINE_SHOW_ATTRIBUTE to define nfsd_reply_cache_stats_fops Date: Fri, 23 Sep 2022 00:31:55 +0800 Message-ID: <20220922163156.2027440-5-chenxiaosong2@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220922163156.2027440-1-chenxiaosong2@huawei.com> References: <20220922163156.2027440-1-chenxiaosong2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600015.china.huawei.com (7.193.23.52) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use DEFINE_SHOW_ATTRIBUTE helper macro to simplify the code. nfsd_net is converted from seq_file->file instead of seq_file->private in nfsd_reply_cache_stats_show(). Signed-off-by: ChenXiaoSong --- fs/nfsd/cache.h | 2 +- fs/nfsd/nfscache.c | 13 +++---------- fs/nfsd/nfsctl.c | 9 ++------- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/fs/nfsd/cache.h b/fs/nfsd/cache.h index 65c331f75e9c..f21259ead64b 100644 --- a/fs/nfsd/cache.h +++ b/fs/nfsd/cache.h @@ -84,6 +84,6 @@ int nfsd_reply_cache_init(struct nfsd_net *); void nfsd_reply_cache_shutdown(struct nfsd_net *); int nfsd_cache_lookup(struct svc_rqst *); void nfsd_cache_update(struct svc_rqst *, int, __be32 *); -int nfsd_reply_cache_stats_open(struct inode *, struct file *); +int nfsd_reply_cache_stats_show(struct seq_file *m, void *v); =20 #endif /* NFSCACHE_H */ diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c index 9b31e1103e7b..3e64a3d50a1c 100644 --- a/fs/nfsd/nfscache.c +++ b/fs/nfsd/nfscache.c @@ -604,9 +604,10 @@ nfsd_cache_append(struct svc_rqst *rqstp, struct kvec = *data) * scraping this file for info should test the labels to ensure they're * getting the correct field. */ -static int nfsd_reply_cache_stats_show(struct seq_file *m, void *v) +int nfsd_reply_cache_stats_show(struct seq_file *m, void *v) { - struct nfsd_net *nn =3D m->private; + struct nfsd_net *nn =3D net_generic(file_inode(m->file)->i_sb->s_fs_info, + nfsd_net_id); =20 seq_printf(m, "max entries: %u\n", nn->max_drc_entries); seq_printf(m, "num entries: %u\n", @@ -626,11 +627,3 @@ static int nfsd_reply_cache_stats_show(struct seq_file= *m, void *v) seq_printf(m, "cachesize at longest: %u\n", nn->longest_chain_cachesize); return 0; } - -int nfsd_reply_cache_stats_open(struct inode *inode, struct file *file) -{ - struct nfsd_net *nn =3D net_generic(file_inode(file)->i_sb->s_fs_info, - nfsd_net_id); - - return single_open(file, nfsd_reply_cache_stats_show, nn); -} diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 51360d0bf424..faaedefec94c 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -204,12 +204,7 @@ static const struct file_operations pool_stats_operati= ons =3D { .release =3D nfsd_pool_stats_release, }; =20 -static const struct file_operations reply_cache_stats_operations =3D { - .open =3D nfsd_reply_cache_stats_open, - .read =3D seq_read, - .llseek =3D seq_lseek, - .release =3D single_release, -}; +DEFINE_SHOW_ATTRIBUTE(nfsd_reply_cache_stats); =20 static const struct file_operations filecache_ops =3D { .open =3D nfsd_file_cache_stats_open, @@ -1354,7 +1349,7 @@ static int nfsd_fill_super(struct super_block *sb, st= ruct fs_context *fc) [NFSD_Threads] =3D {"threads", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_Pool_Threads] =3D {"pool_threads", &transaction_ops, S_IWUSR|S_IRU= SR}, [NFSD_Pool_Stats] =3D {"pool_stats", &pool_stats_operations, S_IRUGO}, - [NFSD_Reply_Cache_Stats] =3D {"reply_cache_stats", &reply_cache_stats_op= erations, S_IRUGO}, + [NFSD_Reply_Cache_Stats] =3D {"reply_cache_stats", &nfsd_reply_cache_sta= ts_fops, S_IRUGO}, [NFSD_Versions] =3D {"versions", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_Ports] =3D {"portlist", &transaction_ops, S_IWUSR|S_IRUGO}, [NFSD_MaxBlkSize] =3D {"max_block_size", &transaction_ops, S_IWUSR|S_IRU= GO}, --=20 2.31.1 From nobody Thu Apr 2 15:02:20 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 963DBC6FA82 for ; Thu, 22 Sep 2022 15:31:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231341AbiIVPbs (ORCPT ); Thu, 22 Sep 2022 11:31:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230466AbiIVPb2 (ORCPT ); Thu, 22 Sep 2022 11:31:28 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07496FB30F; Thu, 22 Sep 2022 08:31:25 -0700 (PDT) Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4MYK032JnVz14S2m; Thu, 22 Sep 2022 23:27:15 +0800 (CST) Received: from kwepemm600015.china.huawei.com (7.193.23.52) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 22 Sep 2022 23:31:23 +0800 Received: from huawei.com (10.175.101.6) by kwepemm600015.china.huawei.com (7.193.23.52) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 22 Sep 2022 23:31:22 +0800 From: ChenXiaoSong To: , CC: , , , , Subject: [PATCH 5/5] nfsd: use DEFINE_SHOW_ATTRIBUTE to define nfsd_file_cache_stats_fops Date: Fri, 23 Sep 2022 00:31:56 +0800 Message-ID: <20220922163156.2027440-6-chenxiaosong2@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220922163156.2027440-1-chenxiaosong2@huawei.com> References: <20220922163156.2027440-1-chenxiaosong2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600015.china.huawei.com (7.193.23.52) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use DEFINE_SHOW_ATTRIBUTE helper macro to simplify the code. Signed-off-by: ChenXiaoSong --- fs/nfsd/filecache.c | 7 +------ fs/nfsd/filecache.h | 2 +- fs/nfsd/nfsctl.c | 9 ++------- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index eeed4ae5b4ad..d5c57360b418 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -1212,7 +1212,7 @@ nfsd_file_create(struct svc_rqst *rqstp, struct svc_f= h *fhp, * scraping this file for info should test the labels to ensure they're * getting the correct field. */ -static int nfsd_file_cache_stats_show(struct seq_file *m, void *v) +int nfsd_file_cache_stats_show(struct seq_file *m, void *v) { unsigned long releases =3D 0, pages_flushed =3D 0, evictions =3D 0; unsigned long hits =3D 0, acquisitions =3D 0; @@ -1259,8 +1259,3 @@ static int nfsd_file_cache_stats_show(struct seq_file= *m, void *v) seq_printf(m, "pages flushed: %lu\n", pages_flushed); return 0; } - -int nfsd_file_cache_stats_open(struct inode *inode, struct file *file) -{ - return single_open(file, nfsd_file_cache_stats_show, NULL); -} diff --git a/fs/nfsd/filecache.h b/fs/nfsd/filecache.h index 8e8c0c47d67d..357832bac736 100644 --- a/fs/nfsd/filecache.h +++ b/fs/nfsd/filecache.h @@ -60,5 +60,5 @@ __be32 nfsd_file_acquire(struct svc_rqst *rqstp, struct s= vc_fh *fhp, unsigned int may_flags, struct nfsd_file **nfp); __be32 nfsd_file_create(struct svc_rqst *rqstp, struct svc_fh *fhp, unsigned int may_flags, struct nfsd_file **nfp); -int nfsd_file_cache_stats_open(struct inode *, struct file *); +int nfsd_file_cache_stats_show(struct seq_file *m, void *v); #endif /* _FS_NFSD_FILECACHE_H */ diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index faaedefec94c..e6be0e2a86ac 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -206,12 +206,7 @@ static const struct file_operations pool_stats_operati= ons =3D { =20 DEFINE_SHOW_ATTRIBUTE(nfsd_reply_cache_stats); =20 -static const struct file_operations filecache_ops =3D { - .open =3D nfsd_file_cache_stats_open, - .read =3D seq_read, - .llseek =3D seq_lseek, - .release =3D single_release, -}; +DEFINE_SHOW_ATTRIBUTE(nfsd_file_cache_stats); =20 /*------------------------------------------------------------------------= ----*/ /* @@ -1354,7 +1349,7 @@ static int nfsd_fill_super(struct super_block *sb, st= ruct fs_context *fc) [NFSD_Ports] =3D {"portlist", &transaction_ops, S_IWUSR|S_IRUGO}, [NFSD_MaxBlkSize] =3D {"max_block_size", &transaction_ops, S_IWUSR|S_IRU= GO}, [NFSD_MaxConnections] =3D {"max_connections", &transaction_ops, S_IWUSR|= S_IRUGO}, - [NFSD_Filecache] =3D {"filecache", &filecache_ops, S_IRUGO}, + [NFSD_Filecache] =3D {"filecache", &nfsd_file_cache_stats_fops, S_IRUGO}, #if defined(CONFIG_SUNRPC_GSS) || defined(CONFIG_SUNRPC_GSS_MODULE) [NFSD_SupportedEnctypes] =3D {"supported_krb5_enctypes", &supported_enct= ypes_fops, S_IRUGO}, #endif /* CONFIG_SUNRPC_GSS or CONFIG_SUNRPC_GSS_MODULE */ --=20 2.31.1