DEBUG_REQ(D_NET, req, "type %d, status %d", ev->type, ev->status);
sptlrpc_request_out_callback(req);
+ spin_lock(&req->rq_lock);
req->rq_real_sent = cfs_time_current_sec();
+ if (ev->unlinked)
+ req->rq_req_unlink = 0;
if (ev->type == LNET_EVENT_UNLINK || ev->status != 0) {
/* Failed send: make it seem like the reply timed out, just
* like failing sends in client.c does currently... */
- spin_lock(&req->rq_lock);
req->rq_net_err = 1;
- spin_unlock(&req->rq_lock);
-
ptlrpc_client_wake_req(req);
}
+ spin_unlock(&req->rq_lock);
ptlrpc_req_finished(req);
req->rq_receiving_reply = 0;
req->rq_early = 0;
if (ev->unlinked)
- req->rq_must_unlink = 0;
+ req->rq_reply_unlink = 0;
if (ev->status)
goto out_wake;
/* Real reply */
req->rq_rep_swab_mask = 0;
req->rq_replied = 1;
+ /* Got reply, no resend required */
+ req->rq_resend = 0;
req->rq_reply_off = ev->offset;
req->rq_nob_received = ev->mlength;
/* LNetMDUnlink can't be called under the LNET_LOCK,
req->rq_history_seq = new_seq;
- cfs_list_add_tail(&req->rq_history_list, &svcpt->scp_hist_reqs);
+ list_add_tail(&req->rq_history_list, &svcpt->scp_hist_reqs);
}
/*
/* We moaned above already... */
return;
}
- OBD_ALLOC_GFP(req, sizeof(*req), CFS_ALLOC_ATOMIC_TRY);
+ req = ptlrpc_request_cache_alloc(ALLOC_ATOMIC_TRY);
if (req == NULL) {
CERROR("Can't allocate incoming request descriptor: "
"Dropping %s RPC from %s\n",
* size to non-zero if this was a successful receive. */
req->rq_xid = ev->match_bits;
req->rq_reqbuf = ev->md.start + ev->offset;
- if (ev->type == LNET_EVENT_PUT && ev->status == 0)
- req->rq_reqdata_len = ev->mlength;
- cfs_gettimeofday(&req->rq_arrival_time);
- req->rq_peer = ev->initiator;
- req->rq_self = ev->target.nid;
- req->rq_rqbd = rqbd;
+ if (ev->type == LNET_EVENT_PUT && ev->status == 0)
+ req->rq_reqdata_len = ev->mlength;
+ do_gettimeofday(&req->rq_arrival_time);
+ req->rq_peer = ev->initiator;
+ req->rq_self = ev->target.nid;
+ req->rq_rqbd = rqbd;
req->rq_phase = RQ_PHASE_NEW;
spin_lock_init(&req->rq_lock);
- CFS_INIT_LIST_HEAD(&req->rq_timed_list);
- CFS_INIT_LIST_HEAD(&req->rq_exp_list);
- cfs_atomic_set(&req->rq_refcount, 1);
- if (ev->type == LNET_EVENT_PUT)
- CDEBUG(D_INFO, "incoming req@%p x"LPU64" msgsize %u\n",
- req, req->rq_xid, ev->mlength);
+ INIT_LIST_HEAD(&req->rq_timed_list);
+ INIT_LIST_HEAD(&req->rq_exp_list);
+ atomic_set(&req->rq_refcount, 1);
+ if (ev->type == LNET_EVENT_PUT)
+ CDEBUG(D_INFO, "incoming req@%p x"LPU64" msgsize %u\n",
+ req, req->rq_xid, ev->mlength);
- CDEBUG(D_RPCTRACE, "peer: %s\n", libcfs_id2str(req->rq_peer));
+ CDEBUG(D_RPCTRACE, "peer: %s\n", libcfs_id2str(req->rq_peer));
spin_lock(&svcpt->scp_lock);
rqbd->rqbd_refcount++;
}
- cfs_list_add_tail(&req->rq_list, &svcpt->scp_req_incoming);
+ list_add_tail(&req->rq_list, &svcpt->scp_req_incoming);
svcpt->scp_nreqs_incoming++;
/* NB everything can disappear under us once the request
* has been queued and we unlock, so do the wake now... */
- cfs_waitq_signal(&svcpt->scp_waitq);
+ wake_up(&svcpt->scp_waitq);
spin_unlock(&svcpt->scp_lock);
EXIT;
desc->bd_md_count--;
/* This is the last callback no matter what... */
if (desc->bd_md_count == 0)
- cfs_waitq_signal(&desc->bd_waitq);
+ wake_up(&desc->bd_waitq);
}
spin_unlock(&desc->bd_lock);
void ptlrpc_ni_fini(void)
{
- cfs_waitq_t waitq;
- struct l_wait_info lwi;
- int rc;
- int retries;
-
- /* Wait for the event queue to become idle since there may still be
- * messages in flight with pending events (i.e. the fire-and-forget
- * messages == client requests and "non-difficult" server
- * replies */
-
- for (retries = 0;; retries++) {
- rc = LNetEQFree(ptlrpc_eq_h);
- switch (rc) {
- default:
- LBUG();
-
- case 0:
- LNetNIFini();
- return;
-
- case -EBUSY:
- if (retries != 0)
- CWARN("Event queue still busy\n");
-
- /* Wait for a bit */
- cfs_waitq_init(&waitq);
- lwi = LWI_TIMEOUT(cfs_time_seconds(2), NULL, NULL);
- l_wait_event(waitq, 0, &lwi);
- break;
- }
- }
- /* notreached */
+ wait_queue_head_t waitq;
+ struct l_wait_info lwi;
+ int rc;
+ int retries;
+
+ /* Wait for the event queue to become idle since there may still be
+ * messages in flight with pending events (i.e. the fire-and-forget
+ * messages == client requests and "non-difficult" server
+ * replies */
+
+ for (retries = 0;; retries++) {
+ rc = LNetEQFree(ptlrpc_eq_h);
+ switch (rc) {
+ default:
+ LBUG();
+
+ case 0:
+ LNetNIFini();
+ return;
+
+ case -EBUSY:
+ if (retries != 0)
+ CWARN("Event queue still busy\n");
+
+ /* Wait for a bit */
+ init_waitqueue_head(&waitq);
+ lwi = LWI_TIMEOUT(cfs_time_seconds(2), NULL, NULL);
+ l_wait_event(waitq, 0, &lwi);
+ break;
+ }
+ }
+ /* notreached */
}
lnet_pid_t ptl_get_pid(void)
rc = LNetNIInit(pid);
if (rc < 0) {
CDEBUG (D_NET, "Can't init network interface: %d\n", rc);
- return (-ENOENT);
+ return rc;
}
/* CAVEAT EMPTOR: how we process portals events is _radically_
CERROR ("Failed to allocate event queue: %d\n", rc);
LNetNIFini();
- return (-ENOMEM);
+ return rc;
}
#ifndef __KERNEL__
-CFS_LIST_HEAD(liblustre_wait_callbacks);
-CFS_LIST_HEAD(liblustre_idle_callbacks);
+struct list_head liblustre_wait_callbacks;
+struct list_head liblustre_idle_callbacks;
void *liblustre_services_callback;
void *
-liblustre_register_waitidle_callback (cfs_list_t *callback_list,
- const char *name,
- int (*fn)(void *arg), void *arg)
+liblustre_register_waitidle_callback(struct list_head *callback_list,
+ const char *name,
+ int (*fn)(void *arg), void *arg)
{
struct liblustre_wait_callback *llwc;
llwc->llwc_name = name;
llwc->llwc_fn = fn;
llwc->llwc_arg = arg;
- cfs_list_add_tail(&llwc->llwc_list, callback_list);
+ list_add_tail(&llwc->llwc_list, callback_list);
return (llwc);
}
void
liblustre_deregister_waitidle_callback (void *opaque)
{
- struct liblustre_wait_callback *llwc = opaque;
+ struct liblustre_wait_callback *llwc = opaque;
- cfs_list_del(&llwc->llwc_list);
- OBD_FREE(llwc, sizeof(*llwc));
+ list_del(&llwc->llwc_list);
+ OBD_FREE(llwc, sizeof(*llwc));
}
void *
int
liblustre_wait_event (int timeout)
{
- cfs_list_t *tmp;
+ struct list_head *tmp;
struct liblustre_wait_callback *llwc;
int found_something = 0;
found_something = 1;
/* Give all registered callbacks a bite at the cherry */
- cfs_list_for_each(tmp, &liblustre_wait_callbacks) {
- llwc = cfs_list_entry(tmp,
+ list_for_each(tmp, &liblustre_wait_callbacks) {
+ llwc = list_entry(tmp,
struct liblustre_wait_callback,
llwc_list);
liblustre_wait_idle(void)
{
static int recursed = 0;
-
- cfs_list_t *tmp;
- struct liblustre_wait_callback *llwc;
- int idle = 0;
+ struct list_head *tmp;
+ struct liblustre_wait_callback *llwc;
+ int idle = 0;
LASSERT(!recursed);
recursed = 1;
idle = 1;
- cfs_list_for_each(tmp, &liblustre_idle_callbacks) {
- llwc = cfs_list_entry(tmp,
- struct liblustre_wait_callback,
- llwc_list);
-
+ list_for_each(tmp, &liblustre_idle_callbacks) {
+ llwc = list_entry(tmp, struct liblustre_wait_callback,
+ llwc_list);
if (!llwc->llwc_fn(llwc->llwc_arg)) {
idle = 0;
break;
if (rc != 0) {
CERROR("network initialisation failed\n");
- return -EIO;
+ return rc;
}
#ifndef __KERNEL__
+ INIT_LIST_HEAD(&liblustre_wait_callbacks);
+ INIT_LIST_HEAD(&liblustre_idle_callbacks);
+
liblustre_services_callback =
liblustre_register_wait_callback("liblustre_check_services",
&liblustre_check_services,