Repository navigation
librgw: Enforce single-call semantics for librgw_create() - #69644
Conversation
0123592 to
26dec4c
Compare
|
jenkins test api |
|
@anoopcs9 Does this need a needs-review label? |
I'm not sure because I've never had to add it before. If that's how it's supposed to be these days, I can add it. |
|
jenkins test api |
|
@mattbenjamin This PR seeks to reverse a design decision from a PR you wrote a decade ago (#7634), specifically this commit 4b42c57. Would you be willing to weigh in? |
26dec4c to
9c754a9
Compare
|
librgw_create() is intended to be called once, because initialization can only be performed once. the "pattern" being adduced by AI is not controlling, if it's even correct. note the pattern is demonstrated in the various unit test programs. and shutdown is similar. what is gained by making many idempotent calls, but requiring them to be balanced? presumptively, I disagree with the logic here. |
I understand the position that librgw_create() is meant to be called once - the unit tests all follow that pattern. But the bug isn't really about whether multiple calls should be supported. It's that the current code does two contradictory things on a second call: it returns I'm happy to drop the refcount commits if the position is that librgw_create() must only be called once. But the first commit still stands as a correctness fix - the function needs to do one thing or the other, not both. If we'd rather enforce single-call semantics, I can change it to return early with an error and not write to *rgw instead. |
|
I agree the intent was that librgw_create() be called once, and librgw_shutdown() called once. If you object to returning the singleton handle if librgw_create() is called more than once, I have no objection to returning nullptr. |
Makes sense, I'll update the patch to return nullptr on a second call and drop the refcount commits. For context on the original motivation - in Samba's forking model, each client connection gets its own forked process, and a single client can connect to multiple RGW-backed shares. Each share's tree connect was calling librgw_create(), which meant multiple calls within the same forked process. We ended up building an internal refcount on the Samba side - calling librgw_create() only on the first tree connect and librgw_shutdown() only on the last disconnect - but having it in librgw would have been the natural place for it. That said, single-call semantics with a clear error is a reasonable contract and keeps librgw simple. |
9c754a9 to
af646f2
Compare
|
@ivancich @mattbenjamin I've closed tracker #77574 as NOTABUG and removed its references from the commits and PR. Let me know if you think this change needs a backport - if so, I can reopen the tracker. |
|
Unless your use of this needs backports, I think we can dispense with them. It's not a bug, just a slight modification of behavior. |
ivancich
left a comment
There was a problem hiding this comment.
Although the policy is still being developed, it's heading towards documenting the use of AI in creating commits. So please follow the guidelines in the ai-coding-assistants.rst file in this RFC PR: https://github.com/ceph/ceph/pull/66788/changes . Thank you!
librgw_create() is intended to be called once per process. On a second call g_ceph_context is already set, the init block is skipped, and rc remains at its initial -EINVAL. However the function still writes a valid handle to *rgw via g_ceph_context->get(), so the caller receives an error code and a live handle at the same time. Make the single-call contract explicit: return -EINVAL with *rgw set to nullptr when librgw_create() is called more than once. Signed-off-by: Anoop C S <[email protected]>
Add ceph_test_librgw_file_create which verifies that librgw_create() succeeds on the first call and returns -EINVAL with a nullptr handle on a subsequent call within the same process. Assisted-by: Claude Opus 4.6 (1M context) <[email protected]> Signed-off-by: Anoop C S <[email protected]>
af646f2 to
b606918
Compare
I've amended the commit wherever appropriate to make the AI assistance explicit. |
|
@anoopcs9 So this will be picked up for a QA run and we'll go from there. Thank you! |
|
This PR has been added to main integration testing by anuchaithra started 2026-08-19-07:20. |
pr testing completed and approved by @ivancich , more details in : https://tracker.ceph.com/issues/79605 |
All good from my side, please go for it ! |
librgw_create() is intended to be called once per process. On a second call the init block is skipped but the function still writes a valid handle to *rgw while returning
-EINVAL, leaving the caller with an error code and a live handle at the same time.Make the contract explicit: return
-EINVALwith *rgw set to nullptr when librgw_create() is called more than once. Add a test verifying the expected behavior for both the first and subsequent calls.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.