Dominique MARTINET wrote on Wed, Jun 29, 2022 at 09:35:44AM +0900: > I also agree writing a simple program like the io_uring test in the > above commit that'd sort of do it like qemu and compare contents would > be ideal. > I'll have a stab at this today. Okay, after half a day failing to reproduce I had a closer look at qemu and... it's a qemu bug. Well, there probably are two bugs, but one should be benign: - qemu short read handling was... rather disappointing. Patch should appear here[1] eventually, but as it seems moderated? I'm reposting it here: ----- diff --git a/block/io_uring.c b/block/io_uring.c index d48e472e74cb..d58aff9615ce 100644 --- a/block/io_uring.c +++ b/block/io_uring.c @@ -103,7 +103,7 @@ static void luring_resubmit_short_read(LuringState *s, LuringAIOCB *luringcb, remaining); /* Update sqe */ - luringcb->sqeq.off = nread; + luringcb->sqeq.off += nread; luringcb->sqeq.addr = (__u64)(uintptr_t)luringcb->resubmit_qiov.iov; luringcb->sqeq.len = luringcb->resubmit_qiov.niov; ----- (basically "just" a typo, but that must have never been tested!) [1] https://lore.kernel.org/qemu-devel/20220629044957.1998430-1-dominique.martinet@atmark-techno.com - comments there also say short reads should never happen on newer kernels (assuming local filesystems?) -- how true is that? If we're doing our best kernel side to avoid short reads I guess we probably ought to have a look at this. It can easily be reproduced with a simple io_uring program -- see example attached that eventually fails with the following error on btrfs: bad read result for io 8, offset 792227840: 266240 should be 1466368 but doesn't fail on tmpfs or without O_DIRECT. feel free to butcher it, it's already a quickly hacked downversion of my original test that had hash computation etc so the flow might feel a bit weird. Just compile with `gcc -o shortreads uring_shortreads.c -luring` and run with file to read in argument. Thanks! -- Dominique