- struct ptlrpc_request *copy_req;
- struct lustre_msg *copy_reqmsg;
- struct ptlrpc_user_desc *udesc = NULL;
-
- OBD_ALLOC_PTR(copy_req);
- if (!copy_req)
- return NULL;
- OBD_ALLOC(copy_reqmsg, orig_req->rq_reqlen);
- if (!copy_reqmsg){
- OBD_FREE_PTR(copy_req);
- return NULL;
- }
-
- if (orig_req->rq_user_desc) {
- int ngroups = orig_req->rq_user_desc->pud_ngroups;
-
- OBD_ALLOC(udesc, sptlrpc_user_desc_size(ngroups));
- if (!udesc) {
- OBD_FREE(copy_reqmsg, orig_req->rq_reqlen);
- OBD_FREE_PTR(copy_req);
- return NULL;
- }
- memcpy(udesc, orig_req->rq_user_desc,
- sptlrpc_user_desc_size(ngroups));
- }
-
- *copy_req = *orig_req;
- memcpy(copy_reqmsg, orig_req->rq_reqmsg, orig_req->rq_reqlen);
- copy_req->rq_reqmsg = copy_reqmsg;
- copy_req->rq_user_desc = udesc;
-
- class_export_rpc_get(copy_req->rq_export);
- CFS_INIT_LIST_HEAD(©_req->rq_list);
- CFS_INIT_LIST_HEAD(©_req->rq_replay_list);
- sptlrpc_svc_ctx_addref(copy_req);
-
- if (copy_req->rq_reply_state) {
- /* the copied req takes over the reply state */
- orig_req->rq_reply_state = NULL;
- /* to catch further access */
- orig_req->rq_repmsg = NULL;
- orig_req->rq_replen = 0;
- }
+ class_export_rpc_get(req->rq_export);
+ LASSERT(list_empty(&req->rq_list));
+ CFS_INIT_LIST_HEAD(&req->rq_replay_list);
+ /* increase refcount to keep request in queue */
+ LASSERT(atomic_read(&req->rq_refcount));
+ atomic_inc(&req->rq_refcount);