Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp482783pxb; Wed, 3 Feb 2021 09:54:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzIhFLABrWjjD5bz0PS1kX86aXX0jIE7F8lL4+ftmcDE54zTRNRmI6ko/f7GKWX1ftsGZrJ X-Received: by 2002:a05:6402:6d6:: with SMTP id n22mr4262989edy.128.1612374888121; Wed, 03 Feb 2021 09:54:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612374888; cv=none; d=google.com; s=arc-20160816; b=nziLeX1BmTynzt5dBCJcDU4lURsNecG+Q/3FNgZglZn87OQWwYmvGsCmFtfBCh4rTu XrKhFw2M3rdsAXtgqv8jNDdveBIsvmd47cG6a0FAKQ6Qb5QGszBXTIor1Yw3IEdHH5Cl ryam/17akuEMiITPsYoJjQ4ef0Bmo4nvCwc72xmgakLOJ5ePk7WCqudJLC4cNhbAn3K9 QctS6dANy5NlREs9JdDSZEQvULchAK/mMHoXpGVbYag+QZSFdGqjPQtmjsPbPxdH/k+D IsqiZYvQZSsuO1mERelihw17ja97/mMUrq7kiLMlrAE8KD1VXivE5rWJy6AHoxfgqE8T V2rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=B9WUy4QA1L4Xvxvnpx0md3xtZtJUXokmMSg4o2/2YQQ=; b=LxVlLiUqqYkAHt6mrGM//wu/KT/2EdH3p7Tg+4reVUUCHdgzSmVS48yogK/XeE7jFe eZqqbvNzBSJbCnGNUuDHI4KkGfv+0YvwQ9+EbEKiP0KP0OURkHUlEBXVmmj2iwWbrxO0 9VoozfHwYviLp1zIJzxZXOBloIcO3ID4+3S11XE35c86GnHyRMRwmCabR+niqWy2nmlN 44ub1V5mQp5huRpJ1y78+l5THMGupi7SVttcdWyjpiVWMTGMr/RtywgJj39hX3z/rJ9c Qs4XNSJixuY5Ivmh29XkTpabTOrTg+1Y1dXwNy03CQFnZyry5Mg5+3g9W1SG1AKlHkmL DTYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b="JB/zDVIY"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u13si1733452edp.96.2021.02.03.09.54.12; Wed, 03 Feb 2021 09:54:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-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=@fieldses.org header.s=default header.b="JB/zDVIY"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231531AbhBCRxP (ORCPT + 99 others); Wed, 3 Feb 2021 12:53:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230257AbhBCRxO (ORCPT ); Wed, 3 Feb 2021 12:53:14 -0500 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1335DC0613ED for ; Wed, 3 Feb 2021 09:52:34 -0800 (PST) Received: by fieldses.org (Postfix, from userid 2815) id 22C516F04; Wed, 3 Feb 2021 12:52:33 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org 22C516F04 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1612374753; bh=B9WUy4QA1L4Xvxvnpx0md3xtZtJUXokmMSg4o2/2YQQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JB/zDVIYzTqFm4P9GPDb9IqTdUugNm/pJekGM9QTpia8sowH1cYnikcHzXXwVViGf 0kLT2qn6ict/jGjA8JkALkPnzzGd69wMI6NN43kznwSX0xVfDHDq/KRQWXTVYVWmSl WOpqP8ArS7XQR7pHfknjgM+j4FesWWI6O68Tl//M= Date: Wed, 3 Feb 2021 12:52:33 -0500 From: Bruce Fields To: Chuck Lever Cc: Linux NFS Mailing List Subject: Re: [PATCH] nfsd: register pernet ops last, unregister first Message-ID: <20210203175233.GB26588@fieldses.org> References: <20210203164213.GA26588@fieldses.org> <70729484-C3C8-477F-8FE3-06B6A70510C6@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <70729484-C3C8-477F-8FE3-06B6A70510C6@oracle.com> User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Wed, Feb 03, 2021 at 04:45:56PM +0000, Chuck Lever wrote: > Hi Bruce- > > > > On Feb 3, 2021, at 11:42 AM, J. Bruce Fields wrote: > > > > From: "J. Bruce Fields" > > > > 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 > > I can't tell how urgent this is. Does it belong in 5.11-rc? I dunno, I wonder what happens when you try to write to and then free a bunch of objects that were allocated from a slab that no longer exists. But, it's triggered by unloading nfsd, and I find it hard to be super concerned about module unloading bugs (does anyone actually *need* to unload the nfsd module?). --b. > > > > --- > > 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 f6d5d783f4a4..0759e589ab52 100644 > > --- a/fs/nfsd/nfsctl.c > > +++ b/fs/nfsd/nfsctl.c > > @@ -1522,12 +1522,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; > > @@ -1544,9 +1541,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: > > @@ -1559,13 +1561,12 @@ static int __init init_nfsd(void) > > 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); > > @@ -1575,7 +1576,6 @@ static void __exit exit_nfsd(void) > > nfsd4_exit_pnfs(); > > unregister_filesystem(&nfsd_fs_type); > > unregister_cld_notifier(); > > - unregister_pernet_subsys(&nfsd_net_ops); > > } > > > > MODULE_AUTHOR("Olaf Kirch "); > > -- > > 2.29.2 > > > > -- > Chuck Lever > >