Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2463150rdh; Sun, 29 Oct 2023 18:13:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGmdbg64e8andMhVRJCmuCxw0p2U1ya1WnLJcFqzKV1zvk23nptsil7fMLSZPSe2bl8XVmc X-Received: by 2002:a05:6870:1019:b0:1e9:c59b:a9af with SMTP id 25-20020a056870101900b001e9c59ba9afmr8976671oai.15.1698628431090; Sun, 29 Oct 2023 18:13:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698628431; cv=none; d=google.com; s=arc-20160816; b=QIegHK5qx1QAuDwALLHWpmCdmowCk1EtZZlN1THUcaVREHAS8ZOpqjJXVGA3EMIbNf lKm/B107kUao2y/kCHdRCJaHJKiLpdT0jXt29GZwIrETm8i8sM6rO+7hQU2QmV7O5BSj QnXtK0TazCXFaE03MFJw9Wrpw8n5OKF+sPqC0RwfldvqtQhnZkj/KlAjngddSUydBnEB Ou9RBp620EeNXhco8vPkMoUWWgY1fYmj3AomRBn0RsBaqtVN7TjIOOkKQIboMnmgit98 mgSov2N85gyYo72P1JnHwcwU1bJMsd1ft1OIIEwB3tZynbT+1VoLGLAz0fribMQcI9dW /3aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=c5JA7fnfIT/HDjDNo3Wkz2nCn14zIt7XZyYBhCTUg9Q=; fh=oGCWKUgN5rqvEqhxhGaFnCKhx0upqxg87fHnuYmJPFg=; b=mEWhRDSryMf8NZsVYWVAjHAp5td8UFl7NP156D7ZCo222xBvsjEaZ9DY1wHt0Loiwd Zko81aSjq+g4Tl03AB8sip+lR2Z+PX7HIo3UHSy4Kwgda77MKN2GLXyuIKKDu7RPKrl6 s2MCRjUBhxX+M2t2q6bCpls3anPbjRWOkXQdYNYe40Cy31FPD0JrJpr88SZLeJoAhmai bePmXy9RUrm0wm+8yWrGU+hF9TRmxP+CeTm1Sec9kF3K73poJjjiXYVoxy80Qf+lnL9m h+8/D+25fojazVYJTyPs12wwuI1gSgNUswG32TApxYPRQvbAVvFLMWuY+oaqAOSyPCqn bWSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=DUUvgzba; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id bv123-20020a632e81000000b005b98cb7b465si1096143pgb.637.2023.10.29.18.13.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Oct 2023 18:13:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=DUUvgzba; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id B701B8062371; Sun, 29 Oct 2023 18:13:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231312AbjJ3BNf (ORCPT + 99 others); Sun, 29 Oct 2023 21:13:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231298AbjJ3BNe (ORCPT ); Sun, 29 Oct 2023 21:13:34 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7434CBD for ; Sun, 29 Oct 2023 18:13:32 -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 216D5218B5; Mon, 30 Oct 2023 01:13:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1698628411; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c5JA7fnfIT/HDjDNo3Wkz2nCn14zIt7XZyYBhCTUg9Q=; b=DUUvgzbai5jmIuADRYp4ZDcGF7S1IfS1pHzTcGi8QQE+NrymlEike5diLCF0K2LnfSERs6 JvUBGFgYMpcYFXy/xaKuDyn4qK94PxuMivxq37+28DUY8T9KSAmL+9Aj4orVgn9yGUx8M+ /kjIPGya0MYBamE7lXwhdjUx6wE6oLQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1698628411; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c5JA7fnfIT/HDjDNo3Wkz2nCn14zIt7XZyYBhCTUg9Q=; b=3rQhWsektXxUY0bRd5rno7UsJa/Cw87dJFLOWm710adhIlmQMUQjvig63UOa5cxplES83+ l6iul8EPnXYZ1OAw== 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 EF05013460; Mon, 30 Oct 2023 01:13:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id soSmJzgDP2V+RwAAMHmgww (envelope-from ); Mon, 30 Oct 2023 01:13:28 +0000 From: NeilBrown To: Chuck Lever , Jeff Layton Cc: linux-nfs@vger.kernel.org, Olga Kornievskaia , Dai Ngo , Tom Talpey Subject: [PATCH 3/5] nfsd: hold nfsd_mutex across entire netlink operation Date: Mon, 30 Oct 2023 12:08:36 +1100 Message-ID: <20231030011247.9794-4-neilb@suse.de> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231030011247.9794-1-neilb@suse.de> References: <20231030011247.9794-1-neilb@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -1.52 X-Spamd-Result: default: False [-1.52 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_MISSING_CHARSET(2.50)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; RCPT_COUNT_FIVE(0.00)[6]; NEURAL_HAM_LONG(-3.00)[-1.000]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-2.42)[97.37%] X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 groat.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 (groat.vger.email [0.0.0.0]); Sun, 29 Oct 2023 18:13:48 -0700 (PDT) Rather than using svc_get() and svc_put() to hold a stable reference to the nfsd_svc for netlink lookups, simply hold the mutex for the entire time. The "entire" time isn't very long, and the mutex is not often contented. This makes way for use to remove the refcounts of svc, which is more confusing than useful. Signed-off-by: NeilBrown --- fs/nfsd/nfsctl.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index d78ae4452946..8f644f1d157c 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -1515,11 +1515,10 @@ int nfsd_nl_rpc_status_get_start(struct netlink_callback *cb) int ret = -ENODEV; mutex_lock(&nfsd_mutex); - if (nn->nfsd_serv) { - svc_get(nn->nfsd_serv); + if (nn->nfsd_serv) ret = 0; - } - mutex_unlock(&nfsd_mutex); + else + mutex_unlock(&nfsd_mutex); return ret; } @@ -1691,8 +1690,6 @@ int nfsd_nl_rpc_status_get_dumpit(struct sk_buff *skb, */ int nfsd_nl_rpc_status_get_done(struct netlink_callback *cb) { - mutex_lock(&nfsd_mutex); - nfsd_put(sock_net(cb->skb->sk)); mutex_unlock(&nfsd_mutex); return 0; -- 2.42.0