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>
This commit is contained in:
parent
e3baced02a
commit
6cda12864c
2 changed files with 11 additions and 14 deletions
|
@ -77,7 +77,7 @@ enum p9_req_status_t {
|
||||||
struct p9_req_t {
|
struct p9_req_t {
|
||||||
int status;
|
int status;
|
||||||
int t_err;
|
int t_err;
|
||||||
struct kref refcount;
|
refcount_t refcount;
|
||||||
wait_queue_head_t wq;
|
wait_queue_head_t wq;
|
||||||
struct p9_fcall tc;
|
struct p9_fcall tc;
|
||||||
struct p9_fcall rc;
|
struct p9_fcall rc;
|
||||||
|
@ -228,12 +228,12 @@ struct p9_req_t *p9_tag_lookup(struct p9_client *c, u16 tag);
|
||||||
|
|
||||||
static inline void p9_req_get(struct p9_req_t *r)
|
static inline void p9_req_get(struct p9_req_t *r)
|
||||||
{
|
{
|
||||||
kref_get(&r->refcount);
|
refcount_inc(&r->refcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int p9_req_try_get(struct p9_req_t *r)
|
static inline int p9_req_try_get(struct p9_req_t *r)
|
||||||
{
|
{
|
||||||
return kref_get_unless_zero(&r->refcount);
|
return refcount_inc_not_zero(&r->refcount);
|
||||||
}
|
}
|
||||||
|
|
||||||
int p9_req_put(struct p9_req_t *r);
|
int p9_req_put(struct p9_req_t *r);
|
||||||
|
|
|
@ -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
|
* callback), so p9_client_cb eats the second ref there
|
||||||
* as the pointer is duplicated directly by virtqueue_add_sgs()
|
* as the pointer is duplicated directly by virtqueue_add_sgs()
|
||||||
*/
|
*/
|
||||||
refcount_set(&req->refcount.refcount, 2);
|
refcount_set(&req->refcount, 2);
|
||||||
|
|
||||||
return req;
|
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);
|
return p9_req_put(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void p9_req_free(struct kref *ref)
|
int p9_req_put(struct p9_req_t *r)
|
||||||
{
|
{
|
||||||
struct p9_req_t *r = container_of(ref, struct p9_req_t, refcount);
|
if (refcount_dec_and_test(&r->refcount)) {
|
||||||
|
|
||||||
p9_fcall_fini(&r->tc);
|
p9_fcall_fini(&r->tc);
|
||||||
p9_fcall_fini(&r->rc);
|
p9_fcall_fini(&r->rc);
|
||||||
kmem_cache_free(p9_req_cache, r);
|
kmem_cache_free(p9_req_cache, r);
|
||||||
}
|
return 1;
|
||||||
|
}
|
||||||
int p9_req_put(struct p9_req_t *r)
|
return 0;
|
||||||
{
|
|
||||||
return kref_put(&r->refcount, p9_req_free);
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(p9_req_put);
|
EXPORT_SYMBOL(p9_req_put);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue