1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (c) 2002, 2003 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
27 #include <liblustre.h>
30 #include <linux/obd_support.h>
31 #include <linux/obd_class.h>
32 #include <linux/lustre_lib.h>
33 #include <linux/lustre_ha.h>
34 #include <linux/lustre_import.h>
36 #include "ptlrpc_internal.h"
38 void ptlrpc_init_client(int req_portal, int rep_portal, char *name,
39 struct ptlrpc_client *cl)
41 cl->cli_request_portal = req_portal;
42 cl->cli_reply_portal = rep_portal;
46 struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid)
48 struct ptlrpc_connection *c;
49 struct ptlrpc_peer peer;
52 err = ptlrpc_uuid_to_peer(uuid, &peer);
54 CERROR("cannot find peer %s!\n", uuid->uuid);
58 c = ptlrpc_get_connection(&peer, uuid);
60 memcpy(c->c_remote_uuid.uuid,
61 uuid->uuid, sizeof(c->c_remote_uuid.uuid));
64 CDEBUG(D_INFO, "%s -> %p\n", uuid->uuid, c);
69 void ptlrpc_readdress_connection(struct ptlrpc_connection *conn,
70 struct obd_uuid *uuid)
72 struct ptlrpc_peer peer;
75 err = ptlrpc_uuid_to_peer(uuid, &peer);
77 CERROR("cannot find peer %s!\n", uuid->uuid);
81 memcpy(&conn->c_peer, &peer, sizeof (peer));
85 static inline struct ptlrpc_bulk_desc *new_bulk(void)
87 struct ptlrpc_bulk_desc *desc;
89 OBD_ALLOC(desc, sizeof(*desc));
93 spin_lock_init(&desc->bd_lock);
94 init_waitqueue_head(&desc->bd_waitq);
95 INIT_LIST_HEAD(&desc->bd_page_list);
96 desc->bd_md_h = PTL_HANDLE_NONE;
97 desc->bd_me_h = PTL_HANDLE_NONE;
102 struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp (struct ptlrpc_request *req,
103 int type, int portal)
105 struct obd_import *imp = req->rq_import;
106 struct ptlrpc_bulk_desc *desc;
108 LASSERT(type == BULK_PUT_SINK || type == BULK_GET_SOURCE);
114 desc->bd_import_generation = req->rq_import_generation;
115 desc->bd_import = class_import_get(imp);
117 desc->bd_type = type;
118 desc->bd_portal = portal;
120 /* This makes req own desc, and free it when she frees herself */
126 struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_exp (struct ptlrpc_request *req,
127 int type, int portal)
129 struct obd_export *exp = req->rq_export;
130 struct ptlrpc_bulk_desc *desc;
132 LASSERT(type == BULK_PUT_SOURCE || type == BULK_GET_SINK);
138 desc->bd_export = class_export_get(exp);
140 desc->bd_type = type;
141 desc->bd_portal = portal;
143 /* NB we don't assign rq_bulk here; server-side requests are
144 * re-used, and the handler frees the bulk desc explicitly. */
149 int ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
150 struct page *page, int pageoffset, int len)
152 struct ptlrpc_bulk_page *bulk;
154 OBD_ALLOC(bulk, sizeof(*bulk));
158 LASSERT(page != NULL);
159 LASSERT(pageoffset >= 0);
161 LASSERT(pageoffset + len <= PAGE_SIZE);
163 bulk->bp_page = page;
164 bulk->bp_pageoffset = pageoffset;
165 bulk->bp_buflen = len;
167 bulk->bp_desc = desc;
168 list_add_tail(&bulk->bp_link, &desc->bd_page_list);
169 desc->bd_page_count++;
173 void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc)
175 struct list_head *tmp, *next;
178 LASSERT(desc != NULL);
179 LASSERT(desc->bd_page_count != 0x5a5a5a5a); /* not freed already */
180 LASSERT(!desc->bd_network_rw); /* network hands off or */
182 list_for_each_safe(tmp, next, &desc->bd_page_list) {
183 struct ptlrpc_bulk_page *bulk;
184 bulk = list_entry(tmp, struct ptlrpc_bulk_page, bp_link);
185 ptlrpc_free_bulk_page(bulk);
188 LASSERT(desc->bd_page_count == 0);
189 LASSERT((desc->bd_export != NULL) ^ (desc->bd_import != NULL));
192 class_export_put(desc->bd_export);
194 class_import_put(desc->bd_import);
196 OBD_FREE(desc, sizeof(*desc));
200 void ptlrpc_free_bulk_page(struct ptlrpc_bulk_page *bulk)
202 LASSERT(bulk != NULL);
204 list_del(&bulk->bp_link);
205 bulk->bp_desc->bd_page_count--;
206 OBD_FREE(bulk, sizeof(*bulk));
209 struct ptlrpc_request *ptlrpc_prep_req(struct obd_import *imp, int opcode,
210 int count, int *lengths, char **bufs)
212 struct ptlrpc_request *request;
216 LASSERT((unsigned long)imp > 0x1000);
218 OBD_ALLOC(request, sizeof(*request));
220 CERROR("request allocation out of memory\n");
224 rc = lustre_pack_request(request, count, lengths, bufs);
226 CERROR("cannot pack request %d\n", rc);
227 OBD_FREE(request, sizeof(*request));
231 if (imp->imp_server_timeout)
232 request->rq_timeout = obd_timeout / 2;
234 request->rq_timeout = obd_timeout;
235 request->rq_send_state = LUSTRE_IMP_FULL;
236 request->rq_type = PTL_RPC_MSG_REQUEST;
237 request->rq_import = class_import_get(imp);
238 request->rq_phase = RQ_PHASE_NEW;
240 /* XXX FIXME bug 249 */
241 request->rq_request_portal = imp->imp_client->cli_request_portal;
242 request->rq_reply_portal = imp->imp_client->cli_reply_portal;
244 spin_lock_init(&request->rq_lock);
245 INIT_LIST_HEAD(&request->rq_list);
246 INIT_LIST_HEAD(&request->rq_replay_list);
247 init_waitqueue_head(&request->rq_reply_waitq);
248 request->rq_xid = ptlrpc_next_xid();
249 atomic_set(&request->rq_refcount, 1);
251 request->rq_reqmsg->opc = opcode;
252 request->rq_reqmsg->flags = 0;
257 struct ptlrpc_request_set *ptlrpc_prep_set(void)
259 struct ptlrpc_request_set *set;
261 OBD_ALLOC(set, sizeof *set);
264 INIT_LIST_HEAD(&set->set_requests);
265 init_waitqueue_head(&set->set_waitq);
266 set->set_remaining = 0;
267 spin_lock_init(&set->set_new_req_lock);
268 INIT_LIST_HEAD(&set->set_new_requests);
273 /* Finish with this set; opposite of prep_set. */
274 void ptlrpc_set_destroy(struct ptlrpc_request_set *set)
276 struct list_head *tmp;
277 struct list_head *next;
282 /* Requests on the set should either all be completed, or all be new */
283 expected_phase = (set->set_remaining == 0) ?
284 RQ_PHASE_COMPLETE : RQ_PHASE_NEW;
285 list_for_each (tmp, &set->set_requests) {
286 struct ptlrpc_request *req =
287 list_entry(tmp, struct ptlrpc_request, rq_set_chain);
289 LASSERT(req->rq_phase == expected_phase);
293 LASSERT(set->set_remaining == 0 || set->set_remaining == n);
295 list_for_each_safe(tmp, next, &set->set_requests) {
296 struct ptlrpc_request *req =
297 list_entry(tmp, struct ptlrpc_request, rq_set_chain);
298 list_del_init(&req->rq_set_chain);
300 LASSERT(req->rq_phase == expected_phase);
302 if (req->rq_phase == RQ_PHASE_NEW) {
304 if (req->rq_interpret_reply != NULL) {
305 int (*interpreter)(struct ptlrpc_request *,
307 req->rq_interpret_reply;
309 /* higher level (i.e. LOV) failed;
310 * let the sub reqs clean up */
311 req->rq_status = -EBADR;
312 interpreter(req, &req->rq_async_args,
315 set->set_remaining--;
319 ptlrpc_req_finished (req);
322 LASSERT(set->set_remaining == 0);
324 OBD_FREE(set, sizeof(*set));
328 void ptlrpc_set_add_req(struct ptlrpc_request_set *set,
329 struct ptlrpc_request *req)
331 /* The set takes over the caller's request reference */
332 list_add_tail(&req->rq_set_chain, &set->set_requests);
334 set->set_remaining++;
337 /* lock so many callers can add things, the context that owns the set
338 * is supposed to notice these and move them into the set proper. */
339 void ptlrpc_set_add_new_req(struct ptlrpc_request_set *set,
340 struct ptlrpc_request *req)
343 spin_lock_irqsave(&set->set_new_req_lock, flags);
344 /* The set takes over the caller's request reference */
345 list_add_tail(&req->rq_set_chain, &set->set_new_requests);
347 spin_unlock_irqrestore(&set->set_new_req_lock, flags);
351 * Based on the current state of the import, determine if the request
352 * can be sent, is an error, or should be delayed.
354 * Returns true if this request should be delayed. If false, and
355 * *status is set, then the request can not be sent and *status is the
356 * error code. If false and status is 0, then request can be sent.
358 * The imp->imp_lock must be held.
360 static int ptlrpc_import_delay_req(struct obd_import *imp,
361 struct ptlrpc_request *req, int *status)
366 LASSERT (status != NULL);
369 if (imp->imp_state == LUSTRE_IMP_NEW) {
370 DEBUG_REQ(D_ERROR, req, "Uninitialized import.");
374 else if (imp->imp_state == LUSTRE_IMP_CLOSED) {
375 DEBUG_REQ(D_ERROR, req, "IMP_CLOSED ");
379 * If the import has been invalidated (such as by an OST failure), the
380 * request must fail with -EIO.
382 else if (imp->imp_invalid) {
383 DEBUG_REQ(D_ERROR, req, "IMP_INVALID");
386 else if (req->rq_import_generation != imp->imp_generation) {
387 DEBUG_REQ(D_ERROR, req, "req wrong generation:");
390 else if (req->rq_send_state != imp->imp_state) {
391 if (imp->imp_obd->obd_no_recov || imp->imp_dlm_fake)
392 *status = -EWOULDBLOCK;
400 static int ptlrpc_check_reply(struct ptlrpc_request *req)
406 /* serialise with network callback */
407 spin_lock_irqsave (&req->rq_lock, flags);
409 if (req->rq_replied) {
410 DEBUG_REQ(D_NET, req, "REPLIED:");
415 DEBUG_REQ(D_ERROR, req, "ABORTED:");
419 if (req->rq_resend) {
420 DEBUG_REQ(D_ERROR, req, "RESEND:");
424 if (req->rq_restart) {
425 DEBUG_REQ(D_ERROR, req, "RESTART:");
430 spin_unlock_irqrestore (&req->rq_lock, flags);
431 DEBUG_REQ(D_NET, req, "rc = %d for", rc);
435 static int ptlrpc_check_status(struct ptlrpc_request *req)
440 err = req->rq_repmsg->status;
441 if (req->rq_repmsg->type == PTL_RPC_MSG_ERR) {
442 DEBUG_REQ(D_ERROR, req, "type == PTL_RPC_MSG_ERR, err == %d",
444 RETURN(err < 0 ? err : -EINVAL);
448 DEBUG_REQ(D_INFO, req, "status is %d", err);
449 } else if (err > 0) {
450 /* XXX: translate this error from net to host */
451 DEBUG_REQ(D_INFO, req, "status is %d", err);
457 static int after_reply(struct ptlrpc_request *req)
460 struct obd_import *imp = req->rq_import;
464 LASSERT(!req->rq_receiving_reply);
465 LASSERT(req->rq_replied);
467 /* NB Until this point, the whole of the incoming message,
468 * including buflens, status etc is in the sender's byte order. */
471 /* Clear reply swab mask; this is a new reply in sender's byte order */
472 req->rq_rep_swab_mask = 0;
474 rc = lustre_unpack_msg(req->rq_repmsg, req->rq_replen);
476 CERROR("unpack_rep failed: %d\n", rc);
480 if (req->rq_repmsg->type != PTL_RPC_MSG_REPLY &&
481 req->rq_repmsg->type != PTL_RPC_MSG_ERR) {
482 CERROR("invalid packet type received (type=%u)\n",
483 req->rq_repmsg->type);
487 /* Store transno in reqmsg for replay. */
488 req->rq_reqmsg->transno = req->rq_transno = req->rq_repmsg->transno;
490 rc = ptlrpc_check_status(req);
492 /* Either we've been evicted, or the server has failed for
493 * some reason. Try to reconnect, and if that fails, punt to the
495 if (rc == -ENOTCONN) {
496 if (req->rq_send_state != LUSTRE_IMP_FULL ||
497 imp->imp_obd->obd_no_recov || imp->imp_dlm_fake) {
501 ptlrpc_request_handle_notconn(req);
506 if (req->rq_import->imp_replayable) {
507 spin_lock_irqsave(&imp->imp_lock, flags);
508 if (req->rq_replay || req->rq_transno != 0)
509 ptlrpc_retain_replayable_request(req, imp);
510 else if (req->rq_commit_cb != NULL)
511 req->rq_commit_cb(req);
513 if (req->rq_transno > imp->imp_max_transno)
514 imp->imp_max_transno = req->rq_transno;
516 /* Replay-enabled imports return commit-status information. */
517 if (req->rq_repmsg->last_committed)
518 imp->imp_peer_committed_transno =
519 req->rq_repmsg->last_committed;
520 ptlrpc_free_committed(imp);
521 spin_unlock_irqrestore(&imp->imp_lock, flags);
527 static int ptlrpc_send_new_req(struct ptlrpc_request *req)
529 struct obd_import *imp;
534 LASSERT(req->rq_phase == RQ_PHASE_NEW);
535 req->rq_phase = RQ_PHASE_RPC;
537 imp = req->rq_import;
538 spin_lock_irqsave(&imp->imp_lock, flags);
540 if (imp->imp_invalid) {
541 spin_unlock_irqrestore(&imp->imp_lock, flags);
542 req->rq_status = -EIO;
543 req->rq_phase = RQ_PHASE_INTERPRET;
547 req->rq_import_generation = imp->imp_generation;
549 if (ptlrpc_import_delay_req(imp, req, &rc)) {
550 spin_lock (&req->rq_lock);
552 spin_unlock (&req->rq_lock);
554 LASSERT(list_empty (&req->rq_list));
556 // list_del(&req->rq_list);
557 list_add_tail(&req->rq_list, &imp->imp_delayed_list);
558 spin_unlock_irqrestore(&imp->imp_lock, flags);
563 spin_unlock_irqrestore(&imp->imp_lock, flags);
565 req->rq_phase = RQ_PHASE_INTERPRET;
569 /* XXX this is the same as ptlrpc_queue_wait */
570 LASSERT(list_empty(&req->rq_list));
571 list_add_tail(&req->rq_list, &imp->imp_sending_list);
572 spin_unlock_irqrestore(&imp->imp_lock, flags);
574 req->rq_reqmsg->status = current->pid;
575 CDEBUG(D_RPCTRACE, "Sending RPC pname:cluuid:pid:xid:ni:nid:opc"
576 " %s:%s:%d:"LPU64":%s:"LPX64":%d\n", current->comm,
577 imp->imp_obd->obd_uuid.uuid, req->rq_reqmsg->status,
579 imp->imp_connection->c_peer.peer_ni->pni_name,
580 imp->imp_connection->c_peer.peer_nid,
581 req->rq_reqmsg->opc);
583 rc = ptl_send_rpc(req);
585 DEBUG_REQ(D_HA, req, "send failed (%d); expect timeout", rc);
592 int ptlrpc_check_set(struct ptlrpc_request_set *set)
595 struct list_head *tmp;
596 int force_timer_recalc = 0;
599 if (set->set_remaining == 0)
602 list_for_each(tmp, &set->set_requests) {
603 struct ptlrpc_request *req =
604 list_entry(tmp, struct ptlrpc_request, rq_set_chain);
605 struct obd_import *imp = req->rq_import;
608 if (req->rq_phase == RQ_PHASE_NEW &&
609 ptlrpc_send_new_req(req)) {
610 force_timer_recalc = 1;
613 if (!(req->rq_phase == RQ_PHASE_RPC ||
614 req->rq_phase == RQ_PHASE_BULK ||
615 req->rq_phase == RQ_PHASE_INTERPRET ||
616 req->rq_phase == RQ_PHASE_COMPLETE)) {
617 DEBUG_REQ(D_ERROR, req, "bad phase %x", req->rq_phase);
621 if (req->rq_phase == RQ_PHASE_COMPLETE)
624 if (req->rq_phase == RQ_PHASE_INTERPRET)
625 GOTO(interpret, req->rq_status);
628 ptlrpc_unregister_reply(req);
629 if (req->rq_status == 0)
630 req->rq_status = -EIO;
631 req->rq_phase = RQ_PHASE_INTERPRET;
633 spin_lock_irqsave(&imp->imp_lock, flags);
634 list_del_init(&req->rq_list);
635 spin_unlock_irqrestore(&imp->imp_lock, flags);
637 GOTO(interpret, req->rq_status);
640 /* ptlrpc_queue_wait->l_wait_event guarantees that rq_intr
641 * will only be set after rq_timedout, but the osic waiting
642 * path sets rq_intr irrespective of whether ptlrpcd has
643 * seen a timeout. our policy is to only interpret
644 * interrupted rpcs after they have timed out */
645 if (req->rq_intr && (req->rq_timedout || req->rq_waiting)) {
646 /* NB could be on delayed list */
647 ptlrpc_unregister_reply(req);
648 req->rq_status = -EINTR;
649 req->rq_phase = RQ_PHASE_INTERPRET;
651 spin_lock_irqsave(&imp->imp_lock, flags);
652 list_del_init(&req->rq_list);
653 spin_unlock_irqrestore(&imp->imp_lock, flags);
655 GOTO(interpret, req->rq_status);
658 if (req->rq_phase == RQ_PHASE_RPC) {
659 if (req->rq_waiting || req->rq_resend) {
661 spin_lock_irqsave(&imp->imp_lock, flags);
663 if (ptlrpc_import_delay_req(imp, req, &status)) {
664 spin_unlock_irqrestore(&imp->imp_lock,
669 list_del(&req->rq_list);
670 list_add_tail(&req->rq_list,
671 &imp->imp_sending_list);
674 req->rq_status = status;
675 req->rq_phase = RQ_PHASE_INTERPRET;
676 spin_unlock_irqrestore(&imp->imp_lock,
678 GOTO(interpret, req->rq_status);
680 spin_unlock_irqrestore(&imp->imp_lock, flags);
683 if (req->rq_resend) {
684 lustre_msg_add_flags(req->rq_reqmsg,
686 ptlrpc_unregister_reply(req);
688 __u64 old_xid = req->rq_xid;
689 ptlrpc_unregister_bulk(req);
690 /* ensure previous bulk fails */
691 req->rq_xid = ptlrpc_next_xid();
692 CDEBUG(D_HA, "resend bulk "
695 old_xid, req->rq_xid);
699 rc = ptl_send_rpc(req);
701 DEBUG_REQ(D_HA, req, "send failed (%d)",
703 force_timer_recalc = 1;
706 /* need to reset the timeout */
707 force_timer_recalc = 1;
710 /* Ensure the network callback returned */
711 spin_lock_irqsave (&req->rq_lock, flags);
712 if (!req->rq_replied) {
713 spin_unlock_irqrestore (&req->rq_lock, flags);
716 spin_unlock_irqrestore (&req->rq_lock, flags);
718 spin_lock_irqsave(&imp->imp_lock, flags);
719 list_del_init(&req->rq_list);
720 spin_unlock_irqrestore(&imp->imp_lock, flags);
722 req->rq_status = after_reply(req);
723 if (req->rq_resend) {
724 /* Add this req to the delayed list so
725 it can be errored if the import is
726 evicted after recovery. */
727 spin_lock_irqsave (&req->rq_lock, flags);
728 list_add_tail(&req->rq_list,
729 &imp->imp_delayed_list);
730 spin_unlock_irqrestore(&req->rq_lock, flags);
734 /* If there is no bulk associated with this request,
735 * then we're done and should let the interpreter
736 * process the reply. Similarly if the RPC returned
737 * an error, and therefore the bulk will never arrive.
739 if (req->rq_bulk == NULL || req->rq_status != 0) {
740 req->rq_phase = RQ_PHASE_INTERPRET;
741 GOTO(interpret, req->rq_status);
744 req->rq_phase = RQ_PHASE_BULK;
747 LASSERT(req->rq_phase == RQ_PHASE_BULK);
748 if (!ptlrpc_bulk_complete (req->rq_bulk))
751 req->rq_phase = RQ_PHASE_INTERPRET;
754 LASSERT(req->rq_phase == RQ_PHASE_INTERPRET);
755 LASSERT(!req->rq_receiving_reply);
757 ptlrpc_unregister_reply(req);
758 if (req->rq_bulk != NULL)
759 ptlrpc_unregister_bulk (req);
761 req->rq_phase = RQ_PHASE_COMPLETE;
763 if (req->rq_interpret_reply != NULL) {
764 int (*interpreter)(struct ptlrpc_request *,void *,int) =
765 req->rq_interpret_reply;
766 req->rq_status = interpreter(req, &req->rq_async_args,
770 CDEBUG(D_RPCTRACE, "Completed RPC pname:cluuid:pid:xid:ni:nid:"
771 "opc %s:%s:%d:"LPU64":%s:"LPX64":%d\n", current->comm,
772 imp->imp_obd->obd_uuid.uuid, req->rq_reqmsg->status,
774 imp->imp_connection->c_peer.peer_ni->pni_name,
775 imp->imp_connection->c_peer.peer_nid,
776 req->rq_reqmsg->opc);
778 set->set_remaining--;
781 /* If we hit an error, we want to recover promptly. */
782 RETURN(set->set_remaining == 0 || force_timer_recalc);
785 int ptlrpc_expire_one_request(struct ptlrpc_request *req)
788 struct obd_import *imp = req->rq_import;
791 DEBUG_REQ(D_ERROR, req, "timeout");
793 spin_lock_irqsave (&req->rq_lock, flags);
794 req->rq_timedout = 1;
795 spin_unlock_irqrestore (&req->rq_lock, flags);
797 ptlrpc_unregister_reply (req);
800 DEBUG_REQ(D_HA, req, "NULL import: already cleaned up?");
804 /* The DLM server doesn't want recovery run on its imports. */
805 if (imp->imp_dlm_fake)
808 /* If this request is for recovery or other primordial tasks,
809 * then error it out here. */
810 if (req->rq_send_state != LUSTRE_IMP_FULL ||
811 imp->imp_obd->obd_no_recov) {
812 spin_lock_irqsave (&req->rq_lock, flags);
813 req->rq_status = -ETIMEDOUT;
815 spin_unlock_irqrestore (&req->rq_lock, flags);
819 ptlrpc_fail_import(imp, req->rq_import_generation);
824 int ptlrpc_expired_set(void *data)
826 struct ptlrpc_request_set *set = data;
827 struct list_head *tmp;
828 time_t now = LTIME_S (CURRENT_TIME);
831 LASSERT(set != NULL);
833 /* A timeout expired; see which reqs it applies to... */
834 list_for_each (tmp, &set->set_requests) {
835 struct ptlrpc_request *req =
836 list_entry(tmp, struct ptlrpc_request, rq_set_chain);
838 /* request in-flight? */
839 if (!((req->rq_phase == RQ_PHASE_RPC && !req->rq_waiting
840 && !req->rq_resend) ||
841 (req->rq_phase == RQ_PHASE_BULK)))
844 if (req->rq_timedout || /* already dealt with */
845 req->rq_sent + req->rq_timeout > now) /* not expired */
848 /* deal with this guy */
849 ptlrpc_expire_one_request (req);
852 /* When waiting for a whole set, we always to break out of the
853 * sleep so we can recalculate the timeout, or enable interrupts
854 * iff everyone's timed out.
859 void ptlrpc_mark_interrupted(struct ptlrpc_request *req)
862 spin_lock_irqsave(&req->rq_lock, flags);
864 spin_unlock_irqrestore(&req->rq_lock, flags);
867 void ptlrpc_interrupted_set(void *data)
869 struct ptlrpc_request_set *set = data;
870 struct list_head *tmp;
872 LASSERT(set != NULL);
873 CERROR("INTERRUPTED SET %p\n", set);
875 list_for_each(tmp, &set->set_requests) {
876 struct ptlrpc_request *req =
877 list_entry(tmp, struct ptlrpc_request, rq_set_chain);
879 if (req->rq_phase != RQ_PHASE_RPC)
882 ptlrpc_mark_interrupted(req);
886 int ptlrpc_set_next_timeout(struct ptlrpc_request_set *set)
888 struct list_head *tmp;
889 time_t now = LTIME_S(CURRENT_TIME);
892 struct ptlrpc_request *req;
895 SIGNAL_MASK_ASSERT(); /* XXX BUG 1511 */
897 list_for_each(tmp, &set->set_requests) {
898 req = list_entry(tmp, struct ptlrpc_request, rq_set_chain);
900 /* request in-flight? */
901 if (!((req->rq_phase == RQ_PHASE_RPC && !req->rq_waiting) ||
902 (req->rq_phase == RQ_PHASE_BULK)))
905 if (req->rq_timedout) /* already timed out */
908 deadline = req->rq_sent + req->rq_timeout;
909 if (deadline <= now) /* actually expired already */
910 timeout = 1; /* ASAP */
911 else if (timeout == 0 || timeout > deadline - now)
912 timeout = deadline - now;
918 int ptlrpc_set_wait(struct ptlrpc_request_set *set)
920 struct list_head *tmp;
921 struct ptlrpc_request *req;
922 struct l_wait_info lwi;
926 LASSERT(!list_empty(&set->set_requests));
927 list_for_each(tmp, &set->set_requests) {
928 req = list_entry(tmp, struct ptlrpc_request, rq_set_chain);
929 (void)ptlrpc_send_new_req(req);
933 timeout = ptlrpc_set_next_timeout(set);
935 /* wait until all complete, interrupted, or an in-flight
937 CDEBUG(D_HA, "set %p going to sleep for %d seconds\n",
939 lwi = LWI_TIMEOUT_INTR((timeout ? timeout : 1) * HZ,
941 ptlrpc_interrupted_set, set);
942 rc = l_wait_event(set->set_waitq, ptlrpc_check_set(set), &lwi);
944 LASSERT(rc == 0 || rc == -EINTR || rc == -ETIMEDOUT);
946 /* -EINTR => all requests have been flagged rq_intr so next
948 * -ETIMEOUTD => someone timed out. When all reqs have
949 * timed out, signals are enabled allowing completion with
951 * I don't really care if we go once more round the loop in
952 * the error cases -eeb. */
955 LASSERT(set->set_remaining == 0);
958 list_for_each(tmp, &set->set_requests) {
959 req = list_entry(tmp, struct ptlrpc_request, rq_set_chain);
961 LASSERT(req->rq_phase == RQ_PHASE_COMPLETE);
962 if (req->rq_status != 0)
966 if (set->set_interpret != NULL) {
967 int (*interpreter)(struct ptlrpc_request_set *set,void *,int) =
969 rc = interpreter (set, &set->set_args, rc);
975 static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked)
978 if (request == NULL) {
983 LASSERT(!request->rq_receiving_reply);
985 /* We must take it off the imp_replay_list first. Otherwise, we'll set
986 * request->rq_reqmsg to NULL while osc_close is dereferencing it. */
987 if (request->rq_import != NULL) {
988 unsigned long flags = 0;
990 spin_lock_irqsave(&request->rq_import->imp_lock, flags);
991 list_del_init(&request->rq_replay_list);
993 spin_unlock_irqrestore(&request->rq_import->imp_lock,
997 if (atomic_read(&request->rq_refcount) != 0) {
998 DEBUG_REQ(D_ERROR, request,
999 "freeing request with nonzero refcount");
1003 if (request->rq_repmsg != NULL) {
1004 OBD_FREE(request->rq_repmsg, request->rq_replen);
1005 request->rq_repmsg = NULL;
1007 if (request->rq_reqmsg != NULL) {
1008 OBD_FREE(request->rq_reqmsg, request->rq_reqlen);
1009 request->rq_reqmsg = NULL;
1011 if (request->rq_export != NULL) {
1012 class_export_put(request->rq_export);
1013 request->rq_export = NULL;
1015 if (request->rq_import != NULL) {
1016 class_import_put(request->rq_import);
1017 request->rq_import = NULL;
1019 if (request->rq_bulk != NULL)
1020 ptlrpc_free_bulk(request->rq_bulk);
1022 OBD_FREE(request, sizeof(*request));
1026 void ptlrpc_free_req(struct ptlrpc_request *request)
1028 __ptlrpc_free_req(request, 0);
1031 static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked);
1032 void ptlrpc_req_finished_with_imp_lock(struct ptlrpc_request *request)
1035 LASSERT(spin_is_locked(&request->rq_import->imp_lock));
1037 (void)__ptlrpc_req_finished(request, 1);
1040 static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked)
1043 if (request == NULL)
1046 if (request == (void *)(unsigned long)(0x5a5a5a5a5a5a5a5a) ||
1047 request->rq_reqmsg == (void *)(unsigned long)(0x5a5a5a5a5a5a5a5a)) {
1048 CERROR("dereferencing freed request (bug 575)\n");
1053 DEBUG_REQ(D_INFO, request, "refcount now %u",
1054 atomic_read(&request->rq_refcount) - 1);
1056 if (atomic_dec_and_test(&request->rq_refcount)) {
1057 __ptlrpc_free_req(request, locked);
1064 void ptlrpc_req_finished(struct ptlrpc_request *request)
1066 __ptlrpc_req_finished(request, 0);
1069 /* Disengage the client's reply buffer from the network
1070 * NB does _NOT_ unregister any client-side bulk.
1071 * IDEMPOTENT, but _not_ safe against concurrent callers.
1072 * The request owner (i.e. the thread doing the I/O) must call...
1074 void ptlrpc_unregister_reply (struct ptlrpc_request *request)
1076 unsigned long flags;
1080 LASSERT(!in_interrupt ()); /* might sleep */
1082 spin_lock_irqsave (&request->rq_lock, flags);
1083 if (!request->rq_receiving_reply) { /* not waiting for a reply */
1084 spin_unlock_irqrestore (&request->rq_lock, flags);
1086 /* NB reply buffer not freed here */
1090 LASSERT(!request->rq_replied); /* callback hasn't completed */
1091 spin_unlock_irqrestore (&request->rq_lock, flags);
1093 rc = PtlMDUnlink (request->rq_reply_md_h);
1098 case PTL_OK: /* unlinked before completion */
1099 LASSERT(request->rq_receiving_reply);
1100 LASSERT(!request->rq_replied);
1101 spin_lock_irqsave (&request->rq_lock, flags);
1102 request->rq_receiving_reply = 0;
1103 spin_unlock_irqrestore (&request->rq_lock, flags);
1104 OBD_FREE(request->rq_repmsg, request->rq_replen);
1105 request->rq_repmsg = NULL;
1109 case PTL_MD_INUSE: /* callback in progress */
1111 /* Network access will complete in finite time but
1112 * the timeout lets us CERROR for visibility */
1113 struct l_wait_info lwi = LWI_TIMEOUT(10*HZ, NULL, NULL);
1115 rc = l_wait_event (request->rq_reply_waitq,
1116 request->rq_replied, &lwi);
1117 LASSERT(rc == 0 || rc == -ETIMEDOUT);
1119 spin_lock_irqsave (&request->rq_lock, flags);
1120 /* Ensure the callback has completed scheduling
1121 * me and taken its hands off the request */
1122 spin_unlock_irqrestore(&request->rq_lock,flags);
1126 CERROR ("Unexpectedly long timeout: req %p\n", request);
1130 case PTL_INV_MD: /* callback completed */
1131 LASSERT(!request->rq_receiving_reply);
1132 LASSERT(request->rq_replied);
1139 /* caller must hold imp->imp_lock */
1140 void ptlrpc_free_committed(struct obd_import *imp)
1142 struct list_head *tmp, *saved;
1143 struct ptlrpc_request *req;
1144 struct ptlrpc_request *last_req = NULL; /* temporary fire escape */
1147 LASSERT(imp != NULL);
1150 LASSERT(spin_is_locked(&imp->imp_lock));
1153 CDEBUG(D_HA, "%s: committing for last_committed "LPU64"\n",
1154 imp->imp_obd->obd_name, imp->imp_peer_committed_transno);
1156 list_for_each_safe(tmp, saved, &imp->imp_replay_list) {
1157 req = list_entry(tmp, struct ptlrpc_request, rq_replay_list);
1159 /* XXX ok to remove when 1357 resolved - rread 05/29/03 */
1160 LASSERT(req != last_req);
1163 if (req->rq_import_generation < imp->imp_generation) {
1164 DEBUG_REQ(D_HA, req, "freeing request with old gen");
1168 if (req->rq_replay) {
1169 DEBUG_REQ(D_HA, req, "keeping (FL_REPLAY)");
1173 /* not yet committed */
1174 if (req->rq_transno > imp->imp_peer_committed_transno) {
1175 DEBUG_REQ(D_HA, req, "stopping search");
1179 DEBUG_REQ(D_HA, req, "committing (last_committed "LPU64")",
1180 imp->imp_peer_committed_transno);
1182 if (req->rq_commit_cb != NULL)
1183 req->rq_commit_cb(req);
1184 list_del_init(&req->rq_replay_list);
1185 __ptlrpc_req_finished(req, 1);
1192 void ptlrpc_cleanup_client(struct obd_import *imp)
1199 void ptlrpc_resend_req(struct ptlrpc_request *req)
1201 unsigned long flags;
1203 DEBUG_REQ(D_HA, req, "going to resend");
1204 req->rq_reqmsg->handle.cookie = 0;
1205 req->rq_status = -EAGAIN;
1207 spin_lock_irqsave (&req->rq_lock, flags);
1209 req->rq_timedout = 0;
1210 if (req->rq_set != NULL)
1211 wake_up (&req->rq_set->set_waitq);
1213 wake_up(&req->rq_reply_waitq);
1214 spin_unlock_irqrestore (&req->rq_lock, flags);
1217 /* XXX: this function and rq_status are currently unused */
1218 void ptlrpc_restart_req(struct ptlrpc_request *req)
1220 unsigned long flags;
1222 DEBUG_REQ(D_HA, req, "restarting (possibly-)completed request");
1223 req->rq_status = -ERESTARTSYS;
1225 spin_lock_irqsave (&req->rq_lock, flags);
1226 req->rq_restart = 1;
1227 req->rq_timedout = 0;
1228 if (req->rq_set != NULL)
1229 wake_up (&req->rq_set->set_waitq);
1231 wake_up(&req->rq_reply_waitq);
1232 spin_unlock_irqrestore (&req->rq_lock, flags);
1235 static int expired_request(void *data)
1237 struct ptlrpc_request *req = data;
1240 RETURN(ptlrpc_expire_one_request(req));
1243 static void interrupted_request(void *data)
1245 unsigned long flags;
1247 struct ptlrpc_request *req = data;
1248 DEBUG_REQ(D_HA, req, "request interrupted");
1249 spin_lock_irqsave (&req->rq_lock, flags);
1251 spin_unlock_irqrestore (&req->rq_lock, flags);
1254 struct ptlrpc_request *ptlrpc_request_addref(struct ptlrpc_request *req)
1257 atomic_inc(&req->rq_refcount);
1261 void ptlrpc_retain_replayable_request(struct ptlrpc_request *req,
1262 struct obd_import *imp)
1264 struct list_head *tmp;
1267 LASSERT(spin_is_locked(&imp->imp_lock));
1270 /* don't re-add requests that have been replayed */
1271 if (!list_empty(&req->rq_replay_list))
1274 LASSERT(imp->imp_replayable);
1275 /* Balanced in ptlrpc_free_committed, usually. */
1276 ptlrpc_request_addref(req);
1277 list_for_each_prev(tmp, &imp->imp_replay_list) {
1278 struct ptlrpc_request *iter =
1279 list_entry(tmp, struct ptlrpc_request, rq_replay_list);
1281 /* We may have duplicate transnos if we create and then
1282 * open a file, or for closes retained if to match creating
1283 * opens, so use req->rq_xid as a secondary key.
1284 * (See bugs 684, 685, and 428.)
1285 * XXX no longer needed, but all opens need transnos!
1287 if (iter->rq_transno > req->rq_transno)
1290 if (iter->rq_transno == req->rq_transno) {
1291 LASSERT(iter->rq_xid != req->rq_xid);
1292 if (iter->rq_xid > req->rq_xid)
1296 list_add(&req->rq_replay_list, &iter->rq_replay_list);
1300 list_add_tail(&req->rq_replay_list, &imp->imp_replay_list);
1303 int ptlrpc_queue_wait(struct ptlrpc_request *req)
1307 struct l_wait_info lwi;
1308 struct obd_import *imp = req->rq_import;
1309 unsigned long flags;
1313 LASSERT(req->rq_set == NULL);
1314 LASSERT(!req->rq_receiving_reply);
1316 /* for distributed debugging */
1317 req->rq_reqmsg->status = current->pid;
1318 LASSERT(imp->imp_obd != NULL);
1319 CDEBUG(D_RPCTRACE, "Sending RPC pname:cluuid:pid:xid:ni:nid:opc "
1320 "%s:%s:%d:"LPU64":%s:"LPX64":%d\n", current->comm,
1321 imp->imp_obd->obd_uuid.uuid,
1322 req->rq_reqmsg->status, req->rq_xid,
1323 imp->imp_connection->c_peer.peer_ni->pni_name,
1324 imp->imp_connection->c_peer.peer_nid,
1325 req->rq_reqmsg->opc);
1327 /* Mark phase here for a little debug help */
1328 req->rq_phase = RQ_PHASE_RPC;
1330 spin_lock_irqsave(&imp->imp_lock, flags);
1331 req->rq_import_generation = imp->imp_generation;
1333 if (ptlrpc_import_delay_req(imp, req, &rc)) {
1334 list_del(&req->rq_list);
1336 list_add_tail(&req->rq_list, &imp->imp_delayed_list);
1337 spin_unlock_irqrestore(&imp->imp_lock, flags);
1339 DEBUG_REQ(D_HA, req, "\"%s\" waiting for recovery: (%s != %s)",
1341 ptlrpc_import_state_name(req->rq_send_state),
1342 ptlrpc_import_state_name(imp->imp_state));
1343 lwi = LWI_INTR(interrupted_request, req);
1344 rc = l_wait_event(req->rq_reply_waitq,
1345 (req->rq_send_state == imp->imp_state ||
1348 DEBUG_REQ(D_HA, req, "\"%s\" awake: (%s == %s or %d == 1)",
1350 ptlrpc_import_state_name(imp->imp_state),
1351 ptlrpc_import_state_name(req->rq_send_state),
1354 spin_lock_irqsave(&imp->imp_lock, flags);
1355 list_del_init(&req->rq_list);
1360 else if (req->rq_intr) {
1369 list_del_init(&req->rq_list);
1370 spin_unlock_irqrestore(&imp->imp_lock, flags);
1371 req->rq_status = rc; // XXX this ok?
1375 if (req->rq_resend) {
1376 lustre_msg_add_flags(req->rq_reqmsg, MSG_RESENT);
1378 if (req->rq_bulk != NULL)
1379 ptlrpc_unregister_bulk (req);
1381 DEBUG_REQ(D_HA, req, "resending: ");
1384 /* XXX this is the same as ptlrpc_set_wait */
1385 LASSERT(list_empty(&req->rq_list));
1386 list_add_tail(&req->rq_list, &imp->imp_sending_list);
1387 spin_unlock_irqrestore(&imp->imp_lock, flags);
1389 rc = ptl_send_rpc(req);
1391 DEBUG_REQ(D_HA, req, "send failed (%d); recovering", rc);
1394 timeout = MAX(req->rq_timeout * HZ, 1);
1395 DEBUG_REQ(D_NET, req, "-- sleeping");
1397 lwi = LWI_TIMEOUT_INTR(timeout, expired_request, interrupted_request,
1399 l_wait_event(req->rq_reply_waitq, ptlrpc_check_reply(req), &lwi);
1400 DEBUG_REQ(D_NET, req, "-- done sleeping");
1402 CDEBUG(D_RPCTRACE, "Completed RPC pname:cluuid:pid:xid:ni:nid:opc "
1403 "%s:%s:%d:"LPU64":%s:"LPX64":%d\n", current->comm,
1404 imp->imp_obd->obd_uuid.uuid,
1405 req->rq_reqmsg->status, req->rq_xid,
1406 imp->imp_connection->c_peer.peer_ni->pni_name,
1407 imp->imp_connection->c_peer.peer_nid,
1408 req->rq_reqmsg->opc);
1410 spin_lock_irqsave(&imp->imp_lock, flags);
1411 list_del_init(&req->rq_list);
1412 spin_unlock_irqrestore(&imp->imp_lock, flags);
1414 /* If the reply was received normally, this just grabs the spinlock
1415 * (ensuring the reply callback has returned), sees that
1416 * req->rq_receiving_reply is clear and returns. */
1417 ptlrpc_unregister_reply (req);
1420 GOTO(out, rc = -EIO);
1422 /* Resend if we need to, unless we were interrupted. */
1423 if (req->rq_resend && !req->rq_intr) {
1424 /* ...unless we were specifically told otherwise. */
1425 if (req->rq_no_resend)
1426 GOTO(out, rc = -ETIMEDOUT);
1427 spin_lock_irqsave(&imp->imp_lock, flags);
1432 /* Should only be interrupted if we timed out. */
1433 if (!req->rq_timedout)
1434 DEBUG_REQ(D_ERROR, req,
1435 "rq_intr set but rq_timedout not");
1436 GOTO(out, rc = -EINTR);
1439 if (req->rq_timedout) { /* non-recoverable timeout */
1440 GOTO(out, rc = -ETIMEDOUT);
1443 if (!req->rq_replied) {
1444 /* How can this be? -eeb */
1445 DEBUG_REQ(D_ERROR, req, "!rq_replied: ");
1447 GOTO(out, rc = req->rq_status);
1450 rc = after_reply (req);
1451 /* NB may return +ve success rc */
1452 if (req->rq_resend) {
1453 spin_lock_irqsave(&imp->imp_lock, flags);
1458 if (req->rq_bulk != NULL) {
1459 if (rc >= 0) { /* success so far */
1460 lwi = LWI_TIMEOUT(timeout, NULL, NULL);
1461 brc = l_wait_event(req->rq_reply_waitq,
1462 ptlrpc_bulk_complete(req->rq_bulk),
1465 LASSERT(brc == -ETIMEDOUT);
1466 CERROR ("Timed out waiting for bulk\n");
1471 ptlrpc_unregister_bulk (req);
1474 LASSERT(!req->rq_receiving_reply);
1475 req->rq_phase = RQ_PHASE_INTERPRET;
1479 struct ptlrpc_replay_async_args {
1481 int praa_old_status;
1484 static int ptlrpc_replay_interpret(struct ptlrpc_request *req,
1485 void * data, int rc)
1487 struct ptlrpc_replay_async_args *aa = data;
1488 struct obd_import *imp = req->rq_import;
1489 unsigned long flags;
1491 atomic_dec(&imp->imp_replay_inflight);
1494 /* Clear reply swab mask; this is a new reply in sender's byte order */
1495 req->rq_rep_swab_mask = 0;
1497 rc = lustre_unpack_msg(req->rq_repmsg, req->rq_replen);
1499 CERROR("unpack_rep failed: %d\n", rc);
1500 GOTO(out, rc = -EPROTO);
1503 if (req->rq_repmsg->type == PTL_RPC_MSG_ERR &&
1504 req->rq_repmsg->status == -ENOTCONN)
1505 GOTO(out, rc = req->rq_repmsg->status);
1507 /* The transno had better not change over replay. */
1508 LASSERT(req->rq_reqmsg->transno == req->rq_repmsg->transno);
1510 DEBUG_REQ(D_HA, req, "got rep");
1512 /* let the callback do fixups, possibly including in the request */
1513 if (req->rq_replay_cb)
1514 req->rq_replay_cb(req);
1516 if (req->rq_replied && req->rq_repmsg->status != aa->praa_old_status) {
1517 DEBUG_REQ(D_ERROR, req, "status %d, old was %d",
1518 req->rq_repmsg->status, aa->praa_old_status);
1520 /* Put it back for re-replay. */
1521 req->rq_repmsg->status = aa->praa_old_status;
1524 spin_lock_irqsave(&imp->imp_lock, flags);
1525 imp->imp_last_replay_transno = req->rq_transno;
1526 spin_unlock_irqrestore(&imp->imp_lock, flags);
1528 /* continue with recovery */
1529 rc = ptlrpc_import_recovery_state_machine(imp);
1531 req->rq_send_state = aa->praa_old_state;
1534 /* this replay failed, so restart recovery */
1535 ptlrpc_connect_import(imp, NULL);
1541 int ptlrpc_replay_req(struct ptlrpc_request *req)
1543 struct ptlrpc_replay_async_args *aa;
1546 LASSERT(req->rq_import->imp_state == LUSTRE_IMP_REPLAY);
1548 /* Not handling automatic bulk replay yet (or ever?) */
1549 LASSERT(req->rq_bulk == NULL);
1551 DEBUG_REQ(D_HA, req, "REPLAY");
1553 LASSERT (sizeof (*aa) <= sizeof (req->rq_async_args));
1554 aa = (struct ptlrpc_replay_async_args *)&req->rq_async_args;
1555 memset(aa, 0, sizeof *aa);
1557 /* Prepare request to be resent with ptlrpcd */
1558 aa->praa_old_state = req->rq_send_state;
1559 req->rq_send_state = LUSTRE_IMP_REPLAY;
1560 req->rq_phase = RQ_PHASE_NEW;
1562 * Q: "How can a req get on the replay list if it wasn't replied?"
1563 * A: "If we failed during the replay of this request, it will still
1564 * be on the list, but rq_replied will have been reset to 0."
1566 if (req->rq_replied) {
1567 aa->praa_old_status = req->rq_repmsg->status;
1569 req->rq_replied = 0;
1572 req->rq_interpret_reply = ptlrpc_replay_interpret;
1573 atomic_inc(&req->rq_import->imp_replay_inflight);
1574 ptlrpc_request_addref(req); /* ptlrpcd needs a ref */
1576 ptlrpcd_add_req(req);
1580 void ptlrpc_abort_inflight(struct obd_import *imp)
1582 unsigned long flags;
1583 struct list_head *tmp, *n;
1586 /* Make sure that no new requests get processed for this import.
1587 * ptlrpc_{queue,set}_wait must (and does) hold imp_lock while testing
1588 * this flag and then putting requests on sending_list or delayed_list.
1590 spin_lock_irqsave(&imp->imp_lock, flags);
1592 /* XXX locking? Maybe we should remove each request with the list
1593 * locked? Also, how do we know if the requests on the list are
1594 * being freed at this time?
1596 list_for_each_safe(tmp, n, &imp->imp_sending_list) {
1597 struct ptlrpc_request *req =
1598 list_entry(tmp, struct ptlrpc_request, rq_list);
1600 DEBUG_REQ(D_HA, req, "inflight");
1602 spin_lock (&req->rq_lock);
1603 if (req->rq_import_generation < imp->imp_generation) {
1605 if (req->rq_set != NULL)
1606 wake_up(&req->rq_set->set_waitq);
1608 wake_up(&req->rq_reply_waitq);
1610 spin_unlock (&req->rq_lock);
1613 list_for_each_safe(tmp, n, &imp->imp_delayed_list) {
1614 struct ptlrpc_request *req =
1615 list_entry(tmp, struct ptlrpc_request, rq_list);
1617 DEBUG_REQ(D_HA, req, "aborting waiting req");
1619 spin_lock (&req->rq_lock);
1620 if (req->rq_import_generation < imp->imp_generation) {
1622 if (req->rq_set != NULL)
1623 wake_up(&req->rq_set->set_waitq);
1625 wake_up(&req->rq_reply_waitq);
1627 spin_unlock (&req->rq_lock);
1630 /* Last chance to free reqs left on the replay list, but we
1631 * will still leak reqs that haven't comitted. */
1632 if (imp->imp_replayable)
1633 ptlrpc_free_committed(imp);
1635 spin_unlock_irqrestore(&imp->imp_lock, flags);
1640 static __u64 ptlrpc_last_xid = 0;
1641 static spinlock_t ptlrpc_last_xid_lock = SPIN_LOCK_UNLOCKED;
1643 __u64 ptlrpc_next_xid(void)
1646 spin_lock(&ptlrpc_last_xid_lock);
1647 tmp = ++ptlrpc_last_xid;
1648 spin_unlock(&ptlrpc_last_xid_lock);