Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp373823lqb; Tue, 4 Jun 2024 14:08:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUEVN9aCPkaKXX0xtzYydtBllFHNfuE3I/lwbtcXnofZNNf1+mYbJFF+h9wrnLlb0uEgMm3XE1fSTYOBQG/xWhqJF6WXTPs6laiZbYJqw== X-Google-Smtp-Source: AGHT+IG8ekn08G9SeX1S4n9PJB31Z7FzXAo4RyhYlajZiOCJdMYaEUJlR8Sis/bmb5ut7nZKfXP5 X-Received: by 2002:a05:6e02:13a3:b0:374:b143:96dd with SMTP id e9e14a558f8ab-374b1ee27cemr5404125ab.3.1717535339603; Tue, 04 Jun 2024 14:08:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717535339; cv=pass; d=google.com; s=arc-20160816; b=K1P/TMm9eem8l9iR0KAPbXDzldew/klJLfzE0Dhe3CCIH8Zl97F8+qikLiZC+RAtY6 ReaNfsDP704qvYFyyJDUXcAyxDMBbc9BQ89nc71lDe/nukewJxmmKhtuEl5zVPTrqklt 5Bn6GcXf80c/sR2aF2Bz7rxKBwlqYWWQpumHYwrxt5UPbiqWS4CbZ92Zi54GJIQhB9TQ xhEZjVHQsTV8ELzXRttqLSDihP3i23oXuC43R3V0ddIjvm7tjnFtzb2k0M2xqOcXhIq6 EbFmg8TiSesyegl1b3GiDZ5w/Tv4Mv8afc14TZIgJunl+8CO61bBvhMbu/+nXYb+lREX S4TQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=dxvw9VPxBjV3RdeN33rg85iaqUT5SSr5p8LjoAEx+jM=; fh=vIhzdmiPOEM1c8uzJAq2BSBhXw58o6Y96fK0ufmUCxg=; b=ak/8PVm6LzNZx3CP7cOmaHQyzGGD4z+sB4IbOcMBCXi6mxP4Kzjg3Pg3keLq9RPrZh 4V0+YQ5b62H63TOXwbwVzprO61LWF2dlewS7wX2O9VSGn48ezxhomA8Y+DMyRY/ioCM5 C7RoNeNUHSV9+ccwneJeDJFYxZjFx36ypZxBWVhWb1aRSAIofvM3wB8rleTed3U+Cl7+ +IQu59jo7DoDNlTNp1RqV805diN+uiAaqKN0QR4WCyQvk6CI05COtDXkHB7f6QWp8uM9 KZVefHRS0uXrRD4XljZy4z1BLiNldRCYKAvHoHClqtPh9hZL3fTQKd1TKFa51veFdx+I 3h2A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ObK8qDcr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-201378-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201378-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c3784c804csi1320679a12.349.2024.06.04.14.08.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 14:08:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201378-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ObK8qDcr; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-201378-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201378-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3337D28533F for ; Tue, 4 Jun 2024 21:08:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5580C14D43B; Tue, 4 Jun 2024 21:08:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ObK8qDcr" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AA0514D2A7; Tue, 4 Jun 2024 21:08:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717535295; cv=none; b=JcanZryhfmWmlWLcsKgUDPKmgvAV7SdgT5VvFoS1ktT9lYCCu69aj9xDQ+UfLRN4szydlXrnmg3M8HAxKr8W8xBKM+VQUozv/8wiRegyCkQNmkLgfuo9OJ9ErPvPd3ydLyo/+NB/IreH7dDtWg0EuaEmNrigUqqviOQM3pFQsKE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717535295; c=relaxed/simple; bh=4ejWVCwRkJi2nJTPzl+iwDP9GaQR2cMB6eHw2ik9W8c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lBbpTrJMIkiWZhS9iBTN6XjL77YnF+zjR2PKqQkebsAhV/2A/Gakm9Wp7Wd478/9VtOT2S1T8Vqnmv+HAbI/MvNoF5nAGKutmgA1U2gLWdhN6jv/d7A5Iwiq5t6Hygul8jRtdtdGO3flFAurIWexyTQUdMTHv60oceXn+YN3d6k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ObK8qDcr; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9A87C4AF14; Tue, 4 Jun 2024 21:08:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717535295; bh=4ejWVCwRkJi2nJTPzl+iwDP9GaQR2cMB6eHw2ik9W8c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ObK8qDcrWdyXVn6H3oK6tqOa3iKG3SQ6Iy+merZdT4LVnpna2cb2yphlQItPgaRcl sin+oLuYF0/U9j+yOMZOLzYianzT/a1nzJqVqq9FZqx/hb274ZZEoj5RFxvfWEprYC 5/JMpCA6JaOTLcSYxnOt3SzmQJA4Vn9TXwIyNxAsuDvXQOPGYNdcGEV9JXAL2Zm+9D 4lWJBDbz2jRsR9xU5HxL7VTKEvCg2/pRWBlSvbiOXu1W3JeXGQwZVFIBK2fO+kjpiJ 2niETsenodZKSUZXEp0rW5XTVgpQZYdwM95rmQSJJFWr2gymRCChq4TyCWQW8+3lhQ vIHJfmWDyr42A== From: Jeff Layton Date: Tue, 04 Jun 2024 17:07:55 -0400 Subject: [PATCH 2/3] nfsd: make nfsd_svc call nfsd_set_nrthreads Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240604-nfsd-next-v1-2-8df686ae61de@kernel.org> References: <20240604-nfsd-next-v1-0-8df686ae61de@kernel.org> In-Reply-To: <20240604-nfsd-next-v1-0-8df686ae61de@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Trond Myklebust , Anna Schumaker , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3981; i=jlayton@kernel.org; h=from:subject:message-id; bh=4ejWVCwRkJi2nJTPzl+iwDP9GaQR2cMB6eHw2ik9W8c=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmX4I6DuBsDDSECRq+rIbwsbYBIBMU8RWrtUpva Hwu9Eb17f2JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZl+COgAKCRAADmhBGVaC FeBKD/4nxsChtoKGX3jR2KqlJXXG9o6Vc5J7ISr9kzag2cZTifpZ7EVZi3MJmNhi0SjoIwgpEVu 79KmyYrFKOo/KPrt6XZtdHrKDrUy9nasrqSQnkMv8VZU3fxhQJZ8RzFoBL69t3ppfYIjYZpDM24 8qCLfIWV04JoT1fMioz7Tad3VMDND8kfkSvC+ilUtQ9/FJjWaCi0nzMv6bBFcsI2Tx0P8hV5u7Q shn+dO2wcYjMkllV/tWSN5j99Wl5B6u6dOCkc7KEILT67CCxvI4EKMf/H+0w1XHSv7WVuj2tWEY 4SXLB02YgocTR8xTgdlt87ooM16TiHJjG3HgT6DM4Vpv6zBgzSvYqXi9hTD0qSGX+ni7Bcp3nfC a9nh+37v2bkMB2bPUS+usBNsXLbnmwr5ny/oq/zYFd70xIqh8IfxbGvRulJZCjEwqtirMmePS+8 Gfj8yu5rmZCaIfNqk7qvYtsEuTgLA9kdeCCypIAbNo4AlZnbwn2E99yLXouZ5h3LctDMt7pflna QTeyJbx/MmIg6xqDKArXPq7r/+pCb8h/MhXGxR6nb6Y2XxUzPrx5GMsFMFTO3gmGQwIGsSLD4hw z6M4i5SPJ3kg8mFtNQjRhPD5GXiiuq3F5gWhxiLkBP3zU+8VbNa+VRYngzD+cXUozvZm0pPIur6 eJXkhino9kXjMhw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Now that the refcounting is fixed, rework nfsd_svc to use the same thread setup as the pool_threads interface. Since the new netlink interface doesn't have the same restriction as pool_threads, move the guard against shutting down all threads to write_pool_threads. Signed-off-by: Jeff Layton --- fs/nfsd/nfsctl.c | 14 ++++++++++++-- fs/nfsd/nfsd.h | 3 ++- fs/nfsd/nfssvc.c | 18 ++---------------- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 202140df8f82..121b866125d4 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -406,7 +406,7 @@ static ssize_t write_threads(struct file *file, char *buf, size_t size) return -EINVAL; trace_nfsd_ctl_threads(net, newthreads); mutex_lock(&nfsd_mutex); - rv = nfsd_svc(newthreads, net, file->f_cred, NULL); + rv = nfsd_svc(1, &newthreads, net, file->f_cred, NULL); mutex_unlock(&nfsd_mutex); if (rv < 0) return rv; @@ -481,6 +481,16 @@ static ssize_t write_pool_threads(struct file *file, char *buf, size_t size) goto out_free; trace_nfsd_ctl_pool_threads(net, i, nthreads[i]); } + + /* + * There must always be a thread in pool 0; the admin + * can't shut down NFS completely using pool_threads. + * + * FIXME: do we really need this? + */ + if (nthreads[0] == 0) + nthreads[0] = 1; + rv = nfsd_set_nrthreads(i, nthreads, net); if (rv) goto out_free; @@ -1722,7 +1732,7 @@ int nfsd_nl_threads_set_doit(struct sk_buff *skb, struct genl_info *info) scope = nla_data(attr); } - ret = nfsd_svc(nthreads, net, get_current_cred(), scope); + ret = nfsd_svc(1, &nthreads, net, get_current_cred(), scope); out_unlock: mutex_unlock(&nfsd_mutex); diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h index 8f4f239d9f8a..cec8697b1cd6 100644 --- a/fs/nfsd/nfsd.h +++ b/fs/nfsd/nfsd.h @@ -103,7 +103,8 @@ bool nfssvc_encode_voidres(struct svc_rqst *rqstp, /* * Function prototypes. */ -int nfsd_svc(int nrservs, struct net *net, const struct cred *cred, const char *scope); +int nfsd_svc(int n, int *nservers, struct net *net, + const struct cred *cred, const char *scope); int nfsd_dispatch(struct svc_rqst *rqstp); int nfsd_nrthreads(struct net *); diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index cd9a6a1a9fc8..076f35dc17e4 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -744,13 +744,6 @@ int nfsd_set_nrthreads(int n, int *nthreads, struct net *net) } } - /* - * There must always be a thread in pool 0; the admin - * can't shut down NFS completely using pool_threads. - */ - if (nthreads[0] == 0) - nthreads[0] = 1; - /* apply the new numbers */ for (i = 0; i < n; i++) { err = svc_set_num_threads(nn->nfsd_serv, @@ -768,7 +761,7 @@ int nfsd_set_nrthreads(int n, int *nthreads, struct net *net) * this is the first time nrservs is nonzero. */ int -nfsd_svc(int nrservs, struct net *net, const struct cred *cred, const char *scope) +nfsd_svc(int n, int *nthreads, struct net *net, const struct cred *cred, const char *scope) { int error; struct nfsd_net *nn = net_generic(net, nfsd_net_id); @@ -778,13 +771,6 @@ nfsd_svc(int nrservs, struct net *net, const struct cred *cred, const char *scop dprintk("nfsd: creating service\n"); - nrservs = max(nrservs, 0); - nrservs = min(nrservs, NFSD_MAXSERVS); - error = 0; - - if (nrservs == 0 && nn->nfsd_serv == NULL) - goto out; - strscpy(nn->nfsd_name, scope ? scope : utsname()->nodename, sizeof(nn->nfsd_name)); @@ -796,7 +782,7 @@ nfsd_svc(int nrservs, struct net *net, const struct cred *cred, const char *scop error = nfsd_startup_net(net, cred); if (error) goto out_put; - error = svc_set_num_threads(serv, NULL, nrservs); + error = nfsd_set_nrthreads(n, nthreads, net); if (error) goto out_put; error = serv->sv_nrthreads; -- 2.45.1