NVMe Base 2.4: Namespace Management: capacity, creation, and attachment

18 minute read

繁體中文

00.01.Namespace Management manages host-visible storage. Creation determines capacity and format; attachment connects the namespace to a controller. Storage existing and being usable through a particular controller are distinct states.

controller
Controller, the entity that implements the NVMe interface, fetches commands, and reports completions.
namespace
Namespace, a formatted quantity of non-volatile memory accessed by a host through a controller.
Host
The system running the operating system and issuing NVMe commands.

The main ideas

01

Plan the storage object

01-01Separate capacity, format, and allocation granularity: how much addressable space is needed, how large each block is, and what allocation the controller recommends.

02

Move from creation to access

02-01Create makes a namespace and returns its identifier. Attach makes it accessible through selected controllers. Follow the distinct outcome of each command.

03

Separate disconnection from deletion

03-01Detach removes access through a controller; Delete removes the namespace. Restoring defaults has its own prerequisites and outcome.

04

Keep the host’s view current

04-01Creation, attachment, and deletion can change what controllers and hosts see. Follow notifications and refresh identification data.

Connecting the main ideas

00.02.Understand capacity and identifiers before preparing creation data. Successful Create returns an NSID; Attachment then establishes access. Configuration changes use Detach, Delete, or restoration of defaults as appropriate, with notifications to affected controllers.

NSID
Namespace Identifier, a controller-visible numeric handle for a namespace; the identifier is not the namespace object itself.

01 Capacity values and allocation granularity

01.01.Establish capacity units before comparing required capacity relationships with recommended allocation granularities. The former govern validity; the latter reduce wasted allocation.

Addressable, allocatable, and allocated are distinctExample: NSZE=1000, NCAP=800, NUSE=600. The LBA address range is distinct from current allocation.NSZE = 1000LBA 0 … 999NCAP = 800NUSE = 600
Example: NSZE=1000, NCAP=800, NUSE=600. The LBA address range is distinct from current allocation.
NCAP
Namespace Capacity, the maximum logical blocks that may be allocated to the namespace at any time.
NSZE
Namespace Size, the total logical-block count whose LBA range is zero through NSZE minus one.
NUSE
Namespace Utilization, the logical blocks currently allocated in the namespace.

01.02.Namespace Size (NSZE) is the total logical-block range from LBA zero through n minus one; Namespace Capacity (NCAP) is the maximum allocatable blocks at any time; and Namespace Utilization (NUSE) is the number currently allocated. NSZE is always at least NCAP, which is at least NUSE.

Sources: NVM Command Set 1.3 §2.1.1

Source: NVME-NVM-CS-1.3, Rev. 1.3, §2.1.1, printed pages 13-14, PDF pages 13-14

Capacity values and allocation granularity
Capacity fieldUnitQuantity described
NSZELogical blocksLBA 0 through NSZE−1
NCAPLogical blocksMaximum allocatable capacity
NUSELogical blocksTracked when THINP is one
NSG/NCGBytesA recommendation; failure to follow it alone cannot reject creation
THINP
Thin Provisioning, the NSFEAT bit governing whether NCAP may be below NSZE and whether the controller tracks NUSE.
NCG
Namespace Capacity Granularity, the controller's preferred NCAP allocation granularity in bytes.
NSG
Namespace Size Granularity, the controller's preferred NSZE allocation granularity in bytes.

02 Data required to create a namespace

02.01.Base Figure 448 defines a 4096-byte envelope, while NVM Command Set Figure 134 defines NVM fields and the Placement Handle List within the first 768 bytes. The host selects operation and command set through SEL/CSI, then fills NSZE, NCAP, format, protection, sharing, and group identifiers. Reserved regions are zeroed, while Protection Information and FDP have separate capability gates.

Protection Information
PI: protection fields containing a Guard and tags for checking data and its associated information.
CSI
I/O Command Set Identifier: selects an I/O command set; NVM uses 00h.
FDP
Flexible Data Placement, a capability connecting data-placement hints with media-reclamation management.
NVM
Non-Volatile Memory, memory that retains data without power.
SEL
Select; the Namespace Management create/delete/restore selector, distinct from Get Features SEL.

