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