Block layer statistics in /sys/block/<dev>/stat

This file documents the contents of the /sys/block/<dev>/stat file.

The stat file provides several statistics about the state of blockdevice <dev>.

  1. Why are there multiple statistics in a single file? Doesn’t sysfsnormally contain a single value per file?
  1. By having a single file, the kernel can guarantee that the statisticsrepresent a consistent snapshot of the state of the device. If thestatistics were exported as multiple files containing one statisticeach, it would be impossible to guarantee that a set of readingsrepresent a single point in time.

The stat file consists of a single line of text containing 11 decimalvalues separated by whitespace. The fields are summarized in thefollowing table, and described in more detail below.

Nameunitsdescription
read I/Osrequestsnumber of read I/Os processed
read mergesrequestsnumber of read I/Os merged with in-queue I/O
read sectorssectorsnumber of sectors read
read ticksmillisecondstotal wait time for read requests
write I/Osrequestsnumber of write I/Os processed
write mergesrequestsnumber of write I/Os merged with in-queue I/O
write sectorssectorsnumber of sectors written
write ticksmillisecondstotal wait time for write requests
in_flightrequestsnumber of I/Os currently in flight
io_ticksmillisecondstotal time this block device has been active
time_in_queuemillisecondstotal wait time for all requests
discard I/Osrequestsnumber of discard I/Os processed
discard mergesrequestsnumber of discard I/Os merged with in-queue I/O
discard sectorssectorsnumber of sectors discarded
discard ticksmillisecondstotal wait time for discard requests
flush I/Osrequestsnumber of flush I/Os processed
flush ticksmillisecondstotal wait time for flush requests

read I/Os, write I/Os, discard I/0s

These values increment when an I/O request completes.

flush I/Os

These values increment when an flush I/O request completes.

Block layer combines flush requests and executes at most one at a time.This counts flush requests executed by disk. Not tracked for partitions.

read merges, write merges, discard merges

These values increment when an I/O request is merged with analready-queued I/O request.

read sectors, write sectors, discard_sectors

These values count the number of sectors read from, written to, ordiscarded from this block device. The “sectors” in question are thestandard UNIX 512-byte sectors, not any device- or filesystem-specificblock size. The counters are incremented when the I/O completes.

read ticks, write ticks, discard ticks, flush ticks

These values count the number of milliseconds that I/O requests havewaited on this block device. If there are multiple I/O requests waiting,these values will increase at a rate greater than 1000/second; forexample, if 60 read requests wait for an average of 30 ms, the read_ticksfield will increase by 60*30 = 1800.

in_flight

This value counts the number of I/O requests that have been issued tothe device driver but have not yet completed. It does not include I/Orequests that are in the queue but not yet issued to the device driver.

io_ticks

This value counts the number of milliseconds during which the device hashad I/O requests queued.

time_in_queue

This value counts the number of milliseconds that I/O requests have waitedon this block device. If there are multiple I/O requests waiting, thisvalue will increase as the product of the number of milliseconds times thenumber of requests waiting (see “read ticks” above for an example).