Libublk
Rust library for building linux ublk target device, which talks with
linux ublk driver^1 for exposing standard linux block device,
meantime all target IO logic can be moved to userspace.
Linux kernel 6.0 starts to support ublk covered by config option of CONFIG_BLK_DEV_UBLK.
Documentations
Quick Start
Follows one totally working 2-queue ublk-null target which is built over libublk 0.1, and each queue depth is 64, and each IO's max buffer size is 512KB.
To use libublk crate, first add this to your Cargo.toml:
[]
= "0.1"
Next we can start using libublk crate.
The following is quick introduction for adding ublk-null block device, which
is against low level APIs.
use UblkCtrl;
use ;
use Arc;
The following ublk-null block device is built over high level APIs, which doesn't support IO closure of FnMut.
use ;
use ;
Test
You can run the test of the library with the following command.
# cargo test
Performance
When running fio t/io_uring /dev/ublkb0^2, IOPS is basically same with
running same test over ublk device created by blktests miniublk^3, which
is written by pure C. And the ublk device is null, which has 2 queues, each
queue's depth is 64.
Examples
null
-
add one null ublk device
cargo run --example null -- add
-
del one null ublk device
cargo run --example null -- del [dev_id]
loop
-
add one loop ublk device
cargo run --example loop -- add ${backing_file_path}
-
del one loop ublk device
cargo run --example loop -- del [dev_id]
License
This project is licensed under either of Apache License, Version 2.0 or MIT license at your option.
Contribution
Any kinds of contributions are welcome!