Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp980180rwb; Thu, 22 Sep 2022 08:39:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM432a5gt4E9o1zzr0q5zzdQz9ki4ojRBkgpYFhoaq6/09LReBfj84h208jl8xWSJ7cG3m4p X-Received: by 2002:a17:90a:db04:b0:203:6731:caf8 with SMTP id g4-20020a17090adb0400b002036731caf8mr4421733pjv.190.1663861167918; Thu, 22 Sep 2022 08:39:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663861167; cv=none; d=google.com; s=arc-20160816; b=uWp4ZdEmE5q9/jipQHvKSCoWDGaoyZlJa2GVstJ0UnmTXgdgkos0KllPtBAALVtsWe kH/FtduQOPaduPGzmPL2zwU392jFQ3dSWvuirdoYilb68NT+n1X5WSEnC8lu/3IoKpy9 PM3vqxpENk7gn+swGDr2fyTjZ2IjsvD0MuTMmiW7HrLOrDBIPj9CMSNuG2t3m7W0Sn58 2NvMmIlRsaw33tJU0FDYhp/kZAuF84HKIFLRGZz4K0baB4ZEyDO49r8oPrTzDi/abzf6 Nff2a/DZk1eNCuWoFoM0ZPD9b6xBakGqLoAhEO0fpAnwtb5z9R1yOI2oZlyu7D0ryqFC QK+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=vU7j9ozEWVekAwlpC43iDPWl53/tNQfQFiQAfOJP2wQ=; b=o8psgH4J+33Mucm/U4IIiQN4rLP/tVe487cJss/agyE32jGRMOTo9eQf+aUq12kQtq 8Z1imAyv8xH7dUxAxCnRhskYT+2jkPZTU87t8cAW5HkZtfr0pDPxBre5hoQTgrJf/ZcJ px6yUf1MTuN+cfftbqCh8wKY5pPZIIs0X4qHAupsdtFj4qnNSp6/mGoKTcttn6xqyc6g I463Sp4yzUlfWlLEGTm4E5L3SUlY4Uewppitq+P9Fm4DYqdhoU/XkS7cbwIXoshd1TDc y39hOSCC8+96GPbDwjOmtfGQKMNfu9591Qg+T4ZVqTEwTbaRZE37rtfaVWJvFse5huxR oxpA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d10-20020a056a00244a00b00535d7265923si6572792pfj.377.2022.09.22.08.39.05; Thu, 22 Sep 2022 08:39:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229791AbiIVPb3 (ORCPT + 99 others); Thu, 22 Sep 2022 11:31:29 -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: 7BIT Content-Type: text/plain; charset=US-ASCII 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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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); #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 = m->private; + struct nfsd_net *nn = net_generic(file_inode(m->file)->i_sb->s_fs_info, + nfsd_net_id); 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 = 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_operations = { .release = nfsd_pool_stats_release, }; -static const struct file_operations reply_cache_stats_operations = { - .open = nfsd_reply_cache_stats_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(nfsd_reply_cache_stats); static const struct file_operations filecache_ops = { .open = nfsd_file_cache_stats_open, @@ -1354,7 +1349,7 @@ static int nfsd_fill_super(struct super_block *sb, struct fs_context *fc) [NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_Pool_Threads] = {"pool_threads", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_Pool_Stats] = {"pool_stats", &pool_stats_operations, S_IRUGO}, - [NFSD_Reply_Cache_Stats] = {"reply_cache_stats", &reply_cache_stats_operations, S_IRUGO}, + [NFSD_Reply_Cache_Stats] = {"reply_cache_stats", &nfsd_reply_cache_stats_fops, S_IRUGO}, [NFSD_Versions] = {"versions", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_Ports] = {"portlist", &transaction_ops, S_IWUSR|S_IRUGO}, [NFSD_MaxBlkSize] = {"max_block_size", &transaction_ops, S_IWUSR|S_IRUGO}, -- 2.31.1