Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Documentation/nvme-connect-all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ SYNOPSIS
[--nbft]
[--no-nbft]
[--nbft-path=<STR>]
[--owner=<NAME>]
[<fabrics-options>]
[<global-options>]

Expand Down Expand Up @@ -82,6 +83,12 @@ OPTIONS
--nbft-path=<STR>::
Use a user-defined path to the NBFT tables

--owner=<NAME>::
Record NAME as the owner of connected controllers in the NVMe
ownership registry, so other orchestrators (and nvme-disconnect-all)
leave them alone. See nvme-disconnect-all(1). When --nbft is also
given, --owner takes precedence over its default owner of 'nbft'.

include::fabrics-options.txt[]

include::global-options.txt[]
Expand Down
6 changes: 6 additions & 0 deletions Documentation/nvme-connect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ SYNOPSIS
--------
[verse]
'nvme' [<global-options>] 'connect' [--config=<filename>]
[--owner=<NAME>]
[<fabrics-options>]

DESCRIPTION
Expand All @@ -22,6 +23,11 @@ OPTIONS
--config=<filename>::
Use the specified JSON configuration file instead of the default.

--owner=<NAME>::
Record NAME as the owner of the connected controller in the NVMe
ownership registry, so other orchestrators (and nvme-disconnect-all)
leave it alone. See nvme-disconnect-all(1).

include::fabrics-options.txt[]

include::global-options.txt[]
Expand Down
7 changes: 3 additions & 4 deletions Documentation/nvme-disconnect-all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ SYNOPSIS
--------
[verse]
'nvme' [<global-options>] 'disconnect-all'
[--transport=<STR> | -r <STR>]
[--owner=<NAME> | -O <NAME>]
[--transport=<STR> | -t <STR>]
[--owner=<NAME>]
[--force]

DESCRIPTION
Expand All @@ -31,12 +31,11 @@ background.

OPTIONS
-------
-r <STR>::
-t <STR>::
--transport=<STR>::
Limit disconnection to controllers using the specified transport
(e.g. tcp, rdma, fc).

-O <NAME>::
--owner=<NAME>::
Disconnect only controllers owned by NAME in the registry.
Requires interactive confirmation when stdin is a terminal.
Expand Down
7 changes: 7 additions & 0 deletions Documentation/nvme-discover.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ SYNOPSIS
[--nbft]
[--no-nbft]
[--nbft-path=<STR>]
[--owner=<NAME>]
[<fabrics-options>]

DESCRIPTION
Expand Down Expand Up @@ -108,6 +109,12 @@ OPTIONS
--nbft-path=<STR>::
Use a user-defined path to the NBFT tables

--owner=<NAME>::
Record NAME as the owner of connected controllers in the NVMe
ownership registry, so other orchestrators (and nvme-disconnect-all)
leave them alone. See nvme-disconnect-all(1). When --nbft is also
given, --owner takes precedence over its default owner of 'nbft'.

include::fabrics-options.txt[]

include::global-options.txt[]
Expand Down
5 changes: 4 additions & 1 deletion completions/_nvme
Original file line number Diff line number Diff line change
Expand Up @@ -2227,6 +2227,7 @@ _nvme () {
--nbft':Only look at NBFT tables'
--no-nbft':Do not look at NBFT tables'
--nbft-patch=':user-defined path for NBFT tables'
--owner=':record this owner in the registry'
)
_arguments '*:: :->subcmds'
_describe -t commands "nvme discover options" _discover
Expand Down Expand Up @@ -2297,6 +2298,7 @@ _nvme () {
--nbft':Only look at NBFT tables'
--no-nbft':Do not look at NBFT tables'
--nbft-patch=':user-defined path for NBFT tables'
--owner=':record this owner in the registry'
)
_arguments '*:: :->subcmds'
_describe -t commands "nvme connect-all options" _connect_all
Expand Down Expand Up @@ -2358,6 +2360,7 @@ _nvme () {
-O':alias for --dump-config'
--output-format=':Output format: normal|json'
-o':alias for --output-format'
--owner=':record this owner in the registry'
)
_arguments '*:: :->subcmds'
_describe -t commands "nvme connect options" _connect
Expand Down Expand Up @@ -2394,7 +2397,7 @@ _nvme () {
local _disconnect_all
_disconnect_all=(
--transport=':transport type'
-r':alias for --transport'
-t':alias for --transport'
--verbose':Increase logging verbosity'
-v':alias for --verbose'
)
Expand Down
7 changes: 4 additions & 3 deletions completions/bash-nvme-completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ nvme_list_opts () {
--nr-io-queues= -i --nr-write-queues= -W \
--nr-poll-queues= -P --queue-size= -Q \
--persistent -p --quiet \
--output-format= -o"
--owner= --output-format= -o"
;;
"connect-all")
opts+=" --transport= -t -traddr= -a -trsvcid= -s \
Expand All @@ -417,7 +417,7 @@ nvme_list_opts () {
--nr-io-queues= -i --nr-write-queues= -W \
--nr-poll-queues= -P --queue-size= -Q \
--persistent -p --quiet \
--output-format= -o"
--owner= --output-format= -o"
;;
"connect")
opts+=" --transport= -t --nqn= -n --traddr= -a --trsvcid -s \
Expand All @@ -426,7 +426,8 @@ nvme_list_opts () {
--keep-alive-tmo= -k --reconnect-delay= -r \
--ctrl-loss-tmo= -l --fast-io-fail-tmo= -f \
--tos= -T --duplicate-connect -D --disable-sqflow \
--hdr-digest -g --data-digest -G --output-format= -o"
--hdr-digest -g --data-digest -G --owner= \
--output-format= -o"
;;
"dim")
opts+=" --task -t --nqn -n --device -d"
Expand Down
31 changes: 27 additions & 4 deletions fabrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect)
bool json_config = false;
bool nbft = false, nonbft = false;
char *nbft_path = NBFT_SYSFS_PATH;
char *owner = NULL;

