1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
37 #define DEBUG_SUBSYSTEM S_RPC
39 #include <liblustre.h>
41 #include <obd_support.h>
42 #include <lustre_net.h>
43 #include <lustre_lib.h>
45 #include "ptlrpc_internal.h"
47 static int ptl_send_buf (lnet_handle_md_t *mdh, void *base, int len,
48 lnet_ack_req_t ack, struct ptlrpc_cb_id *cbid,
49 struct ptlrpc_connection *conn, int portal, __u64 xid,
56 LASSERT (portal != 0);
57 LASSERT (conn != NULL);
58 CDEBUG (D_INFO, "conn=%p id %s\n", conn, libcfs_id2str(conn->c_peer));
61 md.threshold = (ack == LNET_ACK_REQ) ? 2 : 1;
62 md.options = PTLRPC_MD_OPTIONS;
64 md.eq_handle = ptlrpc_eq_h;
66 if (ack == LNET_ACK_REQ &&
67 OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_ACK | OBD_FAIL_ONCE)) {
68 /* don't ask for the ack to simulate failing client */
70 obd_fail_loc |= OBD_FAIL_ONCE | OBD_FAILED;
73 rc = LNetMDBind (md, LNET_UNLINK, mdh);
75 CERROR ("LNetMDBind failed: %d\n", rc);
76 LASSERT (rc == -ENOMEM);
80 CDEBUG(D_NET, "Sending %d bytes to portal %d, xid "LPD64", offset %u\n",
81 len, portal, xid, offset);
83 rc = LNetPut (conn->c_self, *mdh, ack,
84 conn->c_peer, portal, xid, offset, 0);
87 /* We're going to get an UNLINK event when I unlink below,
88 * which will complete just like any other failed send, so
89 * I fall through and return success here! */
90 CERROR("LNetPut(%s, %d, "LPD64") failed: %d\n",
91 libcfs_id2str(conn->c_peer), portal, xid, rc);
92 rc2 = LNetMDUnlink(*mdh);
93 LASSERTF(rc2 == 0, "rc2 = %d\n", rc2);
99 int ptlrpc_start_bulk_transfer(struct ptlrpc_bulk_desc *desc)
101 struct ptlrpc_connection *conn = desc->bd_export->exp_connection;
108 if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_PTLRPC_BULK_PUT_NET))
111 /* NB no locking required until desc is on the network */
112 LASSERT (!desc->bd_network_rw);
113 LASSERT (desc->bd_type == BULK_PUT_SOURCE ||
114 desc->bd_type == BULK_GET_SINK);
115 desc->bd_success = 0;
116 desc->bd_sender = LNET_NID_ANY;
118 md.user_ptr = &desc->bd_cbid;
119 md.eq_handle = ptlrpc_eq_h;
120 md.threshold = 2; /* SENT and ACK/REPLY */
121 md.options = PTLRPC_MD_OPTIONS;
122 ptlrpc_fill_bulk_md(&md, desc);
124 LASSERT (desc->bd_cbid.cbid_fn == server_bulk_callback);
125 LASSERT (desc->bd_cbid.cbid_arg == desc);
127 /* NB total length may be 0 for a read past EOF, so we send a 0
128 * length bulk, since the client expects a bulk event. */
130 rc = LNetMDBind(md, LNET_UNLINK, &desc->bd_md_h);
132 CERROR("LNetMDBind failed: %d\n", rc);
133 LASSERT (rc == -ENOMEM);
137 /* Client's bulk and reply matchbits are the same */
138 xid = desc->bd_req->rq_xid;
139 CDEBUG(D_NET, "Transferring %u pages %u bytes via portal %d "
140 "id %s xid "LPX64"\n", desc->bd_iov_count,
141 desc->bd_nob, desc->bd_portal,
142 libcfs_id2str(conn->c_peer), xid);
144 /* Network is about to get at the memory */
145 desc->bd_network_rw = 1;
147 if (desc->bd_type == BULK_PUT_SOURCE)
148 rc = LNetPut (conn->c_self, desc->bd_md_h, LNET_ACK_REQ,
149 conn->c_peer, desc->bd_portal, xid, 0, 0);
151 rc = LNetGet (conn->c_self, desc->bd_md_h,
152 conn->c_peer, desc->bd_portal, xid, 0);
155 /* Can't send, so we unlink the MD bound above. The UNLINK
156 * event this creates will signal completion with failure,
157 * so we return SUCCESS here! */
158 CERROR("Transfer(%s, %d, "LPX64") failed: %d\n",
159 libcfs_id2str(conn->c_peer), desc->bd_portal, xid, rc);
160 rc2 = LNetMDUnlink(desc->bd_md_h);
167 /* Server side bulk abort. Idempotent. Not thread-safe (i.e. only
168 * serialises with completion callback) */
169 void ptlrpc_abort_bulk(struct ptlrpc_bulk_desc *desc)
171 struct l_wait_info lwi;
174 LASSERT(!in_interrupt()); /* might sleep */
176 if (!ptlrpc_server_bulk_active(desc)) /* completed or */
177 return; /* never started */
179 /* Do not send any meaningful data over the wire for evicted clients */
180 if (desc->bd_export && desc->bd_export->exp_failed)
181 ptl_rpc_wipe_bulk_pages(desc);
183 /* The unlink ensures the callback happens ASAP and is the last
184 * one. If it fails, it must be because completion just happened,
185 * but we must still l_wait_event() in this case, to give liblustre
186 * a chance to run server_bulk_callback()*/
188 LNetMDUnlink(desc->bd_md_h);
191 /* Network access will complete in finite time but the HUGE
192 * timeout lets us CWARN for visibility of sluggish NALs */
193 lwi = LWI_TIMEOUT_INTERVAL(cfs_time_seconds(LONG_UNLINK),
194 cfs_time_seconds(1), NULL, NULL);
195 rc = l_wait_event(desc->bd_waitq,
196 !ptlrpc_server_bulk_active(desc), &lwi);
200 LASSERT(rc == -ETIMEDOUT);
201 CWARN("Unexpectedly long timeout: desc %p\n", desc);
205 int ptlrpc_register_bulk(struct ptlrpc_request *req)
207 struct ptlrpc_bulk_desc *desc = req->rq_bulk;
208 lnet_process_id_t peer;
211 lnet_handle_me_t me_h;
215 if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_PTLRPC_BULK_GET_NET))
218 /* NB no locking required until desc is on the network */
219 LASSERT (desc->bd_nob > 0);
220 LASSERT (!desc->bd_network_rw);
221 LASSERT (desc->bd_iov_count <= PTLRPC_MAX_BRW_PAGES);
222 LASSERT (desc->bd_req != NULL);
223 LASSERT (desc->bd_type == BULK_PUT_SINK ||
224 desc->bd_type == BULK_GET_SOURCE);
226 desc->bd_success = 0;
227 desc->bd_sender = LNET_NID_ANY;
229 peer = desc->bd_import->imp_connection->c_peer;
231 md.user_ptr = &desc->bd_cbid;
232 md.eq_handle = ptlrpc_eq_h;
233 md.threshold = 1; /* PUT or GET */
234 md.options = PTLRPC_MD_OPTIONS |
235 ((desc->bd_type == BULK_GET_SOURCE) ?
236 LNET_MD_OP_GET : LNET_MD_OP_PUT);
237 ptlrpc_fill_bulk_md(&md, desc);
239 LASSERT (desc->bd_cbid.cbid_fn == client_bulk_callback);
240 LASSERT (desc->bd_cbid.cbid_arg == desc);
242 /* XXX Registering the same xid on retried bulk makes my head
243 * explode trying to understand how the original request's bulk
244 * might interfere with the retried request -eeb
245 * On the other hand replaying with the same xid is fine, since
246 * we are guaranteed old request have completed. -green */
247 LASSERTF(!(desc->bd_registered &&
248 req->rq_send_state != LUSTRE_IMP_REPLAY) ||
249 req->rq_xid != desc->bd_last_xid,
250 "registered: %d rq_xid: "LPU64" bd_last_xid: "LPU64"\n",
251 desc->bd_registered, req->rq_xid, desc->bd_last_xid);
252 desc->bd_registered = 1;
253 desc->bd_last_xid = req->rq_xid;
255 rc = LNetMEAttach(desc->bd_portal, peer,
256 req->rq_xid, 0, LNET_UNLINK, LNET_INS_AFTER, &me_h);
258 CERROR("LNetMEAttach failed: %d\n", rc);
259 LASSERT (rc == -ENOMEM);
263 /* About to let the network at it... */
264 desc->bd_network_rw = 1;
265 rc = LNetMDAttach(me_h, md, LNET_UNLINK, &desc->bd_md_h);
267 CERROR("LNetMDAttach failed: %d\n", rc);
268 LASSERT (rc == -ENOMEM);
269 desc->bd_network_rw = 0;
270 rc2 = LNetMEUnlink (me_h);
275 CDEBUG(D_NET, "Setup bulk %s buffers: %u pages %u bytes, xid "LPU64", "
277 desc->bd_type == BULK_GET_SOURCE ? "get-source" : "put-sink",
278 desc->bd_iov_count, desc->bd_nob,
279 req->rq_xid, desc->bd_portal);
283 /* Disconnect a bulk desc from the network. Idempotent. Not
284 * thread-safe (i.e. only interlocks with completion callback). */
285 int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async)
287 struct ptlrpc_bulk_desc *desc = req->rq_bulk;
289 struct l_wait_info lwi;
293 LASSERT(!in_interrupt()); /* might sleep */
295 /* Let's setup deadline for reply unlink. */
296 if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_BULK_UNLINK) &&
297 async && req->rq_bulk_deadline == 0)
298 req->rq_bulk_deadline = cfs_time_current_sec() + LONG_UNLINK;
300 if (!ptlrpc_client_bulk_active(req)) /* completed or */
301 RETURN(1); /* never registered */
303 LASSERT(desc->bd_req == req); /* bd_req NULL until registered */
305 /* the unlink ensures the callback happens ASAP and is the last
306 * one. If it fails, it must be because completion just happened,
307 * but we must still l_wait_event() in this case to give liblustre
308 * a chance to run client_bulk_callback() */
310 LNetMDUnlink(desc->bd_md_h);
312 if (!ptlrpc_client_bulk_active(req)) /* completed or */
313 RETURN(1); /* never registered */
315 /* Move to "Unregistering" phase as bulk was not unlinked yet. */
316 ptlrpc_rqphase_move(req, RQ_PHASE_UNREGISTERING);
318 /* Do not wait for unlink to finish. */
322 if (req->rq_set != NULL)
323 wq = &req->rq_set->set_waitq;
325 wq = &req->rq_reply_waitq;
328 /* Network access will complete in finite time but the HUGE
329 * timeout lets us CWARN for visibility of sluggish NALs */
330 lwi = LWI_TIMEOUT_INTERVAL(cfs_time_seconds(LONG_UNLINK),
331 cfs_time_seconds(1), NULL, NULL);
332 rc = l_wait_event(*wq, !ptlrpc_client_bulk_active(req), &lwi);
334 ptlrpc_rqphase_move(req, req->rq_next_phase);
338 LASSERT(rc == -ETIMEDOUT);
339 DEBUG_REQ(D_WARNING, req, "Unexpectedly long timeout: desc %p",
345 int ptlrpc_send_reply(struct ptlrpc_request *req, int flags)
347 struct ptlrpc_service *svc = req->rq_rqbd->rqbd_service;
348 struct ptlrpc_reply_state *rs = req->rq_reply_state;
349 struct ptlrpc_connection *conn;
351 unsigned int offset = 0;
354 /* We must already have a reply buffer (only ptlrpc_error() may be
355 * called without one). We must also have a request buffer which
356 * is either the actual (swabbed) incoming request, or a saved copy
357 * if this is a req saved in target_queue_final_reply(). */
358 LASSERT (req->rq_reqmsg != NULL);
359 LASSERT (req->rq_repmsg != NULL);
360 LASSERT (rs != NULL);
361 LASSERT (req->rq_repmsg == rs->rs_msg);
362 LASSERT ((flags & PTLRPC_REPLY_MAYBE_DIFFICULT) || !rs->rs_difficult);
363 LASSERT (rs->rs_cb_id.cbid_fn == reply_out_callback);
364 LASSERT (rs->rs_cb_id.cbid_arg == rs);
366 /* There may be no rq_export during failover */
368 if (req->rq_export && req->rq_export->exp_obd &&
369 req->rq_export->exp_obd->obd_fail) {
370 /* Failed obd's only send ENODEV */
371 req->rq_type = PTL_RPC_MSG_ERR;
372 req->rq_status = -ENODEV;
373 CDEBUG(D_HA, "sending ENODEV from failed obd %d\n",
374 req->rq_export->exp_obd->obd_minor);
377 if (req->rq_type != PTL_RPC_MSG_ERR)
378 req->rq_type = PTL_RPC_MSG_REPLY;
380 lustre_msg_set_type(req->rq_repmsg, req->rq_type);
381 lustre_msg_set_status(req->rq_repmsg, req->rq_status);
382 lustre_msg_set_opc(req->rq_repmsg, lustre_msg_get_opc(req->rq_reqmsg));
384 service_time = max_t(int, cfs_time_current_sec() -
385 req->rq_arrival_time.tv_sec, 1);
386 if (!(flags & PTLRPC_REPLY_EARLY) &&
387 (req->rq_type != PTL_RPC_MSG_ERR) &&
388 !(lustre_msg_get_flags(req->rq_reqmsg) &
389 (MSG_RESENT | MSG_REPLAY | MSG_LAST_REPLAY))) {
390 /* early replies, errors and recovery requests don't count
391 * toward our service time estimate */
392 int oldse = at_add(&svc->srv_at_estimate, service_time);
394 DEBUG_REQ(D_ADAPTTO, req,
395 "svc %s changed estimate from %d to %d",
396 svc->srv_name, oldse,
397 at_get(&svc->srv_at_estimate));
399 /* Report actual service time for client latency calc */
400 lustre_msg_set_service_time(req->rq_repmsg, service_time);
401 /* Report service time estimate for future client reqs, but report 0
402 * (to be ignored by client) if it's a error reply during recovery.
404 if (req->rq_type == PTL_RPC_MSG_ERR &&
405 (req->rq_export == NULL || req->rq_export->exp_obd->obd_recovering))
406 lustre_msg_set_timeout(req->rq_repmsg, 0);
408 lustre_msg_set_timeout(req->rq_repmsg,
409 at_get(&svc->srv_at_estimate));
411 target_pack_pool_reply(req);
413 if (lustre_msghdr_get_flags(req->rq_reqmsg) & MSGHDR_AT_SUPPORT) {
414 /* early replies go to offset 0, regular replies go after that*/
415 if (flags & PTLRPC_REPLY_EARLY) {
417 /* Include a checksum on early replies - must be done
418 after all other lustre_msg_set_* */
419 lustre_msg_set_cksum(req->rq_repmsg,
420 lustre_msg_calc_cksum(req->rq_repmsg));
422 offset = lustre_msg_early_size(req);
425 CDEBUG(D_ADAPTTO, "No early reply support: flags=%#x "
426 "req_flags=%#x magic=%d:%x/%x len=%d\n",
427 flags, lustre_msg_get_flags(req->rq_reqmsg),
428 lustre_msg_is_v1(req->rq_reqmsg),
429 lustre_msg_get_magic(req->rq_reqmsg),
430 lustre_msg_get_magic(req->rq_repmsg), req->rq_replen);
433 if (req->rq_export == NULL || req->rq_export->exp_connection == NULL)
434 conn = ptlrpc_connection_get(req->rq_peer, req->rq_self, NULL);
436 conn = ptlrpc_connection_addref(req->rq_export->exp_connection);
439 CERROR("not replying on NULL connection\n"); /* bug 9635 */
443 atomic_inc (&svc->srv_outstanding_replies);
444 ptlrpc_rs_addref(rs); /* +1 ref for the network */
445 req->rq_sent = cfs_time_current_sec();
447 rc = ptl_send_buf (&rs->rs_md_h, req->rq_repmsg, req->rq_replen,
448 rs->rs_difficult ? LNET_ACK_REQ : LNET_NOACK_REQ,
449 &rs->rs_cb_id, conn, svc->srv_rep_portal,
450 req->rq_xid, offset);
452 atomic_dec (&svc->srv_outstanding_replies);
453 ptlrpc_req_drop_rs(req);
455 ptlrpc_connection_put(conn);
459 int ptlrpc_reply (struct ptlrpc_request *req)
461 return (ptlrpc_send_reply (req, 0));
464 int ptlrpc_send_error(struct ptlrpc_request *req, int may_be_difficult)
469 if (!req->rq_repmsg) {
470 rc = lustre_pack_reply(req, 1, NULL, NULL);
475 req->rq_type = PTL_RPC_MSG_ERR;
477 rc = ptlrpc_send_reply(req, may_be_difficult);
481 int ptlrpc_error(struct ptlrpc_request *req)
483 return ptlrpc_send_error(req, 0);
486 int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
490 struct ptlrpc_connection *connection;
491 lnet_handle_me_t reply_me_h;
493 struct obd_device *obd = request->rq_import->imp_obd;
496 OBD_FAIL_RETURN(OBD_FAIL_PTLRPC_DROP_RPC, 0);
498 LASSERT (request->rq_type == PTL_RPC_MSG_REQUEST);
500 /* If this is a re-transmit, we're required to have disengaged
501 * cleanly from the previous attempt */
502 LASSERT(!request->rq_receiving_reply);
504 if (request->rq_import->imp_obd &&
505 request->rq_import->imp_obd->obd_fail) {
506 CDEBUG(D_HA, "muting rpc for failed imp obd %s\n",
507 request->rq_import->imp_obd->obd_name);
508 /* this prevents us from waiting in ptlrpc_queue_wait */
510 request->rq_status = -ENODEV;
514 connection = request->rq_import->imp_connection;
516 if (request->rq_bulk != NULL) {
517 rc = ptlrpc_register_bulk (request);
522 lustre_msg_set_handle(request->rq_reqmsg,
523 &request->rq_import->imp_remote_handle);
524 lustre_msg_set_type(request->rq_reqmsg, PTL_RPC_MSG_REQUEST);
525 lustre_msg_set_conn_cnt(request->rq_reqmsg,
526 request->rq_import->imp_conn_cnt);
527 lustre_msghdr_set_flags(request->rq_reqmsg,
528 request->rq_import->imp_msghdr_flags);
530 if (request->rq_resend)
531 lustre_msg_add_flags(request->rq_reqmsg, MSG_RESENT);
534 LASSERT (request->rq_replen != 0);
535 if (request->rq_repbuf == NULL)
536 OBD_ALLOC(request->rq_repbuf, request->rq_replen);
537 if (request->rq_repbuf == NULL) {
538 /* this prevents us from looping in ptlrpc_queue_wait */
540 request->rq_status = -ENOMEM;
541 GOTO(cleanup_bulk, rc = -ENOMEM);
543 request->rq_repmsg = NULL;
545 rc = LNetMEAttach(request->rq_reply_portal,/*XXX FIXME bug 249*/
546 connection->c_peer, request->rq_xid, 0,
547 LNET_UNLINK, LNET_INS_AFTER, &reply_me_h);
549 CERROR("LNetMEAttach failed: %d\n", rc);
550 LASSERT (rc == -ENOMEM);
551 GOTO(cleanup_repmsg, rc = -ENOMEM);
555 spin_lock(&request->rq_lock);
556 /* If the MD attach succeeds, there _will_ be a reply_in callback */
557 request->rq_receiving_reply = !noreply;
558 /* We are responsible for unlinking the reply buffer */
559 request->rq_must_unlink = !noreply;
560 /* Clear any flags that may be present from previous sends. */
561 request->rq_replied = 0;
563 request->rq_timedout = 0;
564 request->rq_net_err = 0;
565 request->rq_resend = 0;
566 request->rq_restart = 0;
567 request->rq_rep_swab_mask = 0;
568 spin_unlock(&request->rq_lock);
571 reply_md.start = request->rq_repbuf;
572 reply_md.length = request->rq_replen;
573 /* Allow multiple early replies */
574 reply_md.threshold = LNET_MD_THRESH_INF;
575 /* Manage remote for early replies */
576 reply_md.options = PTLRPC_MD_OPTIONS | LNET_MD_OP_PUT |
577 LNET_MD_MANAGE_REMOTE;
578 reply_md.user_ptr = &request->rq_reply_cbid;
579 reply_md.eq_handle = ptlrpc_eq_h;
581 /* We must see the unlink callback to unset rq_must_unlink,
582 so we can't auto-unlink */
583 rc = LNetMDAttach(reply_me_h, reply_md, LNET_RETAIN,
584 &request->rq_reply_md_h);
586 CERROR("LNetMDAttach failed: %d\n", rc);
587 LASSERT (rc == -ENOMEM);
588 spin_lock(&request->rq_lock);
589 /* ...but the MD attach didn't succeed... */
590 request->rq_receiving_reply = 0;
591 spin_unlock(&request->rq_lock);
592 GOTO(cleanup_me, rc = -ENOMEM);
595 CDEBUG(D_NET, "Setup reply buffer: %u bytes, xid "LPU64
597 request->rq_replen, request->rq_xid,
598 request->rq_reply_portal);
601 /* add references on request for request_out_callback */
602 ptlrpc_request_addref(request);
603 if (obd->obd_svc_stats != NULL)
604 lprocfs_counter_add(obd->obd_svc_stats, PTLRPC_REQACTIVE_CNTR,
605 request->rq_import->imp_inflight.counter);
607 OBD_FAIL_TIMEOUT(OBD_FAIL_PTLRPC_DELAY_SEND, request->rq_timeout + 5);
609 request->rq_sent = cfs_time_current_sec();
610 do_gettimeofday(&request->rq_arrival_time);
611 /* We give the server rq_timeout secs to process the req, and
612 add the network latency for our local timeout. */
613 request->rq_deadline = request->rq_sent + request->rq_timeout +
614 ptlrpc_at_get_net_latency(request);
616 ptlrpc_pinger_sending_on_import(request->rq_import);
618 DEBUG_REQ(D_INFO, request, "send flg=%x",
619 lustre_msg_get_flags(request->rq_reqmsg));
620 rc = ptl_send_buf(&request->rq_req_md_h,
621 request->rq_reqmsg, request->rq_reqlen,
622 LNET_NOACK_REQ, &request->rq_req_cbid,
624 request->rq_request_portal,
629 ptlrpc_req_finished(request);
634 /* MEUnlink is safe; the PUT didn't even get off the ground, and
635 * nobody apart from the PUT's target has the right nid+XID to
636 * access the reply buffer. */
637 rc2 = LNetMEUnlink(reply_me_h);
639 /* UNLINKED callback called synchronously */
640 LASSERT(!request->rq_receiving_reply);
643 OBD_FREE(request->rq_repbuf, request->rq_replen);
644 request->rq_repbuf = NULL;
645 request->rq_repmsg = NULL; //remove
648 /* We do sync unlink here as there was no real transfer here so
649 * the chance to have long unlink to sluggish net is smaller here. */
650 ptlrpc_unregister_bulk(request, 0);
654 int ptlrpc_register_rqbd(struct ptlrpc_request_buffer_desc *rqbd)
656 struct ptlrpc_service *service = rqbd->rqbd_service;
657 static lnet_process_id_t match_id = {LNET_NID_ANY, LNET_PID_ANY};
660 lnet_handle_me_t me_h;
662 CDEBUG(D_NET, "LNetMEAttach: portal %d\n",
663 service->srv_req_portal);
665 if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_PTLRPC_RQBD))
668 rc = LNetMEAttach(service->srv_req_portal,
669 match_id, 0, ~0, LNET_UNLINK, LNET_INS_AFTER, &me_h);
671 CERROR("LNetMEAttach failed: %d\n", rc);
675 LASSERT(rqbd->rqbd_refcount == 0);
676 rqbd->rqbd_refcount = 1;
678 md.start = rqbd->rqbd_buffer;
679 md.length = service->srv_buf_size;
680 md.max_size = service->srv_max_req_size;
681 md.threshold = LNET_MD_THRESH_INF;
682 md.options = PTLRPC_MD_OPTIONS | LNET_MD_OP_PUT | LNET_MD_MAX_SIZE;
683 md.user_ptr = &rqbd->rqbd_cbid;
684 md.eq_handle = ptlrpc_eq_h;
686 rc = LNetMDAttach(me_h, md, LNET_UNLINK, &rqbd->rqbd_md_h);
690 CERROR("LNetMDAttach failed: %d; \n", rc);
691 LASSERT (rc == -ENOMEM);
692 rc = LNetMEUnlink (me_h);
694 rqbd->rqbd_refcount = 0;