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 (c) 2002, 2010, Oracle and/or its affiliates. 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 /* We used to poison the pages with 0xab here because we did not want to
180 * send any meaningful data over the wire for evicted clients (bug 9297)
181 * However, this is no longer safe now that we use the page cache on the
184 /* The unlink ensures the callback happens ASAP and is the last
185 * one. If it fails, it must be because completion just happened,
186 * but we must still l_wait_event() in this case, to give liblustre
187 * a chance to run server_bulk_callback()*/
189 LNetMDUnlink(desc->bd_md_h);
192 /* Network access will complete in finite time but the HUGE
193 * timeout lets us CWARN for visibility of sluggish NALs */
194 lwi = LWI_TIMEOUT_INTERVAL(cfs_time_seconds(LONG_UNLINK),
195 cfs_time_seconds(1), NULL, NULL);
196 rc = l_wait_event(desc->bd_waitq,
197 !ptlrpc_server_bulk_active(desc), &lwi);
201 LASSERT(rc == -ETIMEDOUT);
202 CWARN("Unexpectedly long timeout: desc %p\n", desc);
206 int ptlrpc_register_bulk(struct ptlrpc_request *req)
208 struct ptlrpc_bulk_desc *desc = req->rq_bulk;
209 lnet_process_id_t peer;
212 lnet_handle_me_t me_h;
216 if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_PTLRPC_BULK_GET_NET))
219 /* NB no locking required until desc is on the network */
220 LASSERT (desc->bd_nob > 0);
221 LASSERT (!desc->bd_network_rw);
222 LASSERT (desc->bd_iov_count <= PTLRPC_MAX_BRW_PAGES);
223 LASSERT (desc->bd_req != NULL);
224 LASSERT (desc->bd_type == BULK_PUT_SINK ||
225 desc->bd_type == BULK_GET_SOURCE);
227 desc->bd_success = 0;
228 desc->bd_sender = LNET_NID_ANY;
230 peer = desc->bd_import->imp_connection->c_peer;
232 md.user_ptr = &desc->bd_cbid;
233 md.eq_handle = ptlrpc_eq_h;
234 md.threshold = 1; /* PUT or GET */
235 md.options = PTLRPC_MD_OPTIONS |
236 ((desc->bd_type == BULK_GET_SOURCE) ?
237 LNET_MD_OP_GET : LNET_MD_OP_PUT);
238 ptlrpc_fill_bulk_md(&md, desc);
240 LASSERT (desc->bd_cbid.cbid_fn == client_bulk_callback);
241 LASSERT (desc->bd_cbid.cbid_arg == desc);
243 /* XXX Registering the same xid on retried bulk makes my head
244 * explode trying to understand how the original request's bulk
245 * might interfere with the retried request -eeb
246 * On the other hand replaying with the same xid is fine, since
247 * we are guaranteed old request have completed. -green */
248 LASSERTF(!(desc->bd_registered &&
249 req->rq_send_state != LUSTRE_IMP_REPLAY) ||
250 req->rq_xid != desc->bd_last_xid,
251 "registered: %d rq_xid: "LPU64" bd_last_xid: "LPU64"\n",
252 desc->bd_registered, req->rq_xid, desc->bd_last_xid);
253 desc->bd_registered = 1;
254 desc->bd_last_xid = req->rq_xid;
256 rc = LNetMEAttach(desc->bd_portal, peer,
257 req->rq_xid, 0, LNET_UNLINK, LNET_INS_AFTER, &me_h);
259 CERROR("LNetMEAttach failed: %d\n", rc);
260 LASSERT (rc == -ENOMEM);
264 /* About to let the network at it... */
265 desc->bd_network_rw = 1;
266 rc = LNetMDAttach(me_h, md, LNET_UNLINK, &desc->bd_md_h);
268 CERROR("LNetMDAttach failed: %d\n", rc);
269 LASSERT (rc == -ENOMEM);
270 desc->bd_network_rw = 0;
271 rc2 = LNetMEUnlink (me_h);
276 CDEBUG(D_NET, "Setup bulk %s buffers: %u pages %u bytes, xid "LPU64", "
278 desc->bd_type == BULK_GET_SOURCE ? "get-source" : "put-sink",
279 desc->bd_iov_count, desc->bd_nob,
280 req->rq_xid, desc->bd_portal);
284 /* Disconnect a bulk desc from the network. Idempotent. Not
285 * thread-safe (i.e. only interlocks with completion callback). */
286 int ptlrpc_unregister_bulk(struct ptlrpc_request *req, int async)
288 struct ptlrpc_bulk_desc *desc = req->rq_bulk;
290 struct l_wait_info lwi;
294 LASSERT(!in_interrupt()); /* might sleep */
296 /* Let's setup deadline for reply unlink. */
297 if (OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_LONG_BULK_UNLINK) &&
298 async && req->rq_bulk_deadline == 0)
299 req->rq_bulk_deadline = cfs_time_current_sec() + LONG_UNLINK;
301 if (!ptlrpc_client_bulk_active(req)) /* completed or */
302 RETURN(1); /* never registered */
304 LASSERT(desc->bd_req == req); /* bd_req NULL until registered */
306 /* the unlink ensures the callback happens ASAP and is the last
307 * one. If it fails, it must be because completion just happened,
308 * but we must still l_wait_event() in this case to give liblustre
309 * a chance to run client_bulk_callback() */
311 LNetMDUnlink(desc->bd_md_h);
313 if (!ptlrpc_client_bulk_active(req)) /* completed or */
314 RETURN(1); /* never registered */
316 /* Move to "Unregistering" phase as bulk was not unlinked yet. */
317 ptlrpc_rqphase_move(req, RQ_PHASE_UNREGISTERING);
319 /* Do not wait for unlink to finish. */
323 if (req->rq_set != NULL)
324 wq = &req->rq_set->set_waitq;
326 wq = &req->rq_reply_waitq;
329 /* Network access will complete in finite time but the HUGE
330 * timeout lets us CWARN for visibility of sluggish NALs */
331 lwi = LWI_TIMEOUT_INTERVAL(cfs_time_seconds(LONG_UNLINK),
332 cfs_time_seconds(1), NULL, NULL);
333 rc = l_wait_event(*wq, !ptlrpc_client_bulk_active(req), &lwi);
335 ptlrpc_rqphase_move(req, req->rq_next_phase);
339 LASSERT(rc == -ETIMEDOUT);
340 DEBUG_REQ(D_WARNING, req, "Unexpectedly long timeout: desc %p",
346 int ptlrpc_send_reply(struct ptlrpc_request *req, int flags)
348 struct ptlrpc_service *svc = req->rq_rqbd->rqbd_service;
349 struct ptlrpc_reply_state *rs = req->rq_reply_state;
350 struct ptlrpc_connection *conn;
352 unsigned int offset = 0;
355 /* We must already have a reply buffer (only ptlrpc_error() may be
356 * called without one). We must also have a request buffer which
357 * is either the actual (swabbed) incoming request, or a saved copy
358 * if this is a req saved in target_queue_final_reply(). */
359 LASSERT (req->rq_reqmsg != NULL);
360 LASSERT (req->rq_repmsg != NULL);
361 LASSERT (rs != NULL);
362 LASSERT (req->rq_repmsg == rs->rs_msg);
363 LASSERT ((flags & PTLRPC_REPLY_MAYBE_DIFFICULT) || !rs->rs_difficult);
364 LASSERT (rs->rs_cb_id.cbid_fn == reply_out_callback);
365 LASSERT (rs->rs_cb_id.cbid_arg == rs);
367 /* There may be no rq_export during failover */
369 if (req->rq_export && req->rq_export->exp_obd &&
370 req->rq_export->exp_obd->obd_fail) {
371 /* Failed obd's only send ENODEV */
372 req->rq_type = PTL_RPC_MSG_ERR;
373 req->rq_status = -ENODEV;
374 CDEBUG(D_HA, "sending ENODEV from failed obd %d\n",
375 req->rq_export->exp_obd->obd_minor);
378 if (req->rq_type != PTL_RPC_MSG_ERR)
379 req->rq_type = PTL_RPC_MSG_REPLY;
381 lustre_msg_set_type(req->rq_repmsg, req->rq_type);
382 lustre_msg_set_status(req->rq_repmsg, req->rq_status);
383 lustre_msg_set_opc(req->rq_repmsg, lustre_msg_get_opc(req->rq_reqmsg));
385 service_time = max_t(int, cfs_time_current_sec() -
386 req->rq_arrival_time.tv_sec, 1);
387 if (!(flags & PTLRPC_REPLY_EARLY) &&
388 (req->rq_type != PTL_RPC_MSG_ERR) &&
389 !(lustre_msg_get_flags(req->rq_reqmsg) &
390 (MSG_RESENT | MSG_REPLAY | MSG_LAST_REPLAY))) {
391 /* early replies, errors and recovery requests don't count
392 * toward our service time estimate */
393 int oldse = at_measured(&svc->srv_at_estimate, service_time);
395 DEBUG_REQ(D_ADAPTTO, req,
396 "svc %s changed estimate from %d to %d",
397 svc->srv_name, oldse,
398 at_get(&svc->srv_at_estimate));
400 /* Report actual service time for client latency calc */
401 lustre_msg_set_service_time(req->rq_repmsg, service_time);
402 /* Report service time estimate for future client reqs, but report 0
403 * (to be ignored by client) if it's a error reply during recovery.
405 if (req->rq_type == PTL_RPC_MSG_ERR &&
406 (req->rq_export == NULL || req->rq_export->exp_obd->obd_recovering))
407 lustre_msg_set_timeout(req->rq_repmsg, 0);
409 lustre_msg_set_timeout(req->rq_repmsg,
410 at_get(&svc->srv_at_estimate));
412 target_pack_pool_reply(req);
414 if (lustre_msghdr_get_flags(req->rq_reqmsg) & MSGHDR_AT_SUPPORT) {
415 /* early replies go to offset 0, regular replies go after that*/
416 if (flags & PTLRPC_REPLY_EARLY) {
418 /* Include a checksum on early replies - must be done
419 after all other lustre_msg_set_* */
420 lustre_msg_set_cksum(req->rq_repmsg,
421 lustre_msg_calc_cksum(req->rq_repmsg));
423 offset = lustre_msg_early_size(req);
426 CDEBUG(D_ADAPTTO, "No early reply support: flags=%#x "
427 "req_flags=%#x magic=%d:%x/%x len=%d\n",
428 flags, lustre_msg_get_flags(req->rq_reqmsg),
429 lustre_msg_is_v1(req->rq_reqmsg),
430 lustre_msg_get_magic(req->rq_reqmsg),
431 lustre_msg_get_magic(req->rq_repmsg), req->rq_replen);
434 if (req->rq_export == NULL || req->rq_export->exp_connection == NULL)
435 conn = ptlrpc_connection_get(req->rq_peer, req->rq_self, NULL);
437 conn = ptlrpc_connection_addref(req->rq_export->exp_connection);
440 CERROR("not replying on NULL connection\n"); /* bug 9635 */
444 atomic_inc (&svc->srv_outstanding_replies);
445 ptlrpc_rs_addref(rs); /* +1 ref for the network */
446 req->rq_sent = cfs_time_current_sec();
448 rc = ptl_send_buf (&rs->rs_md_h, req->rq_repmsg, req->rq_replen,
449 rs->rs_difficult ? LNET_ACK_REQ : LNET_NOACK_REQ,
450 &rs->rs_cb_id, conn, svc->srv_rep_portal,
451 req->rq_xid, offset);
453 atomic_dec (&svc->srv_outstanding_replies);
454 ptlrpc_req_drop_rs(req);
456 ptlrpc_connection_put(conn);
460 int ptlrpc_reply (struct ptlrpc_request *req)
462 return (ptlrpc_send_reply (req, 0));
465 int ptlrpc_send_error(struct ptlrpc_request *req, int may_be_difficult)
470 if (!req->rq_repmsg) {
471 rc = lustre_pack_reply(req, 1, NULL, NULL);
476 req->rq_type = PTL_RPC_MSG_ERR;
478 rc = ptlrpc_send_reply(req, may_be_difficult);
482 int ptlrpc_error(struct ptlrpc_request *req)
484 return ptlrpc_send_error(req, 0);
487 int ptl_send_rpc(struct ptlrpc_request *request, int noreply)
491 struct ptlrpc_connection *connection;
492 lnet_handle_me_t reply_me_h;
494 struct obd_device *obd = request->rq_import->imp_obd;
497 OBD_FAIL_RETURN(OBD_FAIL_PTLRPC_DROP_RPC, 0);
499 LASSERT (request->rq_type == PTL_RPC_MSG_REQUEST);
501 /* If this is a re-transmit, we're required to have disengaged
502 * cleanly from the previous attempt */
503 LASSERT(!request->rq_receiving_reply);
505 if (request->rq_import->imp_obd &&
506 request->rq_import->imp_obd->obd_fail) {
507 CDEBUG(D_HA, "muting rpc for failed imp obd %s\n",
508 request->rq_import->imp_obd->obd_name);
509 /* this prevents us from waiting in ptlrpc_queue_wait */
510 spin_lock(&request->rq_lock);
512 spin_unlock(&request->rq_lock);
514 request->rq_status = -ENODEV;
518 connection = request->rq_import->imp_connection;
520 if (request->rq_bulk != NULL) {
521 rc = ptlrpc_register_bulk (request);
526 lustre_msg_set_handle(request->rq_reqmsg,
527 &request->rq_import->imp_remote_handle);
528 lustre_msg_set_type(request->rq_reqmsg, PTL_RPC_MSG_REQUEST);
529 lustre_msg_set_conn_cnt(request->rq_reqmsg,
530 request->rq_import->imp_conn_cnt);
531 lustre_msghdr_set_flags(request->rq_reqmsg,
532 request->rq_import->imp_msghdr_flags);
534 if (request->rq_resend)
535 lustre_msg_add_flags(request->rq_reqmsg, MSG_RESENT);
538 LASSERT (request->rq_replen != 0);
539 if (request->rq_repbuf == NULL)
540 OBD_ALLOC(request->rq_repbuf, request->rq_replen);
541 if (request->rq_repbuf == NULL) {
542 /* this prevents us from looping in ptlrpc_queue_wait */
543 spin_lock(&request->rq_lock);
545 spin_unlock(&request->rq_lock);
547 request->rq_status = -ENOMEM;
548 GOTO(cleanup_bulk, rc = -ENOMEM);
550 request->rq_repmsg = NULL;
552 rc = LNetMEAttach(request->rq_reply_portal,/*XXX FIXME bug 249*/
553 connection->c_peer, request->rq_xid, 0,
554 LNET_UNLINK, LNET_INS_AFTER, &reply_me_h);
556 CERROR("LNetMEAttach failed: %d\n", rc);
557 LASSERT (rc == -ENOMEM);
558 GOTO(cleanup_repmsg, rc = -ENOMEM);
562 spin_lock(&request->rq_lock);
563 /* If the MD attach succeeds, there _will_ be a reply_in callback */
564 request->rq_receiving_reply = !noreply;
565 /* We are responsible for unlinking the reply buffer */
566 request->rq_must_unlink = !noreply;
567 /* Clear any flags that may be present from previous sends. */
568 request->rq_replied = 0;
570 request->rq_timedout = 0;
571 request->rq_net_err = 0;
572 request->rq_resend = 0;
573 request->rq_restart = 0;
574 request->rq_rep_swab_mask = 0;
575 request->rq_reply_truncate = 0;
576 spin_unlock(&request->rq_lock);
579 reply_md.start = request->rq_repbuf;
580 reply_md.length = request->rq_replen;
581 /* Allow multiple early replies */
582 reply_md.threshold = LNET_MD_THRESH_INF;
583 /* Manage remote for early replies */
584 reply_md.options = PTLRPC_MD_OPTIONS | LNET_MD_OP_PUT |
585 LNET_MD_MANAGE_REMOTE |
586 LNET_MD_TRUNCATE; /* allow to make EBIG error */
587 reply_md.user_ptr = &request->rq_reply_cbid;
588 reply_md.eq_handle = ptlrpc_eq_h;
590 /* We must see the unlink callback to unset rq_must_unlink,
591 so we can't auto-unlink */
592 rc = LNetMDAttach(reply_me_h, reply_md, LNET_RETAIN,
593 &request->rq_reply_md_h);
595 CERROR("LNetMDAttach failed: %d\n", rc);
596 LASSERT (rc == -ENOMEM);
597 spin_lock(&request->rq_lock);
598 /* ...but the MD attach didn't succeed... */
599 request->rq_receiving_reply = 0;
600 spin_unlock(&request->rq_lock);
601 GOTO(cleanup_me, rc = -ENOMEM);
604 CDEBUG(D_NET, "Setup reply buffer: %u bytes, xid "LPU64
606 request->rq_replen, request->rq_xid,
607 request->rq_reply_portal);
610 /* add references on request for request_out_callback */
611 ptlrpc_request_addref(request);
612 if (obd->obd_svc_stats != NULL)
613 lprocfs_counter_add(obd->obd_svc_stats, PTLRPC_REQACTIVE_CNTR,
614 atomic_read(&request->rq_import->imp_inflight));
616 OBD_FAIL_TIMEOUT(OBD_FAIL_PTLRPC_DELAY_SEND, request->rq_timeout + 5);
618 request->rq_sent = cfs_time_current_sec();
619 do_gettimeofday(&request->rq_arrival_time);
620 /* We give the server rq_timeout secs to process the req, and
621 add the network latency for our local timeout. */
622 request->rq_deadline = request->rq_sent + request->rq_timeout +
623 ptlrpc_at_get_net_latency(request);
625 ptlrpc_pinger_sending_on_import(request->rq_import);
627 DEBUG_REQ(D_INFO, request, "send flg=%x",
628 lustre_msg_get_flags(request->rq_reqmsg));
629 rc = ptl_send_buf(&request->rq_req_md_h,
630 request->rq_reqmsg, request->rq_reqlen,
631 LNET_NOACK_REQ, &request->rq_req_cbid,
633 request->rq_request_portal,
638 ptlrpc_req_finished(request);
643 /* MEUnlink is safe; the PUT didn't even get off the ground, and
644 * nobody apart from the PUT's target has the right nid+XID to
645 * access the reply buffer. */
646 rc2 = LNetMEUnlink(reply_me_h);
648 /* UNLINKED callback called synchronously */
649 LASSERT(!request->rq_receiving_reply);
652 OBD_FREE(request->rq_repbuf, request->rq_replen);
653 request->rq_repbuf = NULL;
654 request->rq_repmsg = NULL; //remove
657 /* We do sync unlink here as there was no real transfer here so
658 * the chance to have long unlink to sluggish net is smaller here. */
659 ptlrpc_unregister_bulk(request, 0);
663 int ptlrpc_register_rqbd(struct ptlrpc_request_buffer_desc *rqbd)
665 struct ptlrpc_service *service = rqbd->rqbd_service;
666 static lnet_process_id_t match_id = {LNET_NID_ANY, LNET_PID_ANY};
669 lnet_handle_me_t me_h;
671 CDEBUG(D_NET, "LNetMEAttach: portal %d\n",
672 service->srv_req_portal);
674 if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_PTLRPC_RQBD))
677 rc = LNetMEAttach(service->srv_req_portal,
678 match_id, 0, ~0, LNET_UNLINK, LNET_INS_AFTER, &me_h);
680 CERROR("LNetMEAttach failed: %d\n", rc);
684 LASSERT(rqbd->rqbd_refcount == 0);
685 rqbd->rqbd_refcount = 1;
687 md.start = rqbd->rqbd_buffer;
688 md.length = service->srv_buf_size;
689 md.max_size = service->srv_max_req_size;
690 md.threshold = LNET_MD_THRESH_INF;
691 md.options = PTLRPC_MD_OPTIONS | LNET_MD_OP_PUT | LNET_MD_MAX_SIZE;
692 md.user_ptr = &rqbd->rqbd_cbid;
693 md.eq_handle = ptlrpc_eq_h;
695 rc = LNetMDAttach(me_h, md, LNET_UNLINK, &rqbd->rqbd_md_h);
699 CERROR("LNetMDAttach failed: %d; \n", rc);
700 LASSERT (rc == -ENOMEM);
701 rc = LNetMEUnlink (me_h);
703 rqbd->rqbd_refcount = 0;