blktrace is a block layer IO tracing mechanism which provide detailed information about request queue operations up to user space.
blkparse will combine streams of events for various devices on various CPUs, and produce a formatted output the the event information.
It take the output of above tool blktrace and convert those information into fency readable form.
In the following, We will use those tools blktrace and blkparse to help us to observe sector numbers which has been written by fio requests.
We will use the fil to generate two diffenrt IO pattern requests, sequence write and random write.
OS: Ubuntu 14.04
you can use following commands to install blktrace and blkparse
In order to make the output of blkparse more easily to read, we set the numjobs to 1.
Following is my fio config
After we setup the fio config, use the fio to generate the IO request. In this example, we ask the fio to generate the IO via sequence write pattern.
During the experiment, you can use the tool
iostat to monitor the I/O information about the device we want to observe.
Open other terminal and use
blktrace to collection the data, there are two parameter we need to use,
First one is -d, which indicate what target device blktrace will monitor to.
Second, is -w, we use it to limit the time (seconds) how long blktrace will run.
So, our final command looks like below.
In the end of blktrace, you can discover some new files has created by blktrace and its prefix name is nvme1n1.blktrac.xx
The number of files is depends how may CPUs in your system.
Now, we can use the blkparse to regenerate human-readable output form the output we get via blktrace before.
We need to indicate source files, you can just use the device name without .blktrace.xx, for example,
nvmen1, it will search all files which match the pattern nvmen1.blktrace.xx and put together to analyze.
Then, the -f option used to foramt the output data, you can find more about it via man blkparse
For our observation, we use %5T.%9t, %p, %C, %a, %S\n to format our result containing timestamp, command, process ID, action and sequence number.
Since the data I/O contains many action, such as complete, queued, inserted..ect. we can use option -a to filter actions, you can find more info via man blktrace.
In this case, we use the write to filter the actions.
In the end, use the -o options to indicate the output file name.
The command will look like below and it will output the result to file output.txt.
open the file, the result looks like
Since the fio will fork to two process to handle the process, we use the grep to focus on one specific process (pid=22892).
Now, the result seems good, we can discover the sequence number (fifth column) is increasing.
One thing we need to care about is the row which action is “C”, which means the completed, since we don’t know how NVME handle those request and reply to upper layer. we only need to focus on other action. such as “Q (queued This notes intent to queue i/o at the given location. No real requests exists yet.)” or “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)”.
Now, we can do all above command again and change the section to rw for fio using the randon write pattern. The blkparse result will show the random sequence number.
In this article, we try to use tools blktrace and blkparse to analysiz the block level I/O for fio request.
We observe the filed sequence number to make sure thhat the fio can generate the sequence or random according to its config.