blkparse 命令详解

| 选择喜欢的代码风格  


blkparse 命令安装:

-bash/zsh: blkparse command not found

apt-get install blktrace

apt-get install blktrace

#Kali Linux
apt-get install blktrace

yum install blktrace

dnf install blktrace

apt-get install blktrace

blkparse 命令补充说明:

blkparse 工具将尝试对各种 CPU 各种设备的事件流相结合,而产生的事件信息的格式输出。具体来说,它将采用 blktrace 实用程序的(机器可读)输出,并将其转换为格式良好且易于阅读的形式。

blkparse 命令语法:

blkparse [ options ]

blkparse 命令选项:

-A hex-mask
Set filter mask to hex-mask, see blktrace (8) for masks
-a mask

Add mask to current filter, see blktrace (8) for masks
-D dir

Prepend dir to input file names
-b batch

Standard input read batching
-i file

Specifies base name for input files -- default is device.blktrace.cpu.
As noted above, specifying -i - runs in live mode with blktrace (reading data from standard in).

-F typ,fmt
-f fmt

Sets output format (See OUTPUT DESCRIPTION AND FORMATTING for details.)
The -f form specifies a format for all events

The -F form allows one to specify a format for a specific event type. The single-character typ field is one of the action specifiers described in ACTION IDENTIFIERS.


When -d is specified, this will stop messages from being output to the file. (Can seriously reduce the size of the resultant file when using the CFQ I/O scheduler.)

Hash processes by name, not by PID
-o file

Output file

Do not produce text output, used for binary (-d) only
-d file

Binary output file

Quiet mode

Displays data sorted by program

Display time deltas per IO
-w span

Display traces for the span specified -- where span can be:
end-time -- Display traces from time 0 through end-time (in ns)
start:end-time -- Display traces from time start through end-time (in ns).

More verbose marginal on marginal errors

Display version

Trace Actions
The following trace actions are recognised:
C -- complete
A previously issued request has been completed. The output will detail the sector and size of that request, as well as the success or failure of it.
D -- issued
A request that previously resided on the block layer queue or in the i/o scheduler has been sent to the driver.
I -- inserted
A request is being sent to the i/o scheduler for addition to the internal queue and later service by the driver. The request is fully formed at this time.
Q -- queued
This notes intent to queue i/o at the given location. No real requests exists yet.
B -- bounced
The data pages attached to this bio are not reachable by the hardware and must be bounced to a lower memory location. This causes a big slowdown in i/o performance, since the data must be copied to/from kernel buffers. Usually this can be fixed with using better hardware -- either a better i/o controller, or a platform with an IOMMU.
M -- back merge
A previously inserted request exists that ends on the boundary of where this i/o begins, so the i/o scheduler can merge them together.
F -- front merge
Same as the back merge, except this i/o ends where a previously inserted requests starts.
M --front or back merge
One of the above

M -- front or back merge
One of the above.
G -- get request
To send any type of request to a block device, a struct request container must be allocated first.
S -- sleep
No available request structures were available, so the issuer has to wait for one to be freed.
P -- plug
When i/o is queued to a previously empty block device queue, Linux will plug the queue in anticipation of future ios being added before this data is needed.
U -- unplug
Some request data already queued in the device, start sending requests to the driver. This may happen automatically if a timeout period has passed (see next entry) or if a number of requests have been added to the queue.
T -- unplug due to timer
If nobody requests the i/o that was queued after plugging the queue, Linux will automatically unplug it after a defined period has passed.
X -- split
On raid or device mapper setups, an incoming i/o may straddle a device or internal zone and needs to be chopped up into smaller pieces for service. This may indicate a performance problem due to a bad setup of that raid/dm device, but may also just be part of normal boundary conditions. dm is notably bad at this and will clone lots of i/o.
A -- remap
For stacked devices, incoming i/o is remapped to device below it in the i/o stack. The remap action details what exactly is being remapped to what.
Output Description and Formatting
The output from blkparse can be tailored for specific use -- in particular, to ease parsing of output, and/or limit output fields to those the user wants to see. The data for fields which can be output include:

Action, a (small) string (1 or 2 characters) -- see table below for more details
CPU id
RWBS field, a (small) string (1-3 characters) -- see section below
for more details

7-character string containing the major and minor numbers of the event's device (separated by a comma).
Error value
Minor number of event's device.
Major number of event's device.
Number of blocks
of bytes

Process ID
Display packet data -- series of hexadecimal values
Sequence numbers
Sector number
Time stamp (nanoseconds)
Time stamp (seconds)
Elapsed value in microseconds (-t command line option)
unsigned integer

Note that the user can optionally specify field display width, and optionally a left-aligned specifier. These precede field specifiers, with a '%' character, followed by the optional left-alignment specifier (-) followed by the width (a decimal number) and then the field.

Thus, to specify the command in a 12-character field that is left aligned:

-f "%-12C"
Action Identifiers
The following table shows the various actions which may be output:

IO was remapped to a different device
IO bounced

IO issued to driver
IO front merged with request on queue
Get request
IO inserted onto request queue
IO back merged with request
on queue

Plug request
IO handled by request queue code
Sleep request
Unplug due to timeout
Unplug request
Rwbs Description
This is a small string containing at least one character ('R' for read, 'W' for write, or 'D' for block discard operation), and optionally either a 'B' (for barrier operations) or 'S' (for synchronous operations).

Default Output
The standard header (or initial fields displayed) include:

"%D %2c %8s %5T.%9t %5p %2a %3d"

Breaking this down:

Displays the event's device major/minor as: %3d,%-3d.
CPU ID (2-character field).
Sequence number
5-character field for the seconds portion of the time stamp and a 9-character field for the nanoseconds in the time stamp.
5-character field for the process ID.
2-character field for one of the actions.
3-character field for the RWBS data.
Seeing this in action:

8,0 3 1 0.000000000 697 G W 223490 + 8 [kjournald]

The header is the data in this line up to the 223490 (starting block). The default output for all event types includes this header.

Default Output Per Action
C -- complete

If a payload is present, this is presented between parenthesis following the header, followed by the error value.
If no payload is present, the sector and number of blocks are presented (with an intervening plus (+) character). If the -t option was specified, then the elapsed time is presented. In either case, it is followed by the error value for the completion.

B -- bounced
D -- issued
I -- inserted
Q -- queued

If a payload is present, the number of payload bytes is output, followed by the payload in hexadecimal between parenthesis.
If no payload is present, the sector and number of blocks are presented (with an intervening plus (+) character). If the -t option was specified, then the elapsed time is presented (in parenthesis). In either case, it is followed by the command associated with the event (surrounded by square brackets).

F -- front merge
G -- get request
M -- back merge
S -- sleep

The starting sector and number of blocks is output (with an intervening plus (+) character), followed by the command associated with the event (surrounded by square brackets).
P -- plug

The command associated with the event (surrounded by square brackets) is output.
U -- unplug
T -- unplug due to timer

The command associated with the event (surrounded by square brackets) is output, followed by the number of requests outstanding.
X -- split

The original starting sector followed by the new sector (separated by a slash (/) is output, followed by the command associated with the event (surrounded by square brackets).
A -- remap

Sector and length is output, along with the original device and sector offset.

blkparse 命令实例:

blkparse 实例详见:blktrace 命令

blkparse 命令扩展阅读:

blkparse 命令评论