Expand description
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), so it needs neither the
blktrace nor the blkparse command line tools.
Capturing requires root and a kernel with debugfs. Building this crate
requires libclang and the kernel UAPI headers
(linux/blktrace_api.h).
§Example
use blktrace_rs::BlkTrace;
let session = BlkTrace::monitor("/dev/sda")?;
// ... do I/O on the device while the tracer runs ...
let report = session.shutdown()?;
for event in &report.events {
if event.is_read() {
println!("read {} bytes at sector {}", event.event.bytes, event.event.sector);
}
}§The async feature
The tracing core is inherently blocking (relay channel reads and ioctl
waits). With features = ["async"] the crate adds monitor_async and
shutdown_async, which run that core on the tokio blocking pool so
async callers never stall their executor.
Structs§
- BlkTrace
- Entry point for starting a trace.
- BlkTrace
Event - One parsed
blk_io_tracerecord together with its trailing pdu data. - BlkTrace
Report - The outcome of a completed tracing session.
- BlkTrace
Session - A live tracing session.
- __
kernel_ fd_ set - __
kernel_ fsid_ t - blk_
io_ trace - blk_
io_ trace2 - blk_
io_ trace_ remap - blk_
user_ trace_ setup - blk_
user_ trace_ setup2
Enums§
- Blktrace
Error - Errors returned by this crate.
Constants§
- BLKTRACE_
BDEV_ SIZE - BLKTRACE_
BDEV_ SIZE2 - BLK_
IO_ TRAC E2_ VERSION - BLK_
IO_ TRACE_ MAGIC - BLK_
IO_ TRACE_ VERSION - BLK_
TC_ SHIFT - Blktrace_
running - Blktrace_
setup - Blktrace_
stopped - __
BITS_ PER_ LONG - __
BITS_ PER_ LONG_ LONG - __
FD_ SETSIZE - blktrace_
act___ BLK_ TA_ ABORT - blktrace_
act___ BLK_ TA_ BACKMERGE - blktrace_
act___ BLK_ TA_ BOUNCE - blktrace_
act___ BLK_ TA_ CGROUP - blktrace_
act___ BLK_ TA_ COMPLETE - blktrace_
act___ BLK_ TA_ DRV_ DATA - blktrace_
act___ BLK_ TA_ FRONTMERGE - blktrace_
act___ BLK_ TA_ GETRQ - blktrace_
act___ BLK_ TA_ INSERT - blktrace_
act___ BLK_ TA_ ISSUE - blktrace_
act___ BLK_ TA_ PLUG - blktrace_
act___ BLK_ TA_ QUEUE - blktrace_
act___ BLK_ TA_ REMAP - blktrace_
act___ BLK_ TA_ REQUEUE - blktrace_
act___ BLK_ TA_ SLEEPRQ - blktrace_
act___ BLK_ TA_ SPLIT - blktrace_
act___ BLK_ TA_ UNPLUG_ IO - blktrace_
act___ BLK_ TA_ UNPLUG_ TIMER - blktrace_
act___ BLK_ TA_ ZONE_ PLUG - blktrace_
act___ BLK_ TA_ ZONE_ UNPLUG - blktrace_
cat_ BLK_ TC_ AHEAD - blktrace_
cat_ BLK_ TC_ COMPLETE - blktrace_
cat_ BLK_ TC_ DISCARD - blktrace_
cat_ BLK_ TC_ DRV_ DATA - blktrace_
cat_ BLK_ TC_ END_ V1 - blktrace_
cat_ BLK_ TC_ END_ V2 - blktrace_
cat_ BLK_ TC_ FLUSH - blktrace_
cat_ BLK_ TC_ FS - blktrace_
cat_ BLK_ TC_ FUA - blktrace_
cat_ BLK_ TC_ ISSUE - blktrace_
cat_ BLK_ TC_ META - blktrace_
cat_ BLK_ TC_ NOTIFY - blktrace_
cat_ BLK_ TC_ PC - blktrace_
cat_ BLK_ TC_ QUEUE - blktrace_
cat_ BLK_ TC_ READ - blktrace_
cat_ BLK_ TC_ REQUEUE - blktrace_
cat_ BLK_ TC_ SYNC - blktrace_
cat_ BLK_ TC_ SYNCIO - blktrace_
cat_ BLK_ TC_ WRITE - blktrace_
cat_ BLK_ TC_ WRITE_ ZEROES - blktrace_
cat_ BLK_ TC_ ZONE_ APPEND - blktrace_
cat_ BLK_ TC_ ZONE_ CLOSE - blktrace_
cat_ BLK_ TC_ ZONE_ FINISH - blktrace_
cat_ BLK_ TC_ ZONE_ OPEN - blktrace_
cat_ BLK_ TC_ ZONE_ RESET - blktrace_
cat_ BLK_ TC_ ZONE_ RESET_ ALL - blktrace_
notify___ BLK_ TN_ CGROUP - blktrace_
notify___ BLK_ TN_ MESSAGE - blktrace_
notify___ BLK_ TN_ PROCESS - blktrace_
notify___ BLK_ TN_ TIMESTAMP
Type Aliases§
- __be16
- __be32
- __be64
- __
kernel_ caddr_ t - __
kernel_ clock_ t - __
kernel_ clockid_ t - __
kernel_ daddr_ t - __
kernel_ gid16_ t - __
kernel_ gid32_ t - __
kernel_ gid_ t - __
kernel_ ino_ t - __
kernel_ ipc_ pid_ t - __
kernel_ key_ t - __
kernel_ loff_ t - __
kernel_ long_ t - __
kernel_ mode_ t - __
kernel_ mqd_ t - __
kernel_ off_ t - __
kernel_ old_ dev_ t - __
kernel_ old_ gid_ t - __
kernel_ old_ time_ t - __
kernel_ old_ uid_ t - __
kernel_ pid_ t - __
kernel_ ptrdiff_ t - __
kernel_ sighandler_ t - __
kernel_ size_ t - __
kernel_ ssize_ t - __
kernel_ suseconds_ t - __
kernel_ time64_ t - __
kernel_ time_ t - __
kernel_ timer_ t - __
kernel_ uid16_ t - __
kernel_ uid32_ t - __
kernel_ uid_ t - __
kernel_ ulong_ t - __
kernel_ uoff_ t - __le16
- __le32
- __le64
- __
poll_ t - __s8
- __s16
- __s32
- __s64
- __s128
- __sum16
- __u8
- __u16
- __u32
- __u64
- __u128
- __wsum
- _bindgen_
ty_ 1 - blktrace_
act - blktrace_
cat - blktrace_
notify