From: ekohande Date: Thu, 19 Sep 2019 01:20:34 +0000 (-0700) Subject: Correct self-test-log output X-Git-Tag: v1.10~75^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=c9c7a8889a6dd515efea1aa5477dc368c9f89302;p=users%2Fsagi%2Fnvme-cli.git 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 --- 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)