File Systems

From DTraceBook

Jump to: navigation, search

This chapter uses DTrace to examine file systems including VFS, ZFS, UFS, HFS+, PCFS, UDFS and TMPFS.

Contents

One-Liners

syscall Provider

Trace file opens with process name:
dtrace -n 'syscall::open*:entry { printf("%s %s", execname, copyinstr(arg0)); }'

Trace file creat() calls with file and process name:
dtrace -n 'syscall::creat*:entry { printf("%s %s", execname, copyinstr(arg0)); }'

Frequency count stat() files:
dtrace -n 'syscall::stat*:entry { @[copyinstr(arg0)] = count(); }'

Tracing "cd":
dtrace -n 'syscall::chdir:entry { printf("%s -> %s", cwd, copyinstr(arg0)); }'

Count read/write syscalls by syscall type:
dtrace -n 'syscall::*read*:entry,syscall::*write*:entry { @[probefunc] = count(); }'

Syscall read(2) by file name:
dtrace -n 'syscall::read:entry { @[fds[arg0].fi_pathname] = count(); }'

Syscall write(2) by file name:
dtrace -n 'syscall::write:entry { @[fds[arg0].fi_pathname] = count(); }'

Syscall read(2) by filesystem type:
dtrace -n 'syscall::read:entry { @[fds[arg0].fi_fs] = count(); }'

Syscall write(2) by filesystem type:
dtrace -n 'syscall::write:entry { @[fds[arg0].fi_fs] = count(); }'

Syscall read(2) by process name for the "zfs" filesystem only:
dtrace -n 'syscall::read:entry /fds[arg0].fi_fs == "zfs"/ { @[execname] = count(); }'

Syscall write(2) by process name and filesystem type:
dtrace -n 'syscall::write:entry { @[execname, fds[arg0].fi_fs] = count(); } END { printa("%18s %16s %16@d\n", @); }'

vminfo Provider

Processes paging in from the filesystem:
dtrace -n 'vminfo:::fspgin { @[execname] = sum(arg0); }'

fsinfo Provider

Count filesystem calls by VFS operation:
dtrace -n 'fsinfo::: { @[probename] = count(); }'

Count filesystem calls by mountpoint:
dtrace -n 'fsinfo::: { @[args[0]->fi_mount] = count(); }'

Bytes read by filename:
dtrace -n 'fsinfo:::read { @[args[0]->fi_pathname] = sum(arg1); }'

Bytes written by filename:
dtrace -n 'fsinfo:::write { @[args[0]->fi_pathname] = sum(arg1); }'

Read I/O size distribution by filesystem mountpoint:
dtrace -n 'fsinfo:::read { @[args[0]->fi_mount] = quantize(arg1); }'

Write I/O size distribution by filesystem mountpoint:
dtrace -n 'fsinfo:::write { @[args[0]->fi_mount] = quantize(arg1); }'

vfs Provider

Count filesystem calls by VFS operation:
dtrace -n 'vfs:vop::entry { @[probefunc] = count(); }'

Namecache hit/miss statistics:
dtrace -n 'vfs:namecache:lookup: { @[probename] = count(); }'

sdt Provider

Who is reading from the ZFS ARC (in-DRAM cache):
dtrace -n 'sdt:::arc-hit,sdt:::arc-miss { @[stack()] = count(); }'

fbt Provider

VFS: Count filesystem calls at the fop interface (Solaris):
dtrace -n 'fbt::fop_*:entry { @[probefunc] = count(); }'

VFS: Count filesystem calls at the VNOP interface (Mac OS X):
dtrace -n 'fbt::VNOP_*:entry { @[probefunc] = count(); }'

VFS: Count filesystem calls at the VOP interface (FreeBSD):
dtrace -n 'fbt::VOP_*:entry { @[probefunc] = count(); }'

ZFS: Show SPA sync with pool name and TXG number:
dtrace -n 'fbt:zfs:spa_sync:entry { printf("%s %d", stringof(args[0]->spa_name),arg1); }'

Scripts

Errata

Links

Personal tools