liburing
liburing copied to clipboard
Feature request: combine POLLIN with ioctl(FIONREAD)
A nice thing about BSD kevent is that when it returns a socket is readable, it includes the amount of data available. The application can allocate a buffer large enough for the receive.
Currently, Linux doesn't support this.
It could be made possible with io_uring by linking poll with ioctl FIONREAD.
That's a good idea. We should probably just make this available directly through the poll command, and not require a linked FIONREAD.
Yes, I don't care about generic ioctl, but about FIONREAD.
Started worked on this: https://git.kernel.dk/cgit/linux-block/log/?h=io_uring-fops
Basically it provides IORING_OP_URING_CMD, which can carry a file type private command type. One example is FIONREAD (which I did implement in the above), and I mostly see this as a way to add the ioctl kind of commands that are interesting to support since ->ioctl() itself is unsupportable.
The fops code has been merged in 5.19, and we also return whether or not there's data left in the socket with that release. Doesn't as-of yet return how many bytes you can read, but it'd be trivial to add at this point if it's needed beyond just knowing if there's data or not.
Closing this one as we do return if there's data to be read, just not how much. The latter would be a trivial addition however.