02.02.Create uses NSID zero, SEL 0h, and CSI 00h for the NVM Command Set. DPTR identifies a 4096-byte structure: bytes 0:511 are I/O-Command-Set-specific, 512:1023 are reserved, and 1024:4095 are vendor specific. The host clears reserved bytes to zero.

DPTR
Data Pointer, the SQE field identifying a command data buffer.
I/O
Input/Output, the class of data operations performed on a namespace.
Sources: Base 2.4 §5.2.25

Source: NVME-BASE-2.4, Rev. 2.4, §5.2.25, printed pages 446-448, PDF pages 472-474

Data required to create a namespace
Region and interpretationPurposeConditions for field validity
Base 0:511SIOCSNVM-specific create data
Base 512:1023ReservedHost clears to zero
Base 1024:4095Vendor SpecificDo not invent a meaning
NVM 512:767Placement Handle ListValidated only when FDP is enabled
SIOCS
Specified I/O Command Set, the Base create-buffer region at bytes 0:511 containing fields for the selected I/O Command Set.

03 Creating, attaching, and using a namespace

03.01.Create, Attach, Detach, and Delete change two dimensions: whether the namespace is allocated and whether a controller is attached. After Create returns NSID in CQE DW0, the object is allocated but no controller is attached. A Controller List in Attach establishes access. Detach preserves capacity, while Delete makes the NSID unallocated.

CQE
Completion Queue Entry, one completion-result structure in a CQ.
From namespace creation to access
  1. Create the namespace and obtain its NSID.
  2. Attach the namespace to the selected controller.
  3. Use that controller’s Identify results to establish the namespace and format.
  4. I/O commands use NSID to select the namespace.
Creating a storage object and making it accessible through a controller are separate actions.

03.02.The complete Namespace Management capability consists of Namespace Management and Namespace Attachment. A supporting controller shall implement both, set OACS.NMS to one, and support the Attached Namespace Attribute Changed event; the Allocated event is a should, while Namespace Granularity and Restore Default are may capabilities.

OACS.NMS
The Namespace Management Supported bit in Optional Admin Command Support; one advertises the complete Manage-plus-Attach capability.
Sources: Base 2.4 §8.1.17

Source: NVME-BASE-2.4, Rev. 2.4, §8.1.17, printed pages 660, PDF pages 686

Creating, attaching, and using a namespace
Management actionObject or relationship changedWhat remains afterward
CreateObject/capacityDoes not attach automatically
AttachAccess relationshipController List may contain multiple CNTLIDs
DetachController-local active stateNamespace remains allocated
DeleteSubsystem inventoryNSID becomes unallocated

04 Deletion and restoration of default configuration

04.01.Delete All and Restore Default are different operations. Delete with NSID FFFFFFFFh succeeds even when no namespaces exist. Restore Default requires RDNCS, SEL 2h, and an empty subsystem inventory. Before successful completion, the controller applies defaults for the current active firmware image and sets DNCS to one.

RDNCS
Restore Default Namespace Configuration Supported, the capability bit advertising the Restore Default operation.
DNCS
Default Namespace Configuration Status, indicating whether the namespace configuration matches the active firmware image defaults.

04.02.Delete NSID selects a created namespace, while FFFFFFFFh means delete all and succeeds even when no namespace exists. Delete removes the namespace and has a detach side effect; the host should detach it from every controller first so events and outstanding-I/O behavior remain controlled.

Sources: Base 2.4 §5.2.25, 8.1.17.1

Source: NVME-BASE-2.4, Rev. 2.4, §5.2.25, 8.1.17.1, printed pages 446, 448, 662, PDF pages 472, 474, 688

Deletion and restoration of default configuration
Deletion or restorationTarget selectionEstablishing the resulting configuration
Delete oneNSID=targetObject is gone after success
Delete allNSID=FFFFFFFFhSucceeds with zero namespaces
RestoreSEL=2h, NSID ignoredRemaining namespace→Sequence Error
Post-conditionDNCS=1Refresh Identify for actual defaults

05 Namespace change notifications and rediscovery

