]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ublk: add PFN-based buffer matching in I/O path
authorMing Lei <ming.lei@redhat.com>
Tue, 31 Mar 2026 15:31:53 +0000 (23:31 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 7 Apr 2026 13:38:36 +0000 (07:38 -0600)
commit4d4a512a1f87b156f694d25c800e3d525aa56e8a
tree6bca1b099bb2abdf1cad3541f6ac705a9ce9e076
parent2fb0ded237bb55dae45bc076666b348fc948ac9e
ublk: add PFN-based buffer matching in I/O path

Add ublk_try_buf_match() which walks a request's bio_vecs, looks up
each page's PFN in the per-device maple tree, and verifies all pages
belong to the same registered buffer at contiguous offsets.

Add ublk_iod_is_shmem_zc() inline helper for checking whether a
request uses the shmem zero-copy path.

Integrate into the I/O path:
- ublk_setup_iod(): if pages match a registered buffer, set
  UBLK_IO_F_SHMEM_ZC and encode buffer index + offset in addr
- ublk_start_io(): skip ublk_map_io() for zero-copy requests
- __ublk_complete_rq(): skip ublk_unmap_io() for zero-copy requests

The feature remains disabled (ublk_support_shmem_zc() returns false)
until the UBLK_F_SHMEM_ZC flag is enabled in the next patch.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://patch.msgid.link/20260331153207.3635125-3-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c