Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3384162ioa; Tue, 26 Apr 2022 02:30:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwIKOqlhETnoGR3PqKmmdUun85sqL4jA5Xz2v+fWAidzWq5eajXJvYfNEia2pjr6l8F/ri X-Received: by 2002:a65:6bd6:0:b0:39d:4f85:9ecf with SMTP id e22-20020a656bd6000000b0039d4f859ecfmr19147369pgw.336.1650965425366; Tue, 26 Apr 2022 02:30:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650965425; cv=none; d=google.com; s=arc-20160816; b=KE0QURUGIm6k/j1a5wPf9QDebQelngMreKs2EHO6s3eEnqVr3prvZRWIBAUd9478cd HQBxtjwP1yCv191QMH/4aY6WflxcBdMpbt/Chum+mGkpRsre7XzV+/qIj5Ah/XWZrRZO HThVtrNq+w5rmA3r8fvfZe+m7a7T2fbVF1cJQ2QTUwnB4eBVBvzdMY26eHpXZk5M4gND fj+1BoR8b1Ni2WuQAxgdQ6zEfE8ObxCGO8AXPDaG6YyVIY7/fjhyDJhlomvWqpqFeTT8 clpONgcoot0ejHMerhDbUdscfb/dsHYsM5a9K8kBypsw78/1lNksNHsErzvClWI+s3LX AE1g== 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=RMqHgOKqXXbxUoCSNWhPfJAimj7IFB101BD794lejj0=; b=nMc0aPg91RgLd9pj1gh9/wOiJOt7y9h6OLICSuZeXsXUWlbIM+0qxWWWegj86pM35t 0wjRtLlm7k1DHCaAVN0csf0qF9SKpVZ1oTi0RbvWAry6882hpVVD0n4U0rTXI6sVpFTw fw3hlC67EsL1Cr47NMuVWtkQtPb9u0kH5xKzocqWoBbA4x3lmYJFIvreKjQdXrZyLXLC AK94XHakadjqX0uhGwh1BpLHeSnB8rcjYZe5x7WKMxb+zONFlwhF6vmAwn0df5NBe8a3 JRcethBCDUtpHveKGjFTa4+0dLnlStb1kkR3TNH8Tjb7iCkbIxYcmglh4bkZwk4wuTDv QDKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=GcIDZNBp; 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 c7-20020a631c07000000b0039859d7cf84si18162888pgc.256.2022.04.26.02.30.01; Tue, 26 Apr 2022 02:30:25 -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; dkim=pass header.i=@fieldses.org header.s=default header.b=GcIDZNBp; 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 S237034AbiDYTiw (ORCPT + 99 others); Mon, 25 Apr 2022 15:38:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244968AbiDYTiv (ORCPT ); Mon, 25 Apr 2022 15:38:51 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 176D211115A; Mon, 25 Apr 2022 12:35:46 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id 90A8014DB; Mon, 25 Apr 2022 15:35:45 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org 90A8014DB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1650915345; bh=RMqHgOKqXXbxUoCSNWhPfJAimj7IFB101BD794lejj0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GcIDZNBprxrZ3zkBj2HiXt23Ne0HH2haVnBRRUJrmbz730MEfO3QqHPz0ZJM3Zo4H UunADjkK9fh0qd8b+y+pWxLnB5TJRncYlAiZGe6dmzyfr2+sAWZ7Djgsa3qrI1rWGU lVSLw94lR6euALxpLFMBG5zJqQemAAw614GFS7GA= Date: Mon, 25 Apr 2022 15:35:45 -0400 From: "J. Bruce Fields" To: dai.ngo@oracle.com Cc: chuck.lever@oracle.com, jlayton@redhat.com, viro@zeniv.linux.org.uk, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH RFC v21 3/7] NFSD: move create/destroy of laundry_wq to init_nfsd and exit_nfsd Message-ID: <20220425193545.GG24825@fieldses.org> References: <1650739455-26096-1-git-send-email-dai.ngo@oracle.com> <1650739455-26096-4-git-send-email-dai.ngo@oracle.com> <8640dbe0-cece-4515-fa4f-efa2e0a14303@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8640dbe0-cece-4515-fa4f-efa2e0a14303@oracle.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,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 On Mon, Apr 25, 2022 at 08:27:22AM -0700, dai.ngo@oracle.com wrote: > This patch has problem to build with this error: > > >>nfsctl.c:(.exit.text+0x0): undefined reference to `laundry_wq' > >>mipsel-linux-ld: nfsctl.c:(.exit.text+0x4): undefined reference to `laundry_wq' > > This happens when CONFIG_NFSD is defined but CONFIG_NFSD_V4 > is not. I think to fix this we need to also move the declaration > of laundry_wq from nfs4state.c to nfsctl.c. However this seems > odd since the laundry_wq is only used for v4, unless you have > any other suggestion. I'd just leave laundry_wq private to nfs4state.c. Define create_laundromat() and destroy_laundromat() in nfs4state.c too. And in nfsd.h, do the usual trick of defining no-op versions of those functions in the non-v4 case. (See e.g. what we do with nfsd4_init/free_slabs().) --b. > > -Dai > > On 4/23/22 11:44 AM, Dai Ngo wrote: > >This patch moves create/destroy of laundry_wq from nfs4_state_start > >and nfs4_state_shutdown_net to init_nfsd and exit_nfsd to prevent > >the laundromat from being freed while a thread is processing a > >conflicting lock. > > > >Signed-off-by: Dai Ngo > >--- > > fs/nfsd/nfs4state.c | 15 ++------------- > > fs/nfsd/nfsctl.c | 6 ++++++ > > fs/nfsd/nfsd.h | 1 + > > 3 files changed, 9 insertions(+), 13 deletions(-) > > > >diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c > >index b08c132648b9..b70ba2eb5665 100644 > >--- a/fs/nfsd/nfs4state.c > >+++ b/fs/nfsd/nfs4state.c > >@@ -125,7 +125,7 @@ static void free_session(struct nfsd4_session *); > > static const struct nfsd4_callback_ops nfsd4_cb_recall_ops; > > static const struct nfsd4_callback_ops nfsd4_cb_notify_lock_ops; > >-static struct workqueue_struct *laundry_wq; > >+struct workqueue_struct *laundry_wq; > > static bool is_session_dead(struct nfsd4_session *ses) > > { > >@@ -7798,22 +7798,12 @@ nfs4_state_start(void) > > { > > int ret; > >- laundry_wq = alloc_workqueue("%s", WQ_UNBOUND, 0, "nfsd4"); > >- if (laundry_wq == NULL) { > >- ret = -ENOMEM; > >- goto out; > >- } > > ret = nfsd4_create_callback_queue(); > > if (ret) > >- goto out_free_laundry; > >+ return ret; > > set_max_delegations(); > > return 0; > >- > >-out_free_laundry: > >- destroy_workqueue(laundry_wq); > >-out: > >- return ret; > > } > > void > >@@ -7850,7 +7840,6 @@ nfs4_state_shutdown_net(struct net *net) > > void > > nfs4_state_shutdown(void) > > { > >- destroy_workqueue(laundry_wq); > > nfsd4_destroy_callback_queue(); > > } > >diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c > >index 16920e4512bd..884e873b46ad 100644 > >--- a/fs/nfsd/nfsctl.c > >+++ b/fs/nfsd/nfsctl.c > >@@ -1544,6 +1544,11 @@ static int __init init_nfsd(void) > > retval = register_cld_notifier(); > > if (retval) > > goto out_free_all; > >+ laundry_wq = alloc_workqueue("%s", WQ_UNBOUND, 0, "nfsd4"); > >+ if (laundry_wq == NULL) { > >+ retval = -ENOMEM; > >+ goto out_free_all; > >+ } > > return 0; > > out_free_all: > > unregister_pernet_subsys(&nfsd_net_ops); > >@@ -1566,6 +1571,7 @@ static int __init init_nfsd(void) > > static void __exit exit_nfsd(void) > > { > >+ destroy_workqueue(laundry_wq); > > unregister_cld_notifier(); > > unregister_pernet_subsys(&nfsd_net_ops); > > nfsd_drc_slab_free(); > >diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h > >index 23996c6ca75e..d41dcf1c4312 100644 > >--- a/fs/nfsd/nfsd.h > >+++ b/fs/nfsd/nfsd.h > >@@ -72,6 +72,7 @@ extern unsigned long nfsd_drc_max_mem; > > extern unsigned long nfsd_drc_mem_used; > > extern const struct seq_operations nfs_exports_op; > >+extern struct workqueue_struct *laundry_wq; > > /* > > * Common void argument and result helpers