Conversation
Export uring_poll_io_fn() for targets which need to customer either poll_fn or read_event() handler. The coming batch example will use it. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
This commit introduces new async APIs and testing infrastructure: - Add ublk_submit_sqe_async() for async io_uring SQE submission - Add __ublk_submit_sqe_async() as internal implementation - Add ublk_join_io_tasks() test helper for QUEUE_RING polling - Export init_task_ring_default as pub(crate) for testing - Add comprehensive tests covering NOP, timeout, concurrent operations, and error handling - Refactor UblkQueue::ublk_submit_sqe() to use new async infrastructure The new API enables proper async/await integration for custom io_uring operations while maintaining compatibility with existing synchronous interfaces. UblkQueue::ublk_submit_sqe() will be deprecated soon. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
This example demonstrates batch coordination among async tasks within ublk's smol::LocalExecutor framework. The motivation is to prepare infrastructure for RAID1 implementation where all writes in a batch need to: 1. Mark 'need_resync' before any actual writes begin 2. Flush all resync markers to disk 3. Only then proceed with data writes to member disks 4. Clear resync markers after all writes complete Key features: - Thread-local context ID communication between run_ops and tasks - Slab-based BatchCoordinator for efficient resource management - Two-phase async coordination using smol channels - Reference counting for automatic cleanup - Per-queue batch state with comprehensive logging - Always runs in async mode (no sync mode support) - Zero overhead when batch coordination is not needed The approach leverages the existing batching boundary (CQE processing in ublk_reap_io_events_with_update_queue) and provides clean async coordination without blocking the executor. This provides a foundation for RAID1 and other use cases requiring batch-level synchronization among async tasks in the ublk framework. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Add zero copy feature to examples/batch.rs following the pattern from examples/null.rs. This enables efficient I/O operations by using automatic buffer registration via UBLK_F_AUTO_BUF_REG. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Remove batch_id field from BatchCoordinator struct and all related logging statements. The batch_id was only used for logging purposes and provided no functional value to the batch coordination logic. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Replace AtomicU32 with Cell<u32> for registered_tasks and completed_tasks fields in BatchCoordinator since all operations happen in single-threaded context. This provides better performance and simpler code without atomic operations overhead. Changes: - Replace AtomicU32::new() with Cell::new() - Replace fetch_add() with get()/set() pattern - Replace load() with get() - Remove unused atomic imports Signed-off-by: Ming Lei <tom.leiming@gmail.com>
…ce bottleneck Major optimizations implemented: - **Eliminated phase1_semaphore**: Removed semaphore.acquire().await blocking - **Real-time write detection**: Direct I/O operation checking in reap_event() - **Zero-copy tag collection**: Extract tags from CQE user_data without allocation - **Simplified coordinator lifecycle**: Direct tag transfer from pending to coordinator - **BatchCoordinator**: Removed completed_tasks counter, stores write tags directly - **QueueBatchState**: Added pending_write_tags collection from reap_event - **Task coordination**: Check current IOD operation type instead of cached tags - **Reusable functions**: is_write_operation() and collect_write_tags_from_cqe() - Export uring_poll_io_fn() for proper default handler polling - Both handle_uring_events_default() and handle_uring_events_smol_readable() use same write tag collection logic - Direct tag-based coordination eliminates race conditions - Only write operations participate in batch coordination - No semaphore blocking: Tasks proceed immediately without phase1 wait - Lock-free detection: Atomic operations and RefCell for coordination state - Precise batching: Only actual write commands trigger coordination overhead - Scalable design: Performance scales with write volume, not total I/O Maintains exact RAID1 coordination semantics while providing significant performance improvements, especially under high I/O loads. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Changes: - Cargo.toml: Added rand = "0.8" dependency for random delay generation - examples/batch.rs: - Added --io-delay command line option to specify maximum random I/O delay in microseconds - Implemented simulate_io_with_delay() function using io_uring timeout operations - Integrated delay simulation into the batch I/O task execution path - Updated function signatures to pass io_delay_us parameter through the call chain - Added random delay logic before I/O operations to simulate realistic workloads Purpose: Enables testing and benchmarking with simulated I/O delays to better cover coordinate batch function. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
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.
export two APIs: uring_poll_io_fn()/ublk_submit_sqe_async(), just make life easier
add batch example for showing how to deal with IO batch, which could be used for raid1 to build resync bitmap or journal data