nvmecmds.cpp, nvmecmds.h, nvmeprint.cpp: Fix check for LPO support.

git-svn-id: http://svn.code.sf.net/p/smartmontools/code/trunk@5124 4ea69e1a-61f1-4043-bf83-b5c94c648137
pull/82/head
chrfranke 2 years ago
parent 186a68cfdb
commit e620922601
  1. 4
      smartmontools/ChangeLog
  2. 10
      smartmontools/nvmecmds.cpp
  3. 4
      smartmontools/nvmecmds.h
  4. 8
      smartmontools/nvmeprint.cpp

@ -1,5 +1,9 @@
$Id$
2020-12-04 Christian Franke <franke@computer.org>
nvmecmds.cpp, nvmecmds.h, nvmeprint.cpp: Fix check for LPO support.
2020-12-03 Christian Franke <franke@computer.org>
nvmeprint.cpp: Print NVMe version.

@ -202,12 +202,12 @@ static bool nvme_read_log_page_1(nvme_device * device, unsigned nsid,
// Read NVMe log page with identifier LID.
unsigned nvme_read_log_page(nvme_device * device, unsigned nsid, unsigned char lid,
void * data, unsigned size, bool nvme_121, unsigned offset /* = 0 */)
void * data, unsigned size, bool lpo_sup, unsigned offset /* = 0 */)
{
unsigned n, bs;
for (n = 0; n < size; n += bs) {
if (!nvme_121 && offset + n > 0) {
device->set_err(ENOSYS, "Log Page Offset requires NVMe >= 1.2.1");
if (!lpo_sup && offset + n > 0) {
device->set_err(ENOSYS, "Log Page Offset not supported");
break;
}
@ -225,10 +225,10 @@ unsigned nvme_read_log_page(nvme_device * device, unsigned nsid, unsigned char l
// Read NVMe Error Information Log.
unsigned nvme_read_error_log(nvme_device * device, nvme_error_log_page * error_log,
unsigned num_entries, bool nvme_121)
unsigned num_entries, bool lpo_sup)
{
unsigned n = nvme_read_log_page(device, 0xffffffff, 0x01, error_log,
num_entries * sizeof(*error_log), nvme_121);
num_entries * sizeof(*error_log), lpo_sup);
if (isbigendian()) {
for (unsigned i = 0; i < n; i++) {

@ -237,11 +237,11 @@ bool nvme_read_id_ns(nvme_device * device, unsigned nsid, smartmontools::nvme_id
// Read NVMe log page with identifier LID.
unsigned nvme_read_log_page(nvme_device * device, unsigned nsid, unsigned char lid,
void * data, unsigned size, bool nvme_121, unsigned offset = 0);
void * data, unsigned size, bool lpo_sup, unsigned offset = 0);
// Read NVMe Error Information Log.
unsigned nvme_read_error_log(nvme_device * device, smartmontools::nvme_error_log_page * error_log,
unsigned num_entries, bool nvme_121);
unsigned num_entries, bool lpo_sup);
// Read NVMe SMART/Health Information log.
bool nvme_read_smart_log(nvme_device * device, smartmontools::nvme_smart_log & smart_log);

@ -548,8 +548,8 @@ int nvmePrintMain(nvme_device * device, const nvme_print_options & options)
}
}
// Log Page Offset requires NVMe >= 1.2.1
bool nvme_121 = (id_ctrl.ver >= 0x10201);
// Check for Log Page Offset support
bool lpo_sup = !!(id_ctrl.lpa & 0x04);
// Print Error Information Log
if (options.error_log_entries) {
@ -561,7 +561,7 @@ int nvmePrintMain(nvme_device * device, const nvme_print_options & options)
nvme_error_log_page * error_log =
reinterpret_cast<nvme_error_log_page *>(error_log_buf.data());
unsigned read_entries = nvme_read_error_log(device, error_log, want_entries, nvme_121);
unsigned read_entries = nvme_read_error_log(device, error_log, want_entries, lpo_sup);
if (!read_entries) {
jerr("Read %u entries from Error Information Log failed: %s\n\n",
want_entries, device->get_errmsg());
@ -592,7 +592,7 @@ int nvmePrintMain(nvme_device * device, const nvme_print_options & options)
break;
}
unsigned read_bytes = nvme_read_log_page(device, nsid, options.log_page, log_buf.data(),
size, nvme_121);
size, lpo_sup);
if (!read_bytes) {
jerr("Read NVMe Log 0x%02x failed: %s\n\n", options.log_page, device->get_errmsg());
return retval | FAILSMART;

Loading…
Cancel
Save