Skip to content

fix(nvmf): increment reservation generation per command - #94

Draft
davidcheng0922 wants to merge 1 commit into
longhorn:longhorn-v26.05from
davidcheng0922:issue-14274-shared-rwx-block-reservation
Draft

davidcheng0922 wants to merge 1 commit into
longhorn:longhorn-v26.05from
davidcheng0922:issue-14274-shared-rwx-block-reservation

Conversation

@davidcheng0922

Copy link
Copy Markdown

Which issue(s) this PR fixes:

longhorn/longhorn#14274

What this PR does / why we need it:

According to the NVMe Base Specification 2.1 Figure 581: Reservation Status Data Structure, the Generation (GEN) field is a 32-bit wrapping counter that is incremented once each time one of the following commands completes successfully:

  • a Reservation Register command;
  • a Reservation Release command with RRELA set to Clear;
  • a Reservation Acquire command with RACQA set to Preempt or Preempt and Abort.

SPDK incremented GEN once per registrant added or removed, in nvmf_ns_reservation_add_registrant() and nvmf_ns_reservation_remove_registrant(). So a Replace or a self-preempt did not increment it, and a Preempt or Clear that removed N registrants incremented it N times.

This change increments GEN once per successful Register, Release with Clear, and Acquire with Preempt or Preempt and Abort command, and updates the unit tests.

This is a minor bug. GEN is informational, and only matters to applications that compare it across reports to detect changes, such as SCSI Persistent Reservation translation (PRgeneration). Reservation enforcement and I/O are not affected.

Special notes for your reviewer:

Additional documentation or context

@davidcheng0922 davidcheng0922 self-assigned this Nov 16, 2026
@davidcheng0922
davidcheng0922 marked this pull request as draft November 16, 2026 06:20
The NVMe Base Specification (Reservation Status data structure, GEN
field) defines the generation as a counter incremented once each time a
Reservation Register command, a Reservation Release command with Clear,
or a Reservation Acquire command with Preempt or Preempt and Abort
completes successfully.

The generation was instead incremented each time a registrant was added
or removed. A Replace, a register with the current key, or a preempt
that removed no registrant did not increment it, and a preempt or clear
that removed several registrants incremented it several times.

Increment the generation once when each of those commands completes
successfully, and no longer when a registrant is added or removed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Change-Id: I2d04db67ac183d152d6978673e6b423265eca35e
Signed-off-by: David Cheng <david.cheng@suse.com>
@davidcheng0922
davidcheng0922 force-pushed the issue-14274-shared-rwx-block-reservation branch from 6a4d51f to 0b5c9e0 Compare November 20, 2026 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant