@@ -352,6 +352,73 @@ For reaching best IO performance, ublk server should align its segment
352352parameter of `struct ublk_param_segment ` with backend for avoiding
353353unnecessary IO split, which usually hurts io_uring performance.
354354
355+ Auto Buffer Registration
356+ ------------------------
357+
358+ The ``UBLK_F_AUTO_BUF_REG `` feature automatically handles buffer registration
359+ and unregistration for I/O requests, which simplifies the buffer management
360+ process and reduces overhead in the ublk server implementation.
361+
362+ This is another feature flag for using zero copy, and it is compatible with
363+ ``UBLK_F_SUPPORT_ZERO_COPY ``.
364+
365+ Feature Overview
366+ ~~~~~~~~~~~~~~~~
367+
368+ This feature automatically registers request buffers to the io_uring context
369+ before delivering I/O commands to the ublk server and unregisters them when
370+ completing I/O commands. This eliminates the need for manual buffer
371+ registration/unregistration via ``UBLK_IO_REGISTER_IO_BUF `` and
372+ ``UBLK_IO_UNREGISTER_IO_BUF `` commands, then IO handling in ublk server
373+ can avoid dependency on the two uring_cmd operations.
374+
375+ This way not only simplifies ublk server implementation, but also makes
376+ concurrent IO handling becomes possible.
377+
378+ Usage Requirements
379+ ~~~~~~~~~~~~~~~~~~
380+
381+ 1. The ublk server must create a sparse buffer table on the same ``io_ring_ctx ``
382+ used for ``UBLK_IO_FETCH_REQ `` and ``UBLK_IO_COMMIT_AND_FETCH_REQ ``.
383+
384+ 2. If uring_cmd is issued on a different ``io_ring_ctx ``, manual buffer
385+ unregistration is required.
386+
387+ 3. Buffer registration data must be passed via uring_cmd's ``sqe->addr `` with the
388+ following structure::
389+
390+ struct ublk_auto_buf_reg {
391+ __u16 index; /* Buffer index for registration */
392+ __u8 flags; /* Registration flags */
393+ __u8 reserved0; /* Reserved for future use */
394+ __u32 reserved1; /* Reserved for future use */
395+ };
396+
397+ 4. All reserved fields in ``ublk_auto_buf_reg `` must be zeroed.
398+
399+ 5. Optional flags can be passed via ``ublk_auto_buf_reg.flags ``.
400+
401+ Fallback Behavior
402+ ~~~~~~~~~~~~~~~~~
403+
404+ When ``UBLK_AUTO_BUF_REG_FALLBACK `` is enabled:
405+
406+ 1. If auto buffer registration fails:
407+ - The uring_cmd is completed
408+ - ``UBLK_IO_F_NEED_REG_BUF `` is set in ``ublksrv_io_desc.op_flags ``
409+ - The ublk server must manually register the buffer
410+
411+ 2. If fallback is not enabled:
412+ - The ublk I/O request fails silently
413+
414+ Limitations
415+ ~~~~~~~~~~~
416+
417+ - Requires same ``io_ring_ctx `` for all operations
418+ - May require manual buffer management in fallback cases
419+ - Reserved fields must be zeroed for future compatibility
420+
421+
355422References
356423==========
357424
0 commit comments