From dedeb3b712ee1beb911e8354851d3ecdbffbab2b Mon Sep 17 00:00:00 2001 From: shaver Date: Tue, 1 Oct 2002 21:53:52 +0000 Subject: [PATCH] Add support for FAILCONN ioctl, for recovery testing and (possibly) adminstrative use. --- lustre/include/linux/lustre_lib.h | 2 ++ lustre/ptlrpc/rpc.c | 36 +++++++++++++++++++++++++++++++----- lustre/utils/lctl.c | 1 + lustre/utils/obd.c | 25 +++++++++++++++++++++++++ lustre/utils/obdctl.h | 1 + 5 files changed, 60 insertions(+), 5 deletions(-) diff --git a/lustre/include/linux/lustre_lib.h b/lustre/include/linux/lustre_lib.h index 0aaf056..e1dc9d7 100644 --- a/lustre/include/linux/lustre_lib.h +++ b/lustre/include/linux/lustre_lib.h @@ -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 diff --git a/lustre/ptlrpc/rpc.c b/lustre/ptlrpc/rpc.c index 6ef7283..ceefc33 100644 --- a/lustre/ptlrpc/rpc.c +++ b/lustre/ptlrpc/rpc.c @@ -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); diff --git a/lustre/utils/lctl.c b/lustre/utils/lctl.c index cc41440..767c286 100644 --- a/lustre/utils/lctl.c +++ b/lustre/utils/lctl.c @@ -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 [newuuid]"}, + {"failconn", jt_obd_failconn, 0, "failconn "}, /* Debug commands */ {"======== debug =========", jt_noop, 0, "debug"}, diff --git a/lustre/utils/obd.c b/lustre/utils/obd.c index 7e280c1..eaa2ce4 100644 --- a/lustre/utils/obd.c +++ b/lustre/utils/obd.c @@ -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) { diff --git a/lustre/utils/obdctl.h b/lustre/utils/obdctl.h index eb907b9..d1b5f20 100644 --- a/lustre/utils/obdctl.h +++ b/lustre/utils/obdctl.h @@ -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 -- 1.8.3.1