-
There are two main system calls for reading from a file: ssize_t
pread(int d, void *buf, size_t nbyte, off_t offset);
ssize_t
read(int fildes, void *buf, size_t nbyte); It seems that void io_uring_prep_read(struct io_uring_sqe *sqe, int fd, void *buf, unsigned nbytes, off_t offset) is closer to |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 19 replies
-
I investigated some existing systems and it seems like supplying |
Beta Was this translation helpful? Give feedback.
-
If you check the man page for io_uring_enter.2, and look at the
So you can safely rely on this behavior. |
Beta Was this translation helpful? Give feedback.
-
It behaves like the regular system calls in this regard. But a socket is a stream, and for streams io_uring passes in NULL ppos regardless of what you set the value to. So actually a bit puzzled, do you have a test case? You could obviously check the file type, but seems wasteful to need to do a stat type call before a read if it isn't needed. Honestly, not a huge fan of current file position, it doesn't make a lot of sense of an async interface. Consider what happens if you queue two reads with -1 offset - they end up reading from the same offset, as the position isn't updated until one of them completes. If at all possible, I'd highly recommend that Ruby use the explicit offsets rather than rely on the internal file position. |
Beta Was this translation helpful? Give feedback.
-
This should probably fix it:
|
Beta Was this translation helpful? Give feedback.
-
Right, for the newer ->read_iter() type interface in the kernel, we pass in the full kiocb structure. This means that they then see offset != 0, which obviously makes them unhappy for a stream. |
Beta Was this translation helpful? Give feedback.
-
I'll get this pushed out for 5.16-rc7, and it should percolate back to stable shortly thereafter and be generally available shortly. |
Beta Was this translation helpful? Give feedback.
-
Now updated with a bit more explanation, and your email. Thanks!! |
Beta Was this translation helpful? Give feedback.
-
And sent out for review as well, you are on the CC. |
Beta Was this translation helpful? Give feedback.
If you check the man page for io_uring_enter.2, and look at the
IORING_OP_{READ,WRITE}
section, it states:So you can safely rely on this behavior.