Skip to content

staslib: let stacd work out what it was managing instead of remembering - #512

Merged
martin-belanger merged 1 commit into
linux-nvme:mainfrom
martin-belanger:stacd-drop-lkc-pickle
Sep 1, 2026
Merged

staslib: let stacd work out what it was managing instead of remembering#512
martin-belanger merged 1 commit into
linux-nvme:mainfrom
martin-belanger:stacd-drop-lkc-pickle

Conversation

@martin-belanger

Copy link
Copy Markdown
Collaborator

stacd wrote the TIDs of the I/O controllers it managed to a pickle in $RUNTIME_DIRECTORY and, on startup, re-created a controller for each one that still had a connection in the kernel. That intersection is the tell: the kernel already knew what was connected, and the pickle only narrowed it to what had been ours. The registry answers that question now - libnvme records owner=stas on the controllers it connects for us, and claim() marks the ones we borrow - so nothing is left for stacd to remember.

Ask the kernel what is connected and the registry who owns each one. This is more robust than the file it replaces: it survives a stacd that was killed before it could write, and it cannot go stale, because the registry entry is keyed by device and goes away with it.

Adoption requires an entry naming us, rather than merely one not naming somebody else. protected() lets an unowned connection through on purpose - nobody has claimed it, so we may - but that is the wrong default here. Starting with no memory of what we were doing, an unowned connection is one we did not make: it predates the registry, or belongs to somebody who never registered it.

stafd keeps its own file. It holds the cached discovery log pages and each controller's origin, neither of which the registry can supply, so the pickle machinery moves from ServiceABC down into Staf. stacd no longer writes to $RUNTIME_DIRECTORY at all, so its unit file no longer asks for one.

Udev.get_tid() comes back, unchanged, from 27705e8 where it was dropped for want of callers.

stacd wrote the TIDs of the I/O controllers it managed to a pickle in
$RUNTIME_DIRECTORY and, on startup, re-created a controller for each one
that still had a connection in the kernel. That intersection is the
tell: the kernel already knew what was connected, and the pickle only
narrowed it to what had been ours. The registry answers that question
now - libnvme records owner=stas on the controllers it connects for us,
and claim() marks the ones we borrow - so nothing is left for stacd to
remember.

Ask the kernel what is connected and the registry who owns each one.
This is more robust than the file it replaces: it survives a stacd that
was killed before it could write, and it cannot go stale, because the
registry entry is keyed by device and goes away with it.

Adoption requires an entry naming us, rather than merely one not naming
somebody else. protected() lets an unowned connection through on
purpose - nobody has claimed it, so we may - but that is the wrong
default here. Starting with no memory of what we were doing, an unowned
connection is one we did not make: it predates the registry, or belongs
to somebody who never registered it.

stafd keeps its own file. It holds the cached discovery log pages and
each controller's origin, neither of which the registry can supply, so
the pickle machinery moves from ServiceABC down into Staf. stacd no
longer writes to $RUNTIME_DIRECTORY at all, so its unit file no longer
asks for one.

Udev.get_tid() comes back, unchanged, from 27705e8 where it was dropped
for want of callers.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
@martin-belanger
martin-belanger merged commit c5e9041 into linux-nvme:main Sep 1, 2026
10 checks passed
@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 43.24324% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.93%. Comparing base (d3c6e77) to head (9340e92).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
staslib/service.py 43.47% 13 Missing ⚠️
staslib/udev.py 33.33% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #512      +/-   ##
==========================================
+ Coverage   68.71%   68.93%   +0.21%     
==========================================
  Files          16       16              
  Lines        2730     2739       +9     
==========================================
+ Hits         1876     1888      +12     
+ Misses        854      851       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@martin-belanger
martin-belanger deleted the stacd-drop-lkc-pickle branch September 1, 2026 18:05
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