Whamcloud - gitweb
smash the HEAD with the contents of b_cmd. HEAD_PRE_CMD_SMASH and
[fs/lustre-release.git] / lustre / ptlrpc / niobuf.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (c) 2002, 2003 Cluster File Systems, Inc.
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
8  *   Lustre is free software; you can redistribute it and/or
9  *   modify it under the terms of version 2 of the GNU General Public
10  *   License as published by the Free Software Foundation.
11  *
12  *   Lustre is distributed in the hope that it will be useful,
13  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *   GNU General Public License for more details.
16  *
17  *   You should have received a copy of the GNU General Public License
18  *   along with Lustre; if not, write to the Free Software
19  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20  *
21  */
22
23 #define DEBUG_SUBSYSTEM S_RPC
24 #ifndef __KERNEL__
25 #include <liblustre.h>
26 #include <portals/lib-types.h>
27 #endif
28 #include <linux/obd_support.h>
29 #include <linux/lustre_net.h>
30 #include <linux/lustre_lib.h>
31 #include <linux/obd.h>
32 #include "ptlrpc_internal.h"
33
34 static int ptl_send_buf (ptl_handle_md_t *mdh, void *base, int len, 
35                          ptl_ack_req_t ack, struct ptlrpc_cb_id *cbid,
36                          struct ptlrpc_connection *conn, int portal, __u64 xid)
37 {
38         ptl_process_id_t remote_id;
39         int              rc;
40         int              rc2;
41         ptl_md_t         md;
42         char str[PTL_NALFMT_SIZE];
43         ENTRY;
44
45         LASSERT (portal != 0);
46         LASSERT (conn != NULL);
47         CDEBUG (D_INFO, "conn=%p ni %s nid "LPX64" (%s) on %s\n",
48                 conn, conn->c_peer.peer_ni->pni_name,
49                 conn->c_peer.peer_nid,
50                 portals_nid2str(conn->c_peer.peer_ni->pni_number,
51                                 conn->c_peer.peer_nid, str),
52                 conn->c_peer.peer_ni->pni_name);
53
54         remote_id.nid = conn->c_peer.peer_nid,
55         remote_id.pid = 0;
56
57         md.start     = base;
58         md.length    = len;
59         md.threshold = (ack == PTL_ACK_REQ) ? 2 : 1;
60         md.options   = PTLRPC_MD_OPTIONS;
61         md.user_ptr  = cbid;
62         md.eventq    = conn->c_peer.peer_ni->pni_eq_h;
63
64         if (ack == PTL_ACK_REQ &&
65             OBD_FAIL_CHECK(OBD_FAIL_PTLRPC_ACK | OBD_FAIL_ONCE)) {
66                 /* don't ask for the ack to simulate failing client */
67                 ack = PTL_NOACK_REQ;
68                 obd_fail_loc |= OBD_FAIL_ONCE | OBD_FAILED;
69         }
70
71         rc = PtlMDBind (conn->c_peer.peer_ni->pni_ni_h, md, 
72                         PTL_UNLINK, mdh);
73         if (rc != PTL_OK) {
74                 CERROR ("PtlMDBind failed: %d\n", rc);
75                 LASSERT (rc == PTL_NO_SPACE);
76                 RETURN (-ENOMEM);
77         }
78
79         CDEBUG(D_NET, "Sending %d bytes to portal %d, xid "LPD64"\n",
80                len, portal, xid);
81
82         rc2 = PtlPut (*mdh, ack, remote_id, portal, 0, xid, 0, 0);
83         if (rc != PTL_OK) {
84                 /* We're going to get an UNLINK event when I unlink below,
85                  * which will complete just like any other failed send, so
86                  * I fall through and return success here! */
87                 CERROR("PtlPut("LPU64", %d, "LPD64") failed: %d\n",
88                        remote_id.nid, portal, xid, rc);
89                 rc2 = PtlMDUnlink(*mdh);
90                 LASSERT (rc2 == PTL_OK);
91         }
92
93         RETURN (0);
94 }
95
96 static void ptlrpc_fill_md(ptl_md_t *md, struct ptlrpc_bulk_desc *desc)
97 {
98         LASSERT(ptl_md_max_iovs() == 0  || 
99                 (desc->bd_iov_count <= ptl_md_max_iovs()));
100
101         if (ptl_requires_iov() || desc->bd_iov_count > 0) {
102                 md->options |= PTLRPC_PTL_MD_IOV;
103                 md->start = &desc->bd_iov[0];
104                 md->niov = desc->bd_iov_count;
105         } else {
106                 md->start = ptl_iov_base(&desc->bd_iov[0]);
107         }
108 }
109
110 int ptlrpc_start_bulk_transfer (struct ptlrpc_bulk_desc *desc)
111 {
112         int                 rc;
113         int                 rc2;
114         struct ptlrpc_peer *peer;
115         ptl_process_id_t    remote_id;
116         ptl_md_t            md;
117         __u64               xid;
118         ENTRY;
119
120         if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_PTLRPC_BULK_PUT_NET)) 
121                 RETURN(0);
122
123         /* NB no locking required until desc is on the network */
124         LASSERT (!desc->bd_network_rw);
125         LASSERT (desc->bd_type == BULK_PUT_SOURCE ||
126                  desc->bd_type == BULK_GET_SINK);
127         desc->bd_success = 0;
128         peer = &desc->bd_export->exp_connection->c_peer;
129
130         md.length = desc->bd_nob;
131         md.eventq = peer->peer_ni->pni_eq_h;
132         md.threshold = 2; /* SENT and ACK/REPLY */
133         md.options = PTLRPC_MD_OPTIONS;
134
135         ptlrpc_fill_md(&md, desc);
136         md.user_ptr = &desc->bd_cbid;
137         LASSERT (desc->bd_cbid.cbid_fn == server_bulk_callback);
138         LASSERT (desc->bd_cbid.cbid_arg == desc);
139
140         /* NB total length may be 0 for a read past EOF, so we send a 0
141          * length bulk, since the client expects a bulk event. */
142
143         rc = PtlMDBind(peer->peer_ni->pni_ni_h, md,
144                        PTL_UNLINK, &desc->bd_md_h);
145         if (rc != PTL_OK) {
146                 CERROR("PtlMDBind failed: %d\n", rc);
147                 LASSERT (rc == PTL_NO_SPACE);
148                 RETURN(-ENOMEM);
149         }
150
151         /* Client's bulk and reply matchbits are the same */
152         xid = desc->bd_req->rq_xid;
153         remote_id.nid = peer->peer_nid;
154         remote_id.pid = 0;
155
156         CDEBUG(D_NET, "Transferring %u pages %u bytes via portal %d on %s "
157                "nid "LPX64" pid %d xid "LPX64"\n", 
158                md.niov, md.length, desc->bd_portal, peer->peer_ni->pni_name,
159                remote_id.nid, remote_id.pid, xid);
160
161         /* Network is about to get at the memory */
162         desc->bd_network_rw = 1;
163
164         if (desc->bd_type == BULK_PUT_SOURCE)
165                 rc = PtlPut (desc->bd_md_h, PTL_ACK_REQ, remote_id,
166                              desc->bd_portal, 0, xid, 0, 0);
167         else
168                 rc = PtlGet (desc->bd_md_h, remote_id,
169                              desc->bd_portal, 0, xid, 0);
170         
171         if (rc != PTL_OK) {
172                 /* Can't send, so we unlink the MD bound above.  The UNLINK
173                  * event this creates will signal completion with failure,
174                  * so we return SUCCESS here! */
175                 CERROR("Transfer("LPU64", %d, "LPX64") failed: %d\n",
176                        remote_id.nid, desc->bd_portal, xid, rc);
177                 rc2 = PtlMDUnlink(desc->bd_md_h);
178                 LASSERT (rc2 == PTL_OK);
179         }
180
181         RETURN(0);
182 }
183
184 void ptlrpc_abort_bulk (struct ptlrpc_bulk_desc *desc)
185 {
186         /* Server side bulk abort. Idempotent. Not thread-safe (i.e. only
187          * serialises with completion callback) */
188         struct l_wait_info lwi;
189         int                rc;
190
191         LASSERT (!in_interrupt ());             /* might sleep */
192
193         if (!ptlrpc_bulk_active(desc))          /* completed or */
194                 return;                         /* never started */
195         
196         /* The unlink ensures the callback happens ASAP and is the last
197          * one.  If it fails, it must be because completion just
198          * happened. */
199
200         rc = PtlMDUnlink (desc->bd_md_h);
201         if (rc == PTL_MD_INVALID) {
202                 LASSERT(!ptlrpc_bulk_active(desc));
203                 return;
204         }
205         
206         LASSERT (rc == PTL_OK);
207
208         for (;;) {
209                 /* Network access will complete in finite time but the HUGE
210                  * timeout lets us CWARN for visibility of sluggish NALs */
211                 lwi = LWI_TIMEOUT (300 * HZ, NULL, NULL);
212                 rc = l_wait_event(desc->bd_waitq, 
213                                   !ptlrpc_bulk_active(desc), &lwi);
214                 if (rc == 0)
215                         return;
216
217                 LASSERT(rc == -ETIMEDOUT);
218                 CWARN("Unexpectedly long timeout: desc %p\n", desc);
219         }
220 }
221
222 int ptlrpc_register_bulk (struct ptlrpc_request *req)
223 {
224         struct ptlrpc_bulk_desc *desc = req->rq_bulk;
225         struct ptlrpc_peer *peer;
226         int rc;
227         int rc2;
228         ptl_process_id_t source_id;
229         ptl_handle_me_t  me_h;
230         ptl_md_t         md;
231         ENTRY;
232
233         if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_PTLRPC_BULK_GET_NET)) 
234                 RETURN(0);
235
236         /* NB no locking required until desc is on the network */
237         LASSERT (desc->bd_nob > 0);
238         LASSERT (!desc->bd_network_rw);
239         LASSERT (desc->bd_iov_count <= PTLRPC_MAX_BRW_PAGES);
240         LASSERT (desc->bd_req != NULL);
241         LASSERT (desc->bd_type == BULK_PUT_SINK ||
242                  desc->bd_type == BULK_GET_SOURCE);
243
244         desc->bd_success = 0;
245
246         peer = &desc->bd_import->imp_connection->c_peer;
247
248         md.length = desc->bd_nob;
249         md.eventq = peer->peer_ni->pni_eq_h;
250         md.threshold = 1;                       /* PUT or GET */
251         md.options = PTLRPC_MD_OPTIONS | 
252                      ((desc->bd_type == BULK_GET_SOURCE) ? 
253                       PTL_MD_OP_GET : PTL_MD_OP_PUT);
254         ptlrpc_fill_md(&md, desc);
255         md.user_ptr = &desc->bd_cbid;
256         LASSERT (desc->bd_cbid.cbid_fn == client_bulk_callback);
257         LASSERT (desc->bd_cbid.cbid_arg == desc);
258
259         /* XXX Registering the same xid on retried bulk makes my head
260          * explode trying to understand how the original request's bulk
261          * might interfere with the retried request -eeb */
262         LASSERT (!desc->bd_registered || req->rq_xid != desc->bd_last_xid);
263         desc->bd_registered = 1;
264         desc->bd_last_xid = req->rq_xid;
265
266         source_id.nid = desc->bd_import->imp_connection->c_peer.peer_nid;
267         source_id.pid = PTL_PID_ANY;
268
269         rc = PtlMEAttach(peer->peer_ni->pni_ni_h,
270                          desc->bd_portal, source_id, req->rq_xid, 0,
271                          PTL_UNLINK, PTL_INS_AFTER, &me_h);
272         if (rc != PTL_OK) {
273                 CERROR("PtlMEAttach failed: %d\n", rc);
274                 LASSERT (rc == PTL_NO_SPACE);
275                 RETURN (-ENOMEM);
276         }
277
278         /* About to let the network at it... */
279         desc->bd_network_rw = 1;
280         rc = PtlMDAttach(me_h, md, PTL_UNLINK, &desc->bd_md_h);
281         if (rc != PTL_OK) {
282                 CERROR("PtlMDAttach failed: %d\n", rc);
283                 LASSERT (rc == PTL_NO_SPACE);
284                 desc->bd_network_rw = 0;
285                 rc2 = PtlMEUnlink (me_h);
286                 LASSERT (rc2 == PTL_OK);
287                 RETURN (-ENOMEM);
288         }
289
290         CDEBUG(D_NET, "Setup bulk %s buffers: %u pages %u bytes, xid "LPX64", "
291                "portal %u on %s\n",
292                desc->bd_type == BULK_GET_SOURCE ? "get-source" : "put-sink",
293                md.niov, md.length,
294                req->rq_xid, desc->bd_portal, peer->peer_ni->pni_name);
295         RETURN(0);
296 }
297
298 void ptlrpc_unregister_bulk (struct ptlrpc_request *req)
299 {
300         /* Disconnect a bulk desc from the network. Idempotent. Not
301          * thread-safe (i.e. only interlocks with completion callback). */
302         struct ptlrpc_bulk_desc *desc = req->rq_bulk;
303         wait_queue_head_t       *wq;
304         struct l_wait_info       lwi;
305         int                      rc;
306
307         LASSERT (!in_interrupt ());             /* might sleep */
308
309         if (!ptlrpc_bulk_active(desc))          /* completed or */
310                 return;                         /* never registered */
311         
312         LASSERT (desc->bd_req == req);          /* bd_req NULL until registered */
313
314         /* the unlink ensures the callback happens ASAP and is the last
315          * one.  If it fails, it must be because completion just
316          * happened. */
317
318         rc = PtlMDUnlink (desc->bd_md_h);
319         if (rc == PTL_MD_INVALID) {
320                 LASSERT(!ptlrpc_bulk_active(desc));
321                 return;
322         }
323         
324         LASSERT (rc == PTL_OK);
325         
326         if (desc->bd_req->rq_set != NULL)
327                 wq = &req->rq_set->set_waitq;
328         else
329                 wq = &req->rq_reply_waitq;
330
331         for (;;) {
332                 /* Network access will complete in finite time but the HUGE
333                  * timeout lets us CWARN for visibility of sluggish NALs */
334                 lwi = LWI_TIMEOUT (300 * HZ, NULL, NULL);
335                 rc = l_wait_event(*wq, !ptlrpc_bulk_active(desc), &lwi);
336                 if (rc == 0)
337                         return;
338                 
339                 LASSERT (rc == -ETIMEDOUT);
340                 CWARN("Unexpectedly long timeout: desc %p\n", desc);
341         }
342 }
343
344 int ptlrpc_send_reply (struct ptlrpc_request *req, int may_be_difficult)
345 {
346         struct ptlrpc_service     *svc = req->rq_rqbd->rqbd_srv_ni->sni_service;
347         struct ptlrpc_reply_state *rs = req->rq_reply_state;
348         struct ptlrpc_connection  *conn;
349         int                        rc;
350
351         /* We must already have a reply buffer (only ptlrpc_error() may be
352          * called without one).  We must also have a request buffer which
353          * is either the actual (swabbed) incoming request, or a saved copy
354          * if this is a req saved in target_queue_final_reply(). */
355         LASSERT (req->rq_reqmsg != NULL);
356         LASSERT (rs != NULL);
357         LASSERT (req->rq_repmsg != NULL);
358         LASSERT (may_be_difficult || !rs->rs_difficult);
359         LASSERT (req->rq_repmsg == &rs->rs_msg);
360         LASSERT (rs->rs_cb_id.cbid_fn == reply_out_callback);
361         LASSERT (rs->rs_cb_id.cbid_arg == rs);
362
363         LASSERT (req->rq_repmsg != NULL);
364         if (req->rq_type != PTL_RPC_MSG_ERR)
365                 req->rq_type = PTL_RPC_MSG_REPLY;
366
367         req->rq_repmsg->type   = req->rq_type;
368         req->rq_repmsg->status = req->rq_status;
369         req->rq_repmsg->opc    = req->rq_reqmsg->opc;
370
371         if (req->rq_export == NULL) 
372                 conn = ptlrpc_get_connection(&req->rq_peer, NULL);
373         else
374                 conn = ptlrpc_connection_addref(req->rq_export->exp_connection);
375
376         atomic_inc (&svc->srv_outstanding_replies);
377
378         rc = ptl_send_buf (&rs->rs_md_h, req->rq_repmsg, req->rq_replen,
379                            rs->rs_difficult ? PTL_ACK_REQ : PTL_NOACK_REQ,
380                            &rs->rs_cb_id, conn,
381                            svc->srv_rep_portal, req->rq_xid);
382         if (rc != 0) {
383                 atomic_dec (&svc->srv_outstanding_replies);
384
385                 if (!rs->rs_difficult) {
386                         /* Callers other than target_send_reply() expect me
387                          * to clean up on a comms error */
388                         lustre_free_reply_state (rs);
389                         req->rq_reply_state = NULL;
390                         req->rq_repmsg = NULL;
391                 }
392         }
393         ptlrpc_put_connection(conn);
394         return rc;
395 }
396
397 int ptlrpc_reply (struct ptlrpc_request *req)
398 {
399         return (ptlrpc_send_reply (req, 0));
400 }
401
402 int ptlrpc_error(struct ptlrpc_request *req)
403 {
404         int rc;
405         ENTRY;
406
407         if (!req->rq_repmsg) {
408                 rc = lustre_pack_reply(req, 0, NULL, NULL);
409                 if (rc)
410                         RETURN(rc);
411         }
412
413         req->rq_type = PTL_RPC_MSG_ERR;
414
415         rc = ptlrpc_send_reply (req, 0);
416         RETURN(rc);
417 }
418
419 int ptl_send_rpc(struct ptlrpc_request *request)
420 {
421         int rc;
422         int rc2;
423         struct ptlrpc_connection *connection;
424         unsigned long flags;
425         ptl_process_id_t source_id;
426         ptl_handle_me_t  reply_me_h;
427         ptl_md_t         reply_md;
428         ENTRY;
429
430         LASSERT (request->rq_type == PTL_RPC_MSG_REQUEST);
431
432         /* If this is a re-transmit, we're required to have disengaged
433          * cleanly from the previous attempt */
434         LASSERT (!request->rq_receiving_reply);
435
436         connection = request->rq_import->imp_connection;
437
438         if (request->rq_bulk != NULL) {
439                 rc = ptlrpc_register_bulk (request);
440                 if (rc != 0)
441                         RETURN(rc);
442         }
443
444         request->rq_reqmsg->handle = request->rq_import->imp_remote_handle;
445         request->rq_reqmsg->type = PTL_RPC_MSG_REQUEST;
446         request->rq_reqmsg->conn_cnt = request->rq_import->imp_conn_cnt;
447
448         source_id.nid = connection->c_peer.peer_nid;
449         source_id.pid = PTL_PID_ANY;
450
451         LASSERT (request->rq_replen != 0);
452         if (request->rq_repmsg == NULL)
453                 OBD_ALLOC(request->rq_repmsg, request->rq_replen);
454         if (request->rq_repmsg == NULL)
455                 GOTO(cleanup_bulk, rc = -ENOMEM);
456
457         rc = PtlMEAttach(connection->c_peer.peer_ni->pni_ni_h,
458                          request->rq_reply_portal, /* XXX FIXME bug 249 */
459                          source_id, request->rq_xid, 0, PTL_UNLINK,
460                          PTL_INS_AFTER, &reply_me_h);
461         if (rc != PTL_OK) {
462                 CERROR("PtlMEAttach failed: %d\n", rc);
463                 LASSERT (rc == PTL_NO_SPACE);
464                 GOTO(cleanup_repmsg, rc = -ENOMEM);
465         }
466
467         spin_lock_irqsave (&request->rq_lock, flags);
468         /* If the MD attach succeeds, there _will_ be a reply_in callback */
469         request->rq_receiving_reply = 1;
470         /* Clear any flags that may be present from previous sends. */
471         request->rq_replied = 0;
472         request->rq_err = 0;
473         request->rq_timedout = 0;
474         request->rq_resend = 0;
475         request->rq_restart = 0;
476         spin_unlock_irqrestore (&request->rq_lock, flags);
477
478         reply_md.start     = request->rq_repmsg;
479         reply_md.length    = request->rq_replen;
480         reply_md.threshold = 1;
481         reply_md.options   = PTLRPC_MD_OPTIONS | PTL_MD_OP_PUT;
482         reply_md.user_ptr  = &request->rq_reply_cbid;
483         reply_md.eventq    = connection->c_peer.peer_ni->pni_eq_h;
484
485         rc = PtlMDAttach(reply_me_h, reply_md, PTL_UNLINK, 
486                          &request->rq_reply_md_h);
487         if (rc != PTL_OK) {
488                 CERROR("PtlMDAttach failed: %d\n", rc);
489                 LASSERT (rc == PTL_NO_SPACE);
490                 GOTO(cleanup_me, rc -ENOMEM);
491         }
492
493         CDEBUG(D_NET, "Setup reply buffer: %u bytes, xid "LPU64
494                ", portal %u on %s\n",
495                request->rq_replen, request->rq_xid,
496                request->rq_reply_portal,
497                connection->c_peer.peer_ni->pni_name);
498
499         ptlrpc_request_addref(request);        /* +1 ref for the SENT callback */
500
501         request->rq_sent = LTIME_S(CURRENT_TIME);
502         ptlrpc_pinger_sending_on_import(request->rq_import);
503         rc = ptl_send_buf(&request->rq_req_md_h, 
504                           request->rq_reqmsg, request->rq_reqlen,
505                           PTL_NOACK_REQ, &request->rq_req_cbid, 
506                           connection,
507                           request->rq_request_portal,
508                           request->rq_xid);
509         if (rc == 0) {
510                 ptlrpc_lprocfs_rpc_sent(request);
511                 RETURN(rc);
512         }
513
514         ptlrpc_req_finished (request);          /* drop callback ref */
515
516  cleanup_me:
517         /* MEUnlink is safe; the PUT didn't even get off the ground, and
518          * nobody apart from the PUT's target has the right nid+XID to
519          * access the reply buffer. */
520         rc2 = PtlMEUnlink(reply_me_h);
521         LASSERT (rc2 == PTL_OK);
522         /* UNLINKED callback called synchronously */
523         LASSERT (!request->rq_receiving_reply);
524
525  cleanup_repmsg:
526         OBD_FREE(request->rq_repmsg, request->rq_replen);
527         request->rq_repmsg = NULL;
528
529  cleanup_bulk:
530         if (request->rq_bulk != NULL)
531                 ptlrpc_unregister_bulk(request);
532
533         return rc;
534 }
535
536 int ptlrpc_register_rqbd (struct ptlrpc_request_buffer_desc *rqbd)
537 {
538         struct ptlrpc_srv_ni    *srv_ni = rqbd->rqbd_srv_ni;
539         struct ptlrpc_service   *service = srv_ni->sni_service;
540         static ptl_process_id_t  match_id = {PTL_NID_ANY, PTL_PID_ANY};
541         int                      rc;
542         ptl_md_t                 md;
543         ptl_handle_me_t          me_h;
544
545         CDEBUG(D_NET, "PtlMEAttach: portal %d on %s\n",
546                service->srv_req_portal, srv_ni->sni_ni->pni_name);
547
548         if (OBD_FAIL_CHECK_ONCE(OBD_FAIL_PTLRPC_RQBD))
549                 return (-ENOMEM);
550
551         rc = PtlMEAttach(srv_ni->sni_ni->pni_ni_h, service->srv_req_portal,
552                          match_id, 0, ~0, PTL_UNLINK, PTL_INS_AFTER, &me_h);
553         if (rc != PTL_OK) {
554                 CERROR("PtlMEAttach failed: %d\n", rc);
555                 return (-ENOMEM);
556         }
557
558         LASSERT(rqbd->rqbd_refcount == 0);
559         rqbd->rqbd_refcount = 1;
560
561         md.start     = rqbd->rqbd_buffer;
562         md.length    = service->srv_buf_size;
563         md.max_size  = service->srv_max_req_size;
564         md.threshold = PTL_MD_THRESH_INF;
565         md.options   = PTLRPC_MD_OPTIONS | PTL_MD_OP_PUT | PTL_MD_MAX_SIZE;
566         md.user_ptr  = &rqbd->rqbd_cbid;
567         md.eventq    = srv_ni->sni_ni->pni_eq_h;
568         
569         rc = PtlMDAttach(me_h, md, PTL_UNLINK, &rqbd->rqbd_md_h);
570         if (rc == PTL_OK)
571                 return (0);
572
573         CERROR("PtlMDAttach failed: %d; \n", rc);
574         LASSERT (rc == PTL_NO_SPACE);
575         rc = PtlMEUnlink (me_h);
576         LASSERT (rc == PTL_OK);
577         rqbd->rqbd_refcount = 0;
578         
579         return (-ENOMEM);
580 }