05.01.Attached and Allocated Namespace Attribute Changed notices correspond to different inventories. Create normally changes the Allocated list, Attach/Detach changes the Active list, and Delete may change both. The event code is not the new list, so the host reissues Identify with the appropriate CNS. Delete reporting also distinguishes the processing controller from other controllers.

CNS
Controller or Namespace Structure: the Identify selector for a response data structure.

05.02.Create changes the Allocated Namespace ID list, attach/detach changes the Active Namespace ID list, and delete may change both. When the corresponding notice is enabled, the host reissues Identify after the asynchronous event rather than inferring inventory from the event code alone. Section 8.1.17.2 distinguishes the controller processing delete from the other controllers.

Sources: Base 2.4 §8.1.17.1-8.1.17.2

Source: NVME-BASE-2.4, Rev. 2.4, §8.1.17.1-8.1.17.2, printed pages 662-663, PDF pages 688-689

Namespace change notifications and rediscovery
Notice or inventoryChange describedInformation to refresh
CNS 02hActive Namespace ID listAttached notice
CNS 10hAllocated Namespace ID listAllocated notice
CreateAllocated changeNew NSID is not yet active
DeleteAllocated and possibly ActiveProcessing-controller rule differs

Where to continue in the specification

06.01.Use the flow above to frame the problem, then open the corresponding sections for fields and full conditions. The Chinese tutorial also explains every in-scope figure with its takeaway, example, and details.

Concept to explainSpecification sections
Capacity values and allocation granularityNVM 1.3 §2.1.1 · Base 2.4 §8.1.17 · NVM 1.3 §5.8
Data required to create a namespaceBase 2.4 §5.2.25 · NVM 1.3 §4.1.6.4 · NVM 1.3 §4.1.6.2 · NVM 1.3 §4.1.6.3 · Base 2.4 §8.1.17
Creating, attaching, and using a namespaceBase 2.4 §8.1.17 · Base 2.4 §5.2.24 · Base 2.4 §5.2.25, 8.1.17.1
Deletion and restoration of default configurationBase 2.4 §5.2.25, 8.1.17.1 · Base 2.4 §5.2.25.1 · Base 2.4 §8.1.17.1-8.1.17.2
Namespace change notifications and rediscoveryBase 2.4 §8.1.17 · Base 2.4 §8.1.17.1-8.1.17.2 · Base 2.4 §5.2.25, 8.1.17.1 · Base 2.4 §5.2.24-5.2.25
Open the complete Chinese tutorial and figure explanations →

Check your understanding

1. Why does a successful Namespace Create returning an NSID not establish I/O access through a controller?

07.01.Create establishes the namespace; Attachment determines which controllers can access it. Attachment, Identify visibility, format, and availability still require confirmation.

Sources

Source: NVME-BASE-2.4, Rev. 2.4, §5.2.25, 8.1.17.1, printed pages 446-448, 662, PDF pages 472-474, 688

Source: NVME-BASE-2.4, Rev. 2.4, §5.2.24, printed pages 444-445, PDF pages 470-471

2. Why distinguish a namespace granularity hint from rounding in media allocation?

07.02.A hint helps the host choose a suitable size or capacity; rounding describes resources that actual allocation may consume. A hint is not an extra command-validity restriction, and capacity planning must account for more than the requested values.

Sources

Source: NVME-BASE-2.4, Rev. 2.4, §8.1.17, printed pages 661, PDF pages 687

Source: NVME-NVM-CS-1.3, Rev. 1.3, §5.8, printed pages 165, PDF pages 165

3. Does Restore Default Namespace recover the original data of a deleted namespace?

07.03.It concerns the default namespace configuration, not data recovery. Creation, deletion, and default-configuration operations do not guarantee preservation or recovery of prior data.

Sources

Source: NVME-BASE-2.4, Rev. 2.4, §5.2.25.1, printed pages 447-448, PDF pages 473-474

Source: NVME-BASE-2.4, Rev. 2.4, §5.2.25, 8.1.17.1, printed pages 446, 448, 662, PDF pages 472, 474, 688

Specification editions

NVM Express NVM Command Set Specification, Revision 1.3

NVM Express Base Specification, Revision 2.4

Jia-Chang

Jia-Chang

Human

Comments

  Write a comment ...