--- /dev/null
+nvme-dapustor-smart-log-add(1)
+==============================
+
+NAME
+----
+nvme-dapustor-smart-log-add - Send NVMe DapuStor Additional SMART log page request,
+returns result and log
+
+SYNOPSIS
+--------
+[verse]
+'nvme dapustor smart-log-add' <device> [--namespace-id=<nsid> | -n <nsid>]
+ [--raw-binary | -b] [--json | -j]
+
+DESCRIPTION
+-----------
+Retrieves the NVMe DapuStor Additional SMART log page from the device and
+provides the returned structure.
+
+The <device> parameter is mandatory and may be either the NVMe character
+device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1).
+
+On success, the returned smart log structure may be returned in one of
+several ways depending on the option flags; the structure may parsed by
+the program and printed in a readable format or the raw buffer may be
+printed to stdout for another program to parse.
+
+OPTIONS
+-------
+-n <nsid>::
+--namespace-id=<nsid>::
+ Retrieve the Additional SMART log for the given nsid. This is
+ optional and its success may depend on the device's capabilities
+ to provide this log on a per-namespace basis (see the NVMe
+ Identify Controller for this capability). The default nsid to
+ use is 0xffffffff for the device global SMART log.
+
+-b::
+--raw-binary::
+ Print the raw DapuStor Additional SMART log buffer to stdout.
+
+-j::
+--json::
+ Dump output in json format.
+
+EXAMPLES
+--------
+* Print the DapuStor Additional SMART log page in a human readable format:
++
+------------
+# nvme dapustor smart-log-add /dev/nvme0
+------------
++
+
+* Print the raw DapuStor Additional SMART log to a file:
++
+------------
+# nvme dapustor smart-log-add /dev/nvme0 --raw-binary > smart_log.raw
+------------
++
+It is probably a bad idea to not redirect stdout when using this mode.
+
+NVME
+----
+Part of the nvme-user suite
return 0
}
+plugin_dapustor_opts () {
+ local opts=""
+ local compargs=""
+
+ local nonopt_args=0
+ for (( i=0; i < ${#words[@]}-1; i++ )); do
+ if [[ ${words[i]} != -* ]]; then
+ let nonopt_args+=1
+ fi
+ done
+
+ if [ $nonopt_args -eq 3 ]; then
+ opts="/dev/nvme* "
+ fi
+
+ opts+=" "
+
+ case "$1" in
+ "smart-log-add")
+ opts+=" --namespace-id= -n --raw-binary -b \
+ --json -j"
+ ;;
+ "help")
+ opts+=$NO_OPTS
+ ;;
+ esac
+
+ COMPREPLY+=( $( compgen $compargs -W "$opts" -- $cur ) )
+
+ return 0
+}
+
plugin_zns_opts () {
local opts=""
local compargs=""
vs-drive-info cloud-SSDplugin-version market-log \
smart-log-add temp-stats version help"
[transcend]="healthvalue badblock"
+ [dapustor]="smart-log-add"
[zns]="id-ctrl id-ns zone-mgmt-recv \
zone-mgmt-send report-zones close-zone \
finish-zone open-zone reset-zone offline-zone \
[sfx]="plugin_sfx_opts"
[solidigm]="plugin_solidigm_opts"
[transcend]="plugin_transcend_opts"
+ [dapustor]="plugin_dapustor_opts"
[zns]="plugin_zns_opts"
[nvidia]="plugin_nvidia_opts"
[ymtc]="plugin_ymtc_opts"
static void show_dapustor_smart_log_jsn(struct nvme_additional_smart_log *smart,
struct nvme_extended_additional_smart_log *ext_smart,
- unsigned int nsid, const char *devname)
+ unsigned int nsid, const char *devname, bool has_ext)
{
struct json_object *root, *dev_stats;
dev_stats = json_create_object();
show_dapustor_add_smart_log_jsn(smart, dev_stats);
- show_dapustor_ext_add_smart_log_jsn(ext_smart, dev_stats);
+ if (has_ext)
+ show_dapustor_ext_add_smart_log_jsn(ext_smart, dev_stats);
json_object_add_value_object(root, "Device stats", dev_stats);
json_print_object(root, NULL);
static void show_dapustor_smart_log(struct nvme_additional_smart_log *smart,
struct nvme_extended_additional_smart_log *ext_smart,
- unsigned int nsid, const char *devname)
+ unsigned int nsid, const char *devname, bool has_ext)
{
printf("Additional Smart Log for NVME device:%s namespace-id:%x\n",
devname, nsid);
printf("key normalized raw\n");
show_dapustor_add_smart_log(smart);
- show_dapustor_ext_add_smart_log(ext_smart);
+ if (has_ext)
+ show_dapustor_ext_add_smart_log(ext_smart);
}
static int dapustor_additional_smart_log_data(
int dev_fd,
struct nvme_additional_smart_log *smart_log,
- struct nvme_extended_additional_smart_log *ext_smart_log)
+ struct nvme_extended_additional_smart_log *ext_smart_log,
+ bool *has_ext)
{
int err;
return err;
}
err = nvme_get_log_simple(dev_fd, 0xcb, sizeof(*ext_smart_log), ext_smart_log);
- if (err)
- nvme_show_status(err);
- return err;
+ *has_ext = !err;
+ return 0;
}
static int dapustor_additional_smart_log(int argc, char **argv, struct command *cmd,
struct nvme_extended_additional_smart_log ext_smart_log;
struct nvme_dev *dev;
int err;
+ bool has_ext = false;
struct config {
uint32_t namespace_id;
if (err)
return err;
- err = dapustor_additional_smart_log_data(dev_fd(dev), &smart_log, &ext_smart_log);
+ err = dapustor_additional_smart_log_data(dev_fd(dev), &smart_log, &ext_smart_log, &has_ext);
if (!err) {
if (cfg.json)
show_dapustor_smart_log_jsn(&smart_log, &ext_smart_log,
- cfg.namespace_id, dev->name);
+ cfg.namespace_id, dev->name, has_ext);
else if (!cfg.raw_binary)
show_dapustor_smart_log(&smart_log, &ext_smart_log,
- cfg.namespace_id, dev->name);
+ cfg.namespace_id, dev->name, has_ext);
else
d_raw((unsigned char *)&smart_log, sizeof(smart_log));
}