]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
nvme-cli: Add namespace-id option to self-test-log
authorRevanth Rajashekar <revanth.rajashekar@intel.com>
Thu, 26 Sep 2019 16:34:20 +0000 (10:34 -0600)
committerRevanth Rajashekar <revanth.rajashekar@intel.com>
Thu, 26 Sep 2019 16:34:20 +0000 (10:34 -0600)
Instead of scanning all the namespaces for logs, the user can specify
the namespace from which he wants to retrieve the self-test log from.

Signed-off-by: Revanth Rajashekar <revanth.rajashekar@intel.com>
nvme-ioctl.c
nvme-ioctl.h
nvme.c

index 69599763bf97c3b632e6db8caa6143ec82827a78..35df04d40da66b8ac9125fd9f2a64e8c109ac3ca 100644 (file)
@@ -523,9 +523,9 @@ int nvme_ana_log(int fd, void *ana_log, size_t ana_log_len, int rgo)
                        true, ana_log_len, ana_log);
 }
 
-int nvme_self_test_log(int fd, struct nvme_self_test_log *self_test_log)
+int nvme_self_test_log(int fd, __u32 nsid, struct nvme_self_test_log *self_test_log)
 {
-       return nvme_get_log(fd, NVME_NSID_ALL, NVME_LOG_DEVICE_SELF_TEST, false,
+       return nvme_get_log(fd, nsid, NVME_LOG_DEVICE_SELF_TEST, false,
                sizeof(*self_test_log), self_test_log);
 }
 
index 565f7648e539120c4fac2801bd4e259483570b55..d784818295ef8716627a1643066102bf6089fe40 100644 (file)
@@ -153,6 +153,6 @@ int nvme_get_property(int fd, int offset, uint64_t *value);
 int nvme_sanitize(int fd, __u8 sanact, __u8 ause, __u8 owpass, __u8 oipbp,
                  __u8 no_dealloc, __u32 ovrpat);
 int nvme_self_test_start(int fd, __u32 nsid, __u32 cdw10);
-int nvme_self_test_log(int fd, struct nvme_self_test_log *self_test_log);
+int nvme_self_test_log(int fd, __u32 nsid, struct nvme_self_test_log *self_test_log);
 int nvme_virtual_mgmt(int fd, __u32 cdw10, __u32 cdw11, __u32 *result);
 #endif                         /* _NVME_LIB_H */
diff --git a/nvme.c b/nvme.c
index 7bf2a50fb0947cd9223bd92d5b82a90fce0d7ee8..8b69f3d13a32ab10aa9f4c813836abc02994768c 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -2152,17 +2152,22 @@ static int self_test_log(int argc, char **argv, struct command *cmd, struct plug
        const char *desc = "Retrieve the self-test log for the given device and given test "\
                        "(or optionally a namespace) in either decoded format "\
                        "(default) or binary.";
+       const char *namespace_id = "Indicate the namespace from which the self-test "\
+                                   "log has to be obtained";
        int err, fmt, fd;
 
        struct config {
+               __u32 namespace_id;
                char *output_format;
        };
 
        struct config cfg = {
+               .namespace_id = NVME_NSID_ALL,
                .output_format = "normal",
        };
 
        OPT_ARGS(opts) = {
+               OPT_UINT("namespace-id", 'n', &cfg.namespace_id,  namespace_id),
                OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
                OPT_END()
        };
@@ -2179,7 +2184,7 @@ static int self_test_log(int argc, char **argv, struct command *cmd, struct plug
                goto close_fd;
        }
 
-       err = nvme_self_test_log(fd, &self_test_log);
+       err = nvme_self_test_log(fd, cfg.namespace_id, &self_test_log);
        if (!err) {
                if (self_test_log.crnt_dev_selftest_oprn == 0) {
                        if (fmt == BINARY)