Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp445834rdg; Tue, 10 Oct 2023 15:31:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG4S9cd4ityUFo1kD9WYBsCdHwx+kn+EEhK9O0XOgUJ//K6+SUP/N6N1wZl+YkKoQd1Zmf+ X-Received: by 2002:a17:902:ec8c:b0:1c9:b187:4d84 with SMTP id x12-20020a170902ec8c00b001c9b1874d84mr4052541plg.14.1696977096346; Tue, 10 Oct 2023 15:31:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696977096; cv=none; d=google.com; s=arc-20160816; b=PFv6fiaOFZ2B+uyN93J7Spw8B28bjEgHxcU9rwFQ328QUOe30C2CjRYuiRtGKy4o28 UP8F0V+2BgFq0ppIbIt/MtO8dTA7DtLz3Mwuuf1Lz+HhnG+K7itOAafTBIZbgRDIUyah qDofzHXu0OT5hFczAmNaj4T14ei/j/dDCVTUkjkXisiCGnp08yy5eZfYY5oHOoDv2ge/ /Kalqbh16C4cXPfmYBr53/6f35p8oFbhPsWwJDhZLDtRWmAK5ThX8xmoWunbcM8Jxpxl XU0d4Yv8/rHALTAZaKPvI6iLw9yCP/9TQdjmFUKzC0ydP9Bty9qq6htMKotFdo0AUk+N +39w== 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=7d90yGy6j1Z+zShNyhLn4RoSC5IpwnmxSENdTEDxVMk=; fh=oGCWKUgN5rqvEqhxhGaFnCKhx0upqxg87fHnuYmJPFg=; b=AG9NIufFzQR7vRvh7NBnhQdUZy1wASsY0Cl7dgLukZPHq8vX8yiwQBzm44NxqCfIeM HOWAI1bg/oZcX7YXqbgW6R/jQ3Sb32b6NbvtrnPNs/oOfQiICnnCeUcNlQgdhiQ+gkSV 6/a2E81X++DJKExeFKCBI+oWmsAhR0Bl8PAWmTtwMIgedtBWc9W7Rae7y9iA63ri5tzo rmfLUImeMNy5CfgeOepE8BRuH0W/re4wvF6qd8IRc31lFnO+yu1fGCrkJtgoToAWKu/Z 1fihGsxCpkfBDVFBYVL3c372jB/h9huGRb9ZrKnmsFbetLbb0R7OYURsgPC6YltNpoTj Aa8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=jiI9ufyo; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.38 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. [23.128.96.38]) by mx.google.com with ESMTPS id q6-20020a17090311c600b001ab089f7329si3326804plh.73.2023.10.10.15.31.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 15:31:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=jiI9ufyo; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.38 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 5CF3F83BB58B; Tue, 10 Oct 2023 15:31:32 -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 S234278AbjJJWbb (ORCPT + 99 others); Tue, 10 Oct 2023 18:31:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231926AbjJJWba (ORCPT ); Tue, 10 Oct 2023 18:31:30 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C297591 for ; Tue, 10 Oct 2023 15:31:29 -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 477172183A; Tue, 10 Oct 2023 22:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1696977088; 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=7d90yGy6j1Z+zShNyhLn4RoSC5IpwnmxSENdTEDxVMk=; b=jiI9ufyoRtObBWanGuHeHlyrDWxixsg7kghGRZGpKh2BJcd408KzzuvO3DVpEDNs4yvXaV RBB1scIHZY9AwMNJpMCr5yBe26EXyNwHSBJ4wtKyZAt8mHvtJYmao3H3nGBexpVt+SMzT8 Xs9OdREFzkwqXqXrqzmCYaWhZgQW2Dc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1696977088; 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=7d90yGy6j1Z+zShNyhLn4RoSC5IpwnmxSENdTEDxVMk=; b=qupyHEtVR0VA4pwqX6sNtK0+aEjRJbTGyZpfwC5Dk/9arFsRzXCJIViGbRQ2M/wbco0XN0 jR+fgFr3haiF+qAQ== 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 1A2D61358F; Tue, 10 Oct 2023 22:31:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 98miL73QJWV6MAAAMHmgww (envelope-from ); Tue, 10 Oct 2023 22:31:25 +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 v2] lockd: hold a reference to nlmsvc_serv while stopping the thread. Date: Wed, 11 Oct 2023 09:31:22 +1100 Message-id: <169697708281.26263.8555620245361496067@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,URIBL_BLOCKED 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]); Tue, 10 Oct 2023 15:31:32 -0700 (PDT) X-Spam-Level: ** Both nfsd and nfsv4-callback take a temporary reference to the svc_serv while calling svc_set_num_threads() to stop the last thread. lockd does not. This extra reference prevents the scv_serv from being freed when the last thread drops its reference count. This not currently needed for lockd as the svc_serv is not accessed after the last thread is told to exit. However a future patch will require svc_exit_thread() to access the svc_serv after the svc_put() so it will need the code that calls svc_set_num_threads() to keep a reference and keep the svc_serv active. So copy the pattern from nfsd and nfsv4-cb to lockd, and take a reference around svc_set_num_threads(.., 0) Reviewed-by: Jeff Layton Tested-by: Jeff Layton Signed-off-by: NeilBrown --- fs/lockd/svc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index 6579948070a4..365cc7adff66 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c @@ -373,7 +373,9 @@ static void lockd_put(void) unregister_inet6addr_notifier(&lockd_inet6addr_notifier); #endif + svc_get(nlmsvc_serv); svc_set_num_threads(nlmsvc_serv, NULL, 0); + svc_put(nlmsvc_serv); timer_delete_sync(&nlmsvc_retry); nlmsvc_serv = NULL; dprintk("lockd_down: service destroyed\n"); -- 2.42.0