From 2fb0b1517fc6ed43efe21d9d516df992c83cd141 Mon Sep 17 00:00:00 2001 From: chrfranke <chrfranke@4ea69e1a-61f1-4043-bf83-b5c94c648137> Date: Fri, 29 Mar 2024 15:49:11 +0000 Subject: [PATCH] nvmeprint.cpp: Fix self-test for single namespace devices. Use broadcast NSID if only one namespace is supported (#1741, GH issues/217). smartctl.8.in: Document new behavior. git-svn-id: https://svn.code.sf.net/p/smartmontools/code/trunk@5603 4ea69e1a-61f1-4043-bf83-b5c94c648137 --- smartmontools/ChangeLog | 7 +++++++ smartmontools/nvmeprint.cpp | 9 +++++++-- smartmontools/smartctl.8.in | 9 ++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/smartmontools/ChangeLog b/smartmontools/ChangeLog index 624931548..53869aeb6 100644 --- a/smartmontools/ChangeLog +++ b/smartmontools/ChangeLog @@ -1,5 +1,12 @@ $Id$ +2024-03-29 Christian Franke <franke@computer.org> + + nvmeprint.cpp: Fix self-test for single namespace devices. + Use broadcast NSID if only one namespace is supported + (#1741, GH issues/217). + smartctl.8.in: Document new behavior. + 2024-03-28 Christian Franke <franke@computer.org> drivedb.h: diff --git a/smartmontools/nvmeprint.cpp b/smartmontools/nvmeprint.cpp index dd5d49b18..c8d373a62 100644 --- a/smartmontools/nvmeprint.cpp +++ b/smartmontools/nvmeprint.cpp @@ -3,7 +3,7 @@ * * Home page of code is: https://www.smartmontools.org * - * Copyright (C) 2016-23 Christian Franke + * Copyright (C) 2016-24 Christian Franke * * SPDX-License-Identifier: GPL-2.0-or-later */ @@ -751,7 +751,12 @@ int nvmePrintMain(nvme_device * device, const nvme_print_options & options) // Check for self-test support bool self_test_sup = !!(id_ctrl.oacs & 0x0010); - unsigned self_test_nsid = device->get_nsid(); // TODO: Support NSID=0 to test controller + + // Use broadcast NSID for self-tests if only one namespace is supported. + // Some single namespace devices return failure if NSID=1 is used to + // address self-tests. + // TODO: Support NSID=0 to test controller + unsigned self_test_nsid = (id_ctrl.nn == 1 ? 0xffffffff : device->get_nsid()); // Read and print Self-test log, check for running test int self_test_completion = -1; diff --git a/smartmontools/smartctl.8.in b/smartmontools/smartctl.8.in index 398a5f74f..8e35bd2b3 100644 --- a/smartmontools/smartctl.8.in +++ b/smartmontools/smartctl.8.in @@ -1,6 +1,6 @@ .ig Copyright (C) 2002-10 Bruce Allen -Copyright (C) 2004-23 Christian Franke +Copyright (C) 2004-24 Christian Franke SPDX-License-Identifier: GPL-2.0-or-later @@ -1477,6 +1477,13 @@ test terminology). .I selftest \- [NVMe: NEW EXPERIMENTAL SMARTCTL 7.4 FEATURE] prints the NVMe self-test log. +.br +[NEW EXPERIMENTAL SMARTCTL 7.5 FEATURE] +If the device does not support multiple namespaces, the broadcast namespace +is always used to read the self-test log and to start the tests (see +\*(Aq\-t TEST\*(Aq below). +This is because some single namespace devices return failure if namespace 1 +is used to address self-tests. .\" %ENDIF OS Darwin FreeBSD Linux NetBSD Windows Cygwin .Sp .I xselftest[,NUM][,selftest] -- GitLab