]> Gentwo Git Trees - linux/.git/commit
ublk: refactor auto buffer register in ublk_dispatch_req()
authorMing Lei <ming.lei@redhat.com>
Fri, 21 Nov 2025 01:58:26 +0000 (09:58 +0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 28 Nov 2025 16:20:13 +0000 (09:20 -0700)
commit0a9beafa7c633e6ff66b05b81eea78231b7e6520
tree1d4fcb42a982f7401eba64ef59bdb89ac81c8cb6
parent8d61ece156bd4f2b9e7d3b2a374a26d42c7a4a06
ublk: refactor auto buffer register in ublk_dispatch_req()

Refactor auto buffer register code and prepare for supporting batch IO
feature, and the main motivation is to put 'ublk_io' operation code
together, so that per-io lock can be applied for the code block.

The key changes are:
- Rename ublk_auto_buf_reg() as ublk_do_auto_buf_reg()
- Introduce an enum `auto_buf_reg_res` to represent the result of
  the buffer registration attempt (FAIL, FALLBACK, OK).
- Split the existing `ublk_do_auto_buf_reg` function into two:
  - `__ublk_do_auto_buf_reg`: Performs the actual buffer registration
    and returns the `auto_buf_reg_res` status.
  - `ublk_do_auto_buf_reg`: A wrapper that calls the internal function
    and handles the I/O preparation based on the result.
- Introduce `ublk_prep_auto_buf_reg_io` to encapsulate the logic for
  preparing the I/O for completion after buffer registration.
- Pass the `tag` directly to `ublk_auto_buf_reg_fallback` to avoid
  recalculating it.

This refactoring makes the control flow clearer and isolates the different
stages of the auto buffer registration process.

Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c