Re: [PATCH v3 04/06] 9p fid refcount: add p9_fid_get/put wrappers

Dominique Martinet
2022-06-15T13:47:44Z

Christian Schoenebeck wrote on Wed, Jun 15, 2022 at 03:00:19PM +0200:
> > - if (!fid || IS_ERR(fid)) {
> > - pr_warn("%s (%d): Trying to clunk with invalid fid\n",
> > - __func__, task_pid_nr(current));
> > - dump_stack();
> > - return 0;
> > - }
> > - if (!refcount_dec_and_test(&fid->count))
> > - return 0;
> > -
>
> I probably would have moved (and that way preserved) that sanity warning to
> p9_fid_put(), but anyway LGTM.

The existing code was careful not to call clunk on error, but I consider
put() calls to be kind of like free in that it's better to make these
easy to call: this allowed patch 6 reworked most fs/ functions getting a
ref to just initialize fids to NULL and inconditionally call
p9_fid_put() before return.

I guess it's just a matter of preference ultimately, but I think that'll
make it a bit easier to not leak fids. Time will tell if this works :)

> Reviewed-by: Christian Schoenebeck <linux_oss@crudebyte.com>

Thanks for this and other reviews!

--
Dominique