Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp102738lqs; Thu, 13 Jun 2024 05:20:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXJvE5pK079dH/noOmCuOBHyM8q87ka4clEpwBhE4RI0WsxckkaBwmPgKlQTMC0oX4y1oVP7LK3jwkPF3SRCakdJPlA4aqONg/kLw/1nA== X-Google-Smtp-Source: AGHT+IG+3bowxwE9fhO8j2hWHUrDAlEoFAWZ+p9C5WYWtmpc5RVTTC4VHq5hfQU2wGXi6aOutgQ4 X-Received: by 2002:a05:6512:3045:b0:52c:8909:bd35 with SMTP id 2adb3069b0e04-52c9a3bfb2amr4853884e87.10.1718281213075; Thu, 13 Jun 2024 05:20:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718281213; cv=pass; d=google.com; s=arc-20160816; b=iEPIrbs92VawoSHafLAuMhcsUfE9UInlPT0eoj6QXB3EaCZ/GigfNEZjS/U8IFCuft euHmjC6FHZ/+OphS1oO2d4XgtulQokDtv/hSaAmo4iX/XP89emGEMq/+ZRdP1+1l+gaU IbCA60i1WlJ2x/XrBO1gUDZgyYNe1eGSCxnHpNKcBEBx0/fdB38oFhzvu0pNtBm3E7ky DQoTqdF+/pC+OJH46YQIBsFR9sMVSh/ak+mMuQ20yMQfv5617MEDIbbkj7zLGLbwEIw3 nE7P8+frhylxh0thR+B+hh9nV8M6AoCmbTY3sJFXztDVJFbnlWOaGBB55UClD93ogRAW ZQaQ== 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=qE0g+9zY+de/OZkJbddFLhiD7JPRNIcoWNHI7ckDkqo=; fh=1/3lXFVz69UqpVG6hQDZ/Hd9qKfdx/7X5bNqh2kvdjo=; b=W9nbe2o6T43UxY2Opcx5sQDMh5O76Xwuc91pXNXXe7FtNCsLxLE6W8TF5Zd2/zsH3g T0AOyMh1u6u25RNzGWTPmP2s/ET/is7wY7nKs7pi6oanpSudzOimRTyc+kGsXZGOX7mv BA6uZZkiEGupHpUVXcGEDHU4ue+VbxzTy+mg5EiCdqWIgvgrpbKLDnPSeKBlkcajZcqR wFV0jNuYxfeJi7TRs5lVbNak1Q+t0OaM+vTyrcAeagX+V0IZuLcGKDdBKgtMxkZMcVJZ FRD0MRlLcBtPMMagE0U36jg31/T4SnwFJCdP4+2d8rwetSzeXatXHYcleQw0t55aPt1M 6Yzg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mDEFkK5X; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-3756-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3756-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a6f56d4c281si65548666b.258.2024.06.13.05.20.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Jun 2024 05:20:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-3756-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mDEFkK5X; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-3756-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3756-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 am.mirrors.kernel.org (Postfix) with ESMTPS id C1CED1F21E7E for ; Thu, 13 Jun 2024 12:20:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 298E41474A6; Thu, 13 Jun 2024 12:17:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mDEFkK5X" X-Original-To: linux-nfs@vger.kernel.org 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 0193F146D7E; Thu, 13 Jun 2024 12:17:00 +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=1718281021; cv=none; b=W34s5ws0RcpNQinnsC+ghHLOdeBuj1Jq3JphjLbYRXYjHoRVQeOmhn88/DrNX/eXbtFc8uRDF12jSxiiuAJ1/38Ptl0NS6l53ONhfencs0+tYgjwoJvYARFyUWdsRRpjQkywpSJ8TP1XZ9Wd03zB6Viv+edXm2j6ezKwthsDxqc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718281021; c=relaxed/simple; bh=F4yQVNCqHoax6TyvivF3/cRELpDg4rafpz6ZL4viPj8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ioEIQbzpn/Odq8NiRBacgjrY8CYaVHanRu0mIydM3ubqfr1xzpV4rfe5+dNhGoHhhWBLqw/zBnVAwnz3+L5jP2iKYNpyzFvcGgrflXltgw66k2C85GRcpFpGmtNCi6TWgBAD0osjoqlwoh3JdOnB8swHv/qK3Yl9soLQ4oU6g/o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mDEFkK5X; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D96FC4AF1D; Thu, 13 Jun 2024 12:16:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718281020; bh=F4yQVNCqHoax6TyvivF3/cRELpDg4rafpz6ZL4viPj8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=mDEFkK5X8REFmA+XJdwQPtixQ6krj6SLc/CT1z8Bv/jq5W1pbFEpnlPfrssSLnOAv 7sNYIeVLfLUEtiO2E5qJzUAHwaPbm2iBF3AV/P/WZagfAHRnlF4byH220rs0ALPJdO +ZHnF366sGdNfDzys7DtydIL8VjiyNZH8zsykDiZW6eJS+5emzKfa92lQrBTjTxS1q BVV+fqxRRHOzEZHsSSLbU0VIy5alDwq9PvrfWF4c/7SdqGuvFtM49GI7lflu5+sOFr wEIo0NtDorR7KQJh27gqdBpNiKxzCmzD8UC3l3mYLqDycvXroxyoslkesR7PedVcTN GcipNaY8JhScQ== From: Jeff Layton Date: Thu, 13 Jun 2024 08:16:40 -0400 Subject: [PATCH v2 3/5] nfsd: allow passing in array of thread counts via netlink Precedence: bulk X-Mailing-List: linux-nfs@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: <20240613-nfsd-next-v2-3-20bf690d65fb@kernel.org> References: <20240613-nfsd-next-v2-0-20bf690d65fb@kernel.org> In-Reply-To: <20240613-nfsd-next-v2-0-20bf690d65fb@kernel.org> To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lorenzo Bianconi 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=3124; i=jlayton@kernel.org; h=from:subject:message-id; bh=F4yQVNCqHoax6TyvivF3/cRELpDg4rafpz6ZL4viPj8=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmauM24ySExYsjOMXyCf5+X98995OYvDizbtzEW 91A3ITsUcWJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZmrjNgAKCRAADmhBGVaC FXYFEACRr3tqAwGMcvRz4Iv2j/7wk/K35X6lQFM+XHzOqegPXgY/Q1E7XWAz+uf2n2xDOVz2DgW PU2cI5fqZtvvROlnSla7Y6F7xkZgZtqpjV7hayRFWtelSRL7IcvLmF/AJNC/75JujuOMuc2nEYM N9yVx5S4cJbJMgbcJQJ9kDwSpv1a152x9eSW4yC4uIaP5gYG6yVU1TugGlFV6DmRbI+ry9wExFj wTIjV5q4CFZ0XZOeKEyvwSfgnCNn6uOkBWcbXafEckAeoAHzgOBbLqC9x9l+BTQ68ZfXlIeiy5Q cH0cbvhXaNWBNEVYUnHJ23EhubUvGdvyGIPrZauxikwjmdCrDodNR9lulO2qnT1Tk6a6aWBNugS HEbL9OszHs7eleJRhyG8KsjaW//n6jpiBPhz9iuMAmvpbWUoYvtYHAy/jkiO1R2Or5Lbq+cmuT/ HJZ4cJd/EHzrSSjlw6dkTrOq7r7QK5Xhxf9tiADU188HEdGX8cESM2ikPIyLVG+DF/PWq+bcXoT +YNvgahF2flKHzCpK5O1d60CqvZ8I3lmbT8x/zW0NsP+vDMJjxwme418b/j+czc2Q0KFVzF9RJN 7ov946+/Eap3QsZTX1E9f6cOtJ5ZnsO9d3ZmTGCFTYLy/3asGbDEm9wILiU+6lCf7EjFtrniWJj TTAKHyxRtK9gi0A== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Now that nfsd_svc can handle an array of thread counts, fix up the netlink threads interface to construct one from the netlink call and pass it through so we can start a pooled server the same way we would start a normal one. Note that any unspecified values in the array are considered zeroes, so it's possible to shut down a pooled server by passing in a short array that has only zeros, or even an empty array. Signed-off-by: Jeff Layton --- fs/nfsd/nfsctl.c | 32 ++++++++++++++++++++------------ fs/nfsd/nfssvc.c | 12 +++++++++++- 2 files changed, 31 insertions(+), 13 deletions(-) diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 121b866125d4..d67057d5b858 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -1673,7 +1673,7 @@ int nfsd_nl_rpc_status_get_done(struct netlink_callback *cb) */ int nfsd_nl_threads_set_doit(struct sk_buff *skb, struct genl_info *info) { - int nthreads = 0, count = 0, nrpools, ret = -EOPNOTSUPP, rem; + int *nthreads, count = 0, nrpools, i, ret = -EOPNOTSUPP, rem; struct net *net = genl_info_net(info); struct nfsd_net *nn = net_generic(net, nfsd_net_id); const struct nlattr *attr; @@ -1690,15 +1690,22 @@ int nfsd_nl_threads_set_doit(struct sk_buff *skb, struct genl_info *info) mutex_lock(&nfsd_mutex); - nrpools = nfsd_nrpools(net); - if (nrpools && count > nrpools) - count = nrpools; - - /* XXX: make this handle non-global pool-modes */ - if (count > 1) + nrpools = max(count, nfsd_nrpools(net)); + nthreads = kcalloc(nrpools, sizeof(int), GFP_KERNEL); + if (!nthreads) { + ret = -ENOMEM; goto out_unlock; + } + + i = 0; + nlmsg_for_each_attr(attr, info->nlhdr, GENL_HDRLEN, rem) { + if (nla_type(attr) == NFSD_A_SERVER_THREADS) { + nthreads[i++] = nla_get_u32(attr); + if (i >= nrpools) + break; + } + } - nthreads = nla_get_u32(info->attrs[NFSD_A_SERVER_THREADS]); if (info->attrs[NFSD_A_SERVER_GRACETIME] || info->attrs[NFSD_A_SERVER_LEASETIME] || info->attrs[NFSD_A_SERVER_SCOPE]) { @@ -1732,12 +1739,13 @@ int nfsd_nl_threads_set_doit(struct sk_buff *skb, struct genl_info *info) scope = nla_data(attr); } - ret = nfsd_svc(1, &nthreads, net, get_current_cred(), scope); - + ret = nfsd_svc(nrpools, nthreads, net, get_current_cred(), scope); + if (ret > 0) + ret = 0; out_unlock: mutex_unlock(&nfsd_mutex); - - return ret == nthreads ? 0 : ret; + kfree(nthreads); + return ret; } /** diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 076f35dc17e4..6754cbc27c71 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -750,8 +750,18 @@ int nfsd_set_nrthreads(int n, int *nthreads, struct net *net) &nn->nfsd_serv->sv_pools[i], nthreads[i]); if (err) - break; + goto out; } + + /* Anything undefined in array is considered to be 0 */ + for (i = n; i < nn->nfsd_serv->sv_nrpools; ++i) { + err = svc_set_num_threads(nn->nfsd_serv, + &nn->nfsd_serv->sv_pools[i], + 0); + if (err) + goto out; + } +out: return err; } -- 2.45.2