1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright 2008 Sun Microsystems, Inc. All rights reserved
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
36 * lustre/ptlrpc/import.c
38 * Author: Mike Shaver <shaver@clusterfs.com>
41 #define DEBUG_SUBSYSTEM S_RPC
43 # include <liblustre.h>
46 #include <obd_support.h>
47 #include <lustre_ha.h>
48 #include <lustre_net.h>
49 #include <lustre_import.h>
50 #include <lustre_export.h>
52 #include <obd_cksum.h>
53 #include <obd_class.h>
55 #include "ptlrpc_internal.h"
57 struct ptlrpc_connect_async_args {
58 __u64 pcaa_peer_committed;
59 int pcaa_initial_connect;
62 /* A CLOSED import should remain so. */
63 #define IMPORT_SET_STATE_NOLOCK(imp, state) \
65 if (imp->imp_state != LUSTRE_IMP_CLOSED) { \
66 CDEBUG(D_HA, "%p %s: changing import state from %s to %s\n", \
67 imp, obd2cli_tgt(imp->imp_obd), \
68 ptlrpc_import_state_name(imp->imp_state), \
69 ptlrpc_import_state_name(state)); \
70 imp->imp_state = state; \
74 #define IMPORT_SET_STATE(imp, state) \
76 spin_lock(&imp->imp_lock); \
77 IMPORT_SET_STATE_NOLOCK(imp, state); \
78 spin_unlock(&imp->imp_lock); \
82 static int ptlrpc_connect_interpret(struct ptlrpc_request *request,
84 int ptlrpc_import_recovery_state_machine(struct obd_import *imp);
86 /* Only this function is allowed to change the import state when it is
87 * CLOSED. I would rather refcount the import and free it after
88 * disconnection like we do with exports. To do that, the client_obd
89 * will need to save the peer info somewhere other than in the import,
91 int ptlrpc_init_import(struct obd_import *imp)
93 spin_lock(&imp->imp_lock);
95 imp->imp_generation++;
96 imp->imp_state = LUSTRE_IMP_NEW;
98 spin_unlock(&imp->imp_lock);
102 EXPORT_SYMBOL(ptlrpc_init_import);
104 #define UUID_STR "_UUID"
105 static void deuuidify(char *uuid, const char *prefix, char **uuid_start,
108 *uuid_start = !prefix || strncmp(uuid, prefix, strlen(prefix))
109 ? uuid : uuid + strlen(prefix);
111 *uuid_len = strlen(*uuid_start);
113 if (*uuid_len < strlen(UUID_STR))
116 if (!strncmp(*uuid_start + *uuid_len - strlen(UUID_STR),
117 UUID_STR, strlen(UUID_STR)))
118 *uuid_len -= strlen(UUID_STR);
121 /* Returns true if import was FULL, false if import was already not
123 * @imp - import to be disconnected
124 * @conn_cnt - connection count (epoch) of the request that timed out
125 * and caused the disconnection. In some cases, multiple
126 * inflight requests can fail to a single target (e.g. OST
127 * bulk requests) and if one has already caused a reconnection
128 * (increasing the import->conn_cnt) the older failure should
129 * not also cause a reconnection. If zero it forces a reconnect.
131 int ptlrpc_set_import_discon(struct obd_import *imp, __u32 conn_cnt)
135 spin_lock(&imp->imp_lock);
137 if (imp->imp_state == LUSTRE_IMP_FULL &&
138 (conn_cnt == 0 || conn_cnt == imp->imp_conn_cnt)) {
142 deuuidify(obd2cli_tgt(imp->imp_obd), NULL,
143 &target_start, &target_len);
145 if (imp->imp_replayable) {
146 LCONSOLE_WARN("%s: Connection to service %.*s via nid "
147 "%s was lost; in progress operations using this "
148 "service will wait for recovery to complete.\n",
149 imp->imp_obd->obd_name, target_len, target_start,
150 libcfs_nid2str(imp->imp_connection->c_peer.nid));
152 LCONSOLE_ERROR_MSG(0x166, "%s: Connection to service "
153 "%.*s via nid %s was lost; in progress"
154 "operations using this service will"
156 imp->imp_obd->obd_name,
157 target_len, target_start,
158 libcfs_nid2str(imp->imp_connection->c_peer.nid));
160 ptlrpc_deactivate_timeouts(imp);
161 IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_DISCON);
162 spin_unlock(&imp->imp_lock);
164 if (obd_dump_on_timeout)
165 libcfs_debug_dumplog();
167 obd_import_event(imp->imp_obd, imp, IMP_EVENT_DISCON);
170 spin_unlock(&imp->imp_lock);
171 CDEBUG(D_HA, "%s: import %p already %s (conn %u, was %u): %s\n",
172 imp->imp_client->cli_name, imp,
173 (imp->imp_state == LUSTRE_IMP_FULL &&
174 imp->imp_conn_cnt > conn_cnt) ?
175 "reconnected" : "not connected", imp->imp_conn_cnt,
176 conn_cnt, ptlrpc_import_state_name(imp->imp_state));
182 /* Must be called with imp_lock held! */
183 static void ptlrpc_deactivate_and_unlock_import(struct obd_import *imp)
186 LASSERT_SPIN_LOCKED(&imp->imp_lock);
188 CDEBUG(D_HA, "setting import %s INVALID\n", obd2cli_tgt(imp->imp_obd));
189 imp->imp_invalid = 1;
190 imp->imp_generation++;
191 spin_unlock(&imp->imp_lock);
193 ptlrpc_abort_inflight(imp);
194 obd_import_event(imp->imp_obd, imp, IMP_EVENT_INACTIVE);
200 * This acts as a barrier; all existing requests are rejected, and
201 * no new requests will be accepted until the import is valid again.
203 void ptlrpc_deactivate_import(struct obd_import *imp)
205 spin_lock(&imp->imp_lock);
206 ptlrpc_deactivate_and_unlock_import(imp);
210 * This function will invalidate the import, if necessary, then block
211 * for all the RPC completions, and finally notify the obd to
212 * invalidate its state (ie cancel locks, clear pending requests,
215 void ptlrpc_invalidate_import(struct obd_import *imp)
217 struct list_head *tmp, *n;
218 struct ptlrpc_request *req;
219 struct l_wait_info lwi;
222 atomic_inc(&imp->imp_inval_count);
225 * If this is an invalid MGC connection, then don't bother
226 * waiting for imp_inflight to drop to 0.
228 if (imp->imp_invalid && imp->imp_recon_bk && !imp->imp_obd->obd_no_recov)
231 if (!imp->imp_invalid || imp->imp_obd->obd_no_recov)
232 ptlrpc_deactivate_import(imp);
234 LASSERT(imp->imp_invalid);
236 /* wait for all requests to error out and call completion callbacks.
237 Cap it at obd_timeout -- these should all have been locally
238 cancelled by ptlrpc_abort_inflight. */
239 lwi = LWI_TIMEOUT_INTERVAL(
240 cfs_timeout_cap(cfs_time_seconds(obd_timeout)),
241 cfs_time_seconds(1), NULL, NULL);
242 rc = l_wait_event(imp->imp_recovery_waitq,
243 (atomic_read(&imp->imp_inflight) == 0), &lwi);
246 CERROR("%s: rc = %d waiting for callback (%d != 0)\n",
247 obd2cli_tgt(imp->imp_obd), rc,
248 atomic_read(&imp->imp_inflight));
249 spin_lock(&imp->imp_lock);
250 list_for_each_safe(tmp, n, &imp->imp_sending_list) {
251 req = list_entry(tmp, struct ptlrpc_request, rq_list);
252 DEBUG_REQ(D_ERROR, req, "still on sending list");
254 list_for_each_safe(tmp, n, &imp->imp_delayed_list) {
255 req = list_entry(tmp, struct ptlrpc_request, rq_list);
256 DEBUG_REQ(D_ERROR, req, "still on delayed list");
258 spin_unlock(&imp->imp_lock);
259 LASSERT(atomic_read(&imp->imp_inflight) == 0);
263 obd_import_event(imp->imp_obd, imp, IMP_EVENT_INVALIDATE);
264 sptlrpc_import_flush_all_ctx(imp);
266 atomic_dec(&imp->imp_inval_count);
267 cfs_waitq_signal(&imp->imp_recovery_waitq);
270 /* unset imp_invalid */
271 void ptlrpc_activate_import(struct obd_import *imp)
273 struct obd_device *obd = imp->imp_obd;
275 spin_lock(&imp->imp_lock);
276 imp->imp_invalid = 0;
277 ptlrpc_activate_timeouts(imp);
278 spin_unlock(&imp->imp_lock);
279 obd_import_event(obd, imp, IMP_EVENT_ACTIVE);
282 void ptlrpc_fail_import(struct obd_import *imp, __u32 conn_cnt)
286 LASSERT(!imp->imp_dlm_fake);
288 if (ptlrpc_set_import_discon(imp, conn_cnt)) {
289 if (!imp->imp_replayable) {
290 CDEBUG(D_HA, "import %s@%s for %s not replayable, "
291 "auto-deactivating\n",
292 obd2cli_tgt(imp->imp_obd),
293 imp->imp_connection->c_remote_uuid.uuid,
294 imp->imp_obd->obd_name);
295 ptlrpc_deactivate_import(imp);
298 CDEBUG(D_HA, "%s: waking up pinger\n",
299 obd2cli_tgt(imp->imp_obd));
301 spin_lock(&imp->imp_lock);
302 imp->imp_force_verify = 1;
303 spin_unlock(&imp->imp_lock);
305 ptlrpc_pinger_wake_up();
310 int ptlrpc_reconnect_import(struct obd_import *imp)
312 ptlrpc_set_import_discon(imp, 0);
313 /* Force a new connect attempt */
314 ptlrpc_invalidate_import(imp);
315 /* Do a fresh connect next time by zeroing the handle */
316 ptlrpc_disconnect_import(imp, 1);
317 /* Wait for all invalidate calls to finish */
318 if (atomic_read(&imp->imp_inval_count) > 0) {
320 struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL);
321 rc = l_wait_event(imp->imp_recovery_waitq,
322 (atomic_read(&imp->imp_inval_count) == 0),
325 CERROR("Interrupted, inval=%d\n",
326 atomic_read(&imp->imp_inval_count));
329 /* Allow reconnect attempts */
330 imp->imp_obd->obd_no_recov = 0;
331 /* Remove 'invalid' flag */
332 ptlrpc_activate_import(imp);
333 /* Attempt a new connect */
334 ptlrpc_recover_import(imp, NULL);
338 EXPORT_SYMBOL(ptlrpc_reconnect_import);
340 static int import_select_connection(struct obd_import *imp)
342 struct obd_import_conn *imp_conn = NULL, *conn;
343 struct obd_export *dlmexp;
347 spin_lock(&imp->imp_lock);
349 if (list_empty(&imp->imp_conn_list)) {
350 CERROR("%s: no connections available\n",
351 imp->imp_obd->obd_name);
352 spin_unlock(&imp->imp_lock);
356 list_for_each_entry(conn, &imp->imp_conn_list, oic_item) {
357 CDEBUG(D_HA, "%s: connect to NID %s last attempt "LPU64"\n",
358 imp->imp_obd->obd_name,
359 libcfs_nid2str(conn->oic_conn->c_peer.nid),
360 conn->oic_last_attempt);
361 /* Don't thrash connections */
362 if (cfs_time_before_64(cfs_time_current_64(),
363 conn->oic_last_attempt +
364 cfs_time_seconds(CONNECTION_SWITCH_MIN))) {
368 /* If we have not tried this connection since the
369 the last successful attempt, go with this one */
370 if ((conn->oic_last_attempt == 0) ||
371 cfs_time_beforeq_64(conn->oic_last_attempt,
372 imp->imp_last_success_conn)) {
378 /* If all of the connections have already been tried
379 since the last successful connection; just choose the
380 least recently used */
383 else if (cfs_time_before_64(conn->oic_last_attempt,
384 imp_conn->oic_last_attempt))
388 /* if not found, simply choose the current one */
390 LASSERT(imp->imp_conn_current);
391 imp_conn = imp->imp_conn_current;
394 LASSERT(imp_conn->oic_conn);
396 /* If we've tried everything, and we're back to the beginning of the
397 list, increase our timeout and try again. It will be reset when
398 we do finally connect. (FIXME: really we should wait for all network
399 state associated with the last connection attempt to drain before
400 trying to reconnect on it.) */
401 if (tried_all && (imp->imp_conn_list.next == &imp_conn->oic_item) &&
402 !imp->imp_recon_bk /* not retrying */) {
403 if (at_get(&imp->imp_at.iat_net_latency) <
404 CONNECTION_SWITCH_MAX) {
405 at_add(&imp->imp_at.iat_net_latency,
406 at_get(&imp->imp_at.iat_net_latency) +
407 CONNECTION_SWITCH_INC);
409 LASSERT(imp_conn->oic_last_attempt);
410 CWARN("%s: tried all connections, increasing latency to %ds\n",
411 imp->imp_obd->obd_name,
412 at_get(&imp->imp_at.iat_net_latency));
415 imp_conn->oic_last_attempt = cfs_time_current_64();
417 /* switch connection, don't mind if it's same as the current one */
418 if (imp->imp_connection)
419 ptlrpc_connection_put(imp->imp_connection);
420 imp->imp_connection = ptlrpc_connection_addref(imp_conn->oic_conn);
422 dlmexp = class_conn2export(&imp->imp_dlm_handle);
423 LASSERT(dlmexp != NULL);
424 if (dlmexp->exp_connection)
425 ptlrpc_connection_put(dlmexp->exp_connection);
426 dlmexp->exp_connection = ptlrpc_connection_addref(imp_conn->oic_conn);
427 class_export_put(dlmexp);
429 if (imp->imp_conn_current != imp_conn) {
430 if (imp->imp_conn_current)
431 LCONSOLE_INFO("Changing connection for %s to %s/%s\n",
432 imp->imp_obd->obd_name,
433 imp_conn->oic_uuid.uuid,
434 libcfs_nid2str(imp_conn->oic_conn->c_peer.nid));
435 imp->imp_conn_current = imp_conn;
438 CDEBUG(D_HA, "%s: import %p using connection %s/%s\n",
439 imp->imp_obd->obd_name, imp, imp_conn->oic_uuid.uuid,
440 libcfs_nid2str(imp_conn->oic_conn->c_peer.nid));
442 spin_unlock(&imp->imp_lock);
448 * must be called under imp_lock
450 int ptlrpc_first_transno(struct obd_import *imp, __u64 *transno)
452 struct ptlrpc_request *req;
453 struct list_head *tmp;
455 if (list_empty(&imp->imp_replay_list))
457 tmp = imp->imp_replay_list.next;
458 req = list_entry(tmp, struct ptlrpc_request, rq_replay_list);
459 *transno = req->rq_transno;
460 if (req->rq_transno == 0) {
461 DEBUG_REQ(D_ERROR, req, "zero transno in replay");
468 int ptlrpc_connect_import(struct obd_import *imp, char *new_uuid)
470 struct obd_device *obd = imp->imp_obd;
471 int initial_connect = 0;
473 __u64 committed_before_reconnect = 0;
474 struct ptlrpc_request *request;
475 char *bufs[] = { NULL,
476 obd2cli_tgt(imp->imp_obd),
478 (char *)&imp->imp_dlm_handle,
479 (char *)&imp->imp_connect_data };
480 struct ptlrpc_connect_async_args *aa;
484 spin_lock(&imp->imp_lock);
485 if (imp->imp_state == LUSTRE_IMP_CLOSED) {
486 spin_unlock(&imp->imp_lock);
487 CERROR("can't connect to a closed import\n");
489 } else if (imp->imp_state == LUSTRE_IMP_FULL) {
490 spin_unlock(&imp->imp_lock);
491 CERROR("already connected\n");
493 } else if (imp->imp_state == LUSTRE_IMP_CONNECTING) {
494 spin_unlock(&imp->imp_lock);
495 CERROR("already connecting\n");
499 IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_CONNECTING);
502 imp->imp_resend_replay = 0;
504 if (!lustre_handle_is_used(&imp->imp_remote_handle))
507 committed_before_reconnect = imp->imp_peer_committed_transno;
509 set_transno = ptlrpc_first_transno(imp, &imp->imp_connect_data.ocd_transno);
510 spin_unlock(&imp->imp_lock);
513 struct obd_uuid uuid;
515 obd_str2uuid(&uuid, new_uuid);
516 rc = import_set_conn_priority(imp, &uuid);
521 rc = import_select_connection(imp);
525 /* last in connection list */
526 if (imp->imp_conn_current->oic_item.next == &imp->imp_conn_list) {
527 if (imp->imp_initial_recov_bk && initial_connect) {
528 CDEBUG(D_HA, "Last connection attempt (%d) for %s\n",
529 imp->imp_conn_cnt, obd2cli_tgt(imp->imp_obd));
530 /* Don't retry if connect fails */
532 obd_set_info_async(obd->obd_self_export,
533 sizeof(KEY_INIT_RECOV),
535 sizeof(rc), &rc, NULL);
537 if (imp->imp_recon_bk) {
538 CDEBUG(D_HA, "Last reconnection attempt (%d) for %s\n",
539 imp->imp_conn_cnt, obd2cli_tgt(imp->imp_obd));
540 spin_lock(&imp->imp_lock);
541 imp->imp_last_recon = 1;
542 spin_unlock(&imp->imp_lock);
546 rc = sptlrpc_import_sec_adapt(imp, NULL, 0);
550 /* Reset connect flags to the originally requested flags, in case
551 * the server is updated on-the-fly we will get the new features. */
552 imp->imp_connect_data.ocd_connect_flags = imp->imp_connect_flags_orig;
553 imp->imp_msghdr_flags &= ~MSGHDR_AT_SUPPORT;
555 rc = obd_reconnect(NULL, imp->imp_obd->obd_self_export, obd,
556 &obd->obd_uuid, &imp->imp_connect_data);
560 request = ptlrpc_request_alloc(imp, &RQF_MDS_CONNECT);
562 GOTO(out, rc = -ENOMEM);
564 rc = ptlrpc_request_bufs_pack(request, LUSTRE_OBD_VERSION,
565 imp->imp_connect_op, bufs, NULL);
567 ptlrpc_request_free(request);
572 lustre_msg_add_op_flags(request->rq_reqmsg, MSG_CONNECT_LIBCLIENT);
574 lustre_msg_add_op_flags(request->rq_reqmsg, MSG_CONNECT_NEXT_VER);
576 request->rq_send_state = LUSTRE_IMP_CONNECTING;
577 /* Allow a slightly larger reply for future growth compatibility */
578 req_capsule_set_size(&request->rq_pill, &RMF_CONNECT_DATA, RCL_SERVER,
579 sizeof(struct obd_connect_data)+16*sizeof(__u64));
580 ptlrpc_request_set_replen(request);
581 request->rq_interpret_reply = ptlrpc_connect_interpret;
583 CLASSERT(sizeof (*aa) <= sizeof (request->rq_async_args));
584 aa = ptlrpc_req_async_args(request);
585 memset(aa, 0, sizeof *aa);
587 aa->pcaa_peer_committed = committed_before_reconnect;
588 aa->pcaa_initial_connect = initial_connect;
590 if (aa->pcaa_initial_connect) {
591 spin_lock(&imp->imp_lock);
592 imp->imp_replayable = 1;
593 spin_unlock(&imp->imp_lock);
594 lustre_msg_add_op_flags(request->rq_reqmsg,
595 MSG_CONNECT_INITIAL);
597 /* AT will use INITIAL_CONNECT_TIMEOUT the first
598 time, adaptive after that. */
599 request->rq_timeout = INITIAL_CONNECT_TIMEOUT;
603 lustre_msg_add_op_flags(request->rq_reqmsg,
604 MSG_CONNECT_TRANSNO);
606 DEBUG_REQ(D_RPCTRACE, request, "(re)connect request");
607 ptlrpcd_add_req(request);
611 IMPORT_SET_STATE(imp, LUSTRE_IMP_DISCON);
616 EXPORT_SYMBOL(ptlrpc_connect_import);
618 static void ptlrpc_maybe_ping_import_soon(struct obd_import *imp)
621 struct obd_import_conn *imp_conn;
627 spin_lock(&imp->imp_lock);
628 if (list_empty(&imp->imp_conn_list))
632 imp_conn = list_entry(imp->imp_conn_list.prev,
633 struct obd_import_conn,
636 /* XXX: When the failover node is the primary node, it is possible
637 * to have two identical connections in imp_conn_list. We must
638 * compare not conn's pointers but NIDs, otherwise we can defeat
639 * connection throttling. (See bug 14774.) */
640 if (imp->imp_conn_current->oic_conn->c_self !=
641 imp_conn->oic_conn->c_self) {
642 ptlrpc_ping_import_soon(imp);
646 /* liblustre has no pinger thead, so we wakup pinger anyway */
651 spin_unlock(&imp->imp_lock);
654 ptlrpc_pinger_wake_up();
659 static int ptlrpc_connect_interpret(struct ptlrpc_request *request,
662 struct ptlrpc_connect_async_args *aa = data;
663 struct obd_import *imp = request->rq_import;
664 struct client_obd *cli = &imp->imp_obd->u.cli;
665 struct lustre_handle old_hdl;
669 spin_lock(&imp->imp_lock);
670 if (imp->imp_state == LUSTRE_IMP_CLOSED) {
671 spin_unlock(&imp->imp_lock);
674 spin_unlock(&imp->imp_lock);
679 LASSERT(imp->imp_conn_current);
681 msg_flags = lustre_msg_get_op_flags(request->rq_repmsg);
683 /* All imports are pingable */
684 spin_lock(&imp->imp_lock);
685 imp->imp_pingable = 1;
687 if (aa->pcaa_initial_connect) {
688 if (msg_flags & MSG_CONNECT_REPLAYABLE) {
689 imp->imp_replayable = 1;
690 spin_unlock(&imp->imp_lock);
691 CDEBUG(D_HA, "connected to replayable target: %s\n",
692 obd2cli_tgt(imp->imp_obd));
694 imp->imp_replayable = 0;
695 spin_unlock(&imp->imp_lock);
698 /* if applies, adjust the imp->imp_msg_magic here
699 * according to reply flags */
701 imp->imp_remote_handle =
702 *lustre_msg_get_handle(request->rq_repmsg);
704 /* Initial connects are allowed for clients with non-random
705 * uuids when servers are in recovery. Simply signal the
706 * servers replay is complete and wait in REPLAY_WAIT. */
707 if (msg_flags & MSG_CONNECT_RECOVERING) {
708 CDEBUG(D_HA, "connect to %s during recovery\n",
709 obd2cli_tgt(imp->imp_obd));
710 IMPORT_SET_STATE(imp, LUSTRE_IMP_REPLAY_LOCKS);
712 IMPORT_SET_STATE(imp, LUSTRE_IMP_FULL);
715 spin_lock(&imp->imp_lock);
716 if (imp->imp_invalid) {
717 spin_unlock(&imp->imp_lock);
718 ptlrpc_activate_import(imp);
720 spin_unlock(&imp->imp_lock);
723 GOTO(finish, rc = 0);
725 spin_unlock(&imp->imp_lock);
728 /* Determine what recovery state to move the import to. */
729 if (MSG_CONNECT_RECONNECT & msg_flags) {
730 memset(&old_hdl, 0, sizeof(old_hdl));
731 if (!memcmp(&old_hdl, lustre_msg_get_handle(request->rq_repmsg),
733 CERROR("%s@%s didn't like our handle "LPX64
734 ", failed\n", obd2cli_tgt(imp->imp_obd),
735 imp->imp_connection->c_remote_uuid.uuid,
736 imp->imp_dlm_handle.cookie);
737 GOTO(out, rc = -ENOTCONN);
740 if (memcmp(&imp->imp_remote_handle,
741 lustre_msg_get_handle(request->rq_repmsg),
742 sizeof(imp->imp_remote_handle))) {
743 int level = msg_flags & MSG_CONNECT_RECOVERING ? D_HA :
746 /* Bug 16611/14775: if server handle have changed,
747 * that means some sort of disconnection happened.
748 * If the server is not in recovery, that also means it
749 * already erased all of our state because of previous
750 * eviction. If it is in recovery - we are safe to
751 * participate since we can reestablish all of our state
752 * with server again */
753 CDEBUG(level,"%s@%s changed server handle from "
754 LPX64" to "LPX64"%s \n" "but is still in recovery \n",
755 obd2cli_tgt(imp->imp_obd),
756 imp->imp_connection->c_remote_uuid.uuid,
757 imp->imp_remote_handle.cookie,
758 lustre_msg_get_handle(request->rq_repmsg)->
760 (MSG_CONNECT_RECOVERING & msg_flags) ?
761 "but is still in recovery" : "");
763 imp->imp_remote_handle =
764 *lustre_msg_get_handle(request->rq_repmsg);
766 if (!(MSG_CONNECT_RECOVERING & msg_flags)) {
767 IMPORT_SET_STATE(imp, LUSTRE_IMP_EVICTED);
768 GOTO(finish, rc = 0);
772 CDEBUG(D_HA, "reconnected to %s@%s after partition\n",
773 obd2cli_tgt(imp->imp_obd),
774 imp->imp_connection->c_remote_uuid.uuid);
777 if (imp->imp_invalid) {
778 CDEBUG(D_HA, "%s: reconnected but import is invalid; "
779 "marking evicted\n", imp->imp_obd->obd_name);
780 IMPORT_SET_STATE(imp, LUSTRE_IMP_EVICTED);
781 } else if (MSG_CONNECT_RECOVERING & msg_flags) {
782 CDEBUG(D_HA, "%s: reconnected to %s during replay\n",
783 imp->imp_obd->obd_name,
784 obd2cli_tgt(imp->imp_obd));
786 spin_lock(&imp->imp_lock);
787 imp->imp_resend_replay = 1;
788 spin_unlock(&imp->imp_lock);
790 IMPORT_SET_STATE(imp, LUSTRE_IMP_REPLAY);
792 IMPORT_SET_STATE(imp, LUSTRE_IMP_RECOVER);
794 } else if ((MSG_CONNECT_RECOVERING & msg_flags) && !imp->imp_invalid) {
795 LASSERT(imp->imp_replayable);
796 imp->imp_remote_handle =
797 *lustre_msg_get_handle(request->rq_repmsg);
798 imp->imp_last_replay_transno = 0;
799 IMPORT_SET_STATE(imp, LUSTRE_IMP_REPLAY);
801 DEBUG_REQ(D_HA, request, "%s: evicting (reconnect/recover flags"
802 " not set: %x)", imp->imp_obd->obd_name, msg_flags);
803 imp->imp_remote_handle =
804 *lustre_msg_get_handle(request->rq_repmsg);
805 IMPORT_SET_STATE(imp, LUSTRE_IMP_EVICTED);
808 /* Sanity checks for a reconnected import. */
809 if (!(imp->imp_replayable) != !(msg_flags & MSG_CONNECT_REPLAYABLE)) {
810 CERROR("imp_replayable flag does not match server "
811 "after reconnect. We should LBUG right here.\n");
814 if (lustre_msg_get_last_committed(request->rq_repmsg) <
815 aa->pcaa_peer_committed) {
816 CERROR("%s went back in time (transno "LPD64
817 " was previously committed, server now claims "LPD64
818 ")! See https://bugzilla.lustre.org/show_bug.cgi?"
820 obd2cli_tgt(imp->imp_obd), aa->pcaa_peer_committed,
821 lustre_msg_get_last_committed(request->rq_repmsg));
825 rc = ptlrpc_import_recovery_state_machine(imp);
827 if (rc == -ENOTCONN) {
828 CDEBUG(D_HA, "evicted/aborted by %s@%s during recovery;"
829 "invalidating and reconnecting\n",
830 obd2cli_tgt(imp->imp_obd),
831 imp->imp_connection->c_remote_uuid.uuid);
832 ptlrpc_connect_import(imp, NULL);
836 struct obd_connect_data *ocd;
837 struct obd_export *exp;
839 ret = req_capsule_get_size(&request->rq_pill, &RMF_CONNECT_DATA,
841 /* server replied obd_connect_data is always bigger */
842 ocd = req_capsule_server_sized_get(&request->rq_pill,
843 &RMF_CONNECT_DATA, ret);
845 spin_lock(&imp->imp_lock);
846 list_del(&imp->imp_conn_current->oic_item);
847 list_add(&imp->imp_conn_current->oic_item, &imp->imp_conn_list);
848 imp->imp_last_success_conn =
849 imp->imp_conn_current->oic_last_attempt;
852 spin_unlock(&imp->imp_lock);
853 CERROR("Wrong connect data from server\n");
858 imp->imp_connect_data = *ocd;
860 exp = class_conn2export(&imp->imp_dlm_handle);
861 spin_unlock(&imp->imp_lock);
863 /* check that server granted subset of flags we asked for. */
864 LASSERTF((ocd->ocd_connect_flags &
865 imp->imp_connect_flags_orig) ==
866 ocd->ocd_connect_flags, LPX64" != "LPX64,
867 imp->imp_connect_flags_orig, ocd->ocd_connect_flags);
870 /* This could happen if export is cleaned during the
872 CERROR("Missing export for %s\n",
873 imp->imp_obd->obd_name);
874 GOTO(out, rc = -ENODEV);
876 exp->exp_connect_flags = ocd->ocd_connect_flags;
877 imp->imp_obd->obd_self_export->exp_connect_flags =
878 ocd->ocd_connect_flags;
879 class_export_put(exp);
881 obd_import_event(imp->imp_obd, imp, IMP_EVENT_OCD);
883 if (!ocd->ocd_ibits_known &&
884 ocd->ocd_connect_flags & OBD_CONNECT_IBITS)
885 CERROR("Inodebits aware server returned zero compatible"
888 if ((ocd->ocd_connect_flags & OBD_CONNECT_VERSION) &&
889 (ocd->ocd_version > LUSTRE_VERSION_CODE +
890 LUSTRE_VERSION_OFFSET_WARN ||
891 ocd->ocd_version < LUSTRE_VERSION_CODE -
892 LUSTRE_VERSION_OFFSET_WARN)) {
893 /* Sigh, some compilers do not like #ifdef in the middle
894 of macro arguments */
897 "older. Consider upgrading this client";
900 "older. Consider recompiling this application";
902 const char *newer = "newer than client version";
904 LCONSOLE_WARN("Server %s version (%d.%d.%d.%d) "
906 obd2cli_tgt(imp->imp_obd),
907 OBD_OCD_VERSION_MAJOR(ocd->ocd_version),
908 OBD_OCD_VERSION_MINOR(ocd->ocd_version),
909 OBD_OCD_VERSION_PATCH(ocd->ocd_version),
910 OBD_OCD_VERSION_FIX(ocd->ocd_version),
911 ocd->ocd_version > LUSTRE_VERSION_CODE ?
912 newer : older, LUSTRE_VERSION_STRING);
915 if (ocd->ocd_connect_flags & OBD_CONNECT_CKSUM) {
916 /* We sent to the server ocd_cksum_types with bits set
917 * for algorithms we understand. The server masked off
918 * the checksum types it doesn't support */
919 if ((ocd->ocd_cksum_types & OBD_CKSUM_ALL) == 0) {
920 LCONSOLE_WARN("The negotiation of the checksum "
921 "alogrithm to use with server %s "
922 "failed (%x/%x), disabling "
924 obd2cli_tgt(imp->imp_obd),
925 ocd->ocd_cksum_types,
927 cli->cl_checksum = 0;
928 cli->cl_supp_cksum_types = OBD_CKSUM_CRC32;
929 cli->cl_cksum_type = OBD_CKSUM_CRC32;
931 cli->cl_supp_cksum_types = ocd->ocd_cksum_types;
933 if (ocd->ocd_cksum_types & OSC_DEFAULT_CKSUM)
934 cli->cl_cksum_type = OSC_DEFAULT_CKSUM;
935 else if (ocd->ocd_cksum_types & OBD_CKSUM_ADLER)
936 cli->cl_cksum_type = OBD_CKSUM_ADLER;
938 cli->cl_cksum_type = OBD_CKSUM_CRC32;
941 /* The server does not support OBD_CONNECT_CKSUM.
942 * Enforce CRC32 for backward compatibility*/
943 cli->cl_supp_cksum_types = OBD_CKSUM_CRC32;
944 cli->cl_cksum_type = OBD_CKSUM_CRC32;
947 if (ocd->ocd_connect_flags & OBD_CONNECT_BRW_SIZE) {
948 cli->cl_max_pages_per_rpc =
949 ocd->ocd_brw_size >> CFS_PAGE_SHIFT;
952 imp->imp_obd->obd_namespace->ns_connect_flags =
953 ocd->ocd_connect_flags;
954 imp->imp_obd->obd_namespace->ns_orig_connect_flags =
955 ocd->ocd_connect_flags;
957 if ((ocd->ocd_connect_flags & OBD_CONNECT_AT) &&
958 (imp->imp_msg_magic == LUSTRE_MSG_MAGIC_V2))
959 /* We need a per-message support flag, because
960 a. we don't know if the incoming connect reply
961 supports AT or not (in reply_in_callback)
963 b. failovered server means export and flags are gone
964 (in ptlrpc_send_reply).
965 Can only be set when we know AT is supported at
967 imp->imp_msghdr_flags |= MSGHDR_AT_SUPPORT;
969 imp->imp_msghdr_flags &= ~MSGHDR_AT_SUPPORT;
971 LASSERT((cli->cl_max_pages_per_rpc <= PTLRPC_MAX_BRW_PAGES) &&
972 (cli->cl_max_pages_per_rpc > 0));
977 IMPORT_SET_STATE(imp, LUSTRE_IMP_DISCON);
978 spin_lock(&imp->imp_lock);
979 if (aa->pcaa_initial_connect && !imp->imp_initial_recov &&
980 (request->rq_import_generation == imp->imp_generation))
981 ptlrpc_deactivate_and_unlock_import(imp);
983 spin_unlock(&imp->imp_lock);
985 if ((imp->imp_recon_bk && imp->imp_last_recon) ||
988 * Give up trying to reconnect
989 * EACCES means client has no permission for connection
991 imp->imp_obd->obd_no_recov = 1;
992 ptlrpc_deactivate_import(imp);
996 struct obd_connect_data *ocd;
998 /* reply message might not be ready */
999 if (request->rq_repmsg == NULL)
1002 ocd = req_capsule_server_get(&request->rq_pill,
1005 (ocd->ocd_connect_flags & OBD_CONNECT_VERSION) &&
1006 (ocd->ocd_version != LUSTRE_VERSION_CODE)) {
1007 /* Actually servers are only supposed to refuse
1008 connection from liblustre clients, so we should
1009 never see this from VFS context */
1010 LCONSOLE_ERROR_MSG(0x16a, "Server %s version "
1012 " refused connection from this client "
1013 "with an incompatible version (%s). "
1014 "Client must be recompiled\n",
1015 obd2cli_tgt(imp->imp_obd),
1016 OBD_OCD_VERSION_MAJOR(ocd->ocd_version),
1017 OBD_OCD_VERSION_MINOR(ocd->ocd_version),
1018 OBD_OCD_VERSION_PATCH(ocd->ocd_version),
1019 OBD_OCD_VERSION_FIX(ocd->ocd_version),
1020 LUSTRE_VERSION_STRING);
1021 ptlrpc_deactivate_import(imp);
1022 IMPORT_SET_STATE(imp, LUSTRE_IMP_CLOSED);
1027 ptlrpc_maybe_ping_import_soon(imp);
1029 CDEBUG(D_HA, "recovery of %s on %s failed (%d)\n",
1030 obd2cli_tgt(imp->imp_obd),
1031 (char *)imp->imp_connection->c_remote_uuid.uuid, rc);
1034 spin_lock(&imp->imp_lock);
1035 imp->imp_last_recon = 0;
1036 spin_unlock(&imp->imp_lock);
1038 cfs_waitq_signal(&imp->imp_recovery_waitq);
1042 static int completed_replay_interpret(struct ptlrpc_request *req,
1043 void * data, int rc)
1046 atomic_dec(&req->rq_import->imp_replay_inflight);
1047 if (req->rq_status == 0) {
1048 ptlrpc_import_recovery_state_machine(req->rq_import);
1050 CDEBUG(D_HA, "%s: LAST_REPLAY message error: %d, "
1052 req->rq_import->imp_obd->obd_name, req->rq_status);
1053 ptlrpc_connect_import(req->rq_import, NULL);
1059 static int signal_completed_replay(struct obd_import *imp)
1061 struct ptlrpc_request *req;
1064 LASSERT(atomic_read(&imp->imp_replay_inflight) == 0);
1065 atomic_inc(&imp->imp_replay_inflight);
1067 req = ptlrpc_request_alloc_pack(imp, &RQF_OBD_PING, LUSTRE_OBD_VERSION,
1070 atomic_dec(&imp->imp_replay_inflight);
1074 ptlrpc_request_set_replen(req);
1075 req->rq_send_state = LUSTRE_IMP_REPLAY_WAIT;
1076 lustre_msg_add_flags(req->rq_reqmsg,
1077 MSG_LOCK_REPLAY_DONE | MSG_REQ_REPLAY_DONE);
1078 req->rq_timeout *= 3;
1079 req->rq_interpret_reply = completed_replay_interpret;
1081 ptlrpcd_add_req(req);
1086 static int ptlrpc_invalidate_import_thread(void *data)
1088 struct obd_import *imp = data;
1092 ptlrpc_daemonize("ll_imp_inval");
1094 CDEBUG(D_HA, "thread invalidate import %s to %s@%s\n",
1095 imp->imp_obd->obd_name, obd2cli_tgt(imp->imp_obd),
1096 imp->imp_connection->c_remote_uuid.uuid);
1098 ptlrpc_invalidate_import(imp);
1100 if (obd_dump_on_eviction) {
1101 CERROR("dump the log upon eviction\n");
1102 libcfs_debug_dumplog();
1105 IMPORT_SET_STATE(imp, LUSTRE_IMP_RECOVER);
1106 ptlrpc_import_recovery_state_machine(imp);
1112 int ptlrpc_import_recovery_state_machine(struct obd_import *imp)
1120 if (imp->imp_state == LUSTRE_IMP_EVICTED) {
1121 deuuidify(obd2cli_tgt(imp->imp_obd), NULL,
1122 &target_start, &target_len);
1123 /* Don't care about MGC eviction */
1124 if (strcmp(imp->imp_obd->obd_type->typ_name,
1125 LUSTRE_MGC_NAME) != 0) {
1126 LCONSOLE_ERROR_MSG(0x167, "This client was evicted by "
1127 "%.*s; in progress operations using "
1128 "this service will fail.\n",
1129 target_len, target_start);
1131 CDEBUG(D_HA, "evicted from %s@%s; invalidating\n",
1132 obd2cli_tgt(imp->imp_obd),
1133 imp->imp_connection->c_remote_uuid.uuid);
1136 rc = cfs_kernel_thread(ptlrpc_invalidate_import_thread, imp,
1137 CLONE_VM | CLONE_FILES);
1139 CERROR("error starting invalidate thread: %d\n", rc);
1144 ptlrpc_invalidate_import(imp);
1146 IMPORT_SET_STATE(imp, LUSTRE_IMP_RECOVER);
1150 if (imp->imp_state == LUSTRE_IMP_REPLAY) {
1151 CDEBUG(D_HA, "replay requested by %s\n",
1152 obd2cli_tgt(imp->imp_obd));
1153 rc = ptlrpc_replay_next(imp, &inflight);
1154 if (inflight == 0 &&
1155 atomic_read(&imp->imp_replay_inflight) == 0) {
1156 IMPORT_SET_STATE(imp, LUSTRE_IMP_REPLAY_LOCKS);
1157 rc = ldlm_replay_locks(imp);
1164 if (imp->imp_state == LUSTRE_IMP_REPLAY_LOCKS) {
1165 if (atomic_read(&imp->imp_replay_inflight) == 0) {
1166 IMPORT_SET_STATE(imp, LUSTRE_IMP_REPLAY_WAIT);
1167 rc = signal_completed_replay(imp);
1174 if (imp->imp_state == LUSTRE_IMP_REPLAY_WAIT) {
1175 if (atomic_read(&imp->imp_replay_inflight) == 0) {
1176 IMPORT_SET_STATE(imp, LUSTRE_IMP_RECOVER);
1180 if (imp->imp_state == LUSTRE_IMP_RECOVER) {
1181 CDEBUG(D_HA, "reconnected to %s@%s\n",
1182 obd2cli_tgt(imp->imp_obd),
1183 imp->imp_connection->c_remote_uuid.uuid);
1185 rc = ptlrpc_resend(imp);
1188 IMPORT_SET_STATE(imp, LUSTRE_IMP_FULL);
1189 ptlrpc_activate_import(imp);
1191 deuuidify(obd2cli_tgt(imp->imp_obd), NULL,
1192 &target_start, &target_len);
1193 LCONSOLE_INFO("%s: Connection restored to service %.*s "
1194 "using nid %s.\n", imp->imp_obd->obd_name,
1195 target_len, target_start,
1196 libcfs_nid2str(imp->imp_connection->c_peer.nid));
1199 if (imp->imp_state == LUSTRE_IMP_FULL) {
1200 cfs_waitq_signal(&imp->imp_recovery_waitq);
1201 ptlrpc_wake_delayed(imp);
1208 static int back_to_sleep(void *unused)
1213 int ptlrpc_disconnect_import(struct obd_import *imp, int noclose)
1215 struct ptlrpc_request *req;
1217 int nowait = imp->imp_obd->obd_force;
1221 GOTO(set_state, rc);
1223 switch (imp->imp_connect_op) {
1224 case OST_CONNECT: rq_opc = OST_DISCONNECT; break;
1225 case MDS_CONNECT: rq_opc = MDS_DISCONNECT; break;
1226 case MGS_CONNECT: rq_opc = MGS_DISCONNECT; break;
1228 CERROR("don't know how to disconnect from %s (connect_op %d)\n",
1229 obd2cli_tgt(imp->imp_obd), imp->imp_connect_op);
1233 if (ptlrpc_import_in_recovery(imp)) {
1234 struct l_wait_info lwi;
1235 cfs_duration_t timeout;
1239 if (imp->imp_server_timeout)
1240 timeout = cfs_time_seconds(obd_timeout / 2);
1242 timeout = cfs_time_seconds(obd_timeout);
1244 int idx = import_at_get_index(imp,
1245 imp->imp_client->cli_request_portal);
1246 timeout = cfs_time_seconds(
1247 at_get(&imp->imp_at.iat_service_estimate[idx]));
1250 lwi = LWI_TIMEOUT_INTR(cfs_timeout_cap(timeout),
1251 back_to_sleep, LWI_ON_SIGNAL_NOOP, NULL);
1252 rc = l_wait_event(imp->imp_recovery_waitq,
1253 !ptlrpc_import_in_recovery(imp), &lwi);
1257 spin_lock(&imp->imp_lock);
1258 if (imp->imp_state != LUSTRE_IMP_FULL)
1261 spin_unlock(&imp->imp_lock);
1263 req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_DISCONNECT,
1264 LUSTRE_OBD_VERSION, rq_opc);
1266 /* We are disconnecting, do not retry a failed DISCONNECT rpc if
1267 * it fails. We can get through the above with a down server
1268 * if the client doesn't know the server is gone yet. */
1269 req->rq_no_resend = 1;
1272 /* We want client umounts to happen quickly, no matter the
1274 req->rq_timeout = min_t(int, req->rq_timeout,
1275 INITIAL_CONNECT_TIMEOUT);
1277 /* ... but we always want liblustre clients to nicely
1278 disconnect, so only use the adaptive value. */
1280 req->rq_timeout = obd_timeout / 3;
1283 IMPORT_SET_STATE(imp, LUSTRE_IMP_CONNECTING);
1284 req->rq_send_state = LUSTRE_IMP_CONNECTING;
1285 ptlrpc_request_set_replen(req);
1286 rc = ptlrpc_queue_wait(req);
1287 ptlrpc_req_finished(req);
1291 spin_lock(&imp->imp_lock);
1294 IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_DISCON);
1296 IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_CLOSED);
1297 memset(&imp->imp_remote_handle, 0, sizeof(imp->imp_remote_handle));
1298 imp->imp_conn_cnt = 0;
1299 /* Try all connections in the future - bz 12758 */
1300 imp->imp_last_recon = 0;
1301 spin_unlock(&imp->imp_lock);
1307 /* Adaptive Timeout utils */
1308 extern unsigned int at_min, at_max, at_history;
1310 /* Bin into timeslices using AT_BINS bins.
1311 This gives us a max of the last binlimit*AT_BINS secs without the storage,
1312 but still smoothing out a return to normalcy from a slow response.
1313 (E.g. remember the maximum latency in each minute of the last 4 minutes.) */
1314 int at_add(struct adaptive_timeout *at, unsigned int val)
1316 unsigned int old = at->at_current;
1317 time_t now = cfs_time_current_sec();
1318 time_t binlimit = max_t(time_t, at_history / AT_BINS, 1);
1322 CDEBUG(D_INFO, "add %u to %p time=%lu v=%u (%u %u %u %u)\n",
1323 val, at, now - at->at_binstart, at->at_current,
1324 at->at_hist[0], at->at_hist[1], at->at_hist[2], at->at_hist[3]);
1327 /* 0's don't count, because we never want our timeout to
1328 drop to 0, and because 0 could mean an error */
1331 spin_lock(&at->at_lock);
1333 if (unlikely(at->at_binstart == 0)) {
1334 /* Special case to remove default from history */
1335 at->at_current = val;
1336 at->at_worst_ever = val;
1337 at->at_worst_time = now;
1338 at->at_hist[0] = val;
1339 at->at_binstart = now;
1340 } else if (now - at->at_binstart < binlimit ) {
1342 at->at_hist[0] = max(val, at->at_hist[0]);
1343 at->at_current = max(val, at->at_current);
1346 unsigned int maxv = val;
1347 /* move bins over */
1348 shift = (now - at->at_binstart) / binlimit;
1350 for(i = AT_BINS - 1; i >= 0; i--) {
1352 at->at_hist[i] = at->at_hist[i - shift];
1353 maxv = max(maxv, at->at_hist[i]);
1358 at->at_hist[0] = val;
1359 at->at_current = maxv;
1360 at->at_binstart += shift * binlimit;
1363 if (at->at_current > at->at_worst_ever) {
1364 at->at_worst_ever = at->at_current;
1365 at->at_worst_time = now;
1368 if (at->at_flags & AT_FLG_NOHIST)
1369 /* Only keep last reported val; keeping the rest of the history
1371 at->at_current = val;
1374 at->at_current = min(at->at_current, at_max);
1375 at->at_current = max(at->at_current, at_min);
1378 if (at->at_current != old)
1379 CDEBUG(D_ADAPTTO, "AT %p change: old=%u new=%u delta=%d "
1380 "(val=%u) hist %u %u %u %u\n", at,
1381 old, at->at_current, at->at_current - old, val,
1382 at->at_hist[0], at->at_hist[1], at->at_hist[2],
1386 /* if we changed, report the old value */
1387 old = (at->at_current != old) ? old : 0;
1389 spin_unlock(&at->at_lock);
1393 /* Find the imp_at index for a given portal; assign if space available */
1394 int import_at_get_index(struct obd_import *imp, int portal)
1396 struct imp_at *at = &imp->imp_at;
1399 for (i = 0; i < IMP_AT_MAX_PORTALS; i++) {
1400 if (at->iat_portal[i] == portal)
1402 if (at->iat_portal[i] == 0)
1407 /* Not found in list, add it under a lock */
1408 spin_lock(&imp->imp_lock);
1410 /* Check unused under lock */
1411 for (; i < IMP_AT_MAX_PORTALS; i++) {
1412 if (at->iat_portal[i] == portal)
1414 if (at->iat_portal[i] == 0)
1419 /* Not enough portals? */
1420 LASSERT(i < IMP_AT_MAX_PORTALS);
1422 at->iat_portal[i] = portal;
1424 spin_unlock(&imp->imp_lock);