Whamcloud - gitweb
Add support for FAILCONN ioctl, for recovery testing and (possibly) adminstrative
authorshaver <shaver>
Tue, 1 Oct 2002 21:53:52 +0000 (21:53 +0000)
committershaver <shaver>
Tue, 1 Oct 2002 21:53:52 +0000 (21:53 +0000)
use.

lustre/include/linux/lustre_lib.h
lustre/ptlrpc/rpc.c
lustre/utils/lctl.c
lustre/utils/obd.c
lustre/utils/obdctl.h

index 0aaf056..e1dc9d7 100644 (file)
@@ -436,6 +436,8 @@ static inline int obd_ioctl_getdata(char **buf, int *len, void *arg)
 #define OBD_IOC_OPEN                   _IOWR('f', 134, long)
 #define OBD_IOC_CLOSE                  _IOWR('f', 135, long)
 
+#define OBD_IOC_RECOVD_FAILCONN        _IOWR('f', 136, long)
+
 /*
  * l_wait_event is a flexible sleeping function, permitting simple caller
  * configuration of interrupt and timeout sensitivity along with actions to
index 6ef7283..ceefc33 100644 (file)
@@ -76,10 +76,10 @@ int connmgr_iocontrol(long cmd, struct lustre_handle *hdl, int len, void *karg,
 
         ENTRY;
 
-        if (cmd != OBD_IOC_RECOVD_NEWCONN)
-                RETURN(0);
+        if (cmd != OBD_IOC_RECOVD_NEWCONN && cmd != OBD_IOC_RECOVD_FAILCONN)
+                RETURN(-EINVAL); /* XXX ENOSYS? */
         
-        /* Find the connection that's been rebuilt. */
+        /* Find the connection that's been rebuilt or has failed. */
         spin_lock(&recovd->recovd_lock);
         list_for_each(tmp, &recovd->recovd_troubled_items) {
                 conn = list_entry(tmp, struct ptlrpc_connection,
@@ -92,9 +92,35 @@ int connmgr_iocontrol(long cmd, struct lustre_handle *hdl, int len, void *karg,
                 conn = NULL;
         }
 
-        if (!conn)
-                GOTO(out, rc = -EINVAL);
+        if (!conn) {
+                if (cmd == OBD_IOC_RECOVD_NEWCONN)
+                        GOTO(out, rc = -EINVAL);
+                /* XXX macroize/inline and share with loop above */
+                list_for_each(tmp, &recovd->recovd_managed_items) {
+                        conn = list_entry(tmp, struct ptlrpc_connection,
+                                          c_recovd_data.rd_managed_chain);
+                        
+                        LASSERT(conn->c_recovd_data.rd_recovd == recovd);
+                        
+                        if (!strcmp(conn->c_remote_uuid, data->ioc_inlbuf1))
+                                break;
+                        conn = NULL;
+                }
+                if (!conn)
+                        GOTO(out, rc = -EINVAL);
+        }
+
+        if (cmd == OBD_IOC_RECOVD_FAILCONN) {
+                spin_unlock(&recovd->recovd_lock);
+                recovd_conn_fail(conn);
+                spin_lock(&recovd->recovd_lock);
+
+                /* Jump straight to the "failed" phase of recovery. */
+                conn->c_recovd_data.rd_phase = RD_FAILED;
+                goto out;
+        }
 
+        /* else (NEWCONN) */
         if (conn->c_recovd_data.rd_phase != RD_PREPARING)
                 GOTO(out, rc = -EALREADY);
 
index cc41440..767c286 100644 (file)
@@ -169,6 +169,7 @@ command_t cmdlist[] = {
         {"dump_ldlm", jt_obd_dump_ldlm, 0,
          "dump all lock manager state (no args)"},
         {"newconn", jt_obd_newconn, 0, "newconn <olduuid> [newuuid]"},
+        {"failconn", jt_obd_failconn, 0, "failconn <uuid>"},
 
         /* Debug commands */
         {"======== debug =========", jt_noop, 0, "debug"},
index 7e280c1..eaa2ce4 100644 (file)
@@ -1357,6 +1357,31 @@ int jt_obd_newconn(int argc, char **argv)
         return rc;
 }
 
+int jt_obd_failconn(int argc, char **argv)
+{
+        int rc;
+        struct obd_ioctl_data data;
+
+        IOCINIT(data);
+        if (argc < 2)
+                return CMD_HELP;
+
+        data.ioc_inllen1 = strlen(argv[1]) + 1;
+        data.ioc_inlbuf1 = argv[1];
+
+        if (obd_ioctl_pack(&data, &buf, max)) {
+                fprintf(stderr, "error: %s: invalid ioctl\n", cmdname(argv[0]));
+                return -2;
+        }
+
+        rc = ioctl(fd, OBD_IOC_RECOVD_FAILCONN, buf);
+        if (rc < 0)
+                fprintf(stderr, "error: %s: %s\n", cmdname(argv[0]),
+                        strerror(rc = errno));
+        
+        return rc;
+}
+
 static void signal_server(int sig)
 {
         if (sig == SIGINT) {
index eb907b9..d1b5f20 100644 (file)
@@ -55,5 +55,6 @@ int jt_obd_ldlm_regress_start(int argc, char **argv);
 int jt_obd_ldlm_regress_stop(int argc, char **argv);
 int jt_obd_dump_ldlm(int argc, char **argv);
 int jt_obd_newconn(int argc, char **argv);
+int jt_obd_failconn(int argc, char **argv);
 
 #endif