Skip to content

Comments

libublk: add UblkQueue::complete_io_cmd_with_auto_buf_reg() and ::sub…#23

Merged
ming1 merged 1 commit intomainfrom
sync-auto-buf-reg
Aug 18, 2025
Merged

libublk: add UblkQueue::complete_io_cmd_with_auto_buf_reg() and ::sub…#23
ming1 merged 1 commit intomainfrom
sync-auto-buf-reg

Conversation

@ming1
Copy link
Collaborator

@ming1 ming1 commented Aug 18, 2025

…mit_fetch_commands_with_auto_buf_reg()

Added Methods

  1. UblkQueue::complete_io_cmd_with_auto_buf_reg()

This method provides zero-copy IO completion for non-async/await cases when UBLK_F_AUTO_BUF_REG is enabled. Key features:

  • Takes tag, buf_reg_data: &sys::ublk_auto_buf_reg, and res: Result<UblkIORes, UblkError>
  • Supports all the same result types as the regular complete_io_cmd() method
  • Handles fat completion features (batch and zoned append)
  • Uses auto buffer registration data to avoid manual buffer management
  1. UblkQueue::submit_fetch_commands_with_auto_buf_reg()

Location: src/io.rs:1023-1049

This method initializes the queue with auto buffer registration for zero-copy operations. Key features:

  • Takes buf_reg_data_list: &[sys::ublk_auto_buf_reg] for each queue depth slot
  • Validates that auto buffer registration is supported
  • Ensures the provided list has enough entries for all queue slots
  • Uses the internal __queue_io_cmd() method with auto buffer address encoding

Implementation Details

Both methods:

  • Use the existing bindings::ublk_auto_buf_reg_to_sqe_addr() function to encode buffer registration data
  • Leverage the existing __queue_io_cmd() infrastructure with the sqe_addr parameter
  • Follow the same patterns as the async versions (submit_io_cmd_with_auto_buf_reg)
  • Include proper documentation and safety assertions

Also add test case for covering the added APIs.

…mit_fetch_commands_with_auto_buf_reg()

Added Methods

1. UblkQueue::complete_io_cmd_with_auto_buf_reg()

This method provides zero-copy IO completion for non-async/await cases when
UBLK_F_AUTO_BUF_REG is enabled. Key features:

- Takes tag, buf_reg_data: &sys::ublk_auto_buf_reg, and res: Result<UblkIORes, UblkError>
- Supports all the same result types as the regular complete_io_cmd() method
- Handles fat completion features (batch and zoned append)
- Uses auto buffer registration data to avoid manual buffer management

2. UblkQueue::submit_fetch_commands_with_auto_buf_reg()

Location: src/io.rs:1023-1049

This method initializes the queue with auto buffer registration for zero-copy
operations. Key features:

- Takes buf_reg_data_list: &[sys::ublk_auto_buf_reg] for each queue depth slot
- Validates that auto buffer registration is supported
- Ensures the provided list has enough entries for all queue slots
- Uses the internal __queue_io_cmd() method with auto buffer address encoding

Implementation Details

Both methods:
- Use the existing bindings::ublk_auto_buf_reg_to_sqe_addr() function to encode buffer registration data
- Leverage the existing __queue_io_cmd() infrastructure with the sqe_addr parameter
- Follow the same patterns as the async versions (submit_io_cmd_with_auto_buf_reg)
- Include proper documentation and safety assertions

Also add test case for covering the added APIs.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
@ming1 ming1 merged commit 27d125a into main Aug 18, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant