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: 81586652bb1f ("selftests: ublk: add generic_06 for covering fault inject") Signed-off-by: Qiliang Yuan --- tools/testing/selftests/ublk/fault_inject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/ublk/fault_inject.c b/tools/testing/selftests/ublk/fault_inject.c index e055f51a65447..4b59f17a918c0 100644 --- a/tools/testing/selftests/ublk/fault_inject.c +++ b/tools/testing/selftests/ublk/fault_inject.c @@ -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); -- 2.43.0