Project

General

Profile

Actions

Feature #14709

closed

nvmeadm list should be able to distinguish between inactive and ignored namespaces

Added by Hans Rosenfeld 3 months ago. Updated 2 months ago.

Status:
Closed
Priority:
Normal
Category:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

Namespaces in a NVMe controller can be in various states:

  • active (attached to the controller)
  • allocated (inactive, not attached to the controller)
  • unallocated

At this time, the nvme driver only distinguishes between usable and "ignored" namespaces. Namespaces are "ignored" when they have invalid properties such as a size of 0 blocks or a 0 blocksize, which happens when a namespace is unallocated or inactive as the "IDENTIFY NAMESPACE" structure returned by the hardware is zero-filled. In a few cases, an active namespace will be ignored because it has properties the driver can't handle, such as having been formatted with protection information.

Right now this doesn't matter much, but with support for namespace management we'll need to be able to distinguish between these states as some operations will change the state and other operations require a namespace to be in a particular state to even work.

So in preparation for namespace management, it would be nice if nvme would track the namespace state and nvmeadm would query it. Until the namespace management support is added to nvme, nvme will consider all known namespaces to be allocated, and all namespaces with non-zero IDENTIFY data to be active.

As a rework of the nvme_is_ignored() function in nvmeadm has been requested in #14550, it will be replaced by a more general nvme_ns_state() function. For now, four state bits will be defined:
  • NVME_NS_STATE_ALLOCATED: the namespace is allocated in the NVMe subsystem
  • NVME_NS_STATE_ACTIVE: the namespace is active (attached to this NVMe controller)
  • NVME_NS_STATE_ATTACHED: the driver has attached a blkdev instance to this namespace
  • NVME_NS_STATE_IGNORED: the driver is ignoring this namespace
"nvmeadm list" will use this to print the following namespace states:
  • "unallocated", if only the IGNORED bit is set
  • "unattached", if neither ATTACHED nor IGNORED are set while ACTIVE is
  • "ignored", if IGNORED is set, ATTACHED isn't set, and ACTIVE is
  • "inactive", if ACTIVE isn't set while ALLOCATED is
  • "invalid state", for any other combination of state bits

If the ATTACHED bit is set, the blkdev cXtXdX is printed instead of just "attached", just as it did before.

Actions #1

Updated by Electric Monk 3 months ago

  • Gerrit CR set to 2060
Actions #2

Updated by Hans Rosenfeld 3 months ago

Here's an example of the new "nvmeadm list" output:

# nvmeadm detach nvme24/3
# nvmeadm list nvme24
nvme24: model: SAMSUNG MZWLL1T6HAJQ-00005, serial: S4C9NA0N402658, FW rev: GPJA3B3Q, NVMe v1.2
  nvme24/1 (c26t344339304E4026580025384100000001d0): Size = 1048576 MB, Capacity = 1048576 MB, Used = 1048576 MB
  nvme24/2 (c26t344339304E4026580025384100000002d0): Size = 749568 MB, Capacity = 749568 MB, Used = 749568 MB
  nvme24/3 (unattached): Size = 16384 MB, Capacity = 16384 MB, Used = 16384 MB
# nvmeadm -v list nvme24
nvme24: model: SAMSUNG MZWLL1T6HAJQ-00005, serial: S4C9NA0N402658, FW rev: GPJA3B3Q, NVMe v1.2
  nvme24/1 (c26t344339304E4026580025384100000001d0): Size = 1048576 MB, Capacity = 1048576 MB, Used = 1048576 MB
  nvme24/2 (c26t344339304E4026580025384100000002d0): Size = 749568 MB, Capacity = 749568 MB, Used = 749568 MB
  nvme24/3 (unattached): Size = 16384 MB, Capacity = 16384 MB, Used = 16384 MB
  nvme24/4 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/5 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/6 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/7 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/8 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/9 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/10 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/11 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/12 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/13 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/14 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/15 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/16 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/17 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/18 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/19 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/20 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/21 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/22 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/23 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/24 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/25 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/26 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/27 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/28 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/29 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/30 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/31 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
  nvme24/32 (inactive): Size = 0 MB, Capacity = 0 MB, Used = 0 MB
Actions #3

Updated by Dan McDonald 2 months ago

Wasn't this pushed in commit baf9a8500e8914f180ede682c95a37266e1a4e37 ? If it was, please close this bug.

Actions #4

Updated by Hans Rosenfeld 2 months ago

  • Status changed from New to Closed
Actions

Also available in: Atom PDF