diff --git a/Documentation/nvme-dispersed-ns-participating-nss-log.txt b/Documentation/nvme-dispersed-ns-participating-nss-log.txt new file mode 100644 index 0000000000..93b00623e5 --- /dev/null +++ b/Documentation/nvme-dispersed-ns-participating-nss-log.txt @@ -0,0 +1,55 @@ +nvme-dispersed-ns-participating-nss-log(1) +========================================== + +NAME +---- +nvme-dispersed-ns-participating-nss-log - Retrieve Dispersed Namespace +Participating NVM Subsystems Log, show it + +SYNOPSIS +-------- +[verse] +'nvme dispersed-ns-participating-nss-log' + [--namespace-id= | -n ] [--verbose | -v] + [--output-format= | -o ] [--timeout=] + +DESCRIPTION +----------- +Retrieve Dispersed Namespace Participating NVM Subsystems Log, show it + +The parameter is mandatory NVMe character device (ex: /dev/nvme0). + +On success it returns 0, error code otherwise. + +OPTIONS +------- +-n :: +--namespace-id=:: + The namespace identifier to delete. + Retrieve the dispersed namespace participating NVM subsystems log for + the given nsid. + +-v:: +--verbose:: + Increase the information detail in the output. + +-o :: +--output-format=:: + Set the reporting format to 'normal', 'json' or 'binary'. Only one + output format can be used at a time. + +-t :: +--timeout=:: + Override default timeout value. In milliseconds. + +EXAMPLES +-------- +* Has the program issue a dispersed-ns-participating-nss-log ++ +------------ +# nvme dispersed-ns-participating-nss-log /dev/nvme0 --namespace-id=2 +------------ + +NVME +---- +Part of the nvme-user suite. diff --git a/completions/_nvme b/completions/_nvme index 4e682e9e0c..827b89f5ee 100644 --- a/completions/_nvme +++ b/completions/_nvme @@ -112,6 +112,7 @@ _nvme () { 'io-mgmt-send:send an I/O management send command' 'mgmt-addr-list-log:retrieve management address list log' 'changed-ns-list-log:retrieve changed allocated namespaces log' + 'dispersed-ns-participating-nss-log:retrieve dispersed namespace participating NVM subsystems log' 'version:show the program version' 'ocp:OCP cloud SSD extensions' 'solidigm:Solidigm plug-in extensions' @@ -2590,7 +2591,7 @@ _nvme () { -t':alias of --timeout' ) _arguments '*:: :->subcmds' - _describe -t commands "nvme set-reg options" _io_mgmt_recv + _describe -t commands "nvme io-mgmt-recv-reg options" _io_mgmt_recv ;; (io-mgmt-send) local _io_mgmt_send @@ -2614,7 +2615,7 @@ _nvme () { -t':alias of --timeout' ) _arguments '*:: :->subcmds' - _describe -t commands "nvme set-reg options" _io_mgmt_send + _describe -t commands "nvme io-mgmt-send options" _io_mgmt_send ;; (mgmt-addr-list-log) local _mal_log @@ -2657,6 +2658,22 @@ _nvme () { _arguments '*:: :->subcmds' _describe -t commands "nvme changed-alloc-ns-list-log options" _changed_alloc_ns_list_log ;; + (dispersed-ns-participating-nss-log) + local _dns_psub_log + _caplog=( + /dev/nvme':supply a device to use (required)' + --namespace-id=':show infos for namespace ' + -n':alias of --namespace-id' + --verbose':Increase the information detail in the output.' + -v':alias for --verbose' + --output-format=':Output format: normal|json|binary' + -o ':alias for --output-format' + --timeout=':value for timeout' + -t ':alias for --timeout' + ) + _arguments '*:: :->subcmds' + _describe -t commands "nvme dispersed-ns-participating-nss-log" _dns_psub_log + ;; (version) local _version _version=( diff --git a/completions/bash-nvme-completion.sh b/completions/bash-nvme-completion.sh index 12b09ef53f..c0dfd5b14f 100644 --- a/completions/bash-nvme-completion.sh +++ b/completions/bash-nvme-completion.sh @@ -465,7 +465,7 @@ nvme_list_opts () { --nmimt= -m --nmd0= -0 --nmd1= -1 --input-file= -i" ;; "get-reg") - opts+=" --offset, -O --human-readable -H --cap --vs --cmbloc \ + opts+=" --offset= -O --human-readable -H --cap --vs --cmbloc \ --cmbsz --bpinfo --cmbsts --cmbebs --cmbswtp --crto \ --pmrcap --pmrsts --pmrebs --pmrswtp --intms --intmc \ --cc --csts --nssr --aqa --asq --acq --bprsel --bpmbl \ @@ -473,10 +473,20 @@ nvme_list_opts () { --output-format -o --verbose -v --timeout= -t" ;; "set-reg") - opts+=" --offset, -O --value= -V --mmio32 -m --intms= --intmc= \ + opts+=" --offset= -O --value= -V --mmio32 -m --intms= --intmc= \ --cc= --csts= --nssr= --aqa= --asq= --acq= --bprsel= \ --bpmbl= --cmbmsc= --nssd= --pmrctl= --pmrmscl= \ - --pmrmscu= --output-format= -o --verbose= -v \ + --pmrmscu= --output-format= -o --verbose -v \ + --timeout= -t" + ;; + "io-mgmt-recv") + opts+=" --namespace-id= -n --mos= -s --mo= -m --data= -d \ + --data-len= -l --output-format= -o --verbose -v \ + --timeout= -t" + ;; + "io-mgmt-send") + opts+=" --namespace-id= -n --mos= -s --mo= -m --data= -d \ + --data-len= -l --output-format= -o --verbose -v \ --timeout= -t" ;; "mgmt-addr-list-log") @@ -490,6 +500,10 @@ nvme_list_opts () { opts+=" --output-format= -o --raw-binary -b --verbose -v \ --timeout= -t" ;; + "dispersed-ns-participating-nss-log") + opts+=" --namespace-id= -n --verbose -v --output-format= -o \ + --timeout= -t" + ;; "version") opts+=$NO_OPTS ;; @@ -1681,7 +1695,8 @@ _nvme_subcmds () { supported-log-pages lockdown media-unit-stat-log \ supported-cap-config-log dim show-topology list-endgrp \ nvme-mi-recv nvme-mi-send get-reg set-reg mgmt-addr-list-log \ - rotational-media-info-log changed-alloc-ns-list-log" + rotational-media-info-log changed-alloc-ns-list-log \ + io-mgmt-recv io-mgmt-send dispersed-ns-participating-nss-log" # Add plugins: for plugin in "${!_plugin_subcmds[@]}"; do diff --git a/nvme-builtin.h b/nvme-builtin.h index 486b1e5a80..caa60721ea 100644 --- a/nvme-builtin.h +++ b/nvme-builtin.h @@ -61,6 +61,7 @@ COMMAND_LIST( ENTRY("mgmt-addr-list-log", "Retrieve Management Address List Log, show it", get_mgmt_addr_list_log) ENTRY("rotational-media-info-log", "Retrieve Rotational Media Information Log, show it", get_rotational_media_info_log) ENTRY("changed-alloc-ns-list-log", "Retrieve Changed Allocated Namespace List, show it", get_changed_alloc_ns_list_log) + ENTRY("dispersed-ns-participating-nss-log", "Retrieve Dispersed Namespace Participating NVM Subsystems Log, show it", get_dispersed_ns_participating_nss_log) ENTRY("set-feature", "Set a feature and show the resulting value", set_feature) ENTRY("set-property", "Set a property and show the resulting value", set_property) ENTRY("get-property", "Get a property and show the resulting value", get_property) diff --git a/nvme-print-binary.c b/nvme-print-binary.c index 2c5135a7b2..e9aa5688b0 100644 --- a/nvme-print-binary.c +++ b/nvme-print-binary.c @@ -316,6 +316,11 @@ static void binary_rotational_media_info_log(struct nvme_rotational_media_info_l d_raw((unsigned char *)info, sizeof(*info)); } +static void binary_dispersed_ns_psub_log(struct nvme_dispersed_ns_participating_nss_log *log) +{ + d_raw((unsigned char *)log, sizeof(*log)); +} + static struct print_ops binary_print_ops = { /* libnvme types.h print functions */ .ana_log = binary_ana_log, @@ -384,6 +389,7 @@ static struct print_ops binary_print_ops = { .show_finish = NULL, .mgmt_addr_list_log = binary_mgmt_addr_list_log, .rotational_media_info_log = binary_rotational_media_info_log, + .dispersed_ns_psub_log = binary_dispersed_ns_psub_log, /* libnvme tree print functions */ .list_item = NULL, diff --git a/nvme-print-json.c b/nvme-print-json.c index ee4338aae2..57110c1539 100644 --- a/nvme-print-json.c +++ b/nvme-print-json.c @@ -4657,6 +4657,26 @@ static void json_rotational_media_info_log(struct nvme_rotational_media_info_log json_print(r); } +static void json_dispersed_ns_psub_log(struct nvme_dispersed_ns_participating_nss_log *log) +{ + struct json_object *r = json_create_object(); + __u64 numpsub = le64_to_cpu(log->numpsub); + __u64 i; + char json_str[STR_LEN]; + char psub[NVME_NQN_LENGTH + 1]; + + obj_add_uint64(r, "genctr", le64_to_cpu(log->genctr)); + obj_add_uint64(r, "numpsub", numpsub); + for (i = 0; i < numpsub; i++) { + snprintf(json_str, sizeof(json_str), "participating_nss %"PRIu64"", (uint64_t)i); + snprintf(psub, sizeof(psub), "%-.*s", NVME_NQN_LENGTH, + &log->participating_nss[i * NVME_NQN_LENGTH]); + obj_add_str(r, json_str, psub); + } + + json_print(r); +} + static struct print_ops json_print_ops = { /* libnvme types.h print functions */ .ana_log = json_ana_log, @@ -4726,6 +4746,7 @@ static struct print_ops json_print_ops = { .show_finish = json_show_finish, .mgmt_addr_list_log = json_mgmt_addr_list_log, .rotational_media_info_log = json_rotational_media_info_log, + .dispersed_ns_psub_log = json_dispersed_ns_psub_log, /* libnvme tree print functions */ .list_item = json_list_item, diff --git a/nvme-print-stdout.c b/nvme-print-stdout.c index cc4d1fcdae..9faf8466a8 100644 --- a/nvme-print-stdout.c +++ b/nvme-print-stdout.c @@ -5603,6 +5603,18 @@ static void stdout_rotational_media_info_log(struct nvme_rotational_media_info_l printf("fldc: %u\n", le32_to_cpu(info->fldc)); } +static void stdout_dispersed_ns_psub_log(struct nvme_dispersed_ns_participating_nss_log *log) +{ + __u64 numpsub = le64_to_cpu(log->numpsub); + __u64 i; + + printf("genctr: %"PRIu64"\n", le64_to_cpu(log->genctr)); + printf("numpsub: %"PRIu64"\n", (uint64_t)numpsub); + for (i = 0; i < numpsub; i++) + printf("participating_nss %"PRIu64": %-.*s\n", (uint64_t)i, NVME_NQN_LENGTH, + &log->participating_nss[i * NVME_NQN_LENGTH]); +} + static struct print_ops stdout_print_ops = { /* libnvme types.h print functions */ .ana_log = stdout_ana_log, @@ -5672,6 +5684,7 @@ static struct print_ops stdout_print_ops = { .show_finish = NULL, .mgmt_addr_list_log = stdout_mgmt_addr_list_log, .rotational_media_info_log = stdout_rotational_media_info_log, + .dispersed_ns_psub_log = stdout_dispersed_ns_psub_log, /* libnvme tree print functions */ .list_item = stdout_list_item, diff --git a/nvme-print.c b/nvme-print.c index bb41543b40..77f4b17ed5 100644 --- a/nvme-print.c +++ b/nvme-print.c @@ -1502,3 +1502,9 @@ void nvme_show_rotational_media_info_log(struct nvme_rotational_media_info_log * { nvme_print(rotational_media_info_log, flags, info); } + +void nvme_show_dispersed_ns_psub_log(struct nvme_dispersed_ns_participating_nss_log *log, + nvme_print_flags_t flags) +{ + nvme_print(dispersed_ns_psub_log, flags, log); +} diff --git a/nvme-print.h b/nvme-print.h index 55616279a3..e446c07ea6 100644 --- a/nvme-print.h +++ b/nvme-print.h @@ -90,6 +90,7 @@ struct print_ops { void (*show_finish)(void); void (*mgmt_addr_list_log)(struct nvme_mgmt_addr_list_log *ma_log); void (*rotational_media_info_log)(struct nvme_rotational_media_info_log *info); + void (*dispersed_ns_psub_log)(struct nvme_dispersed_ns_participating_nss_log *log); /* libnvme tree print functions */ void (*list_item)(nvme_ns_t n); @@ -335,4 +336,6 @@ void nvme_show_mgmt_addr_list_log(struct nvme_mgmt_addr_list_log *ma_list, nvme_print_flags_t flags); void nvme_show_rotational_media_info_log(struct nvme_rotational_media_info_log *info, nvme_print_flags_t flags); +void nvme_show_dispersed_ns_psub_log(struct nvme_dispersed_ns_participating_nss_log *log, + nvme_print_flags_t flags); #endif /* NVME_PRINT_H */ diff --git a/nvme-wrap.c b/nvme-wrap.c index 0b1039a682..2cc5204f93 100644 --- a/nvme-wrap.c +++ b/nvme-wrap.c @@ -451,3 +451,9 @@ int nvme_cli_get_log_rotational_media_info(struct nvme_dev *dev, __u16 endgid, _ return -ENODEV; } + +int nvme_cli_get_log_dispersed_ns_participating_nss(struct nvme_dev *dev, __u32 nsid, __u32 len, + struct nvme_dispersed_ns_participating_nss_log *log) +{ + return do_admin_op(get_log_dispersed_ns_participating_nss, dev, nsid, len, log); +} diff --git a/nvme-wrap.h b/nvme-wrap.h index bde7d720ab..b675f4f0da 100644 --- a/nvme-wrap.h +++ b/nvme-wrap.h @@ -154,4 +154,7 @@ int nvme_cli_get_log_mgmt_addr_list(struct nvme_dev *dev, __u32 len, int nvme_cli_get_log_rotational_media_info(struct nvme_dev *dev, __u16 endgid, __u32 len, struct nvme_rotational_media_info_log *info); +int nvme_cli_get_log_dispersed_ns_participating_nss(struct nvme_dev *dev, __u32 nsid, __u32 len, + struct nvme_dispersed_ns_participating_nss_log *log); + #endif /* _NVME_WRAP_H */ diff --git a/nvme.c b/nvme.c index 06deeaeb56..a50ffab60e 100644 --- a/nvme.c +++ b/nvme.c @@ -10165,6 +10165,94 @@ static int get_rotational_media_info_log(int argc, char **argv, struct command * return err; } +static int get_dispersed_ns_psub(struct nvme_dev *dev, __u32 nsid, + struct nvme_dispersed_ns_participating_nss_log **logp) +{ + int err; + __u64 header_len = sizeof(**logp); + __u64 psub_list_len; + struct nvme_get_log_args args = { + .args_size = sizeof(args), + .fd = dev_fd(dev), + .timeout = NVME_DEFAULT_IOCTL_TIMEOUT, + .lid = NVME_LOG_LID_DISPERSED_NS_PARTICIPATING_NSS, + .nsid = nsid, + .lpo = header_len, + }; + struct nvme_dispersed_ns_participating_nss_log *log = nvme_alloc(header_len); + + if (!log) + return -ENOMEM; + + err = nvme_cli_get_log_dispersed_ns_participating_nss(dev, nsid, header_len, log); + if (err) + goto err_free; + + psub_list_len = le64_to_cpu(log->numpsub) * NVME_NQN_LENGTH; + + log = nvme_realloc(log, header_len + psub_list_len); + if (!log) { + err = -ENOMEM; + goto err_free; + } + + args.log = log->participating_nss, + args.len = psub_list_len; + + err = nvme_cli_get_log_page(dev, NVME_LOG_PAGE_PDU_SIZE, &args); + if (err) + goto err_free; + + *logp = log; + return 0; + +err_free: + free(log); + return err; +} + +static int get_dispersed_ns_participating_nss_log(int argc, char **argv, struct command *cmd, + struct plugin *plugin) +{ + const char *desc = "Retrieve Dispersed Namespace Participating NVM Subsystems Log, show it"; + nvme_print_flags_t flags; + int err; + + _cleanup_nvme_dev_ struct nvme_dev *dev = NULL; + + _cleanup_free_ struct nvme_dispersed_ns_participating_nss_log *log = NULL; + + struct config { + __u32 namespace_id; + }; + + struct config cfg = { + .namespace_id = 1, + }; + + NVME_ARGS(opts, OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id_desired)); + + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; + + err = validate_output_format(nvme_cfg.output_format, &flags); + if (err < 0) { + nvme_show_error("Invalid output format"); + return err; + } + + err = get_dispersed_ns_psub(dev, cfg.namespace_id, &log); + if (!err) + nvme_show_dispersed_ns_psub_log(log, flags); + else if (err > 0) + nvme_show_status(err); + else + nvme_show_perror("dispersed ns participating nss log"); + + return err; +} + void register_extension(struct plugin *plugin) { plugin->parent = &nvme;