Skip to contentSkip to conversation

libublk-rs: v0.2 with async/await support

DISCUSSION Ming Lei 1 participant 1 message Oct 30, 2023

Subsystems (2)
lore
Share & tools
lore

Ming Lei

author
#0 lore raw

Hi,

libublk-rs v0.2 is released:

https://crates.io/crates/libublk
https://github.com/ming1/libublk-rs

Changes:

- support async/await for generic async fn(don't depend on runtime) and io_uring.
- unprivileged ublk
- queue idle handle
- almost all features in libublksrv are supported in libublk-rs now
- command line support for examples

Now each io command can be handled in dedicated io task as following, and it looks like sync programming, but everything is handled in async style:

         let mut cmd_op = libublk::sys::UBLK_IO_FETCH_REQ;
         let mut result = 0;
         let addr = std::ptr::null_mut();
         loop {
             if q.submit_io_cmd(tag, cmd_op, addr, result).await
                 == libublk::sys::UBLK_IO_RES_ABORT
             {
                 break;
             }

             // io_uring async is preferred
             result = handle_io_cmd(&q, tag).await;
             cmd_op = libublk::sys::UBLK_IO_COMMIT_AND_FETCH_REQ;
         }

Roadmap:
1) write more complicated targets with async/await

- re-write qcow2 with clean async/await implementation in rublk project which depends on libublk

https://crates.io/crates/rublk
https://github.com/ming1/rublk

2) tens of thousands of ublk device support
- switch control command to async/await, and make ublk device in one thread with single blocking point

- shared task: one task can create multiple ublk devices

- shared uring: create multiple ublk device with single uring.

3) support tokio async, especially for non-io_uring target io handling

Thanks,
Ming