]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
fabrics: add fast_io_fail_tmo option
authorSagi Grimberg <sagi@grimberg.me>
Mon, 17 May 2021 18:26:16 +0000 (11:26 -0700)
committerKeith Busch <kbusch@kernel.org>
Wed, 26 May 2021 16:46:57 +0000 (09:46 -0700)
Option to fail fast I/O when connecting to a controller. It is useful
to set a fast-fail timeout for nvme in case upper layer SW wants to
detect unresponsive controllers early (e.g. mdraid).

Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Keith Busch <kbusch@kernel.org>
fabrics.c
fabrics.h

index 242b03e4dc77c88d44de1a2424488e22c15af5ff..77eb8f4efc9b5fab6222a6806ea9fb5826ca4fc4 100644 (file)
--- a/fabrics.c
+++ b/fabrics.c
@@ -69,6 +69,7 @@ const char *conarg_host_traddr = "host_traddr";
 
 struct fabrics_config fabrics_cfg = {
        .ctrl_loss_tmo = -1,
+       .fast_io_fail_tmo = -1,
        .output_format = "normal",
 };
 
@@ -1004,6 +1005,8 @@ int build_options(char *argstr, int max_len, bool discover)
            (strncmp(fabrics_cfg.transport, "loop", 4) &&
             add_int_argument(&argstr, &max_len, "ctrl_loss_tmo",
                              fabrics_cfg.ctrl_loss_tmo, true)) ||
+           add_int_argument(&argstr, &max_len, "fast_io_fail_tmo",
+                               fabrics_cfg.fast_io_fail_tmo, true) ||
            add_int_argument(&argstr, &max_len, "tos",
                                fabrics_cfg.tos, true) ||
            add_bool_argument(&argstr, &max_len, "duplicate_connect",
@@ -1185,6 +1188,13 @@ retry:
                p += len;
        }
 
+       if (fabrics_cfg.fast_io_fail_tmo) {
+               len = sprintf(p, ",fast_io_fail_tmo=%d", fabrics_cfg.fast_io_fail_tmo);
+               if (len < 0)
+                       return -EINVAL;
+               p += len;
+       }
+
        if (fabrics_cfg.tos != -1) {
                len = sprintf(p, ",tos=%d", fabrics_cfg.tos);
                if (len < 0)
@@ -1567,6 +1577,7 @@ int fabrics_discover(const char *desc, int argc, char **argv, bool connect)
                OPT_INT("keep-alive-tmo",  'k', &fabrics_cfg.keep_alive_tmo,  "keep alive timeout period in seconds"),
                OPT_INT("reconnect-delay", 'c', &fabrics_cfg.reconnect_delay, "reconnect timeout period in seconds"),
                OPT_INT("ctrl-loss-tmo",   'l', &fabrics_cfg.ctrl_loss_tmo,   "controller loss timeout period in seconds"),
+               OPT_INT("fast_io_fail_tmo",'f',&fabrics_cfg.fast_io_fail_tmo, "fast I/O fail timeout (default off)"),
                OPT_INT("tos",             'T', &fabrics_cfg.tos,             "type of service"),
                OPT_FLAG("hdr_digest",     'g', &fabrics_cfg.hdr_digest,      "enable transport protocol header digest (TCP transport)"),
                OPT_FLAG("data_digest",    'G', &fabrics_cfg.data_digest,     "enable transport protocol data digest (TCP transport)"),
@@ -1650,6 +1661,7 @@ int fabrics_connect(const char *desc, int argc, char **argv)
                OPT_INT("keep-alive-tmo",     'k', &fabrics_cfg.keep_alive_tmo,    "keep alive timeout period in seconds"),
                OPT_INT("reconnect-delay",    'c', &fabrics_cfg.reconnect_delay,   "reconnect timeout period in seconds"),
                OPT_INT("ctrl-loss-tmo",      'l', &fabrics_cfg.ctrl_loss_tmo,     "controller loss timeout period in seconds"),
+               OPT_INT("fast_io_fail_tmo",   'f', &fabrics_cfg.fast_io_fail_tmo,  "fast I/O fail timeout (default off)"),
                OPT_INT("tos",                'T', &fabrics_cfg.tos,               "type of service"),
                OPT_FLAG("duplicate-connect", 'D', &fabrics_cfg.duplicate_connect, "allow duplicate connections between same transport host and subsystem port"),
                OPT_FLAG("disable-sqflow",    'd', &fabrics_cfg.disable_sqflow,    "disable controller sq flow control (default false)"),
index 41e6a2d07b1fb510cd8d4985472fd37f056c9530..b98f6b0d09044cad89d716ab5e582bc9b492dfe9 100644 (file)
--- a/fabrics.h
+++ b/fabrics.h
@@ -29,6 +29,7 @@ struct fabrics_config {
        int  keep_alive_tmo;
        int  reconnect_delay;
        int  ctrl_loss_tmo;
+       int  fast_io_fail_tmo;
        int  tos;
        const char *raw;
        char *device;