Skip to content

crimson/net: read the IOHandler shard without touching shard_states - #72962

Merged
tchaikov merged 1 commit into
ceph:mainfrom
tchaikov:wip-crimson-net-atomic-sid
Oct 31, 2026
Merged

tchaikov merged 1 commit into
ceph:mainfrom
tchaikov:wip-crimson-net-atomic-sid

Conversation

@tchaikov

Copy link
Copy Markdown
Contributor

The IOHandler is not sharded: each connection has a single instance, shared by the messenger core, its I/O core and every core that sends to it. send() and send_keepalive() can run on any of them, and they look up the connection's shard with get_shard_id(), which goes through the shard_states pointer. Only the I/O core is supposed to touch shard_states, and it swaps the pointer in to_new_sid() and set_accepted_sid(), so a sender on another core can find it null or already freed.

The osd.1 log of the failed thrash job shows exactly that: shard 0 accepts a connection from osd.2 and hands it to core 1 with dispatch_accept(1). While core 1 is in to_new_sid(), shard 0 gets the same connection back from send_to_osd() ("connect to existing"), sends to it, and crashes in IOHandler::send().

So keep the shard id in an atomic, and let get_shard_id() read that instead. Senders already recheck the shard after submit_to(), so a stale id is fine. In to_new_sid(), the new id is set after io_crosscore.reset_wait(), since senders on the new core start using io_crosscore as soon as they see it.

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

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.

The IOHandler is not sharded: each connection has a single instance,
shared by the messenger core, its I/O core and every core that sends
to it. IOHandler::send() and send_keepalive() can be called from any of
them, and they find the connection's shard id with get_shard_id(),
which reads it through the shard_states pointer. But only the I/O core
is supposed to touch shard_states, and it replaces the pointer in
to_new_sid() and set_accepted_sid(). So a sender on another core may
read it while it's being swapped, and find it null in to_new_sid(), or
already freed in set_accepted_sid(). In a thrash test, shard 0 got a
connection back with "connect to existing" and sent to it while the
connection's core was in the middle of to_new_sid(), and crashed in
send().

Keep the shard id in an atomic next to shard_states, so senders don't
dereference shard_states. They already cope with a stale id, as they
recheck it after submit_to(). In to_new_sid(), set the id only after
io_crosscore.reset_wait(), because senders on the new core start using
io_crosscore as soon as they see it.

Fixes: https://tracker.ceph.com/issues/75658
Signed-off-by: Kefu Chai <[email protected]>
@tchaikov

Copy link
Copy Markdown
Contributor Author

cc @cyx1231st , in case you'd like to take a look =)

@Matan-B Matan-B added this to Crimson Oct 22, 2026
@Matan-B Matan-B moved this to Needs QA in Crimson Oct 22, 2026
@perezjosibm perezjosibm moved this from Needs QA to QA in Progress in Crimson Oct 22, 2026
@perezjosibm

perezjosibm commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor
PR=wip-perezjos-crimson-only-22-10-2026-PR72962
$ teuthology-suite -s crimson-rados -p 101 --force-priority -c $PR -f debug --filter-out osd-pg-merging,radosbench --suite-branch main --suite-repo https://github.com/ceph/ceph.git
2026-10-22 14:07:10,906.906 INFO:teuthology.suite.run:Test results viewable at 

https://pulpito-ng.ceph.com/jjperez-2026-10-22_14:02:06-crimson-rados-wip-perezjos-crimson-only-22-10-2026-PR72962-distro-debug-trial/

@perezjosibm perezjosibm moved this from QA in Progress to Tested in Crimson Oct 23, 2026
@tchaikov
tchaikov merged commit 54b759d into ceph:main Oct 31, 2026
18 checks passed
@tchaikov
tchaikov deleted the wip-crimson-net-atomic-sid branch October 31, 2026 12:57
@github-actions

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I have resolved the following tracker ticket due to the merge of this PR:

No backports are pending for the ticket. If this is incorrect, please update the tracker
ticket and reset to Pending Backport state.

Update Log: https://github.com/ceph/ceph/actions/runs/41203369434

@Matan-B Matan-B moved this from Tested to Merged (Main) in Crimson Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Merged (Main)

Development

Successfully merging this pull request may close these issues.

3 participants