liburing icon indicating copy to clipboard operation
liburing copied to clipboard

Feature request: combine POLLIN with ioctl(FIONREAD)

Open tmds opened this issue 5 years ago • 4 comments
trafficstars

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.

tmds avatar Mar 22 '20 09:03 tmds

That's a good idea. We should probably just make this available directly through the poll command, and not require a linked FIONREAD.

axboe avatar Mar 22 '20 16:03 axboe

Yes, I don't care about generic ioctl, but about FIONREAD.

tmds avatar Mar 25 '20 14:03 tmds

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.

axboe avatar Dec 18 '20 22:12 axboe

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.

axboe avatar Jun 25 '22 23:06 axboe

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.

axboe avatar Oct 20 '22 21:10 axboe