Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp980475rwb; Thu, 22 Sep 2022 08:39:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Jd6Snwfbvw2UYkTLq7mscZcSqMtfYbG7P8DNATwSn8WFh2mlhmgskkm/gHXtqfRJkA4xi X-Received: by 2002:a05:6402:90e:b0:443:ec4b:2b03 with SMTP id g14-20020a056402090e00b00443ec4b2b03mr3925246edz.71.1663861178028; Thu, 22 Sep 2022 08:39:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663861178; cv=none; d=google.com; s=arc-20160816; b=ZcvfwfRE3LvOszBTTpsNJOTMvv2bb7o6ddGG47dKFAipiFuK+O7xzdBnzhIrk06kas AdpN0OH8BZcQKLl43F2giBzSRq0CDlhk8N/U407l6XDlCHjPfqksWdo8TMqhpFYV1nve 8NMdoJ1uLc2qn+tqhucfJA6tO1hMYxApy+oKWWFFKI4aZKoFnTwdh7Bg4l61aZG3V8/s mCkNo7J7Jxq4BmmvrqGh2Q9Ew+dH8CN2cLMJBXhyK1M9ZLIioNndTQIam4V5Bb6wN6KY u6MY1noLnxEpTtzWel8l6fXQWyziH+m4UAgTvJrlPhWtHqDry4xBW4HucWb2PBYAvNnh G9YA== 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=+2KjNRYXWohlwS/f7Cgc4vXdu2a2ffYylTqPwD4EhgQ=; b=DlDmMb4HjNqZaQzsL1vffDl3beVzQkKteOoK5C2bg38IAkeWlpMkghZjKG7knUninG dG2UPBN59OIimptlL0DDlW4Ikr0xbIvg/OMi42RtpD52kHLWfY9pjkRvGkYtubouPTC0 ICSlovN/0ZI8S8Shqu/QVdnCwRxp5WxrO+Mwosf2Wf84dmSZhi7pPUy0b4zoOGVxsegw Vh4y7gnbgK69VnC5EXGWcyTfy060K4HcijmyH+k1fxqm/f+8j10ScrrzmfHS8LzehCNs iHhmJsaLuwsVQQtyycxvMbJKaq64pmoxECmnGEoQGLnE1VYaXYOUlRJBf/juBI23NR9Y g6zg== 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 y13-20020a056402440d00b0044e7ec802f4si6042281eda.381.2022.09.22.08.39.04; Thu, 22 Sep 2022 08:39:38 -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 S230247AbiIVPb1 (ORCPT + 99 others); Thu, 22 Sep 2022 11:31:27 -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: 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. 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, void *v) return 0; } -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 = { - .open = export_features_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(export_features); #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; } -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 = { - .open = supported_enctypes_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(supported_enctypes); #endif /* CONFIG_SUNRPC_GSS or CONFIG_SUNRPC_GSS_MODULE */ static const struct file_operations pool_stats_operations = { @@ -1365,7 +1345,7 @@ static int nfsd_fill_super(struct super_block *sb, struct fs_context *fc) /* Per-export io stats use same ops as exports file */ [NFSD_Export_Stats] = {"export_stats", &exports_nfsd_operations, S_IRUGO}, [NFSD_Export_features] = {"export_features", - &export_features_operations, S_IRUGO}, + &export_features_fops, S_IRUGO}, [NFSD_FO_UnlockIP] = {"unlock_ip", &transaction_ops, S_IWUSR|S_IRUSR}, [NFSD_FO_UnlockFS] = {"unlock_filesystem", @@ -1381,7 +1361,7 @@ static int nfsd_fill_super(struct super_block *sb, struct fs_context *fc) [NFSD_MaxConnections] = {"max_connections", &transaction_ops, S_IWUSR|S_IRUGO}, [NFSD_Filecache] = {"filecache", &filecache_ops, S_IRUGO}, #if defined(CONFIG_SUNRPC_GSS) || defined(CONFIG_SUNRPC_GSS_MODULE) - [NFSD_SupportedEnctypes] = {"supported_krb5_enctypes", &supported_enctypes_ops, S_IRUGO}, + [NFSD_SupportedEnctypes] = {"supported_krb5_enctypes", &supported_enctypes_fops, S_IRUGO}, #endif /* CONFIG_SUNRPC_GSS or CONFIG_SUNRPC_GSS_MODULE */ #ifdef CONFIG_NFSD_V4 [NFSD_Leasetime] = {"nfsv4leasetime", &transaction_ops, S_IWUSR|S_IRUSR}, -- 2.31.1