Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp445991pxb; Wed, 3 Mar 2021 07:12:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2xVIlwO0mGZZ9Ffcnc1evnpDveW0kT1GqwJY336miO5R4UWlNREjgt9NOArMqa+l/MVwa X-Received: by 2002:aa7:c6d2:: with SMTP id b18mr25686029eds.183.1614784356420; Wed, 03 Mar 2021 07:12:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614784356; cv=none; d=google.com; s=arc-20160816; b=Aw03eAIXnfOUX7G5B0OlQ3Emny16x6bPXOHKKmF0NWa+GJfRDfO23vmKLyWqNsfhP6 Jm98LBt2XnX/abuuubUHpFma/hT4miSRuJrkj6MQGsKXLZ9lgwCKUpLIZjgjVZVwepi9 abEaIc4wrlrFLAC9GoL5RylxYKXDrbvYoZopOg5qHH3hE7fh8WeudZ0Xc5UMWoQ2Z3+X AtSGm7rSBt+4CH9caL5BeoNiFJmF6tV9SBdP4y1BcCu+IPHWmouNYbBxDubdQvaDm9fF Au6S0rhNLmwycwRJsWoiDcytlsq9qUsT+jnKDoWUm86rNk5RIsZXbAwuJ3+6gfl0KAPo GDPQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mA/mM0estW7I2IEHMy+IfvA/RtstqS7HsgWTxpqlMec=; b=PCtzPSXe6vJYiUS8Q1GHlSZzdow9/59An9VuSWVGI9XB7pbOytMzs/wdSqceWoKr6G PP2IJk97O7X7usUTIU7Rak63hKHPKIsctLlVi9YbyFXzLY4xZ73uuZz8eneVQEANBwvO RuOLArAldPTOlyyGlzXDS6YPWCpyjd7KoB06JtcU/y+LnFU9bndg++Y0bmgtxEMXyLRu F3+cr8qR4lOM0kkr575VduOfZkDklf+quloRNPmHptsPXaVXpX9iQqkbvRnp6/pDn1SI FV2tLRIY4KCORADfXbD7Q//t4qfmKJoq65dzmZG/lvxarxzav5ErL8II5dojZ5YUixMM zAnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=frwSGSU2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u12si5463648eda.121.2021.03.03.07.11.58; Wed, 03 Mar 2021 07:12:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=frwSGSU2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343704AbhCAWh3 (ORCPT + 99 others); Mon, 1 Mar 2021 17:37:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:33834 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238914AbhCARnw (ORCPT ); Mon, 1 Mar 2021 12:43:52 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D68DD64FDD; Mon, 1 Mar 2021 16:58:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614617890; bh=9rj+LRcxD1850915KJhU5ryX+AAJC5m4+jNdVpJTFlI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=frwSGSU2xL8Q6EOy0gKd4dNaKLmh6QtF+nYP/UES0mC5MSSVwTB/vQioAkcIIPh7F TcLewa1wSZOtVbnwYw5oVC8i7sEvIJaiunFh7LjThSahic/9MFefzpCzsunpDoSPbi q9hOdfV9xJf1o00zW14QgN/K6dRmmii9pI5Mu6i8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhi Li , "J. Bruce Fields" , Chuck Lever , Sasha Levin Subject: [PATCH 5.4 193/340] nfsd: register pernet ops last, unregister first Date: Mon, 1 Mar 2021 17:12:17 +0100 Message-Id: <20210301161057.806637162@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161048.294656001@linuxfoundation.org> References: <20210301161048.294656001@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: J. Bruce Fields [ Upstream commit bd5ae9288d6451bd346a1b4a59d4fe7e62ba29b7 ] These pernet operations may depend on stuff set up or torn down in the module init/exit functions. And they may be called at any time in between. So it makes more sense for them to be the last to be registered in the init function, and the first to be unregistered in the exit function. In particular, without this, the drc slab is being destroyed before all the per-net drcs are shut down, resulting in an "Objects remaining in nfsd_drc on __kmem_cache_shutdown()" warning in exit_nfsd. Reported-by: Zhi Li Fixes: 3ba75830ce17 "nfsd4: drc containerization" Signed-off-by: J. Bruce Fields Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin --- fs/nfsd/nfsctl.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index be418fccc9d86..7f39d6091dfa0 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -1523,12 +1523,9 @@ static int __init init_nfsd(void) int retval; printk(KERN_INFO "Installing knfsd (copyright (C) 1996 okir@monad.swb.de).\n"); - retval = register_pernet_subsys(&nfsd_net_ops); - if (retval < 0) - return retval; retval = register_cld_notifier(); if (retval) - goto out_unregister_pernet; + return retval; retval = nfsd4_init_slabs(); if (retval) goto out_unregister_notifier; @@ -1546,9 +1543,14 @@ static int __init init_nfsd(void) goto out_free_lockd; retval = register_filesystem(&nfsd_fs_type); if (retval) + goto out_free_exports; + retval = register_pernet_subsys(&nfsd_net_ops); + if (retval < 0) goto out_free_all; return 0; out_free_all: + unregister_pernet_subsys(&nfsd_net_ops); +out_free_exports: remove_proc_entry("fs/nfs/exports", NULL); remove_proc_entry("fs/nfs", NULL); out_free_lockd: @@ -1562,13 +1564,12 @@ out_free_slabs: nfsd4_free_slabs(); out_unregister_notifier: unregister_cld_notifier(); -out_unregister_pernet: - unregister_pernet_subsys(&nfsd_net_ops); return retval; } static void __exit exit_nfsd(void) { + unregister_pernet_subsys(&nfsd_net_ops); nfsd_drc_slab_free(); remove_proc_entry("fs/nfs/exports", NULL); remove_proc_entry("fs/nfs", NULL); @@ -1579,7 +1580,6 @@ static void __exit exit_nfsd(void) nfsd_fault_inject_cleanup(); unregister_filesystem(&nfsd_fs_type); unregister_cld_notifier(); - unregister_pernet_subsys(&nfsd_net_ops); } MODULE_AUTHOR("Olaf Kirch "); -- 2.27.0