Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp6160617ioo; Wed, 1 Jun 2022 23:40:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyb3o+vOXlMApxadgJTEEvq6yeZ7cr190sg1VRkBBGz7iUupxKrSNDA1Fg4m/e1N49EC6Vm X-Received: by 2002:a17:902:bf45:b0:163:ad4b:dde9 with SMTP id u5-20020a170902bf4500b00163ad4bdde9mr3275449pls.25.1654152035915; Wed, 01 Jun 2022 23:40:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654152035; cv=none; d=google.com; s=arc-20160816; b=yGgEY24zEFyob3MrjP0fzZ+EJYjqWBx/BS2HDyuCu4eJpyndqnpmhr4YybP1/JDK+Q bjkP8uBlQ3T0Ln4eDTIXbF13ObXtcbYWmXf08uAtAuncbvsVwYUnCOvkfuawT/nb0sMz aSg8S8bM39R0kZa5Fzn9wD9fLyIRlK6IuV3qDIRCvSGCAkALXBCzDrv+6exSIDCJd/4W 2DkK+H+kXCE3yY2dH0ufmb9MbCNKCAScntejJelw8HFguCbHJGrHRn/srPsoSDQ4dNHQ xoxqmq1gRvqaTioJzgBnzdr6k5LAJn57s4Cd6HNM5vs2jObyKu0zHsppXCagw9ClBU5X IiXw== 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 :message-id:date:subject:cc:to:from; bh=DrZYKOlZPb+t6NwW+4Q6sdVdW5AiKaYJHDoq0sDbsYg=; b=uH+8jcZffZARFXczejy9UDcmjI1eS4fPeNCY/aBnPdOgdB600c1rY+YsWVM4Pgdsta u48aVZu8BI7stfrnCTryk8x9o1aXud9h3t8NnQV07vYp9gGUmGERCEtQ+nklOlVNtjsh ldlb+kSsqosgBqEYx9KD7J4ZdSUAeKlsTAuMrW1YuFdRJt/9pUERv493MqDIZWojnnP6 IikVYVfObisJRv5qzMSXwO57arbt2xOJnzdDNbc39CXy7HHdi5uRiztGsOMw/EPjMv5N AxGWFoB5B9Q2DQa5IS8pygcINhklx99ec3DW+Pm895erq8tvF5K9Tx06qZX4LXV5voMX zaNA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pw13-20020a17090b278d00b001e00edc0c59si4379571pjb.60.2022.06.01.23.40.09; Wed, 01 Jun 2022 23:40:35 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230200AbiFBF4y (ORCPT + 99 others); Thu, 2 Jun 2022 01:56:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230048AbiFBF4v (ORCPT ); Thu, 2 Jun 2022 01:56:51 -0400 Received: from hust.edu.cn (unknown [202.114.0.240]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77D15B05; Wed, 1 Jun 2022 22:56:47 -0700 (PDT) Received: from localhost.localdomain ([172.16.0.254]) (user=dzm91@hust.edu.cn mech=LOGIN bits=0) by mx1.hust.edu.cn with ESMTP id 2525uY8M014913-2525uY8P014913 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO); Thu, 2 Jun 2022 13:56:38 +0800 From: Dongliang Mu To: Chuck Lever Cc: Dongliang Mu , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] fs: nfsd: make destory function more elegant Date: Thu, 2 Jun 2022 13:56:32 +0800 Message-Id: <20220602055633.849545-1-dzm91@hust.edu.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-FEAS-AUTH-USER: dzm91@hust.edu.cn X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Dongliang Mu In init_nfsd, the undo operation of create_proc_exports_entry is: remove_proc_entry("fs/nfs/exports", NULL); remove_proc_entry("fs/nfs", NULL); This may lead to maintaince issue. Declare the undo function destroy_proc_exports_entry based on CONFIG_PROC_FS Signed-off-by: Dongliang Mu --- fs/nfsd/nfsctl.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 0621c2faf242..83b34ccbef5a 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -1450,11 +1450,21 @@ static int create_proc_exports_entry(void) } return 0; } + +static void destroy_proc_exports_entry(void) +{ + remove_proc_entry("fs/nfs/exports", NULL); + remove_proc_entry("fs/nfs", NULL); +} #else /* CONFIG_PROC_FS */ static int create_proc_exports_entry(void) { return 0; } + +static void destroy_proc_exports_entry(void) +{ +} #endif unsigned int nfsd_net_id; @@ -1555,8 +1565,7 @@ static int __init init_nfsd(void) out_free_subsys: unregister_pernet_subsys(&nfsd_net_ops); out_free_exports: - remove_proc_entry("fs/nfs/exports", NULL); - remove_proc_entry("fs/nfs", NULL); + destroy_proc_exports_entry(); out_free_lockd: nfsd_lockd_shutdown(); nfsd_drc_slab_free(); @@ -1576,8 +1585,7 @@ static void __exit exit_nfsd(void) unregister_cld_notifier(); unregister_pernet_subsys(&nfsd_net_ops); nfsd_drc_slab_free(); - remove_proc_entry("fs/nfs/exports", NULL); - remove_proc_entry("fs/nfs", NULL); + destroy_proc_exports_entry(); nfsd_stat_shutdown(); nfsd_lockd_shutdown(); nfsd4_free_slabs(); -- 2.25.1