electron14 » October 8, 2010

Daily Archives: October 8, 2010

Storage

Lifecycle of Linux IO

Published by:

I’ve been playing with blktrace recently, and wanted to understand the flow of IO better and the order in which events take place. For example, when I see something like the following, I can better make sense of it:

8,48   0       50     0.966969101   163  A   W 1370345506 + 8 <- (8,49) 1370345472
8,49   0       51     0.966969659   163  Q   W 1370345506 + 8 [flush-8:48]
8,49   0       52     0.966970358   163  M   W 1370345506 + 8 [flush-8:48]
8,48   0       53     0.966972523   163  A   W 1370345538 + 8 <- (8,49) 1370345504
8,49   0       54     0.966973082   163  Q   W 1370345538 + 8 [flush-8:48]
8,49   0       55     0.966974199   163  G   W 1370345538 + 8 [flush-8:48]
8,49   0       56     0.966974967   163  I   W 1370345538 + 8 [flush-8:48]
8,49   0       60     0.966985444   163  D   W 1370345538 + 8 [flush-8:48]
8,49   0      150     0.967601527     0  C   W 1370345538 + 8 [0]

I couldn’t find any sort of detailed, step-by-step flow of blktrace events, so I put this flowchart together.  The information is based largely on what is described in the book “Understanding the Linux Kernel”, as well as man pages and other bits I’ve gleaned from the internet.

I believe it to be largely correct, although I’m not exactly the king of flowcharts so there may be some errors in the layout. There’s a discrepancy between when a queue is plugged according to the book, vs what I see in blktrace.  The book says the queue is checked for emptiness, then the queue is plugged, then a request descriptor is allocated, but blktrace reliably shows that the queue is plugged after the request descriptor is allocated.  If anyone has better information, or perhaps a better flow chart, I’d appreciate seeing it.