Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp2721673rdh; Mon, 30 Oct 2023 06:03:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH/68SL8gDMqNlTDVSjOcHmGYwizkkCOF2D0Xjby8IY1o72lthIlA9Jy1iErgkMBqfit9yP X-Received: by 2002:a17:903:2054:b0:1cc:4146:9ecb with SMTP id q20-20020a170903205400b001cc41469ecbmr3370105pla.47.1698671000438; Mon, 30 Oct 2023 06:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698671000; cv=none; d=google.com; s=arc-20160816; b=UJYN8peBHMugTH5umQJPdhWWAF+3kW/czL0mrjL1veHYtKeqOec5/xkQE4YCVqYRz7 yGp60mOy/ahgf8+vV0XOftL73AvV7DQU6e7N/4k87qNOryptfObrPxHus1bxNgKxPOQm sfPnmoBQSLLJa3HHH4CCtly+EvsfyJOsL0ortFkyq9ZRJAOjKA1UlYoWRzo+Bmra106i cfmgKn3wwJP7r1wazMmdA9Dwy6gNkSIJYPdSrFjTUqwtmd7MbD0hFijecFWrVZ5+9lA0 l0DElyZo+CjmzrGTGvZJaXXFGUz5gQqCdzd4RTHXrga0nfzYEBnxDBYeE5zspFxuU7cF hB6Q== 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=iu0HEEyE8nKRqDK/Wl/X20AfBUqanxUbS5w2WbwGTYU=; fh=epNsmA83l1K44pb07GzULkySGRzHeMVIRAKIcbmh2aM=; b=EjwCDqOAxQ8+U0Msclb/s2APGfAIsZ7Mu/JrVZm5r5nJUJRDtBlW0MeK8xQ7Rp8imG OLZypPNVltWa6UKEc3Nj7MXRnUJMxVYTQwZBFnnVgTRjnQT4hK5oRHmO28vDe7a4NVub m1vTdF5u0oljzsTuHEM3SS+FeWwGWrDwLPvFNaxceHQwT0Q33G0bT0mTavaFBE+xkrHN lde5QENXiV8mp8G5HAMajHaz8nSYyx9npJz5lywvM73O5HjSXc8BrhCmVUGOyrGM2ds5 VyUNz5XLXOtfb3nJNdp/Q46QGnTIf+mhWrxt3eG80lYtXSHEOdRu650c1ms5+57AQjZp R0Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ofKFkNzT; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id jc4-20020a17090325c400b001c75866c987si4776344plb.584.2023.10.30.06.03.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 06:03:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ofKFkNzT; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 82247807C5F4; Mon, 30 Oct 2023 06:03:16 -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 S233092AbjJ3NDR (ORCPT + 99 others); Mon, 30 Oct 2023 09:03:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232291AbjJ3NDQ (ORCPT ); Mon, 30 Oct 2023 09:03:16 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BEBFC2 for ; Mon, 30 Oct 2023 06:03:14 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AD2CC433C7; Mon, 30 Oct 2023 13:03:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698670994; bh=9Dizicebk3lKHNGfkP6T1KM+uaqihR4FYLlmeCPAik0=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=ofKFkNzT3l+243kgDc1pWc1nwJvLuVkgC9YnP5sStrW/cHYwZk9G3adPWWvW3j05u adrk4Wv+Yioj7WCdPB4YTYZr2+P2oAIfW4jMpoXgonOVVVPgEXKhW2Elu1x58HgusV bwRYlEXcvDevf+SJc0jjXCePVEydNHtA6f+yF5O6yojV3xrVG9HhkQnbV8jchrbzsE Y0DIwemSIKRQmnYZKwj1+XmZIVSlsQlNr/9ZEdvLoNcP44q3r+8gTheA6YMzoFNOde 8nBbYVf66SGCv+V5FYKmFx5UBZMxKz9Cx8xEJ0fpSYTf3XK58SuZigesK+OaLZPgtr WII6jubwtnyCA== Message-ID: <07df60cee15b8c206365613364d4979330c31407.camel@kernel.org> Subject: Re: [PATCH 3/5] nfsd: hold nfsd_mutex across entire netlink operation From: Jeff Layton To: NeilBrown , Chuck Lever Cc: linux-nfs@vger.kernel.org, Olga Kornievskaia , Dai Ngo , Tom Talpey , Lorenzo Bianconi Date: Mon, 30 Oct 2023 09:03:12 -0400 In-Reply-To: <20231030011247.9794-4-neilb@suse.de> References: <20231030011247.9794-1-neilb@suse.de> <20231030011247.9794-4-neilb@suse.de> Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 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 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]); Mon, 30 Oct 2023 06:03:16 -0700 (PDT) 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_c= allback *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 *s= kb, > */ > 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; (cc'ing Lorenzo since he wrote this) I think Lorenzo did it this way originally, and I convinced him to take a reference instead. This should be fine though. Reviewed-by: Jeff Layton