blktrace-rs
Linux block-layer I/O trace capture, straight from the kernel.
blktrace_rs drives the kernel block tracing interface directly: the
BLKTRACESETUP/BLKTRACESTART/BLKTRACESTOP/BLKTRACETEARDOWN ioctls
plus the per-CPU relay channels under debugfs. It needs neither the
blktrace nor the blkparse command line tools, and it gives you the
parsed blk_io_trace records as Rust structs.
Usage
use BlkTrace;
let session = monitor?;
// Reads served from the page cache never reach the block layer:
drop_page_cache?;
// ... do the I/O you want traced ...
let report = session.shutdown?;
for event in &report.events
assert_eq!;
With features = ["async"] the crate adds monitor_async and
shutdown_async, which run the blocking core on the tokio blocking pool so
async callers never stall their executor.
Requirements
- Linux with debugfs, and root to run (the ioctls and debugfs require it).
- Building the crate requires
libclangand the kernel UAPI headers (linux/blktrace_api.h), via bindgen.
License
Apache-2.0, see LICENSE.