From: Hannes Reinecke Date: Thu, 25 Feb 2021 15:53:00 +0000 (+0100) Subject: fabrics: correctly handle ctrl_loss_tmo settings for loop X-Git-Tag: v1.14~63 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=79bb14710ac778a6037bc992ddea38af0954b8f7;p=users%2Fsagi%2Fnvme-cli.git fabrics: correctly handle ctrl_loss_tmo settings for loop 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 --- diff --git a/fabrics.c b/fabrics.c index dfdcf2a2..f71059d9 100644 --- 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;