Feature #14709


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

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

Start date:
Due date:
% Done:


Estimated time:
Gerrit CR:


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.


Also available in: Atom PDF