Skip to content

refactor(driver): record multishot results in ops#748

Merged
Berrysoft merged 4 commits into
compio-rs:masterfrom
Berrysoft:fix/managed-drop
Mar 10, 2026
Merged

refactor(driver): record multishot results in ops#748
Berrysoft merged 4 commits into
compio-rs:masterfrom
Berrysoft:fix/managed-drop

Conversation

@Berrysoft
Copy link
Copy Markdown
Member

Closes #746

@Berrysoft Berrysoft requested a review from Copilot March 8, 2026 16:07
@Berrysoft Berrysoft self-assigned this Mar 8, 2026
@Berrysoft Berrysoft added driver: io-uring About the io-uring driver driver: polling About the polling driver driver: fusion About the fusion driver package: driver Related to compio-driver labels Mar 8, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors io-uring multishot handling so that per-shot results (and selected managed buffers) are recorded inside the operation itself, addressing the buffer-loss scenario described in #746 when a managed op completes after cancellation.

Changes:

  • Move multishot result storage from the io-uring driver (HashMap<ErasedKey, VecDeque<_>>) into the op implementations via new OpCode::{push_multishot,pop_multishot} hooks.
  • Extend io-uring OpCode::set_result to receive &io::Result<usize> and &Extra, allowing ops (notably managed-buffer ops) to record/own selected buffers for later cleanup.
  • Refactor io-uring buffer pool internals to be Clone/Rc-backed and introduce an owned buffer handle that returns buffers on drop.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
compio-driver/src/sys/stub/mod.rs Removes no-longer-needed cleanup_multishot stub API.
compio-driver/src/sys/poll/mod.rs Removes no-longer-needed cleanup_multishot for polling driver.
compio-driver/src/sys/iour/op.rs Implements per-op multishot queues and records selected buffers in managed ops.
compio-driver/src/sys/iour/mod.rs Routes multishot CQEs directly into ops; removes driver-level multishot storage; adjusts buffer-pool release.
compio-driver/src/sys/iocp/mod.rs Removes no-longer-needed cleanup_multishot for IOCP driver.
compio-driver/src/sys/fusion/op.rs For fused ops, forwards the expanded io-uring OpCode surface (fallback/blocking/result/multishot).
compio-driver/src/sys/fusion/mod.rs Removes driver-level cleanup_multishot forwarding.
compio-driver/src/op.rs Renames managed fallback buffer type to FallbackOwnedBuffer to disambiguate with io-uring owned buffers.
compio-driver/src/lib.rs Removes cleanup_multishot calls during pop/pop_with_extra since storage moved into ops.
compio-driver/src/key.rs Calls OpCode::set_result(&Result, &Extra) for io-uring completions to let ops capture selected resources.
compio-driver/src/buffer_pool/iour.rs Makes io-uring buffer pool Clone (Rc-backed) and introduces an owned buffer handle with drop-based reuse.
compio-driver/src/buffer_pool/fusion.rs Renames/re-exports owned buffer types (FallbackOwnedBuffer, IoUringOwnedBuffer) for fusion builds.
compio-driver/src/buffer_pool/fallback.rs Exposes FallbackOwnedBuffer re-export for non-fusion builds.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread compio-driver/src/sys/iour/op.rs
Comment thread compio-driver/src/sys/iour/op.rs
Comment thread compio-driver/src/sys/iour/op.rs
Comment thread compio-driver/src/sys/iour/mod.rs
@Berrysoft Berrysoft requested a review from George-Miao March 8, 2026 16:26
Comment thread compio-driver/src/sys/iour/mod.rs Outdated
Comment thread compio-driver/src/sys/iour/op.rs Outdated
@George-Miao
Copy link
Copy Markdown
Member

George-Miao commented Mar 10, 2026

With BufferPools internalized into Ops now, does that mean maybe we can refactored Managed api and return buffers directly from returned Ops? i.e., TakeBuffer won't need BufferPool arg etc.

Copy link
Copy Markdown
Member

@George-Miao George-Miao left a comment

Choose a reason for hiding this comment

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

LGTM

@Berrysoft Berrysoft merged commit 3d5dba9 into compio-rs:master Mar 10, 2026
63 checks passed
@Berrysoft Berrysoft deleted the fix/managed-drop branch March 10, 2026 14:19
@github-actions github-actions Bot mentioned this pull request Mar 10, 2026
@Berrysoft Berrysoft added this to the v0.19 milestone Mar 11, 2026
This was referenced Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

driver: fusion About the fusion driver driver: io-uring About the io-uring driver driver: polling About the polling driver package: driver Related to compio-driver

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cancelling managed op on io-uring doesn't return the buffer

3 participants