NVMe Persistent Reservations protect shared clustered volumes by enforcing hardware-level access keys and fencing rules directly inside the NVMe controller. Each cluster node registers a unique reservation key via nvme resv commands, allowing the surviving node to preempt and fence a stalled peer during a network split. Controller-enforced fencing prevents simultaneous writes from corrupting shared databases or clustered filesystems.
Preventing Split-Brain Corruption with NVMe Persistent Reservations
When two or more compute nodes mount the same shared NVMe namespace over dual-port PCIe or NVMe-oF, a network partition can trick both hosts into believing they own the volume. NVMe persistent reservations enforce hardware-level I/O fencing inside the controller silicon so stale nodes are rejected immediately with reservation conflict status codes before corrupting metadata.
Core NVMe PR Stack: nvme resv-register, nvme resv-acquire, nvme resv-report, Write Exclusive (WE) / Exclusive Access (EA) modes, HostID 128-bit tokens, sanlock & Pacemaker fence_scsi/PR
Shared dual-port or NVMe-oF namespaces expose clustered databases to silent LBA corruption whenever heartbeat links fail and both nodes assume ownership. Software cluster locks cannot stop in-flight DMA writes from a stalled kernel. Learn how to register unique HostIDs, preempt failed peers, and integrate Pacemaker fencing.
During asymmetric network partitions, an evicted node with live storage paths can replay journals and corrupt shared filesystem extents.
Each cluster member requires a distinct 128-bit HostID and matching Write Exclusive or Exclusive Access reservation policy across multipath links.
Verify reservation capabilities, register node keys with nvme resv-register, and automate preemption through Pacemaker or sanlock fencing agents.
How NVMe Persistent Reservations Stop Split-Brain Disk Corruption
Traditional SCSI-3 Persistent Reservations (PR) required an external SAS expander or Fibre Channel array to track initiator World Wide Names (WWNs) and reservation keys. NVMe natively embeds equivalent semantics into the NVMe command set through four dedicated admin/I/O commands: Reservation Register (opcode 0x0D), Reservation Report (opcode 0x0E), Reservation Acquire (opcode 0x11), and Reservation Release (opcode 0x15).
Hardware-Level I/O Fencing Inside the NVMe Controller
When a dual-port NVMe drive or an NVMe-oF subsystem exposes a shared namespace (NSID) with Reservations enabled (ONCS bit 5 and RESCAP capability flags set in the Identify Namespace data structure), the controller maintains a persistent table in non-volatile metadata. This table stores every registered 64-bit Reservation Key (CRKEY / NRKEY) mapped to each host’s 128-bit Host Identifier (HostID), along with the active reservation type and the current reservation holder.
Crucially, these reservation tables survive controller resets and power cycles when the Persist Through Power Loss (PTPL) bit is set during registration. If Node A loses quorum or experiences a 20-second NMI stall, Node B issues a Preempt action through Reservation Acquire, atomically stripping Node A’s key from the controller table. Any delayed I/O commands still sitting in Node A’s kernel blk-mq queues or PCIe rings immediately fail at the controller with NVMe status code 0x83 (Reservation Conflict), which the Linux NVMe driver surfaces upstream as an EACCES or EBADE I/O error rather than allowing silent block overwrites.
Dual-Port PCIe vs. NVMe-oF Shared Namespace Topologies
Before deploying reservations, verify that your hardware actually supports multi-host visibility and reservation state synchronization:
- Dual-Port U.2 / U.3 / E3.S Enterprise SSDs: Two independent PCIe Gen4/Gen5 root complexes connect to Port A and Port B of the same NVMe controller. Both hosts see the identical namespace EUI-64/NGUID and share a single internal reservation state machine.
- NVMe-oF Targets (TCP or RDMA): A Linux
nvmetkernel target or Intel SPDK user-space NVMe target exports a local namespace or logical volume to multiple remote initiators. The target daemon enforces reservation keys across all connected host NQNs. - Multi-Path ANA Clusters: When each host connects over redundant network paths, Asymmetric Namespace Access (ANA) groups coordinate path states alongside reservations. Pair PR fencing with NVMe/TCP ANA multipathing failover so path-switching never triggers false-positive reservation conflicts.
Comparing NVMe Reservation Types, Registrants, and Preemption Semantics
The NVMe specification defines six reservation types that govern whether non-holder hosts—and unregistered hosts—may read or write to the namespace. Selecting the wrong mode either breaks read-only standby monitoring or leaves the volume vulnerable to unauthenticated writes.
NVMe Reservation Type (RTYPE) |
Read Access Policy | Write Access Policy | Primary Cluster Use Case |
|---|---|---|---|
Write Exclusive (0x01) |
All hosts (even unregistered) may read | Only the single reservation holder | Active-passive DBs needing standby reads |
Exclusive Access (0x02) |
Only the single reservation holder | Only the single reservation holder | Strict single-mount XFS/ext4 failover |
Write Exclusive – Registrants Only (0x03) |
All hosts may read | Any currently registered host | Clustered filesystems (GFS2, OCFS2) |
Exclusive Access – Registrants Only (0x04) |
Any currently registered host | Any currently registered host | Multi-writer hypervisor datastores |
Write Exclusive – All Registrants (0x05) |
All hosts may read | Every registered host (no single holder) | Shared-disk quorum with dynamic fencing |
Exclusive Access – All Registrants (0x06) |
Every registered host | Every registered host | Zero-unregistered-access shared clusters |
Registrants-Only vs. All-Registrants Persistence Behavior
The distinction between Registrants Only (0x03/0x04) and All Registrants (0x05/0x06) matters during node restarts. Under Registrants Only, one specific host holds the reservation; if that holder unregisters cleanly or is preempted without replacement, the reservation drops unless another node takes over. Under All Registrants, every registered host is collectively a holder, so the reservation remains active as long as at least one cluster member remains registered in the controller table.
Configuring Unique HostIDs and Managing Reservations with nvme-cli
Before issuing any reservation command, every server in the cluster must present a distinct 128-bit HostID to the NVMe controller. If two nodes share a cloned OS image with an identical /etc/nvme/hostid, the controller cannot distinguish between them and treats both as the same registrant—completely defeating split-brain protection.
Verifying Controller Reservation Capabilities and Host Identifiers
First, inspect the namespace’s RESCAP (Reservation Capabilities) byte and ensure each cluster node has a unique UUID in /etc/nvme/hostid and /etc/nvme/hostnqn. On local PCIe dual-port drives, the Linux kernel also reads or sets the Host Identifier via Set Features (FID 0x81) during probe.
# 1. Verify unique HostID and HostNQN on each cluster node (must differ across nodes!)
cat /etc/nvme/hostid
cat /etc/nvme/hostnqn
# If cloned, regenerate immediately on Node B:
sudo systemd-machine-id-setup
sudo nvme gen-hostnqn | sudo tee /etc/nvme/hostnqn
sudo uuidgen | sudo tee /etc/nvme/hostid
# 2. Check namespace reservation support (rescap != 0 and bitmask confirms PR types)
sudo nvme id-ns /dev/nvme0n1 -H | grep -E "rescap|ptpl|we|ea|wero|earo|wear|eaar"
# 3. Inspect current Host Identifier feature on the controller (FID 0x81)
sudo nvme get-feature /dev/nvme0 -f 0x81 -H
Registering Keys, Acquiring Exclusive Access, and Preempting Stale Peers
Once rescap confirms support (for example, rescap: 0xfe), Node A registers a 64-bit key (such as 0x1001) with Persist Through Power Loss enabled (--cptpl=2), acquires an Exclusive Access (--rtype=2) or Write Exclusive (--rtype=1) reservation, and verifies the controller’s reservation report.
# On Node A: Register key 0x1001 with Persist Through Power Loss (cptpl=2)
sudo nvme resv-register /dev/nvme0n1 --nrkey=0x1001 --rrega=0 --cptpl=2
# On Node A: Acquire Exclusive Access (rtype=2, racqa=0)
sudo nvme resv-acquire /dev/nvme0n1 --crkey=0x1001 --rtype=2 --racqa=0
# On Node B: Register its own key 0x1002
sudo nvme resv-register /dev/nvme0n1 --nrkey=0x1002 --rrega=0 --cptpl=2
# Inspect active reservation holder and all registered HostIDs from either node
sudo nvme resv-report /dev/nvme0n1 -H
# Failover test: If Node A hangs, Node B atomically preempts Node A's key (0x1001)
# racqa=1 (Preempt), prkey=0x1001 (victim key), crkey=0x1002 (Node B key)
sudo nvme resv-acquire /dev/nvme0n1 --crkey=0x1002 --prkey=0x1001 --rtype=2 --racqa=1
Notice that after Node B executes --racqa=1 (Preempt), nvme resv-report shows only Node B’s 0x1002 key holding the reservation. Any write issued from Node A immediately returns Input/output error in user space and logs Reservation Conflict in dmesg.
Integrating NVMe PR with Pacemaker, LVM lvmlockd, and Multipath Failover
Manual nvme-cli commands are essential for validation, but production clusters automate key registration and preemption through cluster resource managers. Linux’s kernel block layer exposes generic PR ioctls (IOC_PR_REGISTER, IOC_PR_RESERVE, IOC_PR_PREEMPT) directly on /dev/nvme*n* devices, allowing user-space cluster daemons to manage NVMe reservations identically to SCSI PR.
LVM Shared Volume Groups and Pacemaker Fencing Agents
When running clustered LVM (lvmlockd paired with sanlock or dlm) or Pacemaker active-passive database stacks, configure your fencing agent to issue NVMe PR preemptions alongside power-off IPMI fencing. Power fencing takes seconds to drop a BMC chassis, whereas an NVMe PR preemption blocks storage writes in under 100 microseconds. Combining both ensures zero window for in-flight PCIe writes to land on NAND while the dead node’s motherboard powers down.
If your cluster mounts namespaces through Linux native NVMe multipathing (nvme_core.multipath=Y), always target the multipath head device (/dev/nvme0n1) rather than individual controller path nodes (/dev/nvme0c0n1). The kernel multipath driver routes PR ioctls across the active Optimized ANA path and automatically preserves registration state if a secondary NIC or switch port drops.
Production Guardrails for Clustered NVMe Reservation Topologies
Enforce Unique 128-Bit HostIDs
Never clone OS images across cluster nodes without regenerating /etc/nvme/hostid and /etc/nvme/hostnqn; duplicate HostIDs merge key tables and break fencing.
Always Set PTPL Persist Mode
Pass --cptpl=2 when registering keys so a sudden PSU brownout or target controller reboot does not wipe active fences and expose volumes to evicted hosts.
Pre-Register Standby Nodes
Register every cluster member’s key at boot so a failover node can issue an atomic Preempt without first racing to register during a quorum crisis.
Pair PR with IPMI Power Fencing
NVMe PR protects the disk immediately, but a fenced node may still hold stale VIPs or cache state; pair storage fencing with out-of-band BMC power-off.
Resolving Reservation Conflicts, Stale Keys, and Safe Cluster Rollback
When a host is fenced or rebooted uncleanly, its kernel and systemd services may fail to mount filesystems or activate LVM volumes because the NVMe controller still rejects its I/O with Reservation Conflict errors.
Diagnosing Status Code 0x83 and Orphaned Controller Keys
nvme0n1: I/O Cmd(0x02) @ LBA 0, 8 blocks, I/O Error (sct 0x0 / sc 0x83): Status code0x83confirms an active NVMe Reservation Conflict. Runnvme resv-report /dev/nvme0n1 -Hfrom a healthy node to see which HostID currently holds the exclusive reservation.Invalid Field in Commandduringresv-register: Either the drive firmware lacks PR support (rescap == 0), or you attempted--rrega=0(Register) while a key is already registered for that HostID. Use--rrega=2(Replace) or--iekey(Ignore Existing Key) to overwrite a stale local key.resv-acquirefails withReservation Conflict: Your host key is not registered yet, or you specified the wrong--rtypewhen trying to upgrade an existing reservation held by a peer. Use--racqa=1(Preempt) with the peer’s--prkey.
Clearing Stale Reservations and Rolling Back to Unfenced Access
During planned maintenance—such as migrating a clustered namespace back to single-host standalone mode—ensure all peer nodes have unmounted the device, then release the reservation and clear all keys cleanly.
# 1. Verify no active mounts or LVM locks exist on the shared namespace
findmnt /dev/nvme0n1
sudo dmsetup ls
# 2. Release active reservation held by key 0x1002 (rtype=2)
sudo nvme resv-release /dev/nvme0n1 --crkey=0x1002 --rtype=2 --rrela=0
# 3. Or perform an emergency Clear of ALL keys and reservations from a registered node
sudo nvme resv-release /dev/nvme0n1 --crkey=0x1002 --rrela=1 --iekey
# 4. Unregister the remaining local key (rrega=1, nrkey=0) and confirm empty table
sudo nvme resv-register /dev/nvme0n1 --crkey=0x1002 --nrkey=0 --rrega=1
sudo nvme resv-report /dev/nvme0n1 -H
Frequently Asked Questions
Do consumer or single-port M.2 NVMe SSDs support NVMe persistent reservations?
Rarely. Most consumer M.2 drives report rescap: 0 because they only expose a single PCIe port to a single host. NVMe persistent reservations are standard on dual-port enterprise U.2/U.3/E3.S drives and software-defined NVMe-oF targets.
Does Linux block layer caching bypass NVMe reservation checks?
Any dirty pages flushed from the page cache or issued via O_DIRECT must be transmitted as NVMe Write commands to the controller, where they are immediately rejected with status 0x83. However, stale clean reads in a fenced node’s RAM remain until unmounted, which is why active-passive clusters unmount or fence the node.
What is the difference between Preempt (racqa=1) and Preempt and Abort (racqa=2)?
Preempt removes the victim’s key and transfers the reservation immediately. Preempt and Abort additionally instructs the NVMe controller to abort any in-flight commands currently queued from the preempted HostID, preventing queued writes from completing after fencing.
Can I use NVMe persistent reservations across NVMe/TCP and RDMA targets?
Yes. Modern Linux kernel nvmet subsystems (kernel 6.x+) and SPDK NVMe-oF targets support full reservation key tracking across multiple initiator HostNQNs over both NVMe/TCP and NVMe/RDMA fabrics.
What happens if a cluster node reboots without releasing its NVMe persistent reservation key?
The NVMe controller retains registered keys and active reservation state across host reboots and even drive power cycles when Persist Through Power Loss (PTPL) is enabled. A surviving cluster node must explicitly issue a Preempt or Preempt and Abort command using the failed node’s registered key to take ownership and clear stale locks.
Deploy Split-Brain-Proof NVMe Clusters on Dedicated Bare-Metal Nodes
Build resilient active-passive databases and shared NVMe-oF clusters on enterprise bare-metal servers with dual-port NVMe support, isolated private VLANs, and out-of-band IPMI fencing.
