Whamcloud - gitweb
b=13147
[fs/lustre-release.git] / lustre / mgc / mgc_request.c
index e251dde..5de0f95 100644 (file)
@@ -730,6 +730,33 @@ static int mgc_target_register(struct obd_export *exp,
         RETURN(rc);
 }
 
+int mgc_reconnect_import(struct obd_import *imp)
+{
+        /* Force a new connect attempt */
+        ptlrpc_invalidate_import(imp);
+        /* Do a fresh connect next time by zeroing the handle */
+        ptlrpc_disconnect_import(imp, 1);
+        /* Wait for all invalidate calls to finish */
+        if (atomic_read(&imp->imp_inval_count) > 0) {
+                int rc;
+                struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL);
+                rc = l_wait_event(imp->imp_recovery_waitq,
+                                  (atomic_read(&imp->imp_inval_count) == 0),
+                                  &lwi);
+                if (rc)
+                        CERROR("Interrupted, inval=%d\n",
+                               atomic_read(&imp->imp_inval_count));
+        }
+
+        /* Allow reconnect attempts */
+        imp->imp_obd->obd_no_recov = 0;
+        /* Remove 'invalid' flag */
+        ptlrpc_activate_import(imp);
+        /* Attempt a new connect */
+        ptlrpc_recover_import(imp, NULL);
+        return 0;
+}
+
 int mgc_set_info_async(struct obd_export *exp, obd_count keylen,
                        void *key, obd_count vallen, void *val,
                        struct ptlrpc_request_set *set)
@@ -767,20 +794,8 @@ int mgc_set_info_async(struct obd_export *exp, obd_count keylen,
                        imp->imp_replayable, imp->imp_obd->obd_replayable,
                        ptlrpc_import_state_name(imp->imp_state));
                 /* Resurrect if we previously died */
-                if (imp->imp_invalid || value > 1) {
-                        /* Force a new connect attempt */
-                        /* (can't put these in obdclass, module loop) */
-                        ptlrpc_invalidate_import(imp);
-                        /* Do a fresh connect next time by zeroing the handle */
-                        ptlrpc_disconnect_import(imp, 1);
-                        /* See client_disconnect_export */
-                        /* Allow reconnect attempts */
-                        imp->imp_obd->obd_no_recov = 0;
-                        /* Remove 'invalid' flag */
-                        ptlrpc_activate_import(imp);
-                        /* Attempt a new connect */
-                        ptlrpc_recover_import(imp, NULL);
-                }
+                if (imp->imp_invalid || value > 1)
+                        mgc_reconnect_import(imp);
                 RETURN(0);
         }
         /* FIXME move this to mgc_process_config */