On 3/29/22 10:08 AM, Jens Axboe wrote: > On 3/29/22 7:20 AM, Miklos Szeredi wrote: >> Hi, >> >> I'm trying to read multiple files with io_uring and getting stuck, >> because the link and drain flags don't seem to do what they are >> documented to do. >> >> Kernel is v5.17 and liburing is compiled from the git tree at >> 7a3a27b6a384 ("add tests for nonblocking accept sockets"). >> >> Without those flags the attached example works some of the time, but >> that's probably accidental since ordering is not ensured. >> >> Adding the drain or link flags make it even worse (fail in casese that >> the unordered one didn't). >> >> What am I missing? > > I don't think you're missing anything, it looks like a bug. What you > want here is: > > prep_open_direct(sqe); > sqe->flags |= IOSQE_IO_LINK; > ... > prep_read(sqe); > > submit(); > > You don't want link on the read, it just depends on that previous open. > And you don't need drain. > > But there's an issue with file assignment, it's done with the read is > prepped, not before it is run. Hence it will fail with EBADF currently, > which is the issue at hand. > > Let me write up a fix for this, would be great if you could test. Can you try and pull: git://git.kernel.dk/linux-block for-5.18/io_uring into v5.17 and see if that works for you? It will merge cleanly, no rejects. Thanks! -- Jens Axboe