Skip to content

Commit

Permalink
Better nvme capability detection (#129)
Browse files Browse the repository at this point in the history
* utils/nvme: Parse nvme json output not human readable

JSON + bit twiddling is more likely to be future compatible (hopefully).
This library is not a human and thus should not use the human readable
output. I would say that json + bit fiddling is also easier to
understand than a regex based state machine.

* utils/nvme: Use nvme cli internal names for capabilities

These dynamic/generated names don't really work as can probably be
noticed by adding the `fna` and `sanicap` synthetic capabilities. They
don't work because nvme gives different output for enabled/disable,
supported/unsupported, all/single capabilities. So we end up with
enabled/disabled is detected by presence vs absence and we have to look
up two "different" capabilities to determine the status of an _actual_
capability.

So instead of doing that dynamic name we just use the internal nvme
identifiers seen in `nvme-print-stdout.c` at this point in time. We will
not change them later if nvme changes them internally. This way we end
up being more likely to be future proof. It would be much easier for
nvme-cli to tweak the string returned in the human readable output than
it would be for the linux kernel to change meaning of bits returned in
the ioctl call.

* utils/nvme: Get rid of fake nvme capabilities fna and sanicap

These don't really tell much to callers, considering we have a better
breakdown of what fna and sanicap mean so lets just drop it.

* utils/nvme: Explicitly test parsing fna and sanicap values

Better to test explicitly for all expected cases than implicitly/by
proxy from the other tests.
  • Loading branch information
mmlb authored Apr 30, 2024
1 parent 604784c commit 8d28858
Show file tree
Hide file tree
Showing 4 changed files with 377 additions and 424 deletions.
20 changes: 8 additions & 12 deletions fixtures/dell/r6515.go
Original file line number Diff line number Diff line change
Expand Up @@ -1782,20 +1782,16 @@ var (
}

nvmeDriveCapabilities = []*common.Capability{
{Name: "sanicap", Description: "Sanitize Support"},
{Name: "ammasocsind", Description: "Additional media modification after sanitize operation completes successfully is not defined"},
{Name: "nasbiscs", Description: "No-Deallocate After Sanitize bit in Sanitize command Supported"},
{Name: "osons", Description: "Overwrite Sanitize Operation Not Supported"},
{Name: "besons", Description: "Block Erase Sanitize Operation Not Supported"},
{Name: "cesons", Description: "Crypto Erase Sanitize Operation Not Supported"},
{Name: "fna", Description: "Crypto Erase Support", Enabled: true},
{Name: "cesapose", Description: "Crypto Erase Supported as part of Secure Erase", Enabled: true},
{Name: "ceatsn", Description: "Crypto Erase Applies to Single Namespace(s)"},
{Name: "fatsn", Description: "Format Applies to Single Namespace(s)"},
{Name: "fmns", Description: "Format Applies to All/Single Namespace(s) (t:All, f:Single)"},
{Name: "cens", Description: "Crypto Erase Applies to All/Single Namespace(s) (t:All, f:Single)"},
{Name: "cese", Description: "Crypto Erase Supported as part of Secure Erase", Enabled: true},
{Name: "cer", Description: "Crypto Erase Sanitize Operation Supported"},
{Name: "ber", Description: "Block Erase Sanitize Operation Supported"},
{Name: "owr", Description: "Overwrite Sanitize Operation Supported"},
{Name: "ndi", Description: "No-Deallocate After Sanitize bit in Sanitize command Supported"},
}

//
// // r6515 inventory taken with lshw, merged with data from smartctl
// r6515 inventory taken with lshw, merged with data from smartctl
R6515_inventory_lshw_smartctl = &common.Device{
Common: common.Common{
Oem: false,
Expand Down
Loading

0 comments on commit 8d28858

Please sign in to comment.