Skip to content

fix(initiator): detect and replace stale endpoint device nodes#281

Merged
derekbit merged 1 commit into
longhorn:mainfrom
derekbit:issue-13062
May 14, 2026
Merged

fix(initiator): detect and replace stale endpoint device nodes#281
derekbit merged 1 commit into
longhorn:mainfrom
derekbit:issue-13062

Conversation

@derekbit
Copy link
Copy Markdown
Member

Which issue(s) this PR fixes:

Issue longhorn/longhorn#13062

What this PR does / why we need it:

Previously, createEndpoint() unconditionally reused any existing endpoint without validating it. A stale regular file or a device node with wrong major:minor could be left behind when a previous cleanup races with external writers or when deferred dm removal leaves an orphaned node, causing I/O to be routed to the wrong device.

Validate the existing endpoint by stat-ing the node and comparing its type (S_IFBLK) and major:minor against the current dm device. If the endpoint is stale, remove it and recreate with the correct device numbers. Extract the validation into isEndpointValid() for readability.

Also set i.isUp = true when reusing a valid endpoint, so that GetEndpoint() returns the correct path instead of an empty string.

Special notes for your reviewer:

Additional documentation or context

Previously, createEndpoint() unconditionally reused any existing
endpoint without validating it. A stale regular file or a device node
with wrong major:minor could be left behind when a previous cleanup
races with external writers or when deferred dm removal leaves an
orphaned node, causing I/O to be routed to the wrong device.

Validate the existing endpoint by stat-ing the node and comparing
its type (S_IFBLK) and major:minor against the current dm device.
If the endpoint is stale, remove it and recreate with the correct
device numbers. Extract the validation into isEndpointValid() for
readability.

Also set i.isUp = true when reusing a valid endpoint, so that
GetEndpoint() returns the correct path instead of an empty string.

Longhorn 13062

Signed-off-by: Derek Su <derek.su@suse.com>
Copy link
Copy Markdown

@mantissahz mantissahz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@davidcheng0922 davidcheng0922 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@derekbit derekbit merged commit 789b2a1 into longhorn:main May 14, 2026
5 checks passed
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.

3 participants