1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2002 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.lustre.org.
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.
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.
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.
23 #define DEBUG_SUBSYSTEM S_RPC
25 #include <linux/obd_support.h>
26 #include <linux/obd_class.h>
27 #include <linux/lustre_lib.h>
28 #include <linux/lustre_ha.h>
29 #include <linux/lustre_import.h>
31 void ptlrpc_init_client(int req_portal, int rep_portal, char *name,
32 struct ptlrpc_client *cl)
34 cl->cli_request_portal = req_portal;
35 cl->cli_reply_portal = rep_portal;
39 __u8 *ptlrpc_req_to_uuid(struct ptlrpc_request *req)
41 return req->rq_connection->c_remote_uuid;
44 struct ptlrpc_connection *ptlrpc_uuid_to_connection(obd_uuid_t uuid)
46 struct ptlrpc_connection *c;
47 struct lustre_peer peer;
50 err = kportal_uuid_to_peer(uuid, &peer);
52 CERROR("cannot find peer %s!\n", uuid);
56 c = ptlrpc_get_connection(&peer, uuid);
58 memcpy(c->c_remote_uuid, uuid, sizeof(c->c_remote_uuid));
62 CDEBUG(D_INFO, "%s -> %p\n", uuid, c);
67 void ptlrpc_readdress_connection(struct ptlrpc_connection *conn,obd_uuid_t uuid)
69 struct lustre_peer peer;
72 err = kportal_uuid_to_peer(uuid, &peer);
74 CERROR("cannot find peer %s!\n", uuid);
78 memcpy(&conn->c_peer, &peer, sizeof(peer));
82 struct ptlrpc_bulk_desc *ptlrpc_prep_bulk(struct ptlrpc_connection *conn)
84 struct ptlrpc_bulk_desc *desc;
86 OBD_ALLOC(desc, sizeof(*desc));
88 desc->bd_connection = ptlrpc_connection_addref(conn);
89 atomic_set(&desc->bd_refcount, 1);
90 init_waitqueue_head(&desc->bd_waitq);
91 INIT_LIST_HEAD(&desc->bd_page_list);
92 INIT_LIST_HEAD(&desc->bd_set_chain);
93 ptl_set_inv_handle(&desc->bd_md_h);
94 ptl_set_inv_handle(&desc->bd_me_h);
100 int ptlrpc_bulk_error(struct ptlrpc_bulk_desc *desc)
103 if (desc->bd_flags & PTL_RPC_FL_TIMEOUT) {
104 rc = (desc->bd_flags & PTL_RPC_FL_INTR ? -ERESTARTSYS :
110 struct ptlrpc_bulk_page *ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc)
112 struct ptlrpc_bulk_page *bulk;
114 OBD_ALLOC(bulk, sizeof(*bulk));
116 bulk->bp_desc = desc;
117 list_add_tail(&bulk->bp_link, &desc->bd_page_list);
118 desc->bd_page_count++;
123 void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc)
125 struct list_head *tmp, *next;
132 LASSERT(list_empty(&desc->bd_set_chain));
134 list_for_each_safe(tmp, next, &desc->bd_page_list) {
135 struct ptlrpc_bulk_page *bulk;
136 bulk = list_entry(tmp, struct ptlrpc_bulk_page, bp_link);
137 ptlrpc_free_bulk_page(bulk);
140 ptlrpc_put_connection(desc->bd_connection);
142 OBD_FREE(desc, sizeof(*desc));
146 void ptlrpc_free_bulk_page(struct ptlrpc_bulk_page *bulk)
154 list_del(&bulk->bp_link);
155 bulk->bp_desc->bd_page_count--;
156 OBD_FREE(bulk, sizeof(*bulk));
160 static int ll_sync_brw_timeout(void *data)
162 struct obd_brw_set *set = data;
163 struct list_head *tmp;
169 set->brw_flags |= PTL_RPC_FL_TIMEOUT;
171 list_for_each(tmp, &set->brw_desc_head) {
172 struct ptlrpc_bulk_desc *desc =
173 list_entry(tmp, struct ptlrpc_bulk_desc, bd_set_chain);
175 /* Skip descriptors that were completed successfully. */
176 if (desc->bd_flags & (PTL_BULK_FL_RCVD | PTL_BULK_FL_SENT))
179 LASSERT(desc->bd_connection);
181 /* If PtlMDUnlink succeeds, then it hasn't completed yet. If it
182 * fails, the bulk finished _just_ in time (after the timeout
183 * fired but before we got this far) and we'll let it live.
185 if (PtlMDUnlink(desc->bd_md_h) != 0) {
186 CERROR("Near-miss on OST %s -- need to adjust "
188 desc->bd_connection->c_remote_uuid);
192 CERROR("IO of %d pages to/from %s:%d (conn %p) timed out\n",
193 desc->bd_page_count, desc->bd_connection->c_remote_uuid,
194 desc->bd_portal, desc->bd_connection);
195 desc->bd_connection->c_level = LUSTRE_CONN_RECOVD;
197 /* This one will "never" arrive, don't wait for it. */
198 if (atomic_dec_and_test(&set->brw_refcount))
199 wake_up(&set->brw_waitq);
201 if (class_signal_connection_failure)
202 class_signal_connection_failure(desc->bd_connection);
207 /* 0 = We go back to sleep, until we're resumed or interrupted */
208 /* 1 = We can't be recovered, just abort the syscall with -ETIMEDOUT */
212 static int ll_sync_brw_intr(void *data)
214 struct obd_brw_set *set = data;
217 set->brw_flags |= PTL_RPC_FL_INTR;
218 RETURN(1); /* ignored, as of this writing */
221 int ll_brw_sync_wait(struct obd_brw_set *set, int phase)
223 struct l_wait_info lwi;
224 struct list_head *tmp, *next;
230 lwi = LWI_TIMEOUT_INTR(obd_timeout * HZ, ll_sync_brw_timeout,
231 ll_sync_brw_intr, set);
232 rc = l_wait_event(set->brw_waitq,
233 atomic_read(&set->brw_refcount) == 0, &lwi);
235 list_for_each_safe(tmp, next, &set->brw_desc_head) {
236 struct ptlrpc_bulk_desc *desc =
237 list_entry(tmp, struct ptlrpc_bulk_desc,
239 list_del_init(&desc->bd_set_chain);
240 ptlrpc_bulk_decref(desc);
243 case CB_PHASE_FINISH:
244 if (atomic_dec_and_test(&set->brw_refcount))
245 wake_up(&set->brw_waitq);
254 struct ptlrpc_request *ptlrpc_prep_req(struct obd_import *imp, int opcode,
255 int count, int *lengths, char **bufs)
257 struct ptlrpc_connection *conn = imp->imp_connection;
258 struct ptlrpc_request *request;
262 OBD_ALLOC(request, sizeof(*request));
264 CERROR("request allocation out of memory\n");
268 rc = lustre_pack_msg(count, lengths, bufs,
269 &request->rq_reqlen, &request->rq_reqmsg);
271 CERROR("cannot pack request %d\n", rc);
272 OBD_FREE(request, sizeof(*request));
276 request->rq_level = LUSTRE_CONN_FULL;
277 request->rq_type = PTL_RPC_MSG_REQUEST;
278 request->rq_import = imp;
280 /* XXX FIXME bug 625069 */
281 request->rq_request_portal = imp->imp_client->cli_request_portal;
282 request->rq_reply_portal = imp->imp_client->cli_reply_portal;
284 request->rq_connection = ptlrpc_connection_addref(conn);
286 INIT_LIST_HEAD(&request->rq_list);
288 * This will be reduced once when the sender is finished (waiting for
289 * reply, f.e.), and once when the request has been committed and is
290 * removed from the to-be-committed list.
292 * Also, the refcount will be increased in ptl_send_rpc immediately
293 * before we hand it off to portals, and there will be a corresponding
294 * decrease in request_out_cb (which is called to indicate that portals
295 * is finished with the request, and it can be safely freed).
297 * (Except in the DLM server case, where it will be dropped twice
298 * by the sender, and then the last time by request_out_callback.)
300 atomic_set(&request->rq_refcount, 2);
302 spin_lock(&conn->c_lock);
303 request->rq_xid = HTON__u32(++conn->c_xid_out);
304 spin_unlock(&conn->c_lock);
306 request->rq_reqmsg->magic = PTLRPC_MSG_MAGIC;
307 request->rq_reqmsg->version = PTLRPC_MSG_VERSION;
308 request->rq_reqmsg->opc = HTON__u32(opcode);
309 request->rq_reqmsg->flags = 0;
311 ptlrpc_hdl2req(request, &imp->imp_handle);
315 void ptlrpc_req_finished(struct ptlrpc_request *request)
320 if (atomic_dec_and_test(&request->rq_refcount))
321 ptlrpc_free_req(request);
323 DEBUG_REQ(D_INFO, request, "refcount now %u",
324 atomic_read(&request->rq_refcount));
327 void ptlrpc_free_req(struct ptlrpc_request *request)
330 if (request == NULL) {
335 if (atomic_read(&request->rq_refcount) != 0) {
336 CERROR("freeing request %p (%d->%s:%d) with refcount %d\n",
337 request, request->rq_reqmsg->opc,
338 request->rq_connection->c_remote_uuid,
339 request->rq_import->imp_client->cli_request_portal,
340 request->rq_refcount);
344 if (request->rq_repmsg != NULL) {
345 OBD_FREE(request->rq_repmsg, request->rq_replen);
346 request->rq_repmsg = NULL;
347 request->rq_reply_md.start = NULL;
349 if (request->rq_reqmsg != NULL) {
350 OBD_FREE(request->rq_reqmsg, request->rq_reqlen);
351 request->rq_reqmsg = NULL;
354 if (request->rq_connection) {
355 spin_lock(&request->rq_connection->c_lock);
356 list_del_init(&request->rq_list);
357 spin_unlock(&request->rq_connection->c_lock);
360 ptlrpc_put_connection(request->rq_connection);
361 OBD_FREE(request, sizeof(*request));
365 static int ptlrpc_check_reply(struct ptlrpc_request *req)
369 if (req->rq_repmsg != NULL) {
370 struct ptlrpc_connection *conn = req->rq_import->imp_connection;
371 if (req->rq_level > conn->c_level) {
373 "rep to xid "LPD64" op %d to %s:%d: "
374 "recovery started, ignoring (%d > %d)\n",
375 (unsigned long long)req->rq_xid,
376 req->rq_reqmsg->opc, conn->c_remote_uuid,
377 req->rq_import->imp_client->cli_request_portal,
378 req->rq_level, conn->c_level);
379 req->rq_repmsg = NULL;
382 req->rq_transno = NTOH__u64(req->rq_repmsg->transno);
383 req->rq_flags |= PTL_RPC_FL_REPLIED;
387 if (req->rq_flags & PTL_RPC_FL_RESEND) {
388 CERROR("-- RESTART --\n");
392 if (req->rq_flags & PTL_RPC_FL_ERR) {
393 CERROR("-- ABORTED --\n");
398 CDEBUG(D_NET, "req = %p, rc = %d\n", req, rc);
402 int ptlrpc_check_status(struct ptlrpc_request *req, int err)
407 CERROR("err is %d\n", err);
412 CERROR("req == NULL\n");
416 if (req->rq_repmsg == NULL) {
417 CERROR("req->rq_repmsg == NULL\n");
421 err = req->rq_repmsg->status;
422 if (req->rq_repmsg->type == NTOH__u32(PTL_RPC_MSG_ERR)) {
423 CERROR("req->rq_repmsg->type == PTL_RPC_MSG_ERR\n");
424 RETURN(err ? err : -EINVAL);
429 CERROR("req->rq_repmsg->status is %d\n", err);
431 CDEBUG(D_INFO, "req->rq_repmsg->status is %d\n", err);
432 /* XXX: translate this error from net to host */
439 static void ptlrpc_cleanup_request_buf(struct ptlrpc_request *request)
441 OBD_FREE(request->rq_reqmsg, request->rq_reqlen);
442 request->rq_reqmsg = NULL;
443 request->rq_reqlen = 0;
446 /* Abort this request and cleanup any resources associated with it. */
447 static int ptlrpc_abort(struct ptlrpc_request *request)
449 /* First remove the ME for the reply; in theory, this means
450 * that we can tear down the buffer safely. */
451 PtlMEUnlink(request->rq_reply_me_h);
452 OBD_FREE(request->rq_reply_md.start, request->rq_replen);
453 request->rq_repmsg = NULL;
454 request->rq_replen = 0;
458 /* caller must hold conn->c_lock */
459 void ptlrpc_free_committed(struct ptlrpc_connection *conn)
461 struct list_head *tmp, *saved;
462 struct ptlrpc_request *req;
465 list_for_each_safe(tmp, saved, &conn->c_sending_head) {
466 req = list_entry(tmp, struct ptlrpc_request, rq_list);
468 if (req->rq_flags & PTL_RPC_FL_REPLAY) {
469 DEBUG_REQ(D_HA, req, "keeping (FL_REPLAY)");
473 if (!(req->rq_flags & PTL_RPC_FL_REPLIED)) {
474 DEBUG_REQ(D_HA, req, "keeping (in-flight)");
478 /* not yet committed */
479 if (req->rq_transno > conn->c_last_committed)
482 DEBUG_REQ(D_HA, req, "committing (last_committed %Lu)",
483 (long long)conn->c_last_committed);
484 if (atomic_dec_and_test(&req->rq_refcount)) {
485 /* We do this to prevent free_req deadlock. Restarting
486 * after each removal is not so bad, as we are almost
487 * always deleting the first item in the list.
489 * If we use a recursive lock here, we can skip the
490 * unlock/lock/restart sequence.
492 spin_unlock(&conn->c_lock);
493 ptlrpc_free_req(req);
494 spin_lock(&conn->c_lock);
497 list_del(&req->rq_list);
498 list_add(&req->rq_list, &conn->c_dying_head);
506 void ptlrpc_cleanup_client(struct obd_import *imp)
508 struct list_head *tmp, *saved;
509 struct ptlrpc_request *req;
510 struct ptlrpc_connection *conn = imp->imp_connection;
516 spin_lock(&conn->c_lock);
517 list_for_each_safe(tmp, saved, &conn->c_sending_head) {
518 req = list_entry(tmp, struct ptlrpc_request, rq_list);
519 if (req->rq_import != imp)
521 /* XXX we should make sure that nobody's sleeping on these! */
522 DEBUG_REQ(D_HA, req, "cleaning up from sending list");
523 list_del_init(&req->rq_list);
524 req->rq_import = NULL;
525 spin_unlock(&conn->c_lock);
526 ptlrpc_req_finished(req);
530 list_for_each_safe(tmp, saved, &conn->c_dying_head) {
531 req = list_entry(tmp, struct ptlrpc_request, rq_list);
532 if (req->rq_import != imp)
534 DEBUG_REQ(D_ERROR, req, "on dying list at cleanup");
535 list_del_init(&req->rq_list);
536 req->rq_import = NULL;
537 spin_unlock(&conn->c_lock);
538 ptlrpc_req_finished(req);
539 spin_lock(&conn->c_lock);
542 spin_unlock(&conn->c_lock);
548 void ptlrpc_continue_req(struct ptlrpc_request *req)
551 CDEBUG(D_HA, "continue delayed request "LPD64" opc %d\n",
552 req->rq_xid, req->rq_reqmsg->opc);
553 req->rq_reqmsg->addr = req->rq_import->imp_handle.addr;
554 req->rq_reqmsg->cookie = req->rq_import->imp_handle.cookie;
555 wake_up(&req->rq_wait_for_rep);
559 void ptlrpc_resend_req(struct ptlrpc_request *req)
562 CDEBUG(D_HA, "resend request "LPD64", opc %d\n",
563 req->rq_xid, req->rq_reqmsg->opc);
564 req->rq_reqmsg->addr = req->rq_import->imp_handle.addr;
565 req->rq_reqmsg->cookie = req->rq_import->imp_handle.cookie;
566 req->rq_status = -EAGAIN;
567 req->rq_level = LUSTRE_CONN_RECOVD;
568 req->rq_flags |= PTL_RPC_FL_RESEND;
569 req->rq_flags &= ~PTL_RPC_FL_TIMEOUT;
570 wake_up(&req->rq_wait_for_rep);
574 void ptlrpc_restart_req(struct ptlrpc_request *req)
577 CDEBUG(D_HA, "restart completed request "LPD64", opc %d\n",
578 req->rq_xid, req->rq_reqmsg->opc);
579 req->rq_status = -ERESTARTSYS;
580 req->rq_flags |= PTL_RPC_FL_RECOVERY;
581 req->rq_flags &= ~PTL_RPC_FL_TIMEOUT;
582 wake_up(&req->rq_wait_for_rep);
586 static int expired_request(void *data)
588 struct ptlrpc_request *req = data;
597 DEBUG_REQ(D_ERROR, req, "timeout");
598 req->rq_flags |= PTL_RPC_FL_TIMEOUT;
600 if (!req->rq_import) {
601 DEBUG_REQ(D_ERROR, req, "NULL import");
606 if (!req->rq_import->imp_connection) {
607 DEBUG_REQ(D_ERROR, req, "NULL connection");
612 if (!req->rq_import->imp_connection->c_recovd_data.rd_recovd)
616 req->rq_connection->c_level = LUSTRE_CONN_RECOVD;
617 recovd_conn_fail(req->rq_import->imp_connection);
619 /* If this request is for recovery or other primordial tasks,
620 * don't go back to sleep.
622 if (req->rq_level < LUSTRE_CONN_FULL)
627 static int interrupted_request(void *data)
629 struct ptlrpc_request *req = data;
631 req->rq_flags |= PTL_RPC_FL_INTR;
632 RETURN(1); /* ignored, as of this writing */
635 /* If we're being torn down by umount -f, or the import has been
636 * invalidated (such as by an OST failure), the request must fail with
639 * Must be called with conn->c_lock held, will drop it if it returns -EIO.
641 * XXX this should just be testing the import, and umount_begin shouldn't touch
642 * XXX the connection.
644 #define EIO_IF_INVALID(conn, req) \
645 if ((conn->c_flags & CONN_INVALID) || \
646 (req->rq_import->imp_flags & IMP_INVALID)) { \
647 DEBUG_REQ(D_ERROR, req, "%s_INVALID:", \
648 (conn->c_flags & CONN_INVALID) ? "CONN" : "IMP"); \
649 spin_unlock(&conn->c_lock); \
653 int ptlrpc_queue_wait(struct ptlrpc_request *req)
656 struct l_wait_info lwi;
657 //struct ptlrpc_client *cli = req->rq_import->imp_client;
658 struct ptlrpc_connection *conn = req->rq_import->imp_connection;
661 init_waitqueue_head(&req->rq_wait_for_rep);
662 req->rq_reqmsg->status = HTON__u32(current->pid); /* for distributed debugging */
663 CDEBUG(D_RPCTRACE, "Sending RPC pid:xid:nid:opc %d:"
665 NTOH__u32(req->rq_reqmsg->status),
667 conn->c_peer.peer_nid,
668 NTOH__u32(req->rq_reqmsg->opc)
671 //DEBUG_REQ(D_HA, req, "subsys: %s:", cli->cli_name);
673 /* XXX probably both an import and connection level are needed */
674 if (req->rq_level > conn->c_level) {
675 spin_lock(&conn->c_lock);
676 EIO_IF_INVALID(conn, req);
677 list_del(&req->rq_list);
678 list_add_tail(&req->rq_list, &conn->c_delayed_head);
679 spin_unlock(&conn->c_lock);
681 DEBUG_REQ(D_HA, req, "waiting for recovery: (%d < %d)",
682 req->rq_level, conn->c_level);
683 lwi = LWI_INTR(NULL, NULL);
684 rc = l_wait_event(req->rq_wait_for_rep,
685 (req->rq_level <= conn->c_level) ||
686 (req->rq_flags & PTL_RPC_FL_ERR), &lwi);
688 spin_lock(&conn->c_lock);
689 list_del_init(&req->rq_list);
690 spin_unlock(&conn->c_lock);
692 if (req->rq_flags & PTL_RPC_FL_ERR)
698 CERROR("process %d resumed\n", current->pid);
701 req->rq_timeout = obd_timeout;
702 spin_lock(&conn->c_lock);
703 EIO_IF_INVALID(conn, req);
705 list_del(&req->rq_list);
706 list_add_tail(&req->rq_list, &conn->c_sending_head);
707 spin_unlock(&conn->c_lock);
708 rc = ptl_send_rpc(req);
710 CDEBUG(D_HA, "error %d, opcode %d, need recovery\n", rc,
711 req->rq_reqmsg->opc);
712 /* the sleep below will time out, triggering recovery */
715 DEBUG_REQ(D_NET, req, "-- sleeping");
716 lwi = LWI_TIMEOUT_INTR(req->rq_timeout * HZ, expired_request,
717 interrupted_request, req);
718 l_wait_event(req->rq_wait_for_rep, ptlrpc_check_reply(req), &lwi);
719 DEBUG_REQ(D_NET, req, "-- done sleeping");
721 if (req->rq_flags & PTL_RPC_FL_ERR) {
723 GOTO(out, rc = -EIO);
726 /* Don't resend if we were interrupted. */
727 if ((req->rq_flags & (PTL_RPC_FL_RESEND | PTL_RPC_FL_INTR)) ==
729 req->rq_flags &= ~PTL_RPC_FL_RESEND;
730 DEBUG_REQ(D_HA, req, "resending: ");
734 // up(&cli->cli_rpc_sem);
735 if (req->rq_flags & PTL_RPC_FL_INTR) {
736 if (!(req->rq_flags & PTL_RPC_FL_TIMEOUT))
737 LBUG(); /* should only be interrupted if we timed out */
738 /* Clean up the dangling reply buffers */
740 GOTO(out, rc = -EINTR);
743 if (req->rq_flags & PTL_RPC_FL_TIMEOUT)
744 GOTO(out, rc = -ETIMEDOUT);
746 if (!(req->rq_flags & PTL_RPC_FL_REPLIED))
747 GOTO(out, rc = req->rq_status);
749 rc = lustre_unpack_msg(req->rq_repmsg, req->rq_replen);
751 CERROR("unpack_rep failed: %d\n", rc);
755 /* FIXME: Enable when BlueArc makes new release */
756 if (req->rq_repmsg->type != PTL_RPC_MSG_REPLY &&
757 req->rq_repmsg->type != PTL_RPC_MSG_ERR) {
758 CERROR("invalid packet type received (type=%u)\n",
759 req->rq_repmsg->type);
761 GOTO(out, rc = -EINVAL);
764 CDEBUG(D_NET, "got rep "LPD64"\n", req->rq_xid);
765 if (req->rq_repmsg->status == 0)
766 CDEBUG(D_NET, "--> buf %p len %d status %d\n", req->rq_repmsg,
767 req->rq_replen, req->rq_repmsg->status);
769 spin_lock(&conn->c_lock);
771 /* Requests that aren't from replayable imports, or which don't have
772 * transno information, can be "committed" early.
774 * But don't commit anything that's kept indefinitely for replay (has
775 * the PTL_RPC_FL_REPLAY flag set), such as open requests.
777 if ((req->rq_import->imp_flags & IMP_REPLAYABLE) == 0 ||
778 (req->rq_repmsg->transno == 0 &&
779 (req->rq_flags & PTL_RPC_FL_REPLAY) == 0)) {
780 /* This import doesn't support replay, so we can just "commit"
783 DEBUG_REQ(D_HA, req, "not replayable, committing:");
784 list_del_init(&req->rq_list);
785 spin_unlock(&conn->c_lock);
786 ptlrpc_req_finished(req); /* Must be called unlocked. */
787 spin_lock(&conn->c_lock);
788 } else /* if (req->rq_import->imp_flags & IMP_REPLAYABLE) */ {
789 /* Replay-enabled imports return commit-status information. */
790 /* XXX this needs to be per-import, or multiple MDS services on
791 * XXX the same system are going to interfere messily with each
792 * XXX others' transno spaces.
794 conn->c_last_xid = req->rq_repmsg->last_xid;
795 conn->c_last_committed = req->rq_repmsg->last_committed;
796 ptlrpc_free_committed(conn);
799 spin_unlock(&conn->c_lock);
806 #undef EIO_IF_INVALID
808 int ptlrpc_replay_req(struct ptlrpc_request *req)
810 int rc = 0, old_level, old_status = 0;
811 // struct ptlrpc_client *cli = req->rq_import->imp_client;
812 struct l_wait_info lwi;
815 init_waitqueue_head(&req->rq_wait_for_rep);
816 DEBUG_REQ(D_NET, req, "");
818 req->rq_timeout = obd_timeout;
819 req->rq_reqmsg->addr = req->rq_import->imp_handle.addr;
820 req->rq_reqmsg->cookie = req->rq_import->imp_handle.cookie;
822 /* temporarily set request to RECOVD level (reset at out:) */
823 old_level = req->rq_level;
824 if (req->rq_flags & PTL_RPC_FL_REPLIED)
825 old_status = req->rq_repmsg->status;
826 req->rq_level = LUSTRE_CONN_RECOVD;
827 rc = ptl_send_rpc(req);
829 CERROR("error %d, opcode %d\n", rc, req->rq_reqmsg->opc);
830 ptlrpc_cleanup_request_buf(req);
831 // up(&cli->cli_rpc_sem);
835 CDEBUG(D_OTHER, "-- sleeping\n");
836 lwi = LWI_INTR(NULL, NULL); /* XXX needs timeout, nested recovery */
837 l_wait_event(req->rq_wait_for_rep, ptlrpc_check_reply(req), &lwi);
838 CDEBUG(D_OTHER, "-- done\n");
840 // up(&cli->cli_rpc_sem);
842 if (!(req->rq_flags & PTL_RPC_FL_REPLIED)) {
843 CERROR("Unknown reason for wakeup\n");
844 /* XXX Phil - I end up here when I kill obdctl */
846 GOTO(out, rc = -EINTR);
849 rc = lustre_unpack_msg(req->rq_repmsg, req->rq_replen);
851 CERROR("unpack_rep failed: %d\n", rc);
855 CDEBUG(D_NET, "got rep "LPD64"\n", req->rq_xid);
857 /* let the callback do fixups, possibly including in the request */
858 if (req->rq_replay_cb)
859 req->rq_replay_cb(req);
861 if ((req->rq_flags & PTL_RPC_FL_REPLIED) &&
862 req->rq_repmsg->status != old_status) {
863 DEBUG_REQ(D_HA, req, "status %d, old was %d",
864 req->rq_repmsg->status, old_status);
868 req->rq_level = old_level;