tokio-rs / tokio-uring

An io_uring backed runtime for Rust
MIT License
1.11k stars 117 forks source link

Direct IO #259

Open Noah-Kennedy opened 1 year ago

Noah-Kennedy commented 1 year ago

Async direct IO is a very useful feature of io_uring, and it would be awesome to have this capability in here.

This will probably need another abstracted buffer API for aligned buffers.

It may be useful to look at the APIs in glommio for prior art.

shikhar commented 1 year ago

Linking a previous attempt adding DIO support https://github.com/tokio-rs/tokio-uring/pull/73

jumpnbrownweasel commented 3 months ago

Hello!

I was looking at @ahrens comment in the earlier #73 issue here about being able to provide custom direct buffers by implementing traits.

This made me wonder whether it is possible today to use direct IO in tokio_uring by:

  1. providing custom buffers aligned to the file's page size, and
  2. opening the file using std with the clib::O_DIRECT flag, and then converting it using File::from_std.

This seems possible from what I understand about uring and what I've read in the tokio_uring docs.

Has anyone done this? Is there something I'm overlooking or a hidden gotcha I should be aware of, before I try it myself?

Direct IO is important for my database implementation, since I want to rely on my own cache instead of the OS buffer pool.