Skip to content

Commit

Permalink
nvmeprint.cpp: Fix self-test for single namespace devices.
Browse files Browse the repository at this point in the history
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/smartmontools@5603 4ea69e1a-61f1-4043-bf83-b5c94c648137
  • Loading branch information
chrfranke committed Mar 29, 2024
1 parent 2056285 commit 6689a3d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
$Id$

2024-03-29 Christian Franke <[email protected]>

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 <[email protected]>

drivedb.h:
Expand Down
9 changes: 7 additions & 2 deletions nvmeprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 8 additions & 1 deletion smartctl.8.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 6689a3d

Please sign in to comment.