unsigned long rs_prealloc:1; /* rs from prealloc list */
/* transaction committed and rs dispatched by ptlrpc_commit_replies */
unsigned long rs_committed:1;
- atomic_t rs_refcount; /* number of users */
+ struct kref rs_refcount; /* number of users */
/** Number of locks awaiting client ACK */
int rs_nlocks;
int lustre_shrink_msg(struct lustre_msg *msg, int segment,
unsigned int newlen, int move_data);
int lustre_grow_msg(struct lustre_msg *msg, int segment, unsigned int newlen);
-void lustre_free_reply_state(struct ptlrpc_reply_state *rs);
+void lustre_free_reply_state(struct kref *kref);
int __lustre_unpack_msg(struct lustre_msg *m, int len);
__u32 lustre_msg_hdr_size(__u32 magic, __u32 count);
__u32 lustre_msg_size(__u32 magic, int count, __u32 *lengths);
wake_up(&req->rq_set->set_waitq);
}
-static inline void
-ptlrpc_rs_addref(struct ptlrpc_reply_state *rs)
-{
- LASSERT(atomic_read(&rs->rs_refcount) > 0);
- atomic_inc(&rs->rs_refcount);
-}
-
-static inline void
-ptlrpc_rs_decref(struct ptlrpc_reply_state *rs)
-{
- LASSERT(atomic_read(&rs->rs_refcount) > 0);
- if (atomic_dec_and_test(&rs->rs_refcount))
- lustre_free_reply_state(rs);
-}
-
/* Should only be called once per req */
static inline void ptlrpc_req_drop_rs(struct ptlrpc_request *req)
{
req->rq_repmsg = NULL;
spin_unlock(&req->rq_early_free_lock);
- ptlrpc_rs_decref(req->rq_reply_state);
+ kref_put(&req->rq_reply_state->rs_refcount, lustre_free_reply_state);
req->rq_reply_state = NULL;
}
RETURN(rc);
rs = req->rq_reply_state;
- atomic_set(&rs->rs_refcount, 1); /* 1 ref for rq_reply_state */
+ kref_init(&rs->rs_refcount); /* 1 ref for rq_reply_state */
rs->rs_cb_id.cbid_fn = reply_out_callback;
rs->rs_cb_id.cbid_arg = rs;
rs->rs_svcpt = req->rq_rqbd->rqbd_svcpt;
}
EXPORT_SYMBOL(lustre_grow_msg);
-void lustre_free_reply_state(struct ptlrpc_reply_state *rs)
+void lustre_free_reply_state(struct kref *kref)
{
+ struct ptlrpc_reply_state *rs = container_of(kref,
+ struct ptlrpc_reply_state,
+ rs_refcount);
PTLRPC_RS_DEBUG_LRU_DEL(rs);
- LASSERT(atomic_read(&rs->rs_refcount) == 0);
LASSERT(!rs->rs_difficult || rs->rs_handled);
LASSERT(!rs->rs_difficult || rs->rs_unlinked);
LASSERT(!rs->rs_scheduled);