diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-07-04 03:02:49 +0200 |
---|---|---|
committer | Dominique Martinet <dominique.martinet@atmark-techno.com> | 2022-07-09 07:38:12 +0200 |
commit | 6cda12864cb0f99810a5809e11e3ee5b102c9a47 (patch) | |
tree | 6de8ed379115b8458e7e298205223777a384fe39 /net/9p | |
parent | 9p: Fix some kernel-doc comments (diff) | |
download | linux-6cda12864cb0f99810a5809e11e3ee5b102c9a47.tar.xz linux-6cda12864cb0f99810a5809e11e3ee5b102c9a47.zip |
9p: Drop kref usage
An upcoming patch is going to require passing the client through
p9_req_put() -> p9_req_free(), but that's awkward with the kref
indirection - so this patch switches to using refcount_t directly.
Link: https://lkml.kernel.org/r/20220704014243.153050-1-kent.overstreet@gmail.com
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Cc: Eric Van Hensbergen <ericvh@gmail.com>
Cc: Latchesar Ionkov <lucho@ionkov.net>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
Diffstat (limited to 'net/9p')
-rw-r--r-- | net/9p/client.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/net/9p/client.c b/net/9p/client.c index dfe8beb864fc..3717d3f21a9f 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -305,7 +305,7 @@ p9_tag_alloc(struct p9_client *c, int8_t type, unsigned int max_size) * callback), so p9_client_cb eats the second ref there * as the pointer is duplicated directly by virtqueue_add_sgs() */ - refcount_set(&req->refcount.refcount, 2); + refcount_set(&req->refcount, 2); return req; @@ -370,18 +370,15 @@ static int p9_tag_remove(struct p9_client *c, struct p9_req_t *r) return p9_req_put(r); } -static void p9_req_free(struct kref *ref) -{ - struct p9_req_t *r = container_of(ref, struct p9_req_t, refcount); - - p9_fcall_fini(&r->tc); - p9_fcall_fini(&r->rc); - kmem_cache_free(p9_req_cache, r); -} - int p9_req_put(struct p9_req_t *r) { - return kref_put(&r->refcount, p9_req_free); + if (refcount_dec_and_test(&r->refcount)) { + p9_fcall_fini(&r->tc); + p9_fcall_fini(&r->rc); + kmem_cache_free(p9_req_cache, r); + return 1; + } + return 0; } EXPORT_SYMBOL(p9_req_put); |