From patchwork Thu Jul 30 13:52:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 6902841 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CEC9BC05AD for ; Thu, 30 Jul 2015 13:52:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DF74720592 for ; Thu, 30 Jul 2015 13:52:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D0021205BC for ; Thu, 30 Jul 2015 13:52:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753364AbbG3Nwi (ORCPT ); Thu, 30 Jul 2015 09:52:38 -0400 Received: from mail-yk0-f173.google.com ([209.85.160.173]:36655 "EHLO mail-yk0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753345AbbG3Nwf (ORCPT ); Thu, 30 Jul 2015 09:52:35 -0400 Received: by ykay190 with SMTP id y190so34254934yka.3 for ; Thu, 30 Jul 2015 06:52:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=F3kqra/f+ZCycPY4aKqiRJOZFLHyb13b61DR3Y8Klrs=; b=KRib6Mr9cruG5qKYLItnVI05MDl/wXmETNo/GLgXir9ea4FIskBUyYzWxWBjxLha+r TxWScSIOUjW0bDLsb+k+J0OvXKds7Vuv7a52lm6IroM9BCXwP3wKNH/o+8kW+3g1cbmN 0T3vEX22o7iBOFJsCmDI1WLL9SkIoApn6z/J+jLt4Jcez1VxoPQEKCMmHe065esECoSN 8thphc7GFqkKCbd4GQVUOqX9KV1oCYj/X0TXj/XgAtv48aUaNV0OhQ69TUypPJYeDP6Q vkuXifk2rfe6/iKVB6vziBohQJGLOqQAKOyfGl2dnba6TWcJxQkYvxEpiRCSYBU7Bmr2 I0DQ== X-Gm-Message-State: ALoCoQnIuF5dUEVDGwpCSgVInZ6caNs781fyYkl08N0/DyP1v5vf0A+zaWSPlMXQwHGP1r/igLvr X-Received: by 10.170.147.212 with SMTP id o203mr42334360ykc.43.1438264354846; Thu, 30 Jul 2015 06:52:34 -0700 (PDT) Received: from tlielax.poochiereds.net ([2606:a000:1105:8e:3a60:77ff:fe93:a95d]) by smtp.googlemail.com with ESMTPSA id c184sm796301ywb.22.2015.07.30.06.52.33 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Jul 2015 06:52:34 -0700 (PDT) From: Jeff Layton X-Google-Original-From: Jeff Layton To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org Subject: [PATCH 3/9] nfsd: convert laundry_wq to something less nfsd4 specific Date: Thu, 30 Jul 2015 09:52:15 -0400 Message-Id: <1438264341-18048-5-git-send-email-jeff.layton@primarydata.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1438264341-18048-1-git-send-email-jeff.layton@primarydata.com> References: <1438264341-18048-1-git-send-email-jeff.layton@primarydata.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, nfsd uses a singlethread workqueue for this, but that's probably not necessary. If we have multiple namespaces, then there's no need to serialize the laundromat runs. They can run in parallel. Also, create_singlethread_workqueue adds the WQ_MEM_RECLAIM flag, which doesn't really seem to be necessary. The laundromat jobs are always kicked off via a timer, and not from memory reclaim paths. There's no need for a rescuer thread. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4state.c | 23 +++++------------------ fs/nfsd/nfsd.h | 1 + fs/nfsd/nfssvc.c | 14 +++++++++++++- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 79795c898dd1..977a8aee9122 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -4376,7 +4376,6 @@ nfs4_laundromat(struct nfsd_net *nn) return new_timeo; } -static struct workqueue_struct *laundry_wq; static void laundromat_main(struct work_struct *); static void @@ -4390,7 +4389,7 @@ laundromat_main(struct work_struct *laundry) t = nfs4_laundromat(nn); dprintk("NFSD: laundromat_main - sleeping for %ld seconds\n", t); - queue_delayed_work(laundry_wq, &nn->laundromat_work, t*HZ); + queue_delayed_work(nfsd_laundry_wq, &nn->laundromat_work, t*HZ); } static inline __be32 nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stid *stp) @@ -6587,7 +6586,8 @@ nfs4_state_start_net(struct net *net) nfsd4_client_tracking_init(net); printk(KERN_INFO "NFSD: starting %ld-second grace period (net %p)\n", nn->nfsd4_grace, net); - queue_delayed_work(laundry_wq, &nn->laundromat_work, nn->nfsd4_grace * HZ); + queue_delayed_work(nfsd_laundry_wq, &nn->laundromat_work, + nn->nfsd4_grace * HZ); return 0; } @@ -6601,22 +6601,10 @@ nfs4_state_start(void) ret = set_callback_cred(); if (ret) return -ENOMEM; - laundry_wq = create_singlethread_workqueue("nfsd4"); - if (laundry_wq == NULL) { - ret = -ENOMEM; - goto out_recovery; - } ret = nfsd4_create_callback_queue(); - if (ret) - goto out_free_laundry; - - set_max_delegations(); - - return 0; + if (!ret) + set_max_delegations(); -out_free_laundry: - destroy_workqueue(laundry_wq); -out_recovery: return ret; } @@ -6653,7 +6641,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/nfsd.h b/fs/nfsd/nfsd.h index cf980523898b..0199415344ff 100644 --- a/fs/nfsd/nfsd.h +++ b/fs/nfsd/nfsd.h @@ -62,6 +62,7 @@ struct readdir_cd { extern struct svc_program nfsd_program; extern struct svc_version nfsd_version2, nfsd_version3, nfsd_version4; +extern struct workqueue_struct *nfsd_laundry_wq; extern struct mutex nfsd_mutex; extern spinlock_t nfsd_drc_lock; extern unsigned long nfsd_drc_max_mem; diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index ad4e2377dd63..ced9944201a0 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include "nfsd.h" #include "cache.h" @@ -28,6 +29,9 @@ extern struct svc_program nfsd_program; static int nfsd(void *vrqstp); +/* A workqueue for nfsd-related cleanup tasks */ +struct workqueue_struct *nfsd_laundry_wq; + /* * nfsd_mutex protects nn->nfsd_serv -- both the pointer itself and the members * of the svc_serv struct. In particular, ->sv_nrthreads but also to some @@ -224,11 +228,19 @@ static int nfsd_startup_generic(int nrservs) if (ret) goto dec_users; + ret = -ENOMEM; + nfsd_laundry_wq = alloc_workqueue("%s", WQ_UNBOUND, 0, "nfsd-laundry"); + if (!nfsd_laundry_wq) + goto out_racache; + ret = nfs4_state_start(); if (ret) - goto out_racache; + goto out_wq; return 0; +out_wq: + destroy_workqueue(nfsd_laundry_wq); + nfsd_laundry_wq = NULL; out_racache: nfsd_racache_shutdown(); dec_users: