blktrace-rs 0.1.0

Capture and parse Linux block-layer I/O traces via kernel ioctls, without the blktrace CLI tools
docs.rs failed to build blktrace-rs-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: blktrace-rs-0.1.1

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_rs::BlkTrace;

let session = BlkTrace::monitor("/dev/sda")?;
// Reads served from the page cache never reach the block layer:
BlkTrace::drop_page_cache()?;
// ... do the I/O you want traced ...
let report = session.shutdown()?;
for event in &report.events {
    if event.is_read() {
        println!("read {} bytes at sector {}", event.event.bytes, event.event.sector);
    }
}
assert_eq!(report.dropped, 0);

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 libclang and the kernel UAPI headers (linux/blktrace_api.h), via bindgen.

License

Apache-2.0, see LICENSE.