Whamcloud - gitweb
- mds->lmv->mdc propagate lower timeout down to import
[fs/lustre-release.git] / lustre / ptlrpc / import.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (c) 2002, 2003 Cluster File Systems, Inc.
5  *   Author: Mike Shaver <shaver@clusterfs.com>
6  *
7  *   This file is part of Lustre, http://www.lustre.org.
8  *
9  *   Lustre is free software; you can redistribute it and/or
10  *   modify it under the terms of version 2 of the GNU General Public
11  *   License as published by the Free Software Foundation.
12  *
13  *   Lustre is distributed in the hope that it will be useful,
14  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *   GNU General Public License for more details.
17  *
18  *   You should have received a copy of the GNU General Public License
19  *   along with Lustre; if not, write to the Free Software
20  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */
22
23 #define DEBUG_SUBSYSTEM S_RPC
24 #ifdef __KERNEL__
25 # include <linux/config.h>
26 # include <linux/module.h>
27 # include <linux/kmod.h>
28 #else
29 # include <liblustre.h>
30 #endif
31
32 #include <linux/obd_support.h>
33 #include <linux/lustre_ha.h>
34 #include <linux/lustre_net.h>
35 #include <linux/lustre_import.h>
36 #include <linux/lustre_export.h>
37 #include <linux/obd.h>
38 #include <linux/obd_class.h>
39
40 #include "ptlrpc_internal.h"
41
42 struct ptlrpc_connect_async_args {
43          __u64 pcaa_peer_committed;
44         int pcaa_initial_connect;
45 };
46
47 /* A CLOSED import should remain so. */
48 #define IMPORT_SET_STATE_NOLOCK(imp, state)                                    \
49 do {                                                                           \
50         if (imp->imp_state != LUSTRE_IMP_CLOSED) {                             \
51                CDEBUG(D_HA, "%p %s: changing import state from %s to %s\n",    \
52                       imp, imp->imp_target_uuid.uuid,                          \
53                       ptlrpc_import_state_name(imp->imp_state),                \
54                       ptlrpc_import_state_name(state));                        \
55                imp->imp_state = state;                                         \
56         }                                                                      \
57 } while(0)
58
59 #define IMPORT_SET_STATE(imp, state)                    \
60 do {                                                    \
61         unsigned long flags;                            \
62                                                         \
63         spin_lock_irqsave(&imp->imp_lock, flags);       \
64         IMPORT_SET_STATE_NOLOCK(imp, state);            \
65         spin_unlock_irqrestore(&imp->imp_lock, flags);  \
66 } while(0)
67
68
69 static int ptlrpc_connect_interpret(struct ptlrpc_request *request,
70                                     void * data, int rc);
71 int ptlrpc_import_recovery_state_machine(struct obd_import *imp);
72
73 /* Only this function is allowed to change the import state when it is
74  * CLOSED. I would rather refcount the import and free it after
75  * disconnection like we do with exports. To do that, the client_obd
76  * will need to save the peer info somewhere other than in the import,
77  * though. */
78 int ptlrpc_init_import(struct obd_import *imp)
79 {
80         unsigned long flags;
81         
82         spin_lock_irqsave(&imp->imp_lock, flags);
83
84         imp->imp_generation++;
85         imp->imp_state =  LUSTRE_IMP_NEW;
86
87         spin_unlock_irqrestore(&imp->imp_lock, flags);
88
89         return 0;
90 }
91
92 /* Returns true if import was FULL, false if import was already not
93  * connected.
94  */
95 int ptlrpc_set_import_discon(struct obd_import *imp)
96 {
97         unsigned long flags;
98         int rc = 0;
99         
100         spin_lock_irqsave(&imp->imp_lock, flags);
101
102         if (imp->imp_state == LUSTRE_IMP_FULL) {
103                 IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_DISCON);
104                 spin_unlock_irqrestore(&imp->imp_lock, flags); 
105                 obd_import_event(imp->imp_obd, imp, IMP_EVENT_DISCON);
106                 rc = 1;
107         } else {
108                 spin_unlock_irqrestore(&imp->imp_lock, flags);
109                 CDEBUG(D_HA, "%p %s: import already not connected: %s\n",
110                        imp,imp->imp_client->cli_name, 
111                        ptlrpc_import_state_name(imp->imp_state));
112         }
113
114         return rc;
115 }
116
117 /*
118  * This acts as a barrier; all existing requests are rejected, and
119  * no new requests will be accepted until the import is valid again.
120  */
121 void ptlrpc_deactivate_import(struct obd_import *imp)
122 {
123         unsigned long flags;
124         ENTRY;
125
126         spin_lock_irqsave(&imp->imp_lock, flags);
127         CDEBUG(D_HA, "setting import %s INVALID\n",
128                imp->imp_target_uuid.uuid);
129         imp->imp_invalid = 1;
130         imp->imp_generation++;
131         spin_unlock_irqrestore(&imp->imp_lock, flags);
132
133         ptlrpc_abort_inflight(imp);
134         obd_import_event(imp->imp_obd, imp, IMP_EVENT_INACTIVE);
135 }
136
137 /*
138  * This function will invalidate the import, if necessary, then block
139  * for all the RPC completions, and finally notify the obd to
140  * invalidate its state (ie cancel locks, clear pending requests,
141  * etc).
142  *
143  * in_rpc: true if this is called while processing an rpc, like
144  *    CONNECT. It will allow for one RPC to be inflight while
145  *    waiting for requests to complete. Ugly, yes, but I don't see an
146  *    cleaner way right now.
147  */
148 void ptlrpc_invalidate_import(struct obd_import *imp, int in_rpc)
149 {
150         struct l_wait_info lwi;
151         unsigned long timeout;
152         int inflight = 0;
153         int rc;
154
155         if (!imp->imp_invalid)
156                 ptlrpc_deactivate_import(imp);
157         
158         LASSERT(imp->imp_invalid);
159
160         if (in_rpc)
161                 inflight = 1;
162         /* wait for all requests to error out and call completion 
163            callbacks */
164         if (imp->imp_server_timeout)
165                 timeout = obd_timeout / 2;
166         else
167                 timeout = obd_timeout;
168         timeout = MAX(timeout * HZ, 1);
169         lwi = LWI_TIMEOUT_INTR(timeout, NULL, NULL, NULL);
170         rc = l_wait_event(imp->imp_recovery_waitq, 
171                           (atomic_read(&imp->imp_inflight) == inflight), 
172                           &lwi);
173         
174         if (rc)
175                 CERROR("%s: rc = %d waiting for callback (%d != %d)\n",
176                        imp->imp_target_uuid.uuid, rc,
177                        atomic_read(&imp->imp_inflight), inflight);
178         
179         obd_import_event(imp->imp_obd, imp, IMP_EVENT_INVALIDATE);
180 }
181
182 static void ptlrpc_activate_import(struct obd_import *imp)
183 {
184         struct obd_device *obd = imp->imp_obd;
185         unsigned long flags;
186
187         spin_lock_irqsave(&imp->imp_lock, flags);
188         imp->imp_invalid = 0;
189         spin_unlock_irqrestore(&imp->imp_lock, flags);
190
191         obd_import_event(obd, imp, IMP_EVENT_ACTIVE);
192 }
193
194 void ptlrpc_fail_import(struct obd_import *imp, int generation)
195 {
196         ENTRY;
197
198         LASSERT (!imp->imp_dlm_fake);
199
200         if (ptlrpc_set_import_discon(imp)) {
201                 unsigned long flags;
202
203                 if (!imp->imp_replayable) {
204                         CDEBUG(D_HA, "import %s@%s for %s not replayable, "
205                                "auto-deactivating\n",
206                                imp->imp_target_uuid.uuid,
207                                imp->imp_connection->c_remote_uuid.uuid,
208                                imp->imp_obd->obd_name);
209                         ptlrpc_deactivate_import(imp);
210                 }
211                 
212                 CDEBUG(D_HA, "%s: waking up pinger\n", 
213                        imp->imp_target_uuid.uuid);
214                 
215                 spin_lock_irqsave(&imp->imp_lock, flags);
216                 imp->imp_force_verify = 1;
217                 spin_unlock_irqrestore(&imp->imp_lock, flags);
218                 
219                 ptlrpc_pinger_wake_up();
220                 
221         }
222         EXIT;
223 }
224
225 int ptlrpc_connect_import(struct obd_import *imp, char * new_uuid)
226 {
227         struct obd_device *obd = imp->imp_obd;
228         int initial_connect = 0;
229         int rc;
230         __u64 committed_before_reconnect = 0;
231         struct ptlrpc_request *request;
232         int size[] = {sizeof(imp->imp_target_uuid),
233                                  sizeof(obd->obd_uuid),
234                                  sizeof(imp->imp_dlm_handle)};
235         char *tmp[] = {imp->imp_target_uuid.uuid,
236                        obd->obd_uuid.uuid,
237                        (char *)&imp->imp_dlm_handle};
238         struct ptlrpc_connect_async_args *aa;
239         unsigned long flags;
240
241         spin_lock_irqsave(&imp->imp_lock, flags);
242         if (imp->imp_state == LUSTRE_IMP_CLOSED) {
243                 spin_unlock_irqrestore(&imp->imp_lock, flags);
244                 CERROR("can't connect to a closed import\n");
245                 RETURN(-EINVAL);
246         } else if (imp->imp_state == LUSTRE_IMP_FULL) {
247                 spin_unlock_irqrestore(&imp->imp_lock, flags);
248                 CERROR("already connected\n");
249                 RETURN(0);
250         } else if (imp->imp_state == LUSTRE_IMP_CONNECTING) {
251                 spin_unlock_irqrestore(&imp->imp_lock, flags);
252                 CERROR("already connecting\n");
253                 RETURN(-EALREADY);
254         }
255
256         IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_CONNECTING);
257
258         imp->imp_conn_cnt++; 
259         imp->imp_last_replay_transno = 0;
260
261         if (imp->imp_remote_handle.cookie == 0) {
262                 initial_connect = 1;
263         } else {
264                 committed_before_reconnect = imp->imp_peer_committed_transno;;
265
266         }
267
268
269         spin_unlock_irqrestore(&imp->imp_lock, flags);
270
271         if (new_uuid) {
272                 struct ptlrpc_connection *conn;
273                 struct obd_uuid uuid;
274                 struct obd_export *dlmexp;
275
276                 obd_str2uuid(&uuid, new_uuid);
277
278                 conn = ptlrpc_uuid_to_connection(&uuid);
279                 if (!conn)
280                         GOTO(out, rc = -ENOENT);
281
282                 CDEBUG(D_HA, "switching import %s/%s from %s to %s\n",
283                        imp->imp_target_uuid.uuid, imp->imp_obd->obd_name,
284                        imp->imp_connection->c_remote_uuid.uuid,
285                        conn->c_remote_uuid.uuid);
286
287                 /* Switch the import's connection and the DLM export's
288                  * connection (which are almost certainly the same, but we
289                  * keep distinct refs just to make things clearer. I think. */
290                 if (imp->imp_connection)
291                         ptlrpc_put_connection(imp->imp_connection);
292                 /* We hand off the ref from ptlrpc_get_connection. */
293                 imp->imp_connection = conn;
294
295                 dlmexp = class_conn2export(&imp->imp_dlm_handle);
296                 
297                 LASSERT(dlmexp != NULL);
298
299                 if (dlmexp->exp_connection)
300                         ptlrpc_put_connection(dlmexp->exp_connection);
301                 dlmexp->exp_connection = ptlrpc_connection_addref(conn);
302                 class_export_put(dlmexp);
303
304         }
305
306         request = ptlrpc_prep_req(imp, imp->imp_connect_op, 3, size, tmp);
307         if (!request)
308                 GOTO(out, rc = -ENOMEM);
309
310 #ifndef __KERNEL__
311         lustre_msg_add_op_flags(request->rq_reqmsg, MSG_CONNECT_LIBCLIENT);
312 #endif
313
314         request->rq_send_state = LUSTRE_IMP_CONNECTING;
315         request->rq_replen = lustre_msg_size(0, NULL);
316         request->rq_interpret_reply = ptlrpc_connect_interpret;
317
318         LASSERT (sizeof (*aa) <= sizeof (request->rq_async_args));
319         aa = (struct ptlrpc_connect_async_args *)&request->rq_async_args;
320         memset(aa, 0, sizeof *aa);
321
322         aa->pcaa_peer_committed = committed_before_reconnect;
323         aa->pcaa_initial_connect = initial_connect;
324
325         if (aa->pcaa_initial_connect)
326                 imp->imp_replayable = 1;
327
328         ptlrpcd_add_req(request);
329         rc = 0;
330 out:
331         if (rc != 0) {
332                 IMPORT_SET_STATE(imp, LUSTRE_IMP_DISCON);
333         }
334
335         RETURN(rc);
336 }
337
338 static int ptlrpc_connect_interpret(struct ptlrpc_request *request,
339                                     void * data, int rc)
340 {
341         struct ptlrpc_connect_async_args *aa = data;
342         struct obd_import *imp = request->rq_import;
343         struct lustre_handle old_hdl;
344         unsigned long flags;
345         int msg_flags;
346         ENTRY;
347         
348         spin_lock_irqsave(&imp->imp_lock, flags);
349         if (imp->imp_state == LUSTRE_IMP_CLOSED) {
350                 spin_unlock_irqrestore(&imp->imp_lock, flags);
351                 RETURN(0);
352         }
353         spin_unlock_irqrestore(&imp->imp_lock, flags);
354
355         if (rc)
356                 GOTO(out, rc);
357
358         msg_flags = lustre_msg_get_op_flags(request->rq_repmsg);
359
360         if (aa->pcaa_initial_connect) {
361                 if (msg_flags & MSG_CONNECT_REPLAYABLE) {
362                         CDEBUG(D_HA, "connected to replayable target: %s\n",
363                                imp->imp_target_uuid.uuid);
364                         imp->imp_pingable = imp->imp_replayable = 1;
365                 } else {
366                         imp->imp_replayable = 0;
367                 }
368                 imp->imp_remote_handle = request->rq_repmsg->handle;
369                 IMPORT_SET_STATE(imp, LUSTRE_IMP_FULL);
370                 GOTO(finish, rc = 0);
371         }
372
373         /* Determine what recovery state to move the import to. */
374         if (MSG_CONNECT_RECONNECT & msg_flags) {
375                 memset(&old_hdl, 0, sizeof(old_hdl));
376                 if (!memcmp(&old_hdl, &request->rq_repmsg->handle,
377                             sizeof (old_hdl))) {
378                         CERROR("%s@%s didn't like our handle "LPX64
379                                ", failed\n", imp->imp_target_uuid.uuid,
380                                imp->imp_connection->c_remote_uuid.uuid,
381                                imp->imp_dlm_handle.cookie);
382                         GOTO(out, rc = -ENOTCONN);
383                 }
384
385                 if (memcmp(&imp->imp_remote_handle, &request->rq_repmsg->handle,
386                            sizeof(imp->imp_remote_handle))) {
387                         CERROR("%s@%s changed handle from "LPX64" to "LPX64
388                                "; copying, but this may foreshadow disaster\n",
389                                imp->imp_target_uuid.uuid,
390                                imp->imp_connection->c_remote_uuid.uuid,
391                                imp->imp_remote_handle.cookie,
392                                request->rq_repmsg->handle.cookie);
393                         imp->imp_remote_handle = request->rq_repmsg->handle;
394                 } else {
395                         CERROR("reconnected to %s@%s after partition\n",
396                                imp->imp_target_uuid.uuid, 
397                                imp->imp_connection->c_remote_uuid.uuid);
398                 }
399
400                 if (imp->imp_invalid)
401                         IMPORT_SET_STATE(imp, LUSTRE_IMP_EVICTED);
402                 else
403                         IMPORT_SET_STATE(imp, LUSTRE_IMP_RECOVER);
404         } 
405         else if ((MSG_CONNECT_RECOVERING & msg_flags) && !imp->imp_invalid) {
406                 LASSERT(imp->imp_replayable);
407                 imp->imp_remote_handle = request->rq_repmsg->handle;
408                 IMPORT_SET_STATE(imp, LUSTRE_IMP_REPLAY);
409         } 
410         else {
411                 imp->imp_remote_handle = request->rq_repmsg->handle;
412                 IMPORT_SET_STATE(imp, LUSTRE_IMP_EVICTED);
413         }
414         
415         /* Sanity checks for a reconnected import. */
416         if (!(imp->imp_replayable) != 
417              !(msg_flags & MSG_CONNECT_REPLAYABLE)) {
418                 CERROR("imp_replayable flag does not match server "
419                        "after reconnect. We should LBUG right here.\n");
420         }
421
422         if (request->rq_repmsg->last_committed < aa->pcaa_peer_committed) {
423                 CERROR("%s went back in time (transno "LPD64
424                        " was previously committed, server now claims "LPD64
425                        ")! is shared storage not coherent?\n",
426                        imp->imp_target_uuid.uuid,
427                        aa->pcaa_peer_committed,
428                        request->rq_repmsg->last_committed);
429         }
430
431 finish:
432         rc = ptlrpc_import_recovery_state_machine(imp);
433         if (rc != 0) {
434                 if (rc == -ENOTCONN) {
435                         CDEBUG(D_HA, "evicted/aborted by %s@%s during recovery;"
436                                "invalidating and reconnecting\n",
437                                imp->imp_target_uuid.uuid,
438                                imp->imp_connection->c_remote_uuid.uuid);
439                         ptlrpc_connect_import(imp, NULL);
440                         RETURN(0);
441                 } 
442         }
443  out:
444         if (rc != 0) {
445                 IMPORT_SET_STATE(imp, LUSTRE_IMP_DISCON);
446                 if (aa->pcaa_initial_connect && !imp->imp_initial_recov) {
447                         ptlrpc_deactivate_import(imp);
448                 }
449                 /*if (rc == -ETIMEDOUT) {
450                         CDEBUG(D_ERROR, "recovery of %s on %s failed (timeout)\n",
451                                imp->imp_target_uuid.uuid,
452                                (char *)imp->imp_connection->c_remote_uuid.uuid);
453                         ptlrpc_connect_import(imp, NULL);
454                         RETURN(0);
455                 }*/
456                 CDEBUG(D_ERROR, "recovery of %s on %s failed (%d)\n",
457                        imp->imp_target_uuid.uuid,
458                        (char *)imp->imp_connection->c_remote_uuid.uuid, rc);
459         }
460
461         wake_up(&imp->imp_recovery_waitq);
462         RETURN(rc);
463 }
464
465 static int completed_replay_interpret(struct ptlrpc_request *req,
466                                     void * data, int rc)
467 {
468         atomic_dec(&req->rq_import->imp_replay_inflight);
469         ptlrpc_import_recovery_state_machine(req->rq_import);
470         RETURN(0);
471 }
472
473 static int signal_completed_replay(struct obd_import *imp)
474  {
475         struct ptlrpc_request *req;
476         ENTRY;
477
478         LASSERT(atomic_read(&imp->imp_replay_inflight) == 0);
479         atomic_inc(&imp->imp_replay_inflight);
480
481         req = ptlrpc_prep_req(imp, OBD_PING, 0, NULL, NULL);
482         if (!req)
483                 RETURN(-ENOMEM);
484
485         req->rq_replen = lustre_msg_size(0, NULL);
486         req->rq_send_state = LUSTRE_IMP_REPLAY_WAIT;
487         req->rq_reqmsg->flags |= MSG_LAST_REPLAY;
488         req->rq_timeout *= 3; 
489         req->rq_interpret_reply = completed_replay_interpret;
490
491         ptlrpcd_add_req(req);
492         RETURN(0);
493 }
494
495 int ptlrpc_import_recovery_state_machine(struct obd_import *imp)
496 {
497         int rc = 0;
498         int inflight;
499
500         if (imp->imp_state == LUSTRE_IMP_EVICTED) {
501                 CDEBUG(D_HA, "evicted from %s@%s; invalidating\n",
502                        imp->imp_target_uuid.uuid,
503                        imp->imp_connection->c_remote_uuid.uuid);
504
505                 ptlrpc_invalidate_import(imp, 1);
506
507                 IMPORT_SET_STATE(imp, LUSTRE_IMP_RECOVER);
508         } 
509         
510         if (imp->imp_state == LUSTRE_IMP_REPLAY) {
511                 CDEBUG(D_HA, "replay requested by %s\n",
512                        imp->imp_target_uuid.uuid);
513                 rc = ptlrpc_replay_next(imp, &inflight);
514                 if (inflight == 0 && 
515                     atomic_read(&imp->imp_replay_inflight) == 0) {
516                         IMPORT_SET_STATE(imp, LUSTRE_IMP_REPLAY_LOCKS);
517                         rc = ldlm_replay_locks(imp);
518                         if (rc)
519                                 GOTO(out, rc);
520                 }
521                 rc = 0;
522         }
523
524         if (imp->imp_state == LUSTRE_IMP_REPLAY_LOCKS) {
525                 if (atomic_read(&imp->imp_replay_inflight) == 0) {
526                         IMPORT_SET_STATE(imp, LUSTRE_IMP_REPLAY_WAIT);
527                         rc = signal_completed_replay(imp);
528                         if (rc)
529                                 GOTO(out, rc);
530                 }
531
532         }
533
534         if (imp->imp_state == LUSTRE_IMP_REPLAY_WAIT) {
535                 if (atomic_read(&imp->imp_replay_inflight) == 0) {
536                         IMPORT_SET_STATE(imp, LUSTRE_IMP_RECOVER);
537                 }
538         }
539
540         if (imp->imp_state == LUSTRE_IMP_RECOVER) {
541                 CDEBUG(D_HA, "reconnected to %s@%s\n",
542                        imp->imp_target_uuid.uuid,
543                        imp->imp_connection->c_remote_uuid.uuid);
544
545                 rc = ptlrpc_resend(imp);
546                 if (rc)
547                         GOTO(out, rc);
548                 IMPORT_SET_STATE(imp, LUSTRE_IMP_FULL);
549                 ptlrpc_activate_import(imp);
550         } 
551
552         if (imp->imp_state == LUSTRE_IMP_FULL) {
553                 wake_up(&imp->imp_recovery_waitq);
554                 ptlrpc_wake_delayed(imp);
555         }
556
557  out:
558         RETURN(rc);
559 }
560
561 static int back_to_sleep(void *unused) 
562 {
563         return 0;
564 }
565
566 int ptlrpc_disconnect_import(struct obd_import *imp)
567 {
568         struct ptlrpc_request *request;
569         int rq_opc;
570         int rc = 0;
571         unsigned long flags;
572         ENTRY;
573
574         switch (imp->imp_connect_op) {
575         case OST_CONNECT: rq_opc = OST_DISCONNECT; break;
576         case MDS_CONNECT: rq_opc = MDS_DISCONNECT; break;
577         case MGMT_CONNECT:rq_opc = MGMT_DISCONNECT;break;
578         default:
579                 CERROR("don't know how to disconnect from %s (connect_op %d)\n",
580                        imp->imp_target_uuid.uuid, imp->imp_connect_op);
581                 RETURN(-EINVAL);
582         }
583
584
585         if (ptlrpc_import_in_recovery(imp)) {
586                 struct l_wait_info lwi;
587                 unsigned long timeout;
588                 if (imp->imp_server_timeout)
589                         timeout = obd_timeout / 2;
590                 else
591                         timeout = obd_timeout;
592                 timeout = MAX(timeout * HZ, 1);
593                 lwi = LWI_TIMEOUT_INTR(obd_timeout, back_to_sleep, NULL, NULL);
594                 rc = l_wait_event(imp->imp_recovery_waitq, 
595                                   !ptlrpc_import_in_recovery(imp), &lwi);
596
597         }
598
599         spin_lock_irqsave(&imp->imp_lock, flags);
600         if (imp->imp_state != LUSTRE_IMP_FULL) {
601                 GOTO(out, 0);
602         }
603         spin_unlock_irqrestore(&imp->imp_lock, flags);
604
605         request = ptlrpc_prep_req(imp, rq_opc, 0, NULL, NULL);
606         if (request) {
607                 /* For non-replayable connections, don't attempt
608                    reconnect if this fails */
609                 if (!imp->imp_replayable) {
610                         request->rq_no_resend = 1;
611                         IMPORT_SET_STATE(imp, LUSTRE_IMP_CONNECTING);
612                         request->rq_send_state =  LUSTRE_IMP_CONNECTING;
613                 }
614                 request->rq_replen = lustre_msg_size(0, NULL);
615                 rc = ptlrpc_queue_wait(request);
616                 ptlrpc_req_finished(request);
617         }
618
619         spin_lock_irqsave(&imp->imp_lock, flags);
620 out:
621         IMPORT_SET_STATE_NOLOCK(imp, LUSTRE_IMP_CLOSED);
622         memset(&imp->imp_remote_handle, 0, sizeof(imp->imp_remote_handle));
623         spin_unlock_irqrestore(&imp->imp_lock, flags);
624
625         RETURN(rc);
626 }
627