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 obd_uuid *ptlrpc_req_to_uuid(struct ptlrpc_request *req)
48 return &req->rq_connection->c_remote_uuid;
51 struct ptlrpc_connection *ptlrpc_uuid_to_connection(struct obd_uuid *uuid)
53 struct ptlrpc_connection *c;
54 struct ptlrpc_peer peer;
57 err = ptlrpc_uuid_to_peer(uuid, &peer);
59 CERROR("cannot find peer %s!\n", uuid->uuid);
63 c = ptlrpc_get_connection(&peer, uuid);
65 memcpy(c->c_remote_uuid.uuid,
66 uuid->uuid, sizeof(c->c_remote_uuid.uuid));
70 CDEBUG(D_INFO, "%s -> %p\n", uuid->uuid, c);
75 void ptlrpc_readdress_connection(struct ptlrpc_connection *conn,
76 struct obd_uuid *uuid)
78 struct ptlrpc_peer peer;
81 err = ptlrpc_uuid_to_peer(uuid, &peer);
83 CERROR("cannot find peer %s!\n", uuid->uuid);
87 memcpy(&conn->c_peer, &peer, sizeof (peer));
91 static inline struct ptlrpc_bulk_desc *new_bulk(void)
93 struct ptlrpc_bulk_desc *desc;
95 OBD_ALLOC(desc, sizeof(*desc));
99 spin_lock_init(&desc->bd_lock);
100 init_waitqueue_head(&desc->bd_waitq);
101 INIT_LIST_HEAD(&desc->bd_page_list);
102 desc->bd_md_h = PTL_HANDLE_NONE;
103 desc->bd_me_h = PTL_HANDLE_NONE;
108 struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_imp (struct ptlrpc_request *req,
109 int type, int portal)
111 struct obd_import *imp = req->rq_import;
112 struct ptlrpc_bulk_desc *desc;
114 LASSERT(type == BULK_PUT_SINK || type == BULK_GET_SOURCE);
120 desc->bd_import_generation = req->rq_import_generation;
121 desc->bd_import = class_import_get(imp);
123 desc->bd_type = type;
124 desc->bd_portal = portal;
126 /* This makes req own desc, and free it when she frees herself */
132 struct ptlrpc_bulk_desc *ptlrpc_prep_bulk_exp (struct ptlrpc_request *req,
133 int type, int portal)
135 struct obd_export *exp = req->rq_export;
136 struct ptlrpc_bulk_desc *desc;
138 LASSERT(type == BULK_PUT_SOURCE || type == BULK_GET_SINK);
144 desc->bd_export = class_export_get(exp);
146 desc->bd_type = type;
147 desc->bd_portal = portal;
149 /* NB we don't assign rq_bulk here; server-side requests are
150 * re-used, and the handler frees the bulk desc explicitly. */
155 int ptlrpc_prep_bulk_page(struct ptlrpc_bulk_desc *desc,
156 struct page *page, int pageoffset, int len)
158 struct ptlrpc_bulk_page *bulk;
160 OBD_ALLOC(bulk, sizeof(*bulk));
164 LASSERT(page != NULL);
165 LASSERT(pageoffset >= 0);
167 LASSERT(pageoffset + len <= PAGE_SIZE);
169 bulk->bp_page = page;
170 bulk->bp_pageoffset = pageoffset;
171 bulk->bp_buflen = len;
173 bulk->bp_desc = desc;
174 list_add_tail(&bulk->bp_link, &desc->bd_page_list);
175 desc->bd_page_count++;
179 void ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc)
181 struct list_head *tmp, *next;
184 LASSERT(desc != NULL);
185 LASSERT(desc->bd_page_count != 0x5a5a5a5a); /* not freed already */
186 LASSERT(!desc->bd_network_rw); /* network hands off or */
188 list_for_each_safe(tmp, next, &desc->bd_page_list) {
189 struct ptlrpc_bulk_page *bulk;
190 bulk = list_entry(tmp, struct ptlrpc_bulk_page, bp_link);
191 ptlrpc_free_bulk_page(bulk);
194 LASSERT(desc->bd_page_count == 0);
195 LASSERT((desc->bd_export != NULL) ^ (desc->bd_import != NULL));
198 class_export_put(desc->bd_export);
200 class_import_put(desc->bd_import);
202 OBD_FREE(desc, sizeof(*desc));
206 void ptlrpc_free_bulk_page(struct ptlrpc_bulk_page *bulk)
208 LASSERT(bulk != NULL);
210 list_del(&bulk->bp_link);
211 bulk->bp_desc->bd_page_count--;
212 OBD_FREE(bulk, sizeof(*bulk));
215 struct ptlrpc_request *ptlrpc_prep_req(struct obd_import *imp, int opcode,
216 int count, int *lengths, char **bufs)
218 struct ptlrpc_request *request;
222 LASSERT((unsigned long)imp > 0x1000);
224 OBD_ALLOC(request, sizeof(*request));
226 CERROR("request allocation out of memory\n");
230 rc = lustre_pack_msg(count, lengths, bufs,
231 &request->rq_reqlen, &request->rq_reqmsg);
233 CERROR("cannot pack request %d\n", rc);
234 OBD_FREE(request, sizeof(*request));
238 request->rq_timeout = obd_timeout;
239 request->rq_level = LUSTRE_CONN_FULL;
240 request->rq_type = PTL_RPC_MSG_REQUEST;
241 request->rq_import = class_import_get(imp);
242 request->rq_phase = RQ_PHASE_NEW;
244 /* XXX FIXME bug 249 */
245 request->rq_request_portal = imp->imp_client->cli_request_portal;
246 request->rq_reply_portal = imp->imp_client->cli_reply_portal;
248 request->rq_connection = ptlrpc_connection_addref(imp->imp_connection);
250 spin_lock_init(&request->rq_lock);
251 INIT_LIST_HEAD(&request->rq_list);
252 init_waitqueue_head(&request->rq_wait_for_rep);
253 request->rq_xid = ptlrpc_next_xid();
254 atomic_set(&request->rq_refcount, 1);
256 request->rq_reqmsg->opc = opcode;
257 request->rq_reqmsg->flags = 0;
262 struct ptlrpc_request_set *ptlrpc_prep_set(void)
264 struct ptlrpc_request_set *set;
266 OBD_ALLOC(set, sizeof *set);
269 INIT_LIST_HEAD(&set->set_requests);
270 init_waitqueue_head(&set->set_waitq);
271 set->set_remaining = 0;
276 /* Finish with this set; opposite of prep_set. */
277 void ptlrpc_set_destroy(struct ptlrpc_request_set *set)
279 struct list_head *tmp;
280 struct list_head *next;
285 /* Requests on the set should either all be completed, or all be new */
286 expected_phase = (set->set_remaining == 0) ?
287 RQ_PHASE_COMPLETE : RQ_PHASE_NEW;
288 list_for_each (tmp, &set->set_requests) {
289 struct ptlrpc_request *req =
290 list_entry(tmp, struct ptlrpc_request, rq_set_chain);
292 LASSERT(req->rq_phase == expected_phase);
296 LASSERT(set->set_remaining == 0 || set->set_remaining == n);
298 list_for_each_safe(tmp, next, &set->set_requests) {
299 struct ptlrpc_request *req =
300 list_entry(tmp, struct ptlrpc_request, rq_set_chain);
301 list_del_init(&req->rq_set_chain);
303 LASSERT(req->rq_phase == expected_phase);
305 if (req->rq_phase == RQ_PHASE_NEW) {
307 if (req->rq_interpret_reply != NULL) {
308 int (*interpreter)(struct ptlrpc_request *,
310 req->rq_interpret_reply;
312 /* higher level (i.e. LOV) failed;
313 * let the sub reqs clean up */
314 req->rq_status = -EBADR;
315 interpreter(req, &req->rq_async_args,
318 set->set_remaining--;
322 ptlrpc_req_finished (req);
325 LASSERT(set->set_remaining == 0);
327 OBD_FREE(set, sizeof(*set));
331 void ptlrpc_set_add_req(struct ptlrpc_request_set *set,
332 struct ptlrpc_request *req)
334 /* The set takes over the caller's request reference */
335 list_add_tail(&req->rq_set_chain, &set->set_requests);
337 set->set_remaining++;
340 static int ptlrpc_check_reply(struct ptlrpc_request *req)
346 /* serialise with network callback */
347 spin_lock_irqsave (&req->rq_lock, flags);
349 if (req->rq_replied) {
350 DEBUG_REQ(D_NET, req, "REPLIED:");
355 DEBUG_REQ(D_ERROR, req, "ABORTED:");
359 if (req->rq_resend) {
360 DEBUG_REQ(D_ERROR, req, "RESEND:");
364 if (req->rq_restart) {
365 DEBUG_REQ(D_ERROR, req, "RESTART:");
370 spin_unlock_irqrestore (&req->rq_lock, flags);
371 DEBUG_REQ(D_NET, req, "rc = %d for", rc);
375 static int ptlrpc_check_status(struct ptlrpc_request *req)
380 err = req->rq_repmsg->status;
381 if (req->rq_repmsg->type == PTL_RPC_MSG_ERR) {
382 DEBUG_REQ(D_ERROR, req, "type == PTL_RPC_MSG_ERR (%d)", err);
384 CERROR("Error Reply has >= zero status\n");
385 RETURN(err < 0 ? err : -EINVAL);
389 DEBUG_REQ(D_INFO, req, "status is %d", err);
390 } else if (err > 0) {
391 /* XXX: translate this error from net to host */
392 DEBUG_REQ(D_INFO, req, "status is %d", err);
398 static int after_reply(struct ptlrpc_request *req, int *restartp)
401 struct obd_import *imp = req->rq_import;
405 LASSERT(!req->rq_receiving_reply);
406 LASSERT(req->rq_replied);
408 if (restartp != NULL)
411 /* NB Until this point, the whole of the incoming message,
412 * including buflens, status etc is in the sender's byte order. */
415 /* Clear reply swab mask; this is a new reply in sender's byte order */
416 req->rq_rep_swab_mask = 0;
418 rc = lustre_unpack_msg(req->rq_repmsg, req->rq_replen);
420 CERROR("unpack_rep failed: %d\n", rc);
424 if (req->rq_repmsg->type != PTL_RPC_MSG_REPLY &&
425 req->rq_repmsg->type != PTL_RPC_MSG_ERR) {
426 CERROR("invalid packet type received (type=%u)\n",
427 req->rq_repmsg->type);
431 /* Store transno in reqmsg for replay. */
432 req->rq_reqmsg->transno = req->rq_transno = req->rq_repmsg->transno;
434 rc = ptlrpc_check_status(req);
436 /* Either we've been evicted, or the server has failed for
437 * some reason. Try to reconnect, and if that fails, punt to the
439 if (rc == -ENOTCONN) {
440 if (req->rq_level < LUSTRE_CONN_FULL || req->rq_no_recov ||
441 imp->imp_obd->obd_no_recov || imp->imp_dlm_fake) {
445 ptlrpc_request_handle_notconn(req);
450 if (req->rq_no_resend)
451 RETURN(rc); /* -ENOTCONN */
453 if (req->rq_resend) {
454 if (restartp == NULL)
455 LBUG(); /* async resend not supported yet */
456 spin_lock_irqsave (&req->rq_lock, flags);
458 spin_unlock_irqrestore (&req->rq_lock, flags);
460 lustre_msg_add_flags(req->rq_reqmsg, MSG_RESENT);
461 DEBUG_REQ(D_HA, req, "resending: ");
465 CERROR("request should be err or resend: %p\n", req);
469 if (req->rq_import->imp_replayable) {
470 spin_lock_irqsave(&imp->imp_lock, flags);
471 if ((req->rq_replay || req->rq_transno != 0) && rc >= 0)
472 ptlrpc_retain_replayable_request(req, imp);
474 if (req->rq_transno > imp->imp_max_transno)
475 imp->imp_max_transno = req->rq_transno;
477 /* Replay-enabled imports return commit-status information. */
478 if (req->rq_repmsg->last_committed)
479 imp->imp_peer_committed_transno =
480 req->rq_repmsg->last_committed;
481 ptlrpc_free_committed(imp);
482 spin_unlock_irqrestore(&imp->imp_lock, flags);
488 int ptlrpc_check_set(struct ptlrpc_request_set *set)
491 struct list_head *tmp;
494 if (set->set_remaining == 0)
497 list_for_each(tmp, &set->set_requests) {
498 struct ptlrpc_request *req =
499 list_entry(tmp, struct ptlrpc_request, rq_set_chain);
500 struct obd_import *imp = req->rq_import;
503 if (!(req->rq_phase == RQ_PHASE_RPC ||
504 req->rq_phase == RQ_PHASE_BULK ||
505 req->rq_phase == RQ_PHASE_INTERPRET ||
506 req->rq_phase == RQ_PHASE_COMPLETE)) {
507 DEBUG_REQ(D_ERROR, req, "bad phase %x", req->rq_phase);
511 if (req->rq_phase == RQ_PHASE_COMPLETE)
514 if (req->rq_phase == RQ_PHASE_INTERPRET)
515 GOTO(interpret, req->rq_status);
518 ptlrpc_unregister_reply(req);
519 if (req->rq_status == 0)
520 req->rq_status = -EIO;
521 req->rq_phase = RQ_PHASE_INTERPRET;
523 spin_lock_irqsave(&imp->imp_lock, flags);
524 list_del_init(&req->rq_list);
525 spin_unlock_irqrestore(&imp->imp_lock, flags);
527 GOTO(interpret, req->rq_status);
531 /* NB could be on delayed list */
532 ptlrpc_unregister_reply(req);
533 req->rq_status = -EINTR;
534 req->rq_phase = RQ_PHASE_INTERPRET;
536 spin_lock_irqsave(&imp->imp_lock, flags);
537 list_del_init(&req->rq_list);
538 spin_unlock_irqrestore(&imp->imp_lock, flags);
540 GOTO(interpret, req->rq_status);
543 if (req->rq_phase == RQ_PHASE_RPC) {
545 if (req->rq_waiting || req->rq_resend) {
546 spin_lock_irqsave(&imp->imp_lock, flags);
548 if (req->rq_level > imp->imp_level) {
549 spin_unlock_irqrestore(&imp->imp_lock,
554 list_del(&req->rq_list);
555 list_add_tail(&req->rq_list,
556 &imp->imp_sending_list);
558 if (req->rq_import_generation <
559 imp->imp_generation) {
560 req->rq_status = -EIO;
561 req->rq_phase = RQ_PHASE_INTERPRET;
562 spin_unlock_irqrestore(&imp->imp_lock,
564 GOTO(interpret, req->rq_status);
566 spin_unlock_irqrestore(&imp->imp_lock, flags);
569 if (req->rq_resend) {
570 lustre_msg_add_flags(req->rq_reqmsg,
572 spin_lock_irqsave(&req->rq_lock, flags);
574 spin_unlock_irqrestore(&req->rq_lock,
577 ptlrpc_unregister_reply(req);
579 ptlrpc_unregister_bulk(req);
582 rc = ptl_send_rpc(req);
585 req->rq_phase = RQ_PHASE_INTERPRET;
586 GOTO(interpret, req->rq_status);
591 /* Ensure the network callback returned */
592 spin_lock_irqsave (&req->rq_lock, flags);
593 if (!req->rq_replied) {
594 spin_unlock_irqrestore (&req->rq_lock, flags);
597 spin_unlock_irqrestore (&req->rq_lock, flags);
599 spin_lock_irqsave(&imp->imp_lock, flags);
600 list_del_init(&req->rq_list);
601 spin_unlock_irqrestore(&imp->imp_lock, flags);
603 req->rq_status = after_reply(req, &do_restart);
605 spin_lock_irqsave (&req->rq_lock, flags);
606 req->rq_resend = 1; /* ugh */
607 spin_unlock_irqrestore (&req->rq_lock, flags);
611 /* If there is no bulk associated with this request,
612 * then we're done and should let the interpreter
613 * process the reply. Similarly if the RPC returned
614 * an error, and therefore the bulk will never arrive.
616 if (req->rq_bulk == NULL || req->rq_status != 0) {
617 req->rq_phase = RQ_PHASE_INTERPRET;
618 GOTO(interpret, req->rq_status);
621 req->rq_phase = RQ_PHASE_BULK;
624 LASSERT(req->rq_phase == RQ_PHASE_BULK);
625 if (!ptlrpc_bulk_complete (req->rq_bulk))
628 req->rq_phase = RQ_PHASE_INTERPRET;
631 LASSERT(req->rq_phase == RQ_PHASE_INTERPRET);
632 LASSERT(!req->rq_receiving_reply);
634 ptlrpc_unregister_reply(req);
635 if (req->rq_bulk != NULL)
636 ptlrpc_unregister_bulk (req);
638 if (req->rq_interpret_reply != NULL) {
639 int (*interpreter)(struct ptlrpc_request *,void *,int) =
640 req->rq_interpret_reply;
641 req->rq_status = interpreter(req, &req->rq_async_args,
645 CDEBUG(D_RPCTRACE, "Completed RPC pname:cluuid:pid:xid:ni:nid:"
646 "opc %s:%s:%d:"LPU64":%s:"LPX64":%d\n", current->comm,
647 imp->imp_obd->obd_uuid.uuid, req->rq_reqmsg->status,
649 imp->imp_connection->c_peer.peer_ni->pni_name,
650 imp->imp_connection->c_peer.peer_nid,
651 req->rq_reqmsg->opc);
653 req->rq_phase = RQ_PHASE_COMPLETE;
654 set->set_remaining--;
657 RETURN(set->set_remaining == 0);
660 int ptlrpc_expire_one_request(struct ptlrpc_request *req)
663 struct obd_import *imp = req->rq_import;
666 DEBUG_REQ(D_ERROR, req, "timeout");
668 spin_lock_irqsave (&req->rq_lock, flags);
669 req->rq_timedout = 1;
670 spin_unlock_irqrestore (&req->rq_lock, flags);
672 ptlrpc_unregister_reply (req);
675 DEBUG_REQ(D_HA, req, "NULL import: already cleaned up?");
679 /* The DLM server doesn't want recovery run on its imports. */
680 if (imp->imp_dlm_fake)
683 /* If this request is for recovery or other primordial tasks,
684 * don't go back to sleep, and don't start recovery again.. */
685 if (req->rq_level < LUSTRE_CONN_FULL || req->rq_no_recov ||
686 imp->imp_obd->obd_no_recov)
689 ptlrpc_fail_import(imp, req->rq_import_generation);
694 static int expired_set(void *data)
696 struct ptlrpc_request_set *set = data;
697 struct list_head *tmp;
698 time_t now = LTIME_S (CURRENT_TIME);
701 LASSERT(set != NULL);
703 /* A timeout expired; see which reqs it applies to... */
704 list_for_each (tmp, &set->set_requests) {
705 struct ptlrpc_request *req =
706 list_entry(tmp, struct ptlrpc_request, rq_set_chain);
708 /* request in-flight? */
709 if (!((req->rq_phase == RQ_PHASE_RPC && !req->rq_waiting) ||
710 (req->rq_phase == RQ_PHASE_BULK)))
713 if (req->rq_timedout || /* already dealt with */
714 req->rq_sent + req->rq_timeout > now) /* not expired */
717 /* deal with this guy */
718 ptlrpc_expire_one_request (req);
721 /* When waiting for a whole set, we always to break out of the
722 * sleep so we can recalculate the timeout, or enable interrupts
723 * iff everyone's timed out.
728 static void interrupted_set(void *data)
730 struct ptlrpc_request_set *set = data;
731 struct list_head *tmp;
734 LASSERT(set != NULL);
735 CERROR("INTERRUPTED SET %p\n", set);
737 list_for_each(tmp, &set->set_requests) {
738 struct ptlrpc_request *req =
739 list_entry(tmp, struct ptlrpc_request, rq_set_chain);
741 if (req->rq_phase != RQ_PHASE_RPC)
744 spin_lock_irqsave (&req->rq_lock, flags);
746 spin_unlock_irqrestore (&req->rq_lock, flags);
750 int ptlrpc_set_wait(struct ptlrpc_request_set *set)
752 struct list_head *tmp;
753 struct obd_import *imp;
754 struct ptlrpc_request *req;
755 struct l_wait_info lwi;
763 SIGNAL_MASK_ASSERT(); /* XXX BUG 1511 */
764 LASSERT(!list_empty(&set->set_requests));
765 list_for_each(tmp, &set->set_requests) {
766 req = list_entry(tmp, struct ptlrpc_request, rq_set_chain);
768 LASSERT(req->rq_level == LUSTRE_CONN_FULL);
769 LASSERT(req->rq_phase == RQ_PHASE_NEW);
770 req->rq_phase = RQ_PHASE_RPC;
772 imp = req->rq_import;
773 spin_lock_irqsave(&imp->imp_lock, flags);
775 if (imp->imp_invalid) {
776 spin_unlock_irqrestore(&imp->imp_lock, flags);
777 req->rq_status = -EIO;
778 req->rq_phase = RQ_PHASE_INTERPRET;
782 req->rq_import_generation = imp->imp_generation;
784 if (req->rq_level > imp->imp_level) {
785 if (req->rq_no_recov || imp->imp_obd->obd_no_recov ||
787 spin_unlock_irqrestore(&imp->imp_lock, flags);
788 req->rq_status = -EWOULDBLOCK;
789 req->rq_phase = RQ_PHASE_INTERPRET;
793 spin_lock (&req->rq_lock);
795 spin_unlock (&req->rq_lock);
796 LASSERT(list_empty (&req->rq_list));
797 // list_del(&req->rq_list);
798 list_add_tail(&req->rq_list, &imp->imp_delayed_list);
799 spin_unlock_irqrestore(&imp->imp_lock, flags);
803 /* XXX this is the same as ptlrpc_queue_wait */
804 LASSERT(list_empty(&req->rq_list));
805 list_add_tail(&req->rq_list, &imp->imp_sending_list);
806 spin_unlock_irqrestore(&imp->imp_lock, flags);
808 req->rq_reqmsg->status = current->pid;
809 CDEBUG(D_RPCTRACE, "Sending RPC pname:cluuid:pid:xid:ni:nid:opc"
810 " %s:%s:%d:"LPU64":%s:"LPX64":%d\n", current->comm,
811 imp->imp_obd->obd_uuid.uuid, req->rq_reqmsg->status,
813 imp->imp_connection->c_peer.peer_ni->pni_name,
814 imp->imp_connection->c_peer.peer_nid,
815 req->rq_reqmsg->opc);
817 rc = ptl_send_rpc(req);
820 req->rq_phase = RQ_PHASE_INTERPRET;
825 now = LTIME_S (CURRENT_TIME);
827 list_for_each (tmp, &set->set_requests) {
828 req = list_entry(tmp, struct ptlrpc_request,
831 /* request in-flight? */
832 if (!((req->rq_phase == RQ_PHASE_RPC &&
834 (req->rq_phase == RQ_PHASE_BULK)))
837 if (req->rq_timedout) /* already timed out */
840 deadline = req->rq_sent + req->rq_timeout;
841 if (deadline <= now) /* actually expired already */
842 timeout = 1; /* ASAP */
843 else if (timeout == 0 || timeout > deadline - now)
844 timeout = deadline - now;
847 /* wait until all complete, interrupted, or an in-flight
849 CDEBUG(D_HA, "set %p going to sleep for %d seconds\n",
851 lwi = LWI_TIMEOUT_INTR((timeout ? timeout : 1) * HZ,
852 expired_set, interrupted_set, set);
853 rc = l_wait_event(set->set_waitq, ptlrpc_check_set(set), &lwi);
855 LASSERT(rc == 0 || rc == -EINTR || rc == -ETIMEDOUT);
857 /* -EINTR => all requests have been flagged rq_intr so next
859 * -ETIMEOUTD => someone timed out. When all reqs have
860 * timed out, signals are enabled allowing completion with
862 * I don't really care if we go once more round the loop in
863 * the error cases -eeb. */
866 LASSERT(set->set_remaining == 0);
869 list_for_each(tmp, &set->set_requests) {
870 req = list_entry(tmp, struct ptlrpc_request, rq_set_chain);
872 LASSERT(req->rq_phase == RQ_PHASE_COMPLETE);
873 if (req->rq_status != 0)
877 if (set->set_interpret != NULL) {
878 int (*interpreter)(struct ptlrpc_request_set *set,void *,int) =
880 rc = interpreter (set, &set->set_args, rc);
886 static void __ptlrpc_free_req(struct ptlrpc_request *request, int locked)
889 if (request == NULL) {
894 LASSERT(!request->rq_receiving_reply);
896 /* We must take it off the imp_replay_list first. Otherwise, we'll set
897 * request->rq_reqmsg to NULL while osc_close is dereferencing it. */
898 if (request->rq_import != NULL) {
899 unsigned long flags = 0;
901 spin_lock_irqsave(&request->rq_import->imp_lock, flags);
902 list_del_init(&request->rq_list);
904 spin_unlock_irqrestore(&request->rq_import->imp_lock,
908 if (atomic_read(&request->rq_refcount) != 0) {
909 DEBUG_REQ(D_ERROR, request,
910 "freeing request with nonzero refcount");
914 if (request->rq_repmsg != NULL) {
915 OBD_FREE(request->rq_repmsg, request->rq_replen);
916 request->rq_repmsg = NULL;
918 if (request->rq_reqmsg != NULL) {
919 OBD_FREE(request->rq_reqmsg, request->rq_reqlen);
920 request->rq_reqmsg = NULL;
922 if (request->rq_export != NULL) {
923 class_export_put(request->rq_export);
924 request->rq_export = NULL;
926 if (request->rq_import != NULL) {
927 class_import_put(request->rq_import);
928 request->rq_import = NULL;
930 if (request->rq_bulk != NULL)
931 ptlrpc_free_bulk(request->rq_bulk);
933 ptlrpc_put_connection(request->rq_connection);
934 OBD_FREE(request, sizeof(*request));
938 void ptlrpc_free_req(struct ptlrpc_request *request)
940 __ptlrpc_free_req(request, 0);
943 static int __ptlrpc_req_finished(struct ptlrpc_request *request, int locked)
949 if (request == (void *)(long)(0x5a5a5a5a5a5a5a5a) ||
950 request->rq_obd == (void *)(long)(0x5a5a5a5a5a5a5a5a)) {
951 CERROR("dereferencing freed request (bug 575)\n");
956 DEBUG_REQ(D_INFO, request, "refcount now %u",
957 atomic_read(&request->rq_refcount) - 1);
959 if (atomic_dec_and_test(&request->rq_refcount)) {
960 __ptlrpc_free_req(request, locked);
967 void ptlrpc_req_finished(struct ptlrpc_request *request)
969 __ptlrpc_req_finished(request, 0);
972 static void ptlrpc_cleanup_request_buf(struct ptlrpc_request *request)
974 OBD_FREE(request->rq_reqmsg, request->rq_reqlen);
975 request->rq_reqmsg = NULL;
976 request->rq_reqlen = 0;
979 /* Disengage the client's reply buffer from the network
980 * NB does _NOT_ unregister any client-side bulk.
981 * IDEMPOTENT, but _not_ safe against concurrent callers.
982 * The request owner (i.e. the thread doing the I/O) must call...
984 void ptlrpc_unregister_reply (struct ptlrpc_request *request)
990 LASSERT(!in_interrupt ()); /* might sleep */
992 spin_lock_irqsave (&request->rq_lock, flags);
993 if (!request->rq_receiving_reply) { /* not waiting for a reply */
994 spin_unlock_irqrestore (&request->rq_lock, flags);
996 /* NB reply buffer not freed here */
1000 LASSERT(!request->rq_replied); /* callback hasn't completed */
1001 spin_unlock_irqrestore (&request->rq_lock, flags);
1003 rc = PtlMDUnlink (request->rq_reply_md_h);
1008 case PTL_OK: /* unlinked before completion */
1009 LASSERT(request->rq_receiving_reply);
1010 LASSERT(!request->rq_replied);
1011 spin_lock_irqsave (&request->rq_lock, flags);
1012 request->rq_receiving_reply = 0;
1013 spin_unlock_irqrestore (&request->rq_lock, flags);
1014 OBD_FREE(request->rq_repmsg, request->rq_replen);
1015 request->rq_repmsg = NULL;
1019 case PTL_MD_INUSE: /* callback in progress */
1021 /* Network access will complete in finite time but
1022 * the timeout lets us CERROR for visibility */
1023 struct l_wait_info lwi = LWI_TIMEOUT(10*HZ, NULL, NULL);
1025 rc = l_wait_event (request->rq_wait_for_rep,
1026 request->rq_replied, &lwi);
1027 LASSERT(rc == 0 || rc == -ETIMEDOUT);
1029 spin_lock_irqsave (&request->rq_lock, flags);
1030 /* Ensure the callback has completed scheduling
1031 * me and taken its hands off the request */
1032 spin_unlock_irqrestore(&request->rq_lock,flags);
1036 CERROR ("Unexpectedly long timeout: req %p\n", request);
1040 case PTL_INV_MD: /* callback completed */
1041 LASSERT(!request->rq_receiving_reply);
1042 LASSERT(request->rq_replied);
1049 /* caller must hold imp->imp_lock */
1050 void ptlrpc_free_committed(struct obd_import *imp)
1052 struct list_head *tmp, *saved;
1053 struct ptlrpc_request *req;
1054 struct ptlrpc_request *last_req = NULL; /* temporary fire escape */
1057 LASSERT(imp != NULL);
1060 LASSERT(spin_is_locked(&imp->imp_lock));
1063 CDEBUG(D_HA, "%s: committing for last_committed "LPU64"\n",
1064 imp->imp_obd->obd_name, imp->imp_peer_committed_transno);
1066 list_for_each_safe(tmp, saved, &imp->imp_replay_list) {
1067 req = list_entry(tmp, struct ptlrpc_request, rq_list);
1069 /* XXX ok to remove when 1357 resolved - rread 05/29/03 */
1070 LASSERT(req != last_req);
1073 if (req->rq_import_generation < imp->imp_generation) {
1074 DEBUG_REQ(D_HA, req, "freeing request with old gen");
1078 if (req->rq_replay) {
1079 DEBUG_REQ(D_HA, req, "keeping (FL_REPLAY)");
1083 /* not yet committed */
1084 if (req->rq_transno > imp->imp_peer_committed_transno) {
1085 DEBUG_REQ(D_HA, req, "stopping search");
1089 DEBUG_REQ(D_HA, req, "committing (last_committed "LPU64")",
1090 imp->imp_peer_committed_transno);
1092 list_del_init(&req->rq_list);
1093 __ptlrpc_req_finished(req, 1);
1100 void ptlrpc_cleanup_client(struct obd_import *imp)
1107 void ptlrpc_resend_req(struct ptlrpc_request *req)
1109 unsigned long flags;
1111 DEBUG_REQ(D_HA, req, "resending");
1112 req->rq_reqmsg->handle.cookie = 0;
1113 ptlrpc_put_connection(req->rq_connection);
1114 req->rq_connection =
1115 ptlrpc_connection_addref(req->rq_import->imp_connection);
1116 req->rq_status = -EAGAIN;
1118 spin_lock_irqsave (&req->rq_lock, flags);
1120 req->rq_timedout = 0;
1121 if (req->rq_set != NULL)
1122 wake_up (&req->rq_set->set_waitq);
1124 wake_up(&req->rq_wait_for_rep);
1125 spin_unlock_irqrestore (&req->rq_lock, flags);
1128 /* XXX: this function and rq_status are currently unused */
1129 void ptlrpc_restart_req(struct ptlrpc_request *req)
1131 unsigned long flags;
1133 DEBUG_REQ(D_HA, req, "restarting (possibly-)completed request");
1134 req->rq_status = -ERESTARTSYS;
1136 spin_lock_irqsave (&req->rq_lock, flags);
1137 req->rq_restart = 1;
1138 req->rq_timedout = 0;
1139 if (req->rq_set != NULL)
1140 wake_up (&req->rq_set->set_waitq);
1142 wake_up(&req->rq_wait_for_rep);
1143 spin_unlock_irqrestore (&req->rq_lock, flags);
1146 static int expired_request(void *data)
1148 struct ptlrpc_request *req = data;
1151 RETURN(ptlrpc_expire_one_request(req));
1154 static void interrupted_request(void *data)
1156 unsigned long flags;
1158 struct ptlrpc_request *req = data;
1159 DEBUG_REQ(D_HA, req, "request interrupted");
1160 spin_lock_irqsave (&req->rq_lock, flags);
1162 spin_unlock_irqrestore (&req->rq_lock, flags);
1165 struct ptlrpc_request *ptlrpc_request_addref(struct ptlrpc_request *req)
1168 atomic_inc(&req->rq_refcount);
1172 void ptlrpc_retain_replayable_request(struct ptlrpc_request *req,
1173 struct obd_import *imp)
1175 struct list_head *tmp;
1178 LASSERT(spin_is_locked(&imp->imp_lock));
1181 LASSERT(imp->imp_replayable);
1182 /* Balanced in ptlrpc_free_committed, usually. */
1183 ptlrpc_request_addref(req);
1184 list_for_each_prev(tmp, &imp->imp_replay_list) {
1185 struct ptlrpc_request *iter =
1186 list_entry(tmp, struct ptlrpc_request, rq_list);
1188 /* We may have duplicate transnos if we create and then
1189 * open a file, or for closes retained if to match creating
1190 * opens, so use req->rq_xid as a secondary key.
1191 * (See bugs 684, 685, and 428.)
1192 * XXX no longer needed, but all opens need transnos!
1194 if (iter->rq_transno > req->rq_transno)
1197 if (iter->rq_transno == req->rq_transno) {
1198 LASSERT(iter->rq_xid != req->rq_xid);
1199 if (iter->rq_xid > req->rq_xid)
1203 list_add(&req->rq_list, &iter->rq_list);
1207 list_add_tail(&req->rq_list, &imp->imp_replay_list);
1210 int ptlrpc_queue_wait(struct ptlrpc_request *req)
1214 struct l_wait_info lwi;
1215 struct obd_import *imp = req->rq_import;
1216 struct obd_device *obd = imp->imp_obd;
1217 unsigned long flags;
1222 LASSERT(req->rq_set == NULL);
1223 LASSERT(!req->rq_receiving_reply);
1225 /* for distributed debugging */
1226 req->rq_reqmsg->status = current->pid;
1227 LASSERT(imp->imp_obd != NULL);
1228 CDEBUG(D_RPCTRACE, "Sending RPC pname:cluuid:pid:xid:ni:nid:opc "
1229 "%s:%s:%d:"LPU64":%s:"LPX64":%d\n", current->comm,
1230 imp->imp_obd->obd_uuid.uuid,
1231 req->rq_reqmsg->status, req->rq_xid,
1232 imp->imp_connection->c_peer.peer_ni->pni_name,
1233 imp->imp_connection->c_peer.peer_nid,
1234 req->rq_reqmsg->opc);
1236 /* Mark phase here for a little debug help */
1237 req->rq_phase = RQ_PHASE_RPC;
1239 spin_lock_irqsave(&imp->imp_lock, flags);
1240 req->rq_import_generation = imp->imp_generation;
1243 * If the import has been invalidated (such as by an OST failure), the
1244 * request must fail with -EIO. Recovery requests are allowed to go
1245 * through, though, so that they have a chance to revalidate the
1248 if (req->rq_import->imp_invalid && req->rq_level == LUSTRE_CONN_FULL) {
1249 DEBUG_REQ(D_ERROR, req, "IMP_INVALID:");
1250 spin_unlock_irqrestore(&imp->imp_lock, flags);
1251 GOTO(out, rc = -EIO);
1254 if (req->rq_import_generation < imp->imp_generation) {
1255 DEBUG_REQ(D_ERROR, req, "req old gen:");
1256 spin_unlock_irqrestore(&imp->imp_lock, flags);
1257 GOTO(out, rc = -EIO);
1260 if (req->rq_level > imp->imp_level) {
1261 list_del(&req->rq_list);
1262 if (req->rq_no_recov || obd->obd_no_recov ||
1263 imp->imp_dlm_fake) {
1264 spin_unlock_irqrestore(&imp->imp_lock, flags);
1265 GOTO(out, rc = -EWOULDBLOCK);
1268 list_add_tail(&req->rq_list, &imp->imp_delayed_list);
1269 spin_unlock_irqrestore(&imp->imp_lock, flags);
1271 DEBUG_REQ(D_HA, req, "\"%s\" waiting for recovery: (%d > %d)",
1272 current->comm, req->rq_level, imp->imp_level);
1273 lwi = LWI_INTR(NULL, NULL);
1274 rc = l_wait_event(req->rq_wait_for_rep,
1275 (req->rq_level <= imp->imp_level ||
1278 DEBUG_REQ(D_HA, req, "\"%s\" awake: (%d > %d or %d == 1)",
1279 current->comm, imp->imp_level, req->rq_level,
1282 spin_lock_irqsave(&imp->imp_lock, flags);
1283 list_del_init(&req->rq_list);
1286 req->rq_import_generation < imp->imp_generation)
1290 spin_unlock_irqrestore(&imp->imp_lock, flags);
1294 DEBUG_REQ(D_HA, req, "resumed");
1297 /* XXX this is the same as ptlrpc_set_wait */
1298 LASSERT(list_empty(&req->rq_list));
1299 list_add_tail(&req->rq_list, &imp->imp_sending_list);
1300 spin_unlock_irqrestore(&imp->imp_lock, flags);
1302 rc = ptl_send_rpc(req);
1304 /* The DLM's fake imports want to avoid all forms of
1306 if (imp->imp_dlm_fake) {
1307 spin_lock_irqsave(&imp->imp_lock, flags);
1308 list_del_init(&req->rq_list);
1309 spin_unlock_irqrestore(&imp->imp_lock, flags);
1313 DEBUG_REQ(D_ERROR, req, "send failed (%d); recovering", rc);
1315 ptlrpc_fail_import(imp, req->rq_import_generation);
1317 /* If we've been told to not wait, we're done. */
1318 if (req->rq_level < LUSTRE_CONN_FULL || req->rq_no_recov ||
1319 obd->obd_no_recov) {
1320 spin_lock_irqsave(&imp->imp_lock, flags);
1321 list_del_init(&req->rq_list);
1322 spin_unlock_irqrestore(&imp->imp_lock, flags);
1326 /* If we errored, allow the user to interrupt immediately */
1329 timeout = req->rq_timeout * HZ;
1330 DEBUG_REQ(D_NET, req, "-- sleeping");
1333 lwi = LWI_TIMEOUT_INTR(timeout, expired_request, interrupted_request,
1335 l_wait_event(req->rq_wait_for_rep, ptlrpc_check_reply(req), &lwi);
1338 extern int reply_in_callback(ptl_event_t *ev);
1339 ptl_event_t reply_ev;
1340 PtlEQWait(req->rq_connection->c_peer.peer_ni->pni_reply_in_eq_h,
1342 reply_in_callback(&reply_ev);
1344 LASSERT(reply_ev.mem_desc.user_ptr == (void *)req);
1345 // ptlrpc_check_reply(req);
1346 // not required now it only tests
1350 DEBUG_REQ(D_NET, req, "-- done sleeping");
1352 CDEBUG(D_RPCTRACE, "Completed RPC pname:cluuid:pid:xid:ni:nid:opc "
1353 "%s:%s:%d:"LPU64":%s:"LPX64":%d\n", current->comm,
1354 imp->imp_obd->obd_uuid.uuid,
1355 req->rq_reqmsg->status, req->rq_xid,
1356 imp->imp_connection->c_peer.peer_ni->pni_name,
1357 imp->imp_connection->c_peer.peer_nid,
1358 req->rq_reqmsg->opc);
1360 spin_lock_irqsave(&imp->imp_lock, flags);
1361 list_del_init(&req->rq_list);
1362 spin_unlock_irqrestore(&imp->imp_lock, flags);
1364 /* If the reply was received normally, this just grabs the spinlock
1365 * (ensuring the reply callback has returned), sees that
1366 * req->rq_receiving_reply is clear and returns. */
1367 ptlrpc_unregister_reply (req);
1370 GOTO(out, rc = -EIO);
1372 /* Resend if we need to, unless we were interrupted. */
1373 if (req->rq_resend && !req->rq_intr) {
1374 /* ...unless we were specifically told otherwise. */
1375 if (req->rq_no_resend) {
1376 spin_lock_irqsave (&req->rq_lock, flags);
1377 req->rq_no_resend = 0;
1378 spin_unlock_irqrestore (&req->rq_lock, flags);
1379 GOTO(out, rc = -ETIMEDOUT);
1381 spin_lock_irqsave (&req->rq_lock, flags);
1383 spin_unlock_irqrestore (&req->rq_lock, flags);
1384 lustre_msg_add_flags(req->rq_reqmsg, MSG_RESENT);
1386 if (req->rq_bulk != NULL)
1387 ptlrpc_unregister_bulk (req);
1389 DEBUG_REQ(D_HA, req, "resending: ");
1390 spin_lock_irqsave(&imp->imp_lock, flags);
1395 /* Should only be interrupted if we timed out. */
1396 if (!req->rq_timedout)
1397 DEBUG_REQ(D_ERROR, req,
1398 "rq_intr set but rq_timedout not");
1399 GOTO(out, rc = -EINTR);
1402 if (req->rq_timedout) { /* non-recoverable timeout */
1403 GOTO(out, rc = -ETIMEDOUT);
1406 if (!req->rq_replied) {
1407 /* How can this be? -eeb */
1408 DEBUG_REQ(D_ERROR, req, "!rq_replied: ");
1410 GOTO(out, rc = req->rq_status);
1413 rc = after_reply (req, &do_restart);
1414 /* NB may return +ve success rc */
1416 if (req->rq_bulk != NULL)
1417 ptlrpc_unregister_bulk (req);
1418 DEBUG_REQ(D_HA, req, "resending: ");
1419 spin_lock_irqsave(&imp->imp_lock, flags);
1424 if (req->rq_bulk != NULL) {
1425 if (rc >= 0) { /* success so far */
1426 lwi = LWI_TIMEOUT(timeout, NULL, NULL);
1427 brc = l_wait_event(req->rq_wait_for_rep,
1428 ptlrpc_bulk_complete(req->rq_bulk),
1431 LASSERT(brc == -ETIMEDOUT);
1432 CERROR ("Timed out waiting for bulk\n");
1437 /* MDS blocks for put ACKs before replying */
1438 /* OSC sets rq_no_resend for the time being */
1439 LASSERT(req->rq_no_resend);
1440 ptlrpc_unregister_bulk (req);
1444 LASSERT(!req->rq_receiving_reply);
1445 req->rq_phase = RQ_PHASE_INTERPRET;
1449 int ptlrpc_replay_req(struct ptlrpc_request *req)
1451 int rc = 0, old_level, old_status = 0;
1452 // struct ptlrpc_client *cli = req->rq_import->imp_client;
1453 struct l_wait_info lwi;
1456 /* I don't touch rq_phase here, so the debug log can show what
1457 * state it was left in */
1459 /* Not handling automatic bulk replay yet (or ever?) */
1460 LASSERT(req->rq_bulk == NULL);
1462 DEBUG_REQ(D_NET, req, "about to replay");
1464 /* Update request's state, since we might have a new connection. */
1465 ptlrpc_put_connection(req->rq_connection);
1466 req->rq_connection =
1467 ptlrpc_connection_addref(req->rq_import->imp_connection);
1469 /* temporarily set request to RECOVD level (reset at out:) */
1470 old_level = req->rq_level;
1471 if (req->rq_replied)
1472 old_status = req->rq_repmsg->status;
1473 req->rq_level = LUSTRE_CONN_RECOVER;
1474 rc = ptl_send_rpc(req);
1476 CERROR("error %d, opcode %d\n", rc, req->rq_reqmsg->opc);
1477 ptlrpc_cleanup_request_buf(req);
1478 // up(&cli->cli_rpc_sem);
1479 GOTO(out, rc = -rc);
1482 CDEBUG(D_OTHER, "-- sleeping\n");
1483 lwi = LWI_INTR(NULL, NULL); /* XXX needs timeout, nested recovery */
1484 l_wait_event(req->rq_wait_for_rep, ptlrpc_check_reply(req), &lwi);
1485 CDEBUG(D_OTHER, "-- done\n");
1487 // up(&cli->cli_rpc_sem);
1489 /* If the reply was received normally, this just grabs the spinlock
1490 * (ensuring the reply callback has returned), sees that
1491 * req->rq_receiving_reply is clear and returns. */
1492 ptlrpc_unregister_reply (req);
1494 if (!req->rq_replied) {
1495 CERROR("Unknown reason for wakeup\n");
1496 /* XXX Phil - I end up here when I kill obdctl */
1497 /* ...that's because signals aren't all masked in
1498 * l_wait_event() -eeb */
1499 GOTO(out, rc = -EINTR);
1503 /* Clear reply swab mask; this is a new reply in sender's byte order */
1504 req->rq_rep_swab_mask = 0;
1506 rc = lustre_unpack_msg(req->rq_repmsg, req->rq_replen);
1508 CERROR("unpack_rep failed: %d\n", rc);
1509 GOTO(out, rc = -EPROTO);
1512 /* FIXME: Enable when BlueArc makes new release */
1513 if (req->rq_repmsg->type != PTL_RPC_MSG_REPLY &&
1514 req->rq_repmsg->type != PTL_RPC_MSG_ERR) {
1515 CERROR("invalid packet type received (type=%u)\n",
1516 req->rq_repmsg->type);
1517 GOTO(out, rc = -EPROTO);
1521 /* The transno had better not change over replay. */
1522 LASSERT(req->rq_reqmsg->transno == req->rq_repmsg->transno);
1524 CDEBUG(D_NET, "got rep "LPD64"\n", req->rq_xid);
1526 /* let the callback do fixups, possibly including in the request */
1527 if (req->rq_replay_cb)
1528 req->rq_replay_cb(req);
1530 if (req->rq_replied && req->rq_repmsg->status != old_status) {
1531 DEBUG_REQ(D_HA, req, "status %d, old was %d",
1532 req->rq_repmsg->status, old_status);
1536 req->rq_level = old_level;
1540 void ptlrpc_abort_inflight(struct obd_import *imp)
1542 unsigned long flags;
1543 struct list_head *tmp, *n;
1546 /* Make sure that no new requests get processed for this import.
1547 * ptlrpc_{queue,set}_wait must (and does) hold imp_lock while testing
1548 * this flag and then putting requests on sending_list or delayed_list.
1550 spin_lock_irqsave(&imp->imp_lock, flags);
1552 /* XXX locking? Maybe we should remove each request with the list
1553 * locked? Also, how do we know if the requests on the list are
1554 * being freed at this time?
1556 list_for_each_safe(tmp, n, &imp->imp_sending_list) {
1557 struct ptlrpc_request *req =
1558 list_entry(tmp, struct ptlrpc_request, rq_list);
1560 DEBUG_REQ(D_HA, req, "inflight");
1562 spin_lock (&req->rq_lock);
1563 if (req->rq_import_generation < imp->imp_generation) {
1565 if (req->rq_set != NULL)
1566 wake_up(&req->rq_set->set_waitq);
1568 wake_up(&req->rq_wait_for_rep);
1570 spin_unlock (&req->rq_lock);
1573 list_for_each_safe(tmp, n, &imp->imp_delayed_list) {
1574 struct ptlrpc_request *req =
1575 list_entry(tmp, struct ptlrpc_request, rq_list);
1577 DEBUG_REQ(D_HA, req, "aborting waiting req");
1579 spin_lock (&req->rq_lock);
1580 if (req->rq_import_generation < imp->imp_generation) {
1582 if (req->rq_set != NULL)
1583 wake_up(&req->rq_set->set_waitq);
1585 wake_up(&req->rq_wait_for_rep);
1587 spin_unlock (&req->rq_lock);
1590 /* Last chance to free reqs left on the replay list, but we
1591 * will still leak reqs that haven't comitted. */
1592 if (imp->imp_replayable)
1593 ptlrpc_free_committed(imp);
1595 spin_unlock_irqrestore(&imp->imp_lock, flags);
1600 static __u64 ptlrpc_last_xid = 0;
1601 static spinlock_t ptlrpc_last_xid_lock = SPIN_LOCK_UNLOCKED;
1603 __u64 ptlrpc_next_xid(void)
1606 spin_lock(&ptlrpc_last_xid_lock);
1607 tmp = ++ptlrpc_last_xid;
1608 spin_unlock(&ptlrpc_last_xid_lock);