Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2194568rdb; Mon, 9 Oct 2023 16:35:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGwrDz5NpHvFyPPVC0YctFYJ8hUg3r/vmiMrwVT8q5Tu4YWPqnGooQdRBx3rV1obu4xdjjn X-Received: by 2002:a17:90b:1047:b0:277:6985:a3ff with SMTP id gq7-20020a17090b104700b002776985a3ffmr12447179pjb.3.1696894556210; Mon, 09 Oct 2023 16:35:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696894556; cv=none; d=google.com; s=arc-20160816; b=X093moUVbXm9BBL7b8MIuWHs+V8bz8soDbrZKsByIkQNE7kDre+9Ia7BMKWj6fi+f6 3r0GwAh4b0UcxAiEiF6fuH5kNaLM3n3nBYRvpDOn3Zl66ELYD3nWG+eWhd917duJxgBL LgmYTEPJOgR+hOlRMli5RAJhSsevHkP29LpkJK3T927tVlqlSQJYTpqhbsQdQF5UpD+1 4mFqjKI2c1WZrI+JjGRTs4VzrKrQeCERHNb87+UbQumwKGd6xwwujtXqvvkR0vjOnWGI 17v0J6qPCaVlNojPIWphzYvnsuZoTsmkgeEVeeBocIVhi1VcagcMHsYH9McrExvi7ztW GsOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:mime-version :content-transfer-encoding:dkim-signature:dkim-signature; bh=M8ctveJWNGn+Wbc/BQFgOI+zmmIPnmg7OwmWYfxr39Y=; fh=oGCWKUgN5rqvEqhxhGaFnCKhx0upqxg87fHnuYmJPFg=; b=zvMUO66VbyCDZPLCvmLDXQjbgcNUv9HpQmuxdr5Fxbzx125vKki/14OXNNT8q8wVOZ 6E5nQy+fgYJ2JRDbklD69gBdzAJUT5x8r7P1ji3MhW4NsNi2ryf1XNUvCiBhwgBJ9wy5 /LO5bzw7zAwOHPP1Y/6fFYZJjtJ1NuTiPid6/jdYt70QayF9iBkAoFGY0ebzvD8QnpD3 gkaLy2m88mD/KeTyfcdCiehCP1cJTAFOmagvQsV1PN4JFjNhdUoKmNDKI8KYetZvgSMH yl7uWJ4n+4cDdPpxVTaKhcIgwYnBw9dao64kwxMrlOaX1JTUJgBtOHuCStEezlBGTRBi gK5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=uMeFGAjV; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=a50DhDFm; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id hg6-20020a17090b300600b00277387bc11dsi10251468pjb.188.2023.10.09.16.35.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 16:35:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=uMeFGAjV; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=a50DhDFm; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 54E82802B556; Mon, 9 Oct 2023 16:35:53 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234617AbjJIXfw (ORCPT + 99 others); Mon, 9 Oct 2023 19:35:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234601AbjJIXfv (ORCPT ); Mon, 9 Oct 2023 19:35:51 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E98589D for ; Mon, 9 Oct 2023 16:35:49 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 64EFC21883; Mon, 9 Oct 2023 23:35:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1696894548; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=M8ctveJWNGn+Wbc/BQFgOI+zmmIPnmg7OwmWYfxr39Y=; b=uMeFGAjVMU8NUtg9VWB1xFmGKrt3vQgboRu6EuBWO4S+53jelc/8ozkomAVizU9fWeDfA5 F1CoOt3vzA5UNUpOwpwxZJom7RKfy+eknVJm8oPUgSnQn1dZoATNkrO1aBdhRjIMwyulcE f7AbY4+WGt5nvGUBHyI2h0AAnB4PmWk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1696894548; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=M8ctveJWNGn+Wbc/BQFgOI+zmmIPnmg7OwmWYfxr39Y=; b=a50DhDFmGaCRPvW1WaQ4eYP6RuhKtm37KEaMaUv2eW5cDzBJhUzX/lFSpL7QpdyKAErj0o FM4I1TZGEZbd9bCQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 57DAC13905; Mon, 9 Oct 2023 23:35:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id RY3dA1KOJGWiBwAAMHmgww (envelope-from ); Mon, 09 Oct 2023 23:35:46 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit MIME-Version: 1.0 From: "NeilBrown" To: Chuck Lever , Jeff Layton Cc: linux-nfs@vger.kernel.org, Olga Kornievskaia , Dai Ngo , Tom Talpey Subject: [PATCH] lockd: hold a reference to nlmsvc_serv while stopping thread. Date: Tue, 10 Oct 2023 10:35:43 +1100 Message-id: <169689454310.26263.15848180396022999880@noble.neil.brown.name> X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 fry.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 (fry.vger.email [0.0.0.0]); Mon, 09 Oct 2023 16:35:53 -0700 (PDT) X-Spam-Level: ** 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. lockd doesn't do this. After startup, the only reference is held by the running thread. 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. 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. Reported-by: Jeff Layton Fixes: 68cc388c3238 ("SUNRPC: change how svc threads are asked to exit.") Signed-off-by: NeilBrown --- Thanks for the report Jeff !!! fs/lockd/svc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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) serv->sv_maxconn = nlm_max_connections; error = 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; + } nlmsvc_serv = serv; register_inetaddr_notifier(&lockd_inetaddr_notifier); @@ -374,6 +374,7 @@ static void lockd_put(void) svc_set_num_threads(nlmsvc_serv, NULL, 0); timer_delete_sync(&nlmsvc_retry); + svc_put(nlmsvc_serv); nlmsvc_serv = NULL; dprintk("lockd_down: service destroyed\n"); } -- 2.42.0