Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp85901rdg; Tue, 10 Oct 2023 05:10:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGEJ0xpA+t9j9fW8xgCL2+7dNmNkMn2kRpKrk9+80llGZgMvD3GnilKuHdv+ua+aa1Sir1j X-Received: by 2002:a17:903:41c4:b0:1c6:294c:f89c with SMTP id u4-20020a17090341c400b001c6294cf89cmr20599027ple.63.1696939842047; Tue, 10 Oct 2023 05:10:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696939842; cv=none; d=google.com; s=arc-20160816; b=WBgN+ld6ftUxjaUTlXRvQpRUb4r314AOcqBWLnVyuWg/nRc/jgTSbxGrmSAbhR70Kd PFxGTpevcT6xQQDx08xcMfmc0KS8gqELs6JSTa0txekgoceASu1YjKvoKuUcC1Y6vy+3 F6Pp6slu38eS6x2fdMp2X4aNJ7RNoZiWncCpWWL9DR2Jt7wwjHJIppCbeDFKNm0f54E5 usDjFYX5yytV6YrBfsCxx8xi15Wx/dYhk6uoJZu+HwRBU8jQk9GUjewpXcL3Bgs35NjM D5vMsKHGjCIccruLxnOktHJQrwtApD+swaQKKk/XXL8sVMv5ERJsVsGdPAT+yXUCRXYF og7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=QpuTHmfZBS/VqRM1dxDcYk9RldHaKl+fDl0cokdSSVs=; fh=OcKsFOYHXkFUuroZFv0kDoaH9wMEljnKMGoW5XIvX+Q=; b=jJYViMOf4eBT0/hT2pSq0WmbByGnZxySnLqytMO6WvEq5mAKWOskgFesLrxdBJVjtw ztc14asDkBtGDnRrrqJz0ILfvK4gA9UTs5+IYmDrVSrtQJ8x6Z8u+Xr0mfJGgiez5Bqi 048Nywe0jmGGxD56nF7MZtt/TkprE36Dcxxl/UdwULmqFeSlHrDNefH0AnsFp+lt1bgO Oi5/3H4tv2Ly/BI/N4T/LbkTG2Jbikt99uObv9EPhIyzIGxEp5RkDBy/dICHR3/Ph/pa v7EFbaq0hMcMDsmdKO5gDY2nrqEul56pZuohlCwMhDnk5pf1YkthJ3P84xsNo3XjAIkq ChiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RfyEPY4t; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.36 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. [23.128.96.36]) by mx.google.com with ESMTPS id m14-20020a170902db0e00b001bb8f59aca3si12476799plx.583.2023.10.10.05.10.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 05:10:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RfyEPY4t; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.36 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 872CC8083A93; Tue, 10 Oct 2023 05:10:18 -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 S231365AbjJJMKR (ORCPT + 99 others); Tue, 10 Oct 2023 08:10:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231311AbjJJMKQ (ORCPT ); Tue, 10 Oct 2023 08:10:16 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32B9494 for ; Tue, 10 Oct 2023 05:10:15 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1EDFFC433C7; Tue, 10 Oct 2023 12:10:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696939814; bh=BhvqaimQ+dMrJmv0i50mvyKBawex152Ep4BJI8h8gz8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=RfyEPY4tK7SwmNDMD1p7Ya6FdvnoRkoI5gv07DoIJL2PDqvjAGjq3hAca8KpykcwD SQKOc7R8MOHL+ANXcdXedqZxB4wum++C1kydFbQ0PFB8aZh14WE5jgXL4koZ4WiZou ub9Gm+jzLfuwYWSVeMe8YTuKpD9Hr10qgaouJu20GBLnCgr1WdPwnAG/Q0RKAJhVOa IZEU/orMRlbmiL9UzRbapYzh7GM4UQEaigtd1sAWpijcBg4ctzI6i2TX2Vd0XdRLEw hnFchG8euFVUKdmP9s1hPIo7euynj3lY0qB1H/z+N2FHbfM9U4Y4yggtm/Nm3M35Am i6LipqH7gVgmg== Message-ID: <4cc5b614a2b8c4bae3aa1fe271f6915bd538ba22.camel@kernel.org> Subject: Re: [PATCH] lockd: hold a reference to nlmsvc_serv while stopping thread. From: Jeff Layton To: NeilBrown , Chuck Lever Cc: linux-nfs@vger.kernel.org, Olga Kornievskaia , Dai Ngo , Tom Talpey Date: Tue, 10 Oct 2023 08:10:12 -0400 In-Reply-To: <169689454310.26263.15848180396022999880@noble.neil.brown.name> References: <169689454310.26263.15848180396022999880@noble.neil.brown.name> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.module_f38+17164+63eeee4a) MIME-Version: 1.0 X-Spam-Status: No, score=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no 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]); Tue, 10 Oct 2023 05:10:19 -0700 (PDT) X-Spam-Level: ** On Tue, 2023-10-10 at 10:35 +1100, NeilBrown wrote: > We are required to hold a reference to the svc_serv struct while > stopping the last thread, as doing that could otherwise drop the last > reference itself and the svc_serv would be freed while still in use. >=20 > lockd doesn't do this. After startup, the only reference is held by the > running thread. >=20 > So change locked to hold a reference on nlmsvc_serv while-ever the > service is active, and only drop it after the last thread has been > stopped. >=20 > Note: it doesn't really make sense for threads to hold references to the > svc_serv any more. The fact threads are included in serv->sv_nrthreads > is sufficient. Maybe a future patch could address this. >=20 > Reported-by: Jeff Layton > Fixes: 68cc388c3238 ("SUNRPC: change how svc threads are asked to exit.") > Signed-off-by: NeilBrown > --- >=20 > Thanks for the report Jeff !!! >=20 > fs/lockd/svc.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) >=20 > diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c > index b441c706c2b8..7a5c90a00522 100644 > --- a/fs/lockd/svc.c > +++ b/fs/lockd/svc.c > @@ -345,10 +345,10 @@ static int lockd_get(void) > =20 > serv->sv_maxconn =3D nlm_max_connections; > error =3D svc_set_num_threads(serv, NULL, 1); > - /* The thread now holds the only reference */ > - svc_put(serv); > - if (error < 0) > + if (error < 0) { > + svc_put(serv); > return error; > + } > =20 > nlmsvc_serv =3D serv; > register_inetaddr_notifier(&lockd_inetaddr_notifier); > @@ -374,6 +374,7 @@ static void lockd_put(void) > =20 > svc_set_num_threads(nlmsvc_serv, NULL, 0); > timer_delete_sync(&nlmsvc_retry); > + svc_put(nlmsvc_serv); > nlmsvc_serv =3D NULL; > dprintk("lockd_down: service destroyed\n"); > } Thanks Neil! You can add: Reviewed-by: Jeff Layton Tested-by: Jeff Layton