Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2892757rdh; Mon, 30 Oct 2023 10:33:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG0IABwS6IazJTK7Ky/E3GXFz7A7s5gSnBje/gKNlwnFbL7VkYNZgosja7yIWWqpJ9J+4lI X-Received: by 2002:a05:6359:6513:b0:168:e707:2e56 with SMTP id sk19-20020a056359651300b00168e7072e56mr4629173rwb.16.1698687196850; Mon, 30 Oct 2023 10:33:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698687196; cv=none; d=google.com; s=arc-20160816; b=oeottnWSf2PkCvrVuH4lj+D7Q3RZfpEOMz2KoIQIzpGDhvrv6jwmcST1m11cMnmlXC ipIcifpidVeDE2PSSu35QbCD7mlfLIGjhUk8eeGqAnN01k79ms4H/umV/ANGldJyW7ln 1p0E4OiDbLIBSFKpeciBu2eHgL5WvGHzxmqr7qoxRsRn9Ls2JBktcWyjWbNDsK4nwM4m o6wSxU47kyM58ltBNYeRTBAU4BbMaQlbHDD6/fM9EfXAaJchzcYkn7ldU2af/ff5xY/j pICcen/F0tOuQr0AlnjznVuVECaR2l9sV/4Rv1vqTaw3r0olHcsh7l0llC3QvNNzWDPT F6/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=E3wJH+u5kvtbCQX6vU11aWd//XQ9X9m5UYfcHKGPFg8=; fh=T3gz0vu3ywFYxuk7LYqiZMiXgU5oTUKthLhZ4Clpnys=; b=mqL/cRmz0BMORQyiYsOMnd1oDobO8/SUhpPuRMj/HTCHzN62KFU08R7+4JgZ/CR7tR SeFC99zjJhXmMb6AT6tjIP1tm9i8G86U6M8a/AmszzEz7urj6PaxVTUnNEoMGj02uEhR jE4A77VtmGXOLOpvapaW8fNfpJ6NyfWs5uXdugL7E1ZtPr5Nlegj0eVMEiXV9AGyKqdN 434+T2jW+eCaLOOKSAmK5PsKpWyKyiev0n/yKqubV+yuGYFz9T91qvv4DIV2VXUuttb4 RMqXaN3FAzfI0gIWKmX26qYjiY41fftluatj0jBz/x3sIlc6i85uQWHkKWg8eYXBidRP DbOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="k8D7hDd/"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id bw39-20020a056a0204a700b00573fc592e9dsi3668466pgb.848.2023.10.30.10.33.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 10:33:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="k8D7hDd/"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 0DE448047544; Mon, 30 Oct 2023 10:33:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233916AbjJ3RdG (ORCPT + 99 others); Mon, 30 Oct 2023 13:33:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233912AbjJ3RdF (ORCPT ); Mon, 30 Oct 2023 13:33:05 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D290AC4; Mon, 30 Oct 2023 10:33:01 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C874C433C8; Mon, 30 Oct 2023 17:33:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698687181; bh=NmBMUZ0aub9K48dR63VKdL58hnY2i/0sav/2YAAE35U=; h=From:Date:Subject:To:Cc:From; b=k8D7hDd/jRRDxRUikY75NK4PT5NJhZ/JiMopIn/+4CIsU1/N56OAa8sJnbV8ozULt l4IUAHFIiYMiCFgedv+jMf7KNxpdMyuoXrbbjlvYcNw8PtPACykq89SBaE116KHjP+ ZJeBR2nXRHXLw3Y8tSR0N9yGINbTCSWeo6zoIM5IFNHu8luS0308YpF3Gtk4bGNF5P ZZYdIM0vlTuVH9XqDSg0lpZC6kDeih5Z108J1xlE/sJn+iKz4+J0WJSGTcGQcDprN8 DfQw9Bhe3VhdFK1BRbIRWO7rac35BLD8sO0HFkduXt/BnyB/fz0thsGs5TqiS0THlM Dz/Gy0fSLEtnw== From: Jeff Layton Date: Mon, 30 Oct 2023 13:32:54 -0400 Subject: [PATCH RFC] nfsd: fix error handling in nfsd_svc MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231030-kdevops-v1-1-bae6baf62c69@kernel.org> X-B4-Tracking: v=1; b=H4sIAMXoP2UC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDI2NDA2MD3eyU1LL8gmJd0zRzYzMzC0vz1DQTJaDqgqLUtMwKsEnRSkFuzkq xtbUAjF+kFl4AAAA= To: Chuck Lever , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, Zhi Li , Jeff Layton X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2391; i=jlayton@kernel.org; h=from:subject:message-id; bh=NmBMUZ0aub9K48dR63VKdL58hnY2i/0sav/2YAAE35U=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBlP+jMieljdWA7oHspQdewsswpVd+f8UwiG+n1y ZIOVFya9s+JAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZT/ozAAKCRAADmhBGVaC FdeTD/0cUpezDGAcWntDUPpmiPKDSMP0JDjOOjg1nZH/FLgYmNnXxGcmyPoLkd1bljXM1mIhCMo mUP/N41fq6xkawH6x4GI4FBxDcdESCgPXmbM8x8KecHWHzAzN/ILD5KJrD6OwUjRTd1ekE8F20p 3slYBEjrDLH2BBeNQP2V8JxU31wyOC2y83SiGU9/kLzQTrTjbxRCVfzP5CjgGarYQEE7QxYlxJK zZkpV4C6bISQ+OaaXlKStvmzKuEV6ArwO2AB4YuRooh/hYxwzdwUU8z/3omEm/moGsE3Q4oN1rF TmE0LH7zTlypSFTjGstS4JaHAXeRZAUDL4MLI0rk8ncAo6SmIqFBM0oMoQ/tDLEtqO/hYmbqrqh AulROmOxJHXxF2/qLsSHgkq1T1dLXtbPvSQEkPwG8x+6hti7f0g1egisuDn5drEMVVUt1PiKRW4 bRrjPCJC1t1GyO6DK6QE+nhqY8PYNeJ/2U3catucMquw7s5EYqHaM04VnvGvp5e9027vcjTIrms RALPlyQMkiX8+Vmt0oIiiz7uNvaHiiqbXpyxvDt2LgYTJwguVyPaKMF+asYd0vpdfBt00NqdrdO Nq8rra1LEJ7ua9hRtBAwFA1yYcPRRz6zPCUo3hMSqlc6mZ66T0sbRbvzYTfDUWb0uT23arDI20t 9XDU0hItO9deQdw== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Mon, 30 Oct 2023 10:33:11 -0700 (PDT) Once we've set the nfsd_serv pointer in nfsd_svc, we still need to call nfsd_last_thread if the server fails to be started. Remove the special casing for nfsd_up_before case since shutting down the per-net stuff is also handled by nfsd_last_thread. Finally, add a new special case at the start and skip doing anything if the service already exists, 0 threads were requested and serv->sv_nrthreads is 0. Fixes: 9f28a971ee9f ("nfsd: separate nfsd_last_thread() from nfsd_put()") Reported-by: Zhi Li Signed-off-by: Jeff Layton --- Here's what I was thinking for a targeted patch for stable. Testing it now, but I won't have results until tomorrow. --- fs/nfsd/nfssvc.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 3deef000afa9..187b68769815 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -787,7 +787,6 @@ int nfsd_svc(int nrservs, struct net *net, const struct cred *cred) { int error; - bool nfsd_up_before; struct nfsd_net *nn = net_generic(net, nfsd_net_id); struct svc_serv *serv; @@ -797,8 +796,9 @@ nfsd_svc(int nrservs, struct net *net, const struct cred *cred) nrservs = max(nrservs, 0); nrservs = min(nrservs, NFSD_MAXSERVS); error = 0; + serv = nn->nfsd_serv; - if (nrservs == 0 && nn->nfsd_serv == NULL) + if (nrservs == 0 && (serv == NULL || serv->sv_nrthreads == 0)) goto out; strscpy(nn->nfsd_name, utsname()->nodename, @@ -808,22 +808,17 @@ nfsd_svc(int nrservs, struct net *net, const struct cred *cred) if (error) goto out; - nfsd_up_before = nn->nfsd_net_up; serv = nn->nfsd_serv; error = nfsd_startup_net(net, cred); if (error) goto out_put; error = svc_set_num_threads(serv, NULL, nrservs); - if (error) - goto out_shutdown; - error = serv->sv_nrthreads; if (error == 0) - nfsd_last_thread(net); -out_shutdown: - if (error < 0 && !nfsd_up_before) - nfsd_shutdown_net(net); + error = serv->sv_nrthreads; out_put: + if (serv->sv_nrthreads == 0) + nfsd_last_thread(net); /* Threads now hold service active */ if (xchg(&nn->keep_active, 0)) svc_put(serv); --- base-commit: 31b5a36c4b88b44c91cdd523997b1e86fb47339d change-id: 20231030-kdevops-5f7366897ef4 Best regards, -- Jeff Layton