Skip to content

qa/tasks/nvme_loop: fall back to sysfs-based discovery if needed - #69837

Merged
rkachach merged 3 commits into
ceph:mainfrom
rkachach:fix_issue_77106
Sep 24, 2026
Merged

rkachach merged 3 commits into
ceph:mainfrom
rkachach:fix_issue_77106

Conversation

@rkachach

@rkachach rkachach commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes: https://tracker.ceph.com/issues/77106

Summary

Add a sysfs-based fallback to qa/tasks/nvme_loop.py for discovering NVMe loop namespace devices when nvme list -o json repeatedly fails.

The fallback is compatible with native NVMe multipath and restricts discovery to namespace heads belonging to the NVMe subsystems created by the task.

Problem

On some systems, nvme list -o json can fail even though the NVMe loop devices were successfully created.

The original fallback walked controller-specific paths under /sys/class/nvme, which is unreliable with native NVMe multipath because namespace-head and controller-path device names can differ.

A later fallback based only on the set of newly appearing /sys/class/block/nvme*n* devices fixed the multipath issue, but could also include unrelated NVMe namespaces that appeared during setup.

Since discovered devices are later passed to bluestore_zap(), the fallback needs to ensure that only namespaces belonging to the task are selected.

Fix

The task now:

  • records the existing NVMe namespace heads before creating the loop devices
  • derives the expected subsystem NQNs from the scratch-device basenames
  • walks /sys/class/nvme-subsystem/nvme-subsys*
  • reads each subsystem's subsysnqn
  • returns only namespace-head devices matching the expected subsystem NQNs
  • subtracts the pre-existing namespace set before using the discovered devices

This keeps the discovery compatible with native NVMe multipath while excluding unrelated NVMe devices.

The normal nvme list -o json path remains unchanged and the sysfs logic is only used after repeated nvme list failures.

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@github-actions github-actions Bot added the tests label Jun 30, 2026
@rkachach
rkachach marked this pull request as ready for review July 23, 2026 14:54
Copilot AI review requested due to automatic review settings July 23, 2026 14:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds sysfs-based NVMe loop-device discovery when nvme list -o json repeatedly crashes.

Changes:

  • Tracks consecutive JSON command crashes.
  • Falls back to sysfs discovery after five failures.
  • Adds a helper for enumerating NVMe namespace devices.

Comment thread qa/tasks/nvme_loop.py Resolved
@ShwetaBhosale1

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Reviewers differed on whether the sysfs fallback is safe for automated approval.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@rkachach
rkachach force-pushed the fix_issue_77106 branch 4 times, most recently from 58b9e7f to f0514aa Compare September 4, 2026 12:01
@rkachach
rkachach requested a balanced review from Copilot September 4, 2026 12:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The reviewed change has no unresolved approval-blocking issues.

Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@rkachach

rkachach commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor Author

The changes on this PR were tested in combination with #71971 results showed all the test cases where nvme_loop is used ran successfully. NFS errors are not related:

https://pulpito.ceph.com/rkachach-2026-09-22_20:34:48-orch:cephadm-wip-rkachach-testing-2-2026-09-22-1751-distro-default-trial/

@rkachach

Copy link
Copy Markdown
Contributor Author

jenkins test make check

nvme list -o json segfaults deterministically on kernel 6.8.0-*
nodes (ubuntu_22.04/24.04), exhausting all 15 safe_while
retries (ceph#69232 lets it retry, but every retry hits the same crash)
and failing smoke-roleless nvme_loop jobs.

This adds a fallback: after 5 consecutive CommandCrashedErrors, skip
nvme list -o json and discover devices via sysfs instead. Each loop
subsystem is connected using the device's basename as its NQN, which
the kernel exposes at /sys/class/nvme/nvmeX/subsysnqn; we match that
against /sys/class/nvme/nvmeX/nvmeXnY to recover the device path, with
no nvme-cli JSON parsing involved.

The existing JSON path is unchanged for nodes where it works normally
— json_failures resets on any success, so the fallback only triggers
on sustained crashes.

https://tracker.ceph.com/issues/77106
Assisted-by: ChatGPT <chatgpt.com>
Signed-off-by: Redouane Kachach <[email protected]>
`nvme_loop.py` falls back to sysfs-based device discovery when `nvme
list -o json` repeatedly crashes.

The existing fallback walks controller-specific paths such as:

```text
/sys/class/nvme/nvmeX/nvmeXnY
```

This is not reliable with native NVMe multipath, where the
user-visible namespace-head device may be exposed separately under
`/sys/class/block` and use a different naming relationship from the
controller path.

As a result, the fallback can return no devices even though the newly
connected NVMe loop devices are already visible through `lsblk`,
eventually causing the task to fail with `MaxWhileTries`.

This change:

* records the existing NVMe namespace devices before creating the loop connections;
* discovers visible namespace-head devices from `/sys/class/block`;
* identifies the new loop devices using the before/after difference;
* excludes partitions and controller-path devices.

The normal `nvme list -o json` path remains unchanged. Only the
fallback discovery path is modified.

https://tracker.ceph.com/issues/77106
Assisted-by: ChatGPT <chatgpt.com>
Signed-off-by: Redouane Kachach <[email protected]>

@guits guits left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

one 'nice to have' comment
I think extra logging can really help if the fallback fails...

otherwise the patch looks good to me

Comment thread qa/tasks/nvme_loop.py Resolved

@kginonredhat kginonredhat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The sysfs fallback is the right approach for the nvme list -o json crashes, but the NQN compare needs a strip before merge.

On a host with real NVMe devices, /sys/class/nvme-subsystem/*/subsysnqn is space-padded (Identify SUBNQN). Exact match then misses even when the glob already found nvme0n1 / nvme1n1.

expected_nqns must stay the scratch-device basenames used by nvme connect -n. Do not substitute vendor NQNs such as nqn.1994-11.com.samsung:…; those are the physical drives and would be passed to bluestore_zap().

Comment thread qa/tasks/nvme_loop.py Resolved
Restrict sysfs fallback discovery to NVMe namespace heads whose
subsystem NQN matches one of the scratch-device basenames.

This preserves native multipath-compatible discovery while preventing
unrelated NVMe namespaces that appear during setup from being selected
and potentially passed to bluestore_zap().

https://tracker.ceph.com/issues/77106
Assisted-by: ChatGPT <chatgpt.com>
Signed-off-by: Redouane Kachach <[email protected]>

@kginonredhat kginonredhat left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, the sysfs NQN strip looks good and expected_nqns stays the scratch-device basenames. LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants