ringbahn / iou

Rust interface to io_uring
Apache License 2.0
328 stars 22 forks source link

Add RegisteredBuf API to manage registered buffers #51

Closed withoutboats closed 4 years ago

withoutboats commented 4 years ago

cc @mxxo

Generalizes RegisteredFd to also support RegisteredBuf with a similar strategy. Now, users can pre-register both FDs and buffers and pass either to prep_read and prep_write to get a correctly prepared IO event.

mxxo commented 4 years ago

Wow! Very very nice! I was just reading about the provide_buffers API the other day and it's exciting to see the implementation :)

withoutboats commented 4 years ago

Wow! Very very nice! I was just reading about the provide_buffers API the other day and it's exciting to see the implementation :)

There's two different APIs for registering buffers: the io_uring_register-based "register buffers" API and the "provide buffers" SQE operation. They're confusingly similar, but different. :sweat_smile:

This only works for the READ_FIXED/WRITE_FIXED operations, in which you still select the buffer you're doing IO in in the user program, just the kernel already has it mmaped into its memory space. On the other hand, with the provide buffers API you give the kernel a bunch of buffers and then it selects one to write in and tells the userspace program which buffer to look in.