]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
Correct self-test-log output
authorekohande <abe.kohandel@intel.com>
Thu, 19 Sep 2019 01:20:34 +0000 (18:20 -0700)
committerekohande <abe.kohandel@intel.com>
Thu, 19 Sep 2019 06:23:44 +0000 (23:23 -0700)
Changes determination of Device Self-Test in progress to be based on the
Current Device Self-Test Operation field as opposed to the Current
Device Self-Test Completion field.

Current implementation assumes that the Current Device Self-Test
Completion field will be 100% when no Device Self-Test operation is in
progress. This is an unsafe assumption as the NVMe Specification
explicitly specifies that the Current Device Self-Test Completion field
is invalid when no Device Self-Test operation in progress as indicated
by a value of 0 in the Current Device Self-Test Operation field.

A safe assumption is to use the Current Device Self-Test Operation field
which will be 0 when no Device Self-Test operation is in progress.

Signed-off-by: ekohande <abe.kohandel@intel.com>
nvme.c

diff --git a/nvme.c b/nvme.c
index aa7fa1eb5dcbbf77f9eef22d9a661b8363b8050c..1cd62f852c35f77179914ed34e660819c48701d8 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -2178,7 +2178,7 @@ static int self_test_log(int argc, char **argv, struct command *cmd, struct plug
 
        err = nvme_self_test_log(fd, &self_test_log);
        if (!err) {
-               if (self_test_log.crnt_dev_selftest_compln == 100) {
+               if (self_test_log.crnt_dev_selftest_oprn == 0) {
                        if (fmt == BINARY)
                                d_raw((unsigned char *)&self_test_log, sizeof(self_test_log));
                        else if (fmt == JSON)