Ming Lei [Thu, 27 Mar 2025 09:51:20 +0000 (17:51 +0800)]
selftests: ublk: add test for checking zero copy related parameter
ublk zero copy usually requires to set dma and segment parameter correctly,
so hard-code null target's dma & segment parameter in non-default value,
and verify if they are setup correctly by ublk driver.
Ming Lei [Thu, 27 Mar 2025 09:51:17 +0000 (17:51 +0800)]
ublk: implement ->queue_rqs()
Implement ->queue_rqs() for improving perf in case of MQ.
In this way, we just need to call io_uring_cmd_complete_in_task() once for
whole IO batch, then both io_uring and ublk server can get exact batch from
ublk frontend.
Ming Lei [Thu, 27 Mar 2025 09:51:15 +0000 (17:51 +0800)]
ublk: add segment parameter
IO split is usually bad in io_uring world, since -EAGAIN is caused and
IO handling may have to fallback to io-wq, this way does hurt performance.
ublk starts to support zero copy recently, for avoiding unnecessary IO
split, ublk driver's segment limit should be aligned with backend
device's segment limit.
Another reason is that io_buffer_register_bvec() needs to allocate bvecs,
which number is aligned with ublk request segment number, so that big
memory allocation can be avoided by setting reasonable max_segments limit.
So add segment parameter for providing ublk server chance to align
segment limit with backend, and keep it reasonable from implementation
viewpoint.
Ming Lei [Thu, 27 Mar 2025 09:51:11 +0000 (17:51 +0800)]
ublk: comment on ubq->canceling handling in ublk_queue_rq()
In ublk_queue_rq(), ubq->canceling has to be handled after ->fail_io and
->force_abort are dealt with, otherwise the request may not be failed
when deleting disk.
Ming Lei [Thu, 27 Mar 2025 09:51:10 +0000 (17:51 +0800)]
ublk: make sure ubq->canceling is set when queue is frozen
Now ublk driver depends on `ubq->canceling` for deciding if the request
can be dispatched via uring_cmd & io_uring_cmd_complete_in_task().
Once ubq->canceling is set, the uring_cmd can be done via ublk_cancel_cmd()
and io_uring_cmd_done().
So set ubq->canceling when queue is frozen, this way makes sure that the
flag can be observed from ublk_queue_rq() reliably, and avoids
use-after-free on uring_cmd.