It's also possible to trace block I/O using only trace events subsystem, which can be useful for casual tracing if you don't want bother dealing with the userspace tools.
To enable tracing for a given device, use /sys/block/xxx/trace/enable, where xxx is the device name. This for example enables tracing for /dev/sdc:
root@crownbay:/sys/kernel/debug/tracing# echo 1 > /sys/block/sdc/trace/enable
Once you've selected the device(s) you want to trace, selecting the 'blk' tracer will turn the blk tracer on:
root@crownbay:/sys/kernel/debug/tracing# cat available_tracers blk function_graph function nop root@crownbay:/sys/kernel/debug/tracing# echo blk > current_tracer
Execute the workload you're interested in:
root@crownbay:/sys/kernel/debug/tracing# cat /media/sdc/testfile.txt
And look at the output (note here that we're using 'trace_pipe' instead of trace to capture this trace - this allows us to wait around on the pipe for data to appear):
root@crownbay:/sys/kernel/debug/tracing# cat trace_pipe cat-3587 [001] d..1 3023.276361: 8,32 Q R 1699848 + 8 [cat] cat-3587 [001] d..1 3023.276410: 8,32 m N cfq3587 alloced cat-3587 [001] d..1 3023.276415: 8,32 G R 1699848 + 8 [cat] cat-3587 [001] d..1 3023.276424: 8,32 P N [cat] cat-3587 [001] d..2 3023.276432: 8,32 I R 1699848 + 8 [cat] cat-3587 [001] d..1 3023.276439: 8,32 m N cfq3587 insert_request cat-3587 [001] d..1 3023.276445: 8,32 m N cfq3587 add_to_rr cat-3587 [001] d..2 3023.276454: 8,32 U N [cat] 1 cat-3587 [001] d..1 3023.276464: 8,32 m N cfq workload slice:150 cat-3587 [001] d..1 3023.276471: 8,32 m N cfq3587 set_active wl_prio:0 wl_type:2 cat-3587 [001] d..1 3023.276478: 8,32 m N cfq3587 fifo= (null) cat-3587 [001] d..1 3023.276483: 8,32 m N cfq3587 dispatch_insert cat-3587 [001] d..1 3023.276490: 8,32 m N cfq3587 dispatched a request cat-3587 [001] d..1 3023.276497: 8,32 m N cfq3587 activate rq, drv=1 cat-3587 [001] d..2 3023.276500: 8,32 D R 1699848 + 8 [cat]
And this turns off tracing for the specified device:
root@crownbay:/sys/kernel/debug/tracing# echo 0 > /sys/block/sdc/trace/enable