NVMF_ARGS(opts, fa,
OPT_STRING("device", 'd', "DEV", &device, "use existing discovery controller device"),
Expand All @@ -570,6 +571,7 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect)
OPT_FLAG("force", 0, &force, "Force persistent discovery controller creation"),
OPT_FLAG("nbft", 0, &nbft, "Only look at NBFT tables"),
OPT_FLAG("no-nbft", 0, &nonbft, "Do not look at NBFT tables"),
OPT_STRING("owner", 0, "NAME", &owner, "record this owner in the registry"),
OPT_STRING("nbft-path", 0, "STR", &nbft_path, "user-defined path for NBFT tables"));

nvmf_default_args(&fa);
Expand Down Expand Up @@ -597,8 +599,19 @@ int fabrics_discovery(const char *desc, int argc, char **argv, bool connect)
libnvme_strerror(errno));
return -ENOMEM;
}
if (nbft)
libnvme_set_owner(ctx, "nbft");
/*
* --nbft defaults the owner to "nbft" so legacy boot scripts that
* call "connect-all --nbft" record ownership unchanged. An explicit
* --owner overrides that default.
*/
if (owner || nbft) {
ret = libnvme_set_owner(ctx, owner ? owner : "nbft");
if (ret) {
fprintf(stderr, "failed to set owner: %s\n",
libnvme_strerror(-ret));
return ret;
}
}

if (!nvme_read_config_checked(ctx, config_file))
json_config = true;
Expand Down Expand Up @@ -661,6 +674,7 @@ int fabrics_connect(const char *desc, int argc, char **argv)
__cleanup_free char *hnqn = NULL;
__cleanup_free char *hid = NULL;
char *config_file = NULL;
char *owner = NULL;
__cleanup_nvme_global_ctx struct libnvme_global_ctx *ctx = NULL;
__cleanup_nvmf_context struct libnvmf_context *fctx = NULL;
__cleanup_nvme_ctrl libnvme_ctrl_t c = NULL;
Expand All @@ -670,6 +684,7 @@ int fabrics_connect(const char *desc, int argc, char **argv)

NVMF_ARGS(opts, fa,
OPT_STRING("config", 'J', "FILE", &config_file, nvmf_config_file),
OPT_STRING("owner", 0, "NAME", &owner, "record this owner in the registry"),
OPT_FLAG("dump-config", 'O', &dump_config, "Dump JSON configuration to stdout"));

nvmf_default_args(&fa);
Expand Down Expand Up @@ -719,6 +734,14 @@ int fabrics_connect(const char *desc, int argc, char **argv)
libnvme_strerror(errno));
return -ENOMEM;
}
if (owner) {
ret = libnvme_set_owner(ctx, owner);
if (ret) {
fprintf(stderr, "failed to set owner: %s\n",
libnvme_strerror(-ret));
return ret;
}
}

libnvme_read_config(ctx, config_file);
nvme_read_volatile_config(ctx);
Expand Down Expand Up @@ -924,8 +947,8 @@ int fabrics_disconnect_all(const char *desc, int argc, char **argv)
struct config cfg = { 0 };

NVME_ARGS(opts,
OPT_STRING("transport", 'r', "STR", (char *)&cfg.transport, nvmf_tport),
OPT_STRING("owner", 'O', "NAME", &cfg.owner, owner_help),
OPT_STRING("transport", 't', "STR", &cfg.transport, nvmf_tport),
OPT_STRING("owner", 0, "NAME", &cfg.owner, owner_help),
OPT_FLAG("force", 0, &cfg.force, force_help));

ret = argconfig_parse(argc, argv, desc, opts);
Expand Down
Loading