ublk: use copy_{to,from}_iter() for user copy
authorCaleb Sander Mateos <csander@purestorage.com>
Thu, 6 Nov 2025 17:16:46 +0000 (10:16 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 6 Nov 2025 23:26:04 +0000 (16:26 -0700)
commit2299ceec364eecdc0a5b4ec80c757551d130389c
tree1fb9844bf73f08c54d533caa2be9581dddcac2a1
parent15638d52cbcf6e969f4a5e2757b118355db583f3
ublk: use copy_{to,from}_iter() for user copy

ublk_copy_user_pages()/ublk_copy_io_pages() currently uses
iov_iter_get_pages2() to extract the pages from the iov_iter and
memcpy()s between the bvec_iter and the iov_iter's pages one at a time.
Switch to using copy_to_iter()/copy_from_iter() instead. This avoids the
user page reference count increments and decrements and needing to split
the memcpy() at user page boundaries. It also simplifies the code
considerably.
Ming reports a 40% throughput improvement when issuing I/O to the
selftests null ublk server with zero-copy disabled.

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