]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
fabrics: correctly handle ctrl_loss_tmo settings for loop
authorHannes Reinecke <hare@suse.de>
Thu, 25 Feb 2021 15:53:00 +0000 (16:53 +0100)
committerKeith Busch <kbusch@kernel.org>
Tue, 2 Mar 2021 19:31:55 +0000 (12:31 -0700)
The previous fix had an issue with referrals, as it would take
the default values and apply them to all referral entries.
And if the default entries were for 'loop', the default ctrl_loss_tmo
setting would not be used, but rather '-1'.
So this patch reverts the previous patch and correctly blanks
out the ctrl_loss_tmo setting when constructing the connect string.

Fixes: bdf4f3b ("fabrics: ctrl_loss_tmo setting is invalid for 'loop'")
Signed-off-by: Hannes Reinecke <hare@suse.de>
fabrics.c

index dfdcf2a2d307d5fd89cb7376e50c51f8f3f1dd7e..f71059d9e7cd3f1d2cae372ff817dfe82c114f24 100644 (file)
--- a/fabrics.c
+++ b/fabrics.c
@@ -90,7 +90,7 @@ static struct config {
        bool matching_only;
        char *output_format;
 } cfg = {
-       .ctrl_loss_tmo = -1,
+       .ctrl_loss_tmo = NVMF_DEF_CTRL_LOSS_TMO,
        .output_format = "normal",
 };
 
@@ -927,9 +927,6 @@ static int build_options(char *argstr, int max_len, bool discover)
                        fprintf(stderr, "need a address (-a) argument\n");
                        return -EINVAL;
                }
-               /* Use the default ctrl loss timeout if unset */
-               if (cfg.ctrl_loss_tmo == -1)
-                       cfg.ctrl_loss_tmo = NVMF_DEF_CTRL_LOSS_TMO;
        }
 
        /* always specify nqn as first arg - this will init the string */
@@ -961,8 +958,9 @@ static int build_options(char *argstr, int max_len, bool discover)
                                cfg.keep_alive_tmo, false) ||
            add_int_argument(&argstr, &max_len, "reconnect_delay",
                                cfg.reconnect_delay, false) ||
-           add_int_argument(&argstr, &max_len, "ctrl_loss_tmo",
-                               cfg.ctrl_loss_tmo, true) ||
+           (strncmp(cfg.transport, "loop", 4) &&
+            add_int_argument(&argstr, &max_len, "ctrl_loss_tmo",
+                               cfg.ctrl_loss_tmo, true)) ||
            add_int_argument(&argstr, &max_len, "tos",
                                cfg.tos, true) ||
            add_bool_argument(&argstr, &max_len, "duplicate_connect",
@@ -1127,7 +1125,7 @@ retry:
                p += len;
        }
 
-       if (cfg.ctrl_loss_tmo >= -1) {
+       if ((e->trtype != NVMF_TRTYPE_LOOP) && (cfg.ctrl_loss_tmo >= -1)) {
                len = sprintf(p, ",ctrl_loss_tmo=%d", cfg.ctrl_loss_tmo);
                if (len < 0)
                        return -EINVAL;