From 9174789519ef527b929867ce314f8f3d296e253f Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Thu, 11 Jul 2024 18:42:23 +0200 Subject: [PATCH 1/3] fabrics: check if json config is existing nvme_read_config will return success even if the file doesn't exist. This leads to the situation that we always execute discover_from_json_config_file even though there is no json config file. One side effect of this is that when executing 'nvme discover -d /dev/nvmeXXX' we will always do a discover for the first controller we find. Signed-off-by: Daniel Wagner --- fabrics.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fabrics.c b/fabrics.c index f8136c4ab8..6ca1d23adb 100644 --- a/fabrics.c +++ b/fabrics.c @@ -666,6 +666,15 @@ static int nvme_read_volatile_config(nvme_root_t r) return ret; } +static int nvme_read_config_checked(nvme_root_t r, const char *filename) +{ + if (!access(filename, F_OK)) + return -ENOENT; + if (nvme_read_config(r, filename)) + return -errno; + return 0; +} + int nvmf_discover(const char *desc, int argc, char **argv, bool connect) { char *subsysnqn = NVME_DISC_SUBSYS_NAME; @@ -730,7 +739,7 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) if (context) nvme_root_set_application(r, context); - if (!nvme_read_config(r, config_file)) + if (!nvme_read_config_checked(r, config_file)) json_config = true; if (!nvme_read_volatile_config(r)) json_config = true; From be3d098944c5a31920a306be60252a681999cad1 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Thu, 11 Jul 2024 18:53:36 +0200 Subject: [PATCH 2/3] fabrics: drop --disable-sqflow alias -d The alias for --disable-sqflow -d clashes with --device for the discover command. Since the --disable-sqflow is not so commonly used, let's free -d for other uses. Fixes: 18de3a6d61a7 ("Convert to libnvme") Signed-off-by: Daniel Wagner --- Documentation/nvme-config.txt | 3 +-- Documentation/nvme-connect.txt | 3 +-- completions/_nvme | 3 --- completions/bash-nvme-completion.sh | 2 +- fabrics.c | 2 +- 5 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Documentation/nvme-config.txt b/Documentation/nvme-config.txt index 8a66644754..98009e4d8e 100644 --- a/Documentation/nvme-config.txt +++ b/Documentation/nvme-config.txt @@ -27,7 +27,7 @@ SYNOPSIS [--keep-alive-tmo=<#> | -k <#>] [--reconnect-delay=<#> | -c <#>] [--ctrl-loss-tmo=<#> | -l <#>] - [--duplicate-connect | -D] [--disable-sqflow | -d] + [--duplicate-connect | -D] [--disable-sqflow ] [--hdr-digest | -g] [--data-digest | -G] [--output-format= | -o ] [--verbose | -v] @@ -168,7 +168,6 @@ OPTIONS Allows duplicated connections between same transport host and subsystem port. --d:: --disable-sqflow:: Disables SQ flow control to omit head doorbell update for submission queues when sending nvme completions. diff --git a/Documentation/nvme-connect.txt b/Documentation/nvme-connect.txt index 72b80007e9..0112e110be 100644 --- a/Documentation/nvme-connect.txt +++ b/Documentation/nvme-connect.txt @@ -27,7 +27,7 @@ SYNOPSIS [--reconnect-delay=<#> | -c <#>] [--ctrl-loss-tmo=<#> | -l <#>] [--tos=<#> | -T <#>] [--keyring=<#>] [--tls_key=<#>] - [--duplicate-connect | -D] [--disable-sqflow | -d] + [--duplicate-connect | -D] [--disable-sqflow ] [--hdr-digest | -g] [--data-digest | -G] [--tls] [--concat] [--dump-config | -O] [--application=] [--output-format= | -o ] [--verbose | -v] @@ -162,7 +162,6 @@ OPTIONS Allows duplicated connections between same transport host and subsystem port. --d:: --disable-sqflow:: Disables SQ flow control to omit head doorbell update for submission queues when sending nvme completions. diff --git a/completions/_nvme b/completions/_nvme index 28786bbdfb..cf7e949aad 100644 --- a/completions/_nvme +++ b/completions/_nvme @@ -2014,7 +2014,6 @@ _nvme () { --duplicate-connect':allow duplicate connections between same transport host and subsystem port' -D':alias for --duplicate-connect' --disable-sqflow':disable controller sq flow control (default false)' - -d':alias for --disable-sqflow' --hdr-digest':enable transport protocol header digest (TCP transport)' -g':alias for --hdr-digest' --data-digest':enable transport protocol data digest (TCP transport)' @@ -2086,7 +2085,6 @@ _nvme () { --duplicate-connect':allow duplicate connections between same transport host and subsystem port' -D':alias for --duplicate-connect' --disable-sqflow':disable controller sq flow control (default false)' - -d':alias for --disable-sqflow' --hdr-digest':enable transport protocol header digest (TCP transport)' -g':alias for --hdr-digest' --data-digest':enable transport protocol data digest (TCP transport)' @@ -2156,7 +2154,6 @@ _nvme () { --duplicate-connect':allow duplicate connections between same transport host and subsystem port' -D':alias for --duplicate-connect' --disable-sqflow':disable controller sq flow control (default false)' - -d':alias for --disable-sqflow' --hdr-digest':enable transport protocol header digest (TCP transport)' -g':alias for --hdr-digest' --data-digest':enable transport protocol data digest (TCP transport)' diff --git a/completions/bash-nvme-completion.sh b/completions/bash-nvme-completion.sh index 00ea5e9b27..f2b299b791 100644 --- a/completions/bash-nvme-completion.sh +++ b/completions/bash-nvme-completion.sh @@ -409,7 +409,7 @@ nvme_list_opts () { --nr-poll-queues= -P --queue-size= -Q \ --keep-alive-tmo= -k --reconnect-delay= -r \ --ctrl-loss-tmo= -l --fast-io-fail-tmo= -f \ - --tos= -T --duplicate-connect -D --disable-sqflow -d\ + --tos= -T --duplicate-connect -D --disable-sqflow \ --hdr-digest -g --data-digest -G --output-format= -o" ;; "dim") diff --git a/fabrics.c b/fabrics.c index 6ca1d23adb..d747053253 100644 --- a/fabrics.c +++ b/fabrics.c @@ -114,7 +114,7 @@ static const char *nvmf_context = "execution context identification string"; OPT_INT("keyring", 0, &c.keyring, nvmf_keyring), \ OPT_INT("tls_key", 0, &c.tls_key, nvmf_tls_key), \ OPT_FLAG("duplicate-connect", 'D', &c.duplicate_connect, nvmf_dup_connect), \ - OPT_FLAG("disable-sqflow", 'd', &c.disable_sqflow, nvmf_disable_sqflow), \ + OPT_FLAG("disable-sqflow", 0, &c.disable_sqflow, nvmf_disable_sqflow), \ OPT_FLAG("hdr-digest", 'g', &c.hdr_digest, nvmf_hdr_digest), \ OPT_FLAG("data-digest", 'G', &c.data_digest, nvmf_data_digest), \ OPT_FLAG("tls", 0, &c.tls, nvmf_tls), \ From fff6c3eed50ca51f49837648e231185f9eb75256 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Thu, 11 Jul 2024 19:06:29 +0200 Subject: [PATCH 3/3] fabrics: drop --quiet alias -S -S has been allocated for the global dhchap secret option. It's likely that the --quiet option is less used, thus drop the -S alias for it. Fixes: 0571307d3af0 ("nvme-connect: Add 'dhchap-secret' and 'dhchap-ctrl-secret' arguments") Signed-off-by: Daniel Wagner --- Documentation/nvme-connect-all.txt | 3 +-- Documentation/nvme-discover.txt | 3 +-- completions/_nvme | 2 -- completions/bash-nvme-completion.sh | 4 ++-- fabrics.c | 4 ++-- 5 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Documentation/nvme-connect-all.txt b/Documentation/nvme-connect-all.txt index 4cd1873426..68708e5ffb 100644 --- a/Documentation/nvme-connect-all.txt +++ b/Documentation/nvme-connect-all.txt @@ -27,7 +27,7 @@ SYNOPSIS [--nr-poll-queues=<#> | -P <#>] [--queue-size=<#> | -Q <#>] [--keyring=<#>] [--tls_key=<#>] [--hdr-digest | -g] [--data-digest | -G] - [--persistent | -p] [--tls] [--concat] [--quiet | -S] + [--persistent | -p] [--tls] [--concat] [--quiet] [--dump-config | -O] [--nbft] [--no-nbft] [--nbft-path=] [--context=] [--output-format= | -o ] [--verbose | -v] @@ -189,7 +189,6 @@ OPTIONS --concat:: Enable secure concatenation (TCP). --S:: --quiet:: Suppress error messages. diff --git a/Documentation/nvme-discover.txt b/Documentation/nvme-discover.txt index 1069d3cea1..e3017eb964 100644 --- a/Documentation/nvme-discover.txt +++ b/Documentation/nvme-discover.txt @@ -27,7 +27,7 @@ SYNOPSIS [--nr-poll-queues=<#> | -P <#>] [--queue-size=<#> | -Q <#>] [--keyring=<#>] [--tls_key=<#>] [--hdr-digest | -g] [--data-digest | -G] - [--persistent | -p] [--quiet | -S] [--tls] [--concat] + [--persistent | -p] [--quiet] [--tls] [--concat] [--dump-config | -O] [--output-format= | -o ] [--force] [--nbft] [--no-nbft] [--nbft-path=] [--context=] @@ -209,7 +209,6 @@ OPTIONS --concat:: Enable secure concatenation (TCP). --S:: --quiet:: Suppress already connected errors. diff --git a/completions/_nvme b/completions/_nvme index cf7e949aad..7ae208a623 100644 --- a/completions/_nvme +++ b/completions/_nvme @@ -2026,7 +2026,6 @@ _nvme () { --persistent':' -p':alias for --' --quiet':' - -S':alias for --' --config=':Use specified JSON configuration file or none to disable' -J':alias for --config' --verbose':Increase logging verbosity' @@ -2097,7 +2096,6 @@ _nvme () { --persistent':' -p':alias for --' --quiet':' - -S':alias for --' --config=':Use specified JSON configuration file or none to disable' -J':alias for --config' --verbose':Increase logging verbosity' diff --git a/completions/bash-nvme-completion.sh b/completions/bash-nvme-completion.sh index f2b299b791..d6285664cf 100644 --- a/completions/bash-nvme-completion.sh +++ b/completions/bash-nvme-completion.sh @@ -388,7 +388,7 @@ nvme_list_opts () { --tos= -T --hdr-digest= -g --data-digest -G \ --nr-io-queues= -i --nr-write-queues= -W \ --nr-poll-queues= -P --queue-size= -Q \ - --persistent -p --quiet -S \ + --persistent -p --quiet \ --output-format= -o" ;; "connect-all") @@ -400,7 +400,7 @@ nvme_list_opts () { --tos= -T --hdr-digest= -g --data-digest -G \ --nr-io-queues= -i --nr-write-queues= -W \ --nr-poll-queues= -P --queue-size= -Q \ - --persistent -p --quiet -S \ + --persistent -p --quiet \ --output-format= -o" ;; "connect") diff --git a/fabrics.c b/fabrics.c index d747053253..bd88cb2fe6 100644 --- a/fabrics.c +++ b/fabrics.c @@ -420,7 +420,7 @@ static int discover_from_conf_file(nvme_root_t r, nvme_host_t h, OPT_FMT("output-format", 'o', &format, output_format), OPT_FILE("raw", 'r', &raw, "save raw output to file"), OPT_FLAG("persistent", 'p', &persistent, "persistent discovery connection"), - OPT_FLAG("quiet", 'S', &quiet, "suppress already connected errors"), + OPT_FLAG("quiet", 0, &quiet, "suppress already connected errors"), OPT_INCR("verbose", 'v', &verbose, "Increase logging verbosity"), OPT_FLAG("force", 0, &force, "Force persistent discovery controller creation")); @@ -703,7 +703,7 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) OPT_FMT("output-format", 'o', &format, output_format), OPT_FILE("raw", 'r', &raw, "save raw output to file"), OPT_FLAG("persistent", 'p', &persistent, "persistent discovery connection"), - OPT_FLAG("quiet", 'S', &quiet, "suppress already connected errors"), + OPT_FLAG("quiet", 0, &quiet, "suppress already connected errors"), OPT_STRING("config", 'J', "FILE", &config_file, nvmf_config_file), OPT_INCR("verbose", 'v', &verbose, "Increase logging verbosity"), OPT_FLAG("dump-config", 'O', &dump_config, "Dump configuration file to stdout"),