From c9c7a8889a6dd515efea1aa5477dc368c9f89302 Mon Sep 17 00:00:00 2001 From: ekohande Date: Wed, 18 Sep 2019 18:20:34 -0700 Subject: [PATCH] Correct self-test-log output 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 --- nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvme.c b/nvme.c index aa7fa1eb..1cd62f85 100644 --- 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) -- 2.50.1