Merged
Conversation
Collaborator
ming1
commented
Sep 12, 2025
- refactor ctrl async vs. sync
- add one test for showing how to write completely async style io handler, just with some performance loss
Remove redundant OnceCell wrapper from thread-local CTRL_URING since thread_local! is already lazy. Simplify the structure while keeping the ublk_init_ctrl_task_ring() API for backward compatibility. Changes: - Change CTRL_URING from OnceCell<RefCell<IoUring>> to RefCell<Option<IoUring>> - Update with_ctrl_ring_internal and with_ctrl_ring_mut_internal macros - Preserve ublk_init_ctrl_task_ring() function with updated signature - Update documentation examples to reflect simplified API Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Implement Phase 2 of io.rs cleanup by consolidating documentation to reduce redundancy and improve maintainability. Changes: - Add comprehensive module-level documentation with complete examples for ring initialization (basic/advanced) and unified buffer APIs - Simplify individual method documentation by removing redundant examples and referencing module-level docs instead: * ublk_init_task_ring(): Remove 48 lines of duplicate examples * submit_io_cmd_unified(): Remove verbose usage examples * submit_fetch_commands_unified(): Remove redundant buffer examples * complete_io_cmd_unified(): Streamline validation/performance docs - Clean up outdated comments: * Remove historical "Previously had separate TASK_URING" comment * Remove outdated "todo: apply io_uring flags" comment Benefits: - Single source of truth for documentation examples - Better discoverability with comprehensive module-level docs - Reduced maintenance burden from duplicate examples - Improved readability with focused method documentation - All functionality preserved with better organization The documentation now follows Rust best practices with comprehensive module docs and concise method docs that reference the examples. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Update the module-level documentation example for traditional buffer operations to use IoBuf instead of raw arrays, which is more consistent with the library's established patterns and best practices. Changes: - Replace raw array `[0u8; 4096]` with `IoBuf::<u8>::new(4096)` - Use `BufDesc::from_io_buf()` helper method for proper conversion - Add missing `use libublk::helpers::IoBuf;` import This example now demonstrates the recommended approach for traditional buffer operations and aligns with how IoBuf is used throughout the codebase and other examples. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Add UblkCtrl::set_thread_affinity() API for setting queue thread affinity. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Export it, which is still helpful for target code. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Extract common command data preparation logic for ADD_DEV into prepare_add_cmd() method. Both sync and async variants now use the same preparation logic, reducing code duplication while maintaining identical behavior. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Extract common command data preparation logic for DEL_DEV into prepare_del_cmd() method. All three deletion variants now use the same preparation logic with a force_async parameter, reducing code duplication while maintaining identical behavior. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Extract common command data preparation logic for: - GET_FEATURES: prepare_get_features_cmd() - GET_DEV_INFO/GET_DEV_INFO2: prepare_read_dev_info_cmd() Both sync and async variants now use the same preparation logic, reducing code duplication while maintaining identical behavior. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Extract common command data preparation logic for: - START_DEV: prepare_start_cmd() - STOP_DEV: prepare_stop_cmd() - GET_PARAMS: prepare_get_params_cmd() - SET_PARAMS: prepare_set_params_cmd() Both sync and async variants now use the same preparation logic, reducing code duplication while maintaining identical behavior. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Extract common command data preparation logic for: - GET_QUEUE_AFFINITY: prepare_get_queue_affinity_cmd() - START_USER_RECOVERY: prepare_start_user_recover_cmd() - END_USER_RECOVERY: prepare_end_user_recover_cmd() Both sync and async variants now use the same preparation logic, reducing code duplication while maintaining identical behavior. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Extract common JSON building logic into helper methods: - build_json_internal() and build_json_internal_async() for data generation - update_json_queue_tids() for shared TID update logic Both sync and async versions now share validation and data preparation logic while maintaining separate execution paths. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Extract common parameter validation logic into validate_new_params() method. Both sync and async constructors now share identical validation logic, ensuring consistent parameter checking while maintaining separate initialization paths. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Extract common device info printing logic into dump_device_info() helper method. Both sync and async dump methods now share identical formatting and display logic while maintaining separate data collection paths. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
- async command should run in async environment with UBLK_CTRL_ASYNC_AWAIT set. - sync command should run in sync environment without UBLK_CTRL_ASYNC_AWAIT Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
smol doesn't belong to libublk, we shouldn't add more such mess. Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Update all smol executor usage to use exe.run(async { ... }) instead of
smol::block_on(async { ... }) for proper executor integration.
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.