btrace - perform live tracing for block devices

btrace can show detailed info about what is happening on a block device io queue. This is valuable for diagnosing and fixing performance or application problems relating to block layer io.

The btrace script provides a quick and easy way to do live tracing of block devices. It calls blktrace on the specified devices and pipes the output through blkparse for formatting.

            btrace  [-s]
                    [-t]
                    [-w N]
                    [-n N]
                    [-b N]
                    [-a <trace>...]
                    [-r <dbg mnt>]
                    [-h]
                    [-v]
                    <dev>...        Specifies the device to trace.

    实际是执行

        blktrace ${TRACEOPTS} -o- $@  |  blkparse "-b100000" ${PARSEOPTS} -i-

            ${TRACEOPTS}
                    [-w N]          Sets run time to the number of seconds specified
                    [-n N]          Specifies the number of buffers to use
                    [-b N]          Specifies buffer size for event extraction (scaled by 1024) 
                    [-a <trace>...] Adds mask to current filter
                    [-r <dbg mnt>]  Specifies the debugfs mountpoint.           
            ${PARSEOPTS}
                    [-s]            Displays data sorted by blkparse
                    [-t]            Displays time deltas per IO
                    [-h]            Hash processes by name, not by PID
                    [-v]            More verbose marginal on marginal errors