EXPORT_SYMBOL(ptlrpc_prep_req);
/**
- * Allocate "fake" request that would not be sent anywhere in the end.
- * Only used as a hack because we have no other way of performing
- * async actions in lustre between layers.
- * Used on MDS to request object preallocations from more than one OST at a
- * time.
- */
-struct ptlrpc_request *ptlrpc_prep_fakereq(struct obd_import *imp,
- unsigned int timeout,
- ptlrpc_interpterer_t interpreter)
-{
- struct ptlrpc_request *request = NULL;
- ENTRY;
-
- OBD_ALLOC(request, sizeof(*request));
- if (!request) {
- CERROR("request allocation out of memory\n");
- RETURN(NULL);
- }
-
- request->rq_send_state = LUSTRE_IMP_FULL;
- request->rq_type = PTL_RPC_MSG_REQUEST;
- request->rq_import = class_import_get(imp);
- request->rq_export = NULL;
- request->rq_import_generation = imp->imp_generation;
-
- request->rq_timeout = timeout;
- request->rq_sent = cfs_time_current_sec();
- request->rq_deadline = request->rq_sent + timeout;
- request->rq_reply_deadline = request->rq_deadline;
- request->rq_interpret_reply = interpreter;
- request->rq_phase = RQ_PHASE_RPC;
- request->rq_next_phase = RQ_PHASE_INTERPRET;
- /* don't want reply */
- request->rq_receiving_reply = 0;
- request->rq_must_unlink = 0;
- request->rq_no_delay = request->rq_no_resend = 1;
- request->rq_fake = 1;
-
- cfs_spin_lock_init(&request->rq_lock);
- CFS_INIT_LIST_HEAD(&request->rq_list);
- CFS_INIT_LIST_HEAD(&request->rq_replay_list);
- CFS_INIT_LIST_HEAD(&request->rq_set_chain);
- CFS_INIT_LIST_HEAD(&request->rq_history_list);
- CFS_INIT_LIST_HEAD(&request->rq_exp_list);
- cfs_waitq_init(&request->rq_reply_waitq);
- cfs_waitq_init(&request->rq_set_waitq);
-
- request->rq_xid = ptlrpc_next_xid();
- cfs_atomic_set(&request->rq_refcount, 1);
-
- RETURN(request);
-}
-EXPORT_SYMBOL(ptlrpc_prep_fakereq);
-
-/**
- * Indicate that processing of "fake" request is finished.
- */
-void ptlrpc_fakereq_finished(struct ptlrpc_request *req)
-{
- struct ptlrpc_request_set *set = req->rq_set;
- int wakeup = 0;
-
- /* hold ref on the request to prevent others (ptlrpcd) to free it */
- ptlrpc_request_addref(req);
- cfs_list_del_init(&req->rq_list);
-
- /* if we kill request before timeout - need adjust counter */
- if (req->rq_phase == RQ_PHASE_RPC && set != NULL &&
- cfs_atomic_dec_and_test(&set->set_remaining))
- wakeup = 1;
-
- ptlrpc_rqphase_move(req, RQ_PHASE_COMPLETE);
-
- /* Only need to call wakeup once when to be empty. */
- if (wakeup)
- cfs_waitq_signal(&set->set_waitq);
- ptlrpc_req_finished(req);
-}
-EXPORT_SYMBOL(ptlrpc_fakereq_finished);
-
-/**
* Allocate and initialize new request set structure.
* Returns a pointer to the newly allocated set structure or NULL on error.
*/
__u32 opc;
int err;
- /* Fake requests include no rq_reqmsg */
- if (req->rq_fake)
- return 0;
-
LASSERT(req->rq_reqmsg != NULL);
opc = lustre_msg_get_opc(req->rq_reqmsg);
req->rq_timedout = 1;
cfs_spin_unlock(&req->rq_lock);
- DEBUG_REQ(req->rq_fake ? D_INFO : D_WARNING, req, "Request "
- " sent has %s: [sent "CFS_DURATION_T"/"
- "real "CFS_DURATION_T"]",
+ DEBUG_REQ(D_WARNING, req, "Request sent has %s: [sent "CFS_DURATION_T
+ "/real "CFS_DURATION_T"]",
req->rq_net_err ? "failed due to network error" :
((req->rq_real_sent == 0 ||
cfs_time_before(req->rq_real_sent, req->rq_sent) ||
RETURN(1);
}
- if (req->rq_fake)
- RETURN(1);
-
cfs_atomic_inc(&imp->imp_timeouts);
/* The DLM server doesn't want recovery run on its imports. */