Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2738496rdh; Mon, 30 Oct 2023 06:28:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHy5hQXINmgErrwCJuP03tz/PcwJjtDVAOkAFByyv54jahMOC3yQPtFoL6WbCNBMvVCpl8b X-Received: by 2002:a17:902:f54c:b0:1c9:cc88:5029 with SMTP id h12-20020a170902f54c00b001c9cc885029mr13072196plf.32.1698672486629; Mon, 30 Oct 2023 06:28:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698672486; cv=none; d=google.com; s=arc-20160816; b=DgG/1D+3M9GjAfrlKfnDtmfoDHNw6hGIRmiuBErdV+xUQ1Og0zlvMwnEAY4bFcWGFb FheZzThpvmadFvoGDRl5VNTJl+jG8Jp1KUKkPLmPYjcKZdSanVRHbJ5PhyJyPWdQuAiV WIAxKgSWf+gMPGV6++wpR+WK4LnoU4JAQCvun4dfAIUcBXTzDAGRnrWDxe8t9E6s0Oar blpHWWpzagBpVnjj90KWhBWAY2OrSzkJS9iOgYEkdFtg0RqTcnA3zkqFNS0weRyi7ypI K6quR3srJTJdb3WMjMozLP7vmvOC5sOwmR1cy9om5FnLbo5V1B3DCJT9efRRhIDBoZD5 NdDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=FyhYUTVBwNBwwdjzfRCpaSaSCi9p4+ELJzk1b4oPgUc=; fh=+5Lz5smGQDBQKAdxxCEPh+O9Jkhw7+Nc+3vyKkqrueQ=; b=1CbGRgFOc2OUgQZu1oQJm0JzWOL9oskFBglNW7hwTnk0GOiKkQk3UOyQ8jnfM0zMbL BEKnFssR8tkLuC+xVmf7IB9uEs6QULBjK4lhbjO4n4fXOyiRI4qRpc/AgCB8uWS1/GXK xeY1c9qruv4y5OgySn7t8qKxmcB8GneqtRnx20IOT2IdooFh0rOzpbA7oWNWTcvG7A6S +sWA/3feSYf1P4Jltt02Kr4AyEw3xAeXAY2TorEbKzSwZYfrtIJF5iuc2wgRd3Xm5zao qhD/UZd3tn0NyXWKJqa14IPJ75NIC3IceCT2rgc+4i5zrtJ5eE/AxSmfBVoN0UTNV6Ez QnrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=mGmzxRHN; 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=kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id l8-20020a170903244800b001c566ea86eesi2432477pls.177.2023.10.30.06.28.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:28:06 -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=@kernel.org header.s=k20201202 header.b=mGmzxRHN; 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=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id E4FF880A0573; Mon, 30 Oct 2023 06:28:03 -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 S233428AbjJ3N1x (ORCPT + 99 others); Mon, 30 Oct 2023 09:27:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233430AbjJ3N1w (ORCPT ); Mon, 30 Oct 2023 09:27:52 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47E4ED3 for ; Mon, 30 Oct 2023 06:27:50 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 971F4C433CA; Mon, 30 Oct 2023 13:27:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698672469; bh=KQPospHCSgaiG2LHqwxGwfPogISqTzasFopAM1Nn04E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mGmzxRHNaZFAcmTIuhMMKwtXmILhto7t5auF82/4sw8qBWLR6jDT7N77a91y7E5Ue yI7EQrrVVTcpVw3Zw6OxWVzd0XfmRqdmwHyQ6alEfb0XEWRtGxU5DuKmZd4EBPSA2V mVmRvqZ8Xhz9ko8gsaJMMtRXVci0KWCQ5Ypzhxoa3cC11Lrjgt0x5gWDcn6ioMPVPt FlnEZyY29UPk2d147YZNT1E8+NXBYW40HHoDGOV0qdgK3CnXdFaOmxwk/9c0MtfX2f nG5BmBVMBhd3COnSs1JDHiWmW+21f6bRC1v8og08AWIFAC+qzgj2zprm2ClHnIdRPy S1pE3e+bgQHTg== Date: Mon, 30 Oct 2023 14:27:46 +0100 From: Lorenzo Bianconi To: Jeff Layton Cc: NeilBrown , Chuck Lever , linux-nfs@vger.kernel.org, Olga Kornievskaia , Dai Ngo , Tom Talpey Subject: Re: [PATCH 3/5] nfsd: hold nfsd_mutex across entire netlink operation Message-ID: References: <20231030011247.9794-1-neilb@suse.de> <20231030011247.9794-4-neilb@suse.de> <07df60cee15b8c206365613364d4979330c31407.camel@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="JFSCYX3CYslEtjRO" Content-Disposition: inline In-Reply-To: <07df60cee15b8c206365613364d4979330c31407.camel@kernel.org> 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 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, 30 Oct 2023 06:28:04 -0700 (PDT) --JFSCYX3CYslEtjRO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > On Mon, 2023-10-30 at 12:08 +1100, NeilBrown wrote: > > 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. > >=20 > > The "entire" time isn't very long, and the mutex is not often contented. > >=20 > > This makes way for use to remove the refcounts of svc, which is more > > confusing than useful. > >=20 > > Signed-off-by: NeilBrown > > --- > > fs/nfsd/nfsctl.c | 9 +++------ > > 1 file changed, 3 insertions(+), 6 deletions(-) > >=20 > > 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 =3D -ENODEV; > > =20 > > mutex_lock(&nfsd_mutex); > > - if (nn->nfsd_serv) { > > - svc_get(nn->nfsd_serv); > > + if (nn->nfsd_serv) > > ret =3D 0; > > - } > > - mutex_unlock(&nfsd_mutex); > > + else > > + mutex_unlock(&nfsd_mutex); > > =20 > > 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); > > =20 > > return 0; >=20 > (cc'ing Lorenzo since he wrote this) >=20 > I think Lorenzo did it this way originally, and I convinced him to take > a reference instead. This should be fine though. yep, the idea was to avoid grabbing the mutex and dump the refcount instead= but I think it is fine. Regards, Lorenzo >=20 > Reviewed-by: Jeff Layton --JFSCYX3CYslEtjRO Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQTquNwa3Txd3rGGn7Y6cBh0uS2trAUCZT+vUgAKCRA6cBh0uS2t rFMyAP90yVhTeDeOin4j7bfLTwRqpq7DfjLnYZssex0R3lNzIQEAhJjoCnnX/tpe eUIpY6iKyhmim0aL3gMJ15TcQIH4mQM= =LWFr -----END PGP SIGNATURE----- --JFSCYX3CYslEtjRO--