-void server_bulk_callback (lnet_event_t *ev)
-{
- struct ptlrpc_cb_id *cbid = ev->md.user_ptr;
- struct ptlrpc_bulk_desc *desc = cbid->cbid_arg;
- ENTRY;
-
- LASSERT (ev->type == LNET_EVENT_SEND ||
- ev->type == LNET_EVENT_UNLINK ||
- (desc->bd_type == BULK_PUT_SOURCE &&
- ev->type == LNET_EVENT_ACK) ||
- (desc->bd_type == BULK_GET_SINK &&
- ev->type == LNET_EVENT_REPLY));
-
- CDEBUG((ev->status == 0) ? D_NET : D_ERROR,
- "event type %d, status %d, desc %p\n",
- ev->type, ev->status, desc);
-
- spin_lock(&desc->bd_lock);
-
- if ((ev->type == LNET_EVENT_ACK ||
- ev->type == LNET_EVENT_REPLY) &&
- ev->status == 0) {
- /* We heard back from the peer, so even if we get this
- * before the SENT event (oh yes we can), we know we
- * read/wrote the peer buffer and how much... */
- desc->bd_success = 1;
- desc->bd_nob_transferred = ev->mlength;
- desc->bd_sender = ev->sender;
- }
-
- if (ev->unlinked) {
- /* This is the last callback no matter what... */
- desc->bd_network_rw = 0;
- cfs_waitq_signal(&desc->bd_waitq);
- }
-
- spin_unlock(&desc->bd_lock);
- EXIT;
-}
-
-static void ptlrpc_master_callback(lnet_event_t *ev)
-{
- struct ptlrpc_cb_id *cbid = ev->md.user_ptr;
- void (*callback)(lnet_event_t *ev) = cbid->cbid_fn;
-
- /* Honestly, it's best to find out early. */
- LASSERT (cbid->cbid_arg != LP_POISON);
- LASSERT (callback == request_out_callback ||
- callback == reply_in_callback ||
- callback == client_bulk_callback ||
- callback == request_in_callback ||
- callback == reply_out_callback ||
- callback == server_bulk_callback);
-
- callback (ev);
-}
-
-int ptlrpc_uuid_to_peer (struct obd_uuid *uuid,
- lnet_process_id_t *peer, lnet_nid_t *self)
-{
- int best_dist = 0;
- int best_order = 0;
- int count = 0;
- int rc = -ENOENT;
- int portals_compatibility;
- int dist;
- int order;
- lnet_nid_t dst_nid;
- lnet_nid_t src_nid;
-
- portals_compatibility = LNetCtl(IOC_LIBCFS_PORTALS_COMPATIBILITY, NULL);
-
- peer->pid = LUSTRE_SRV_LNET_PID;
-
- /* Choose the matching UUID that's closest */
- while (lustre_uuid_to_peer(uuid->uuid, &dst_nid, count++) == 0) {
- dist = LNetDist(dst_nid, &src_nid, &order);
- if (dist < 0)
- continue;
-
- if (dist == 0) { /* local! use loopback LND */
- peer->nid = *self = LNET_MKNID(LNET_MKNET(LOLND, 0), 0);
- rc = 0;
- break;
- }
-
- LASSERT (order >= 0);
- if (rc < 0 ||
- dist < best_dist ||
- (dist == best_dist && order < best_order)) {
- best_dist = dist;
- best_order = order;
-
- if (portals_compatibility > 1) {
- /* Strong portals compatibility: Zero the nid's
- * NET, so if I'm reading new config logs, or
- * getting configured by (new) lconf I can
- * still talk to old servers. */
- dst_nid = LNET_MKNID(0, LNET_NIDADDR(dst_nid));
- src_nid = LNET_MKNID(0, LNET_NIDADDR(src_nid));
- }
- peer->nid = dst_nid;
- *self = src_nid;
- rc = 0;
- }
- }
-
- CDEBUG(D_NET,"%s->%s\n", uuid->uuid, libcfs_id2str(*peer));
- if (rc != 0)
- CERROR("No NID found for %s\n", uuid->uuid);
- return rc;
-}
-
-void ptlrpc_ni_fini(void)