selftests: ublk: make the fault_inject delay a pure timeout

ublk_fault_inject_queue_io() queues the delay of each I/O as an
IORING_OP_TIMEOUT with a completion count of 1. Such a timeout also
completes as soon as any other CQE is posted on the ring.

With more than one I/O in flight, the completion of one I/O ends the
delay of the others, and ublk_fault_inject_tgt_io_done() reports every
early completion as "unexpected cqe res 0".

Pass a count of 0 so that only the expiry of the timer completes the
timeout.

fio 4k random reads for 10 s at queue depth 4 on a fault_inject device
with --delay_us 1000000:

                            before      after   expected
  I/Os                     2263170         40         40
  mean latency             16.3 us    1.000 s        1 s
  "unexpected cqe res 0"   2263169          0          0

Fixes: 81586652bb ("selftests: ublk: add generic_06 for covering fault inject")
Signed-off-by: Qiliang Yuan <odys.yuan@gmail.com>
Reviewed-by: Ming Lei <tom.leiming@gmail.com>
Link: https://patch.msgid.link/20261008-bug-ublk-selftest-fault-inject-delay-v1-2-a96af7ead06e@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Qiliang Yuan 2026-10-08 22:45:40 +08:00 committed by Jens Axboe
parent 955cba87d9
commit 69ae59173a

View File

@ -92,7 +92,7 @@ static int ublk_fault_inject_queue_io(struct ublk_thread *t,
* reads it only when the SQE is submitted.
*/
ublk_io_alloc_sqes(t, &sqe, 1);
io_uring_prep_timeout(sqe, &opts->delay, 1, 0);
io_uring_prep_timeout(sqe, &opts->delay, 0, 0);
sqe->user_data = build_user_data(tag, ublksrv_get_op(iod), 0, q->q_id, 1);
ublk_queued_tgt_io(t, q, tag, 1);