Skip to content

Commit 07e1e53

Browse files
alistair23igaw
authored andcommitted
fabrics: set persistent when connecting to a discovery controller
Currently a user can use the `nvme discover` to connect to a discovery controller. This then allows the user to use a --persistent argument to maintain a persistent or not. This correctly sets a KATO and works as expected. A user can also perform `nvme connect` to connect to a discovery controller. In this case a KATO is not specified to the kernel (KATO of 0) yet we are actually creating a persistent connection. This results in the nvme target constantly generating keep-alive timeouts as a Linux target sets a KATO of 120 seconds (as allowed by the spec) yet we have no keep-alive timer running for the persistent connection. This patch checks if we are connecting to a discovery controller and if we are sets the persistent option to true. We know it's a persistent connection because we are using `nvme connect` so we want to stay connected. This fixes an issue where performing a `nvme connect -n nqn.2014-08.org.nvmexpress.discovery ... ` to a Linux NVMe target would result in constant keep-alive timeouts from the target. Signed-off-by: Alistair Francis <[email protected]>
1 parent c1241bb commit 07e1e53

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

fabrics.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,16 @@ int nvmf_connect(const char *desc, int argc, char **argv)
11201120

11211121
nvme_parse_tls_args(keyring, tls_key, tls_key_identity, &cfg, c);
11221122

1123+
/*
1124+
* We are connecting to a discovery controller, so let's treat
1125+
* this as a persistent connection and specify a KATO.
1126+
*/
1127+
if (!strcmp(subsysnqn, NVME_DISC_SUBSYS_NAME)) {
1128+
persistent = true;
1129+
1130+
set_discovery_kato(&cfg);
1131+
}
1132+
11231133
ret = nvme_add_ctrl(h, c, &cfg);
11241134
if (ret) {
11251135
fprintf(stderr, "could not add new controller: %s\n",

0 commit comments

Comments
 (0)