From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B77A9CCA481 for ; Mon, 13 Jun 2022 20:45:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345941AbiFMUpG (ORCPT ); Mon, 13 Jun 2022 16:45:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351422AbiFMUoG (ORCPT ); Mon, 13 Jun 2022 16:44:06 -0400 Received: from nautica.notk.org (ipv6.notk.org [IPv6:2001:41d0:1:7a93::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 154EADEB6 for ; Mon, 13 Jun 2022 12:51:08 -0700 (PDT) Received: by nautica.notk.org (Postfix, from userid 108) id 47C0FC009; Mon, 13 Jun 2022 21:51:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1655149867; bh=UEvKISJURFgyGo3z5EU/K/Ie2JUi/EPJT4jZw0U6fw8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RceXwHRGU7mqLO5rOsg7z085gkBFou3uzTxjZfPWhq0xDjwKssqvNp89OR90eUn7V HX9lENgU62yupn1S9FeQRbWZdIHuTofXJAUWyF8AxIiQ1O4fVIg3NMs3TxhqX1VCkW rRselTe5r0wl0cgMXHNvizTFcVjNlI6iO9i5dft8d/hCv+BvVzTj3WfnxNguZRyg3H S3pllg24g4HcTbzS9ZgB1JGroeXYutAO4oMTvW6WlTR//Vhc1eNpmqlqffeXV2Qa2F cc9d/jhqInRKiHT7a1sXYjYMKEnXuImEtAIfzRr4Wtft+IXmZ8eAPtu287JNr+IgOw vMJrx+D0bRW1A== Received: from odin.codewreck.org (localhost [127.0.0.1]) by nautica.notk.org (Postfix) with ESMTPS id 97D3EC009; Mon, 13 Jun 2022 21:51:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1655149866; bh=UEvKISJURFgyGo3z5EU/K/Ie2JUi/EPJT4jZw0U6fw8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Sk0XCve553x6PF2rViDkpNAIAyr7AA8IvuCw6ijYTB1QOjfqK7/iYhH+nFjU3x1A3 MVm9LmcLyaKJs5JQOnkbTBbHQNUOcP/aB/4O0r37Ce72bsEtEiHkx/s8kUk8GgPevm uOSYm8N27rnBzpH+XMSPYn1VNZ61KKUKWNPazusRgFFd84/uEl+qmuoP+XDVEAe4DU uy4rrqCdSecetimU8CpHVtW4Op+gsfE2ntoculz1V4QsCysyuhuRDE2XSZaalAZGqF +CW2FJpCtgi169KQqCr2CaII3pglXwORvZBLDdlmvuggqbX+0wy8OqGvj5UEC0xYeN Cp7DlgCEk2R/A== Received: from localhost (odin.codewreck.org [local]) by odin.codewreck.org (OpenSMTPD) with ESMTPA id cc73f8c0; Mon, 13 Jun 2022 19:51:01 +0000 (UTC) Date: Tue, 14 Jun 2022 04:50:45 +0900 From: Dominique Martinet To: Tyler Hicks Cc: Christian Schoenebeck , Eric Van Hensbergen , Latchesar Ionkov , v9fs-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH 06/06] 9p fid refcount: cleanup p9_fid_put calls Message-ID: References: <20220612085330.1451496-1-asmadeus@codewreck.org> <20220612085330.1451496-7-asmadeus@codewreck.org> <20220613175509.GE7401@sequoia> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220613175509.GE7401@sequoia> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for the reviews, Tyler Hicks wrote on Mon, Jun 13, 2022 at 12:55:09PM -0500: > > @@ -189,13 +197,13 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry, > > else > > uname = v9ses->uname; > > > > - root_fid = p9_client_attach(v9ses->clnt, NULL, uname, uid, > > - v9ses->aname); > > - if (IS_ERR(root_fid)) > > - return root_fid; > > + fid = p9_client_attach(v9ses->clnt, NULL, uname, uid, > > To keep the readability benefits in my "9p: Track the root fid with its > own variable during lookups" patch, I think root_fid should be assigned > here and then used in the error check and return statement. > > > + v9ses->aname); > > + if (IS_ERR(fid)) > > + return fid; > > > > - p9_fid_get(root_fid); > > - v9fs_fid_add(dentry->d_sb->s_root, root_fid); > > + root_fid = p9_fid_get(fid); > > + v9fs_fid_add(dentry->d_sb->s_root, &fid); > > root_fid should be used in the two lines above, too. This actually was the only place where we still want to use the root_fid after calling v9fs_fid_add; if we keep root_fid above we need to do something like fid = p9_fid_get(root_fid); v9fs_Fid_add(dentry->d_sb->s_root, &root_fid); root_fid = fid; // fid = NULL; ? not strictly needed as we set it again shortly afterwards which I wanted to avoid, but I guess I don't mind strongly either way -- pick your poison. I could also just keep v9fs_fid_add as a non-stealing version, but I think it's better that way as it strongly signal that we stashed that ref away and shouldn't use the fid anymore unless another ref was obtained through fid_get like we do here. (I was actually tempted to do the same with p9_fid_put, but checking other kernel "put"s I didn't see any code that does this so I refrained from that churn) -- Dominique