Messages in this thread | | | Date | Tue, 14 Jun 2022 04:50:45 +0900 | From | Dominique Martinet <> | Subject | Re: [PATCH 06/06] 9p fid refcount: cleanup p9_fid_put calls |
| |
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
| |