libnvme, python: pass global context to registry public APIs and fix python test issue#3460
Open
martin-belanger wants to merge 2 commits into
Open
libnvme, python: pass global context to registry public APIs and fix python test issue#3460martin-belanger wants to merge 2 commits into
martin-belanger wants to merge 2 commits into
Conversation
added 2 commits
June 19, 2026 13:47
Make struct libnvme_global_ctx the first argument of every public libnvmf_registry_* function. Most do not use it yet, but threading it in now lets a future version log via libnvme_msg() or reach per-context state without breaking the ABI again. Each public function rejects a NULL context with -EINVAL; the internal *_instance helpers only forward it and do not re-validate. Also forward-declare the struct in registry.h so the public header is self-contained. While here, fix disconnect_all_match() in fabrics.c to take the caller's context instead of creating one per controller. It also returned -ENOMEM from a function declared bool, which coerces to true and would have disconnected controllers on an allocation failure. Signed-off-by: Martin Belanger <martin.belanger@dell.com> Assisted-by: Claude:claude-opus-4-8 [Claude Code]
The python-registry parallel-writes test only passed under the "fork"
multiprocessing start method. Python 3.14 makes "forkserver" the default
on Linux, where the test failed two ways:
- Each child re-imports the test module, which unconditionally created
a fresh NVME_REGISTRY_DIR. The children then wrote to a directory the
parent never reads, so the final value came back as the parent's
initial write.
- The libnvme context was passed as a Process argument. A SwigPyObject
cannot be pickled for spawn/forkserver, and a context is not meant to
be shared across processes anyway.
Reuse an inherited /tmp registry directory instead of always creating a
new one, and have each writer process create its own GlobalCtx. Verified
under fork, forkserver and spawn.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Assisted-by: Claude:claude-opus-4-8 [Claude Code]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@igaw - Per our discussion. This PR has two commit.