/* Should only be called once per req */
static inline void ptlrpc_req_drop_rs(struct ptlrpc_request *req)
{
- if (req->rq_reply_state == NULL)
- return; /* shouldn't occur */
- ptlrpc_rs_decref(req->rq_reply_state);
- req->rq_reply_state = NULL;
- req->rq_repmsg = NULL;
+ if (req->rq_reply_state == NULL)
+ return; /* shouldn't occur */
+
+ /* req_repmsg equals rq_reply_state->rs_msg,
+ * so set it to NULL before rq_reply_state is possibly freed
+ */
+ spin_lock(&req->rq_early_free_lock);
+ req->rq_repmsg = NULL;
+ spin_unlock(&req->rq_early_free_lock);
+
+ ptlrpc_rs_decref(req->rq_reply_state);
+ req->rq_reply_state = NULL;
}
static inline __u32 lustre_request_magic(struct ptlrpc_request *req)
GOTO(out_free, rc = -ENOMEM);
*reqcopy = *req;
+ spin_lock_init(&reqcopy->rq_early_free_lock);
reqcopy->rq_reply_state = NULL;
reqcopy->rq_rep_swab_mask = 0;
reqcopy->rq_pack_bulk = 0;