Skip to contentSkip to conversation

nvme-fabrics: Allow 0 as KATO value

PATCH New Guilherme G. Piccoli 2 participants 3 messages Aug 28, 2017 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme-fabrics: Allow 0 as KATO value

Currently, driver code allows user to set 0 as KATO (Keep Alive TimeOut), but it's not being respected. This patch enforces the expected behavior.

Signed-off-by Guilherme G. Piccoli <gpiccoli at linux.vnet.ibm.com>

---

There is some possible discussion about what is the mean (or expected mean) of a 0 value for KATO.

(1) This patch will allow 0 and this way we get a timeout right after connection, because target will send the keep alive anyway. Is this useful as debug?

(2) We might stop sending keep alives from target side to the initiators that set KATO as 0 (I think this make sense and I could implement this way if linux-nvme folks agree).

(3) Extreme case: we don't allow KATO to be 0, so we should remove this code/comment from driver.

Thoughts appreciated.
Thanks in advance!

 drivers/nvme/host/fabrics.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/host/fabrics.c +3 -1
index 2e582a240943..d734ae852e1a 100644
@@ -556,6 +556,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
 {
 	substring_t args[MAX_OPT_ARGS];
 	char *options, *o, *p;
+	bool set_kato = true;
 	int token, ret = 0;
 	size_t nqnlen  = 0;
 	int ctrl_loss_tmo = NVMF_DEF_CTRL_LOSS_TMO;
@@ -668,6 +669,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
 			} else if (token == 0) {
 				/* Allowed for debug */
 				pr_warn("keep_alive_tmo 0 won't execute keep alives!!!\n");
+				set_kato = false;
 			}
 			opts->kato = token;
 			break;
@@ -761,7 +763,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
 	uuid_copy(&opts->host->id, &hostid);
 
 out:
-	if (!opts->discovery_nqn && !opts->kato)
+	if (set_kato && !opts->discovery_nqn && !opts->kato)
 		opts->kato = NVME_DEFAULT_KATO;
 	kfree(options);
 	return ret;
Signature · 1 line
2.14.1
maintainer
#1 lore raw

PATCH 1/1 nvme-fabrics: Allow 0 as KATO value

Quoted 4 lines

Currently, driver code allows user to set 0 as KATO (Keep Alive TimeOut), but it's not being respected. This patch enforces the expected behavior.

It was originally possible to set it to zero, but I guess somewhere down the road the restriction was added.

Quoted 22 lines
drivers/nvme/host/fabrics.c +2 -0
index 2e582a240943..d734ae852e1a 100644
@@ -556,6 +556,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
  {
  	substring_t args[MAX_OPT_ARGS];
  	char *options, *o, *p;
+	bool set_kato = true;
  	int token, ret = 0;
  	size_t nqnlen  = 0;
  	int ctrl_loss_tmo = NVMF_DEF_CTRL_LOSS_TMO;
@@ -668,6 +669,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
  			} else if (token == 0) {
  				/* Allowed for debug */
  				pr_warn("keep_alive_tmo 0 won't execute keep alives!!!\n");
+				set_kato = false;
  			}
  			opts->kato = token;
  			break;

drivers/nvme/host/fabrics.c static int nvmf_parse_options(struct nvmf_ctrl_options *opts, · line 769

Quoted 8 lines
drivers/nvme/host/fabrics.c +1 -1
@@ -761,7 +763,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
  	uuid_copy(&opts->host->id, &hostid);
 
  out:
-	if (!opts->discovery_nqn && !opts->kato)
+	if (set_kato && !opts->discovery_nqn && !opts->kato)
  		opts->kato = NVME_DEFAULT_KATO;
  	kfree(options);
  	return ret;

How about simply setting opts->kato = NVME_DEFAULT_KATO as a default at the beginning and remove this condition instead..

#2 lore raw

PATCH 1/1 nvme-fabrics: Allow 0 as KATO value

Quoted 5 lines · Sagi Grimberg

[...]
How about simply setting opts->kato = NVME_DEFAULT_KATO as a default at the beginning and remove this condition instead..

Good for me, I can send a v2.
Thanks Sagi.
Cheers,

Guilherme