Closed aconz2 closed 3 weeks ago
I'd say, IOSQE_FIXED_FILE
is for requests that take a file as an argument and using it to do something, so the man page from above lies. "direct" is for requests manipulating io_uring fixed file table, like creating a file and installing it there or removing a file. There can be some inconsistencies, but that's because it was gradually developed and we can't change the ABI.
io_uring_read_direct
would be confusing, exactly because reads just use the file and don't alter the file table.
It would indeed be nice to have a bit of consistency in terms of how requests are prepared, but at least for the open case, as Pavel says, IOSQE_FIXED_FILE
is set when you're passing in a fixed file descriptor. When creating one, it doesn't really make sense.
Would love a PR with a man page update! Thanks.
Awesome makes sense, I understand io_uring a bit better now, thanks very much! To be honest after re-reading, the quote I pulled isn't directly wrong, but was easy to get confused that it was referring to subsequent operations not the current one. I opened https://github.com/axboe/liburing/pull/1254 with something that seems a bit clearer to me.
In the man pages for
io_uring_prep_openat_direct
it saysBut the source for (v6.11)
__io_openat_prep
shows that ifREQ_F_FIXED_FILE
is set, then we getEBADF
. (from my reading,req
gets its flags initialized from thesqe
andREQ_F_FIXED_FILE
corresponds to checking ifIOSQE_FIXED_FILE
was set). Indeed, if I make this change:then it prints
open res -9
test failed.I've gone round and round in the kernel but think I understand now that
sqe->file_index
is set for ops (when you want fixed file) that create an fd but shouldn't haveIOSQE_FIXED_FILE
set, while ops that use an fd (their opdef hasneeds_file
) likeread/write
should havesqe->fd
set withIOSQE_FIXED_FILE
set. Andclose
can use eitherfd
xorfile_index
but never usesIOSQE_FIXED_FILE
. Does that sound about right?I had a followup about whether
io_uring_read_direct
could be added, but I'm not sure anymore. On the one hand it is consistent in that if you use a_direct
thefd
you pass is a fixed fd, but on the other, it is inconsistent if you understand that a_direct
setsfile_index
(with handling for asking for the kernel to allocate in your table) and without_direct
setsfd
.Can send a PR if you agree with my assessment on the openat man page if you'd like. Thanks!