Mauro Carvalho Chehab | 898bd37 | 2019-04-18 19:45:00 -0300 | [diff] [blame] | 1 | =============================================== |
Andy Isaacson | 37a3279 | 2006-01-08 01:04:00 -0800 | [diff] [blame] | 2 | Block layer statistics in /sys/block/<dev>/stat |
| 3 | =============================================== |
| 4 | |
| 5 | This file documents the contents of the /sys/block/<dev>/stat file. |
| 6 | |
| 7 | The stat file provides several statistics about the state of block |
| 8 | device <dev>. |
| 9 | |
Mauro Carvalho Chehab | 898bd37 | 2019-04-18 19:45:00 -0300 | [diff] [blame] | 10 | Q. |
| 11 | Why are there multiple statistics in a single file? Doesn't sysfs |
Andy Isaacson | 37a3279 | 2006-01-08 01:04:00 -0800 | [diff] [blame] | 12 | normally contain a single value per file? |
Mauro Carvalho Chehab | 898bd37 | 2019-04-18 19:45:00 -0300 | [diff] [blame] | 13 | |
| 14 | A. |
| 15 | By having a single file, the kernel can guarantee that the statistics |
Andy Isaacson | 37a3279 | 2006-01-08 01:04:00 -0800 | [diff] [blame] | 16 | represent a consistent snapshot of the state of the device. If the |
| 17 | statistics were exported as multiple files containing one statistic |
| 18 | each, it would be impossible to guarantee that a set of readings |
| 19 | represent a single point in time. |
| 20 | |
Gao Mingfei | e53eeac | 2021-06-01 08:51:45 +0000 | [diff] [blame] | 21 | The stat file consists of a single line of text containing 17 decimal |
Andy Isaacson | 37a3279 | 2006-01-08 01:04:00 -0800 | [diff] [blame] | 22 | values separated by whitespace. The fields are summarized in the |
| 23 | following table, and described in more detail below. |
| 24 | |
Mauro Carvalho Chehab | 898bd37 | 2019-04-18 19:45:00 -0300 | [diff] [blame] | 25 | |
| 26 | =============== ============= ================================================= |
Andy Isaacson | 37a3279 | 2006-01-08 01:04:00 -0800 | [diff] [blame] | 27 | Name units description |
Mauro Carvalho Chehab | 898bd37 | 2019-04-18 19:45:00 -0300 | [diff] [blame] | 28 | =============== ============= ================================================= |
Andy Isaacson | 37a3279 | 2006-01-08 01:04:00 -0800 | [diff] [blame] | 29 | read I/Os requests number of read I/Os processed |
| 30 | read merges requests number of read I/Os merged with in-queue I/O |
| 31 | read sectors sectors number of sectors read |
| 32 | read ticks milliseconds total wait time for read requests |
| 33 | write I/Os requests number of write I/Os processed |
| 34 | write merges requests number of write I/Os merged with in-queue I/O |
| 35 | write sectors sectors number of sectors written |
| 36 | write ticks milliseconds total wait time for write requests |
| 37 | in_flight requests number of I/Os currently in flight |
| 38 | io_ticks milliseconds total time this block device has been active |
| 39 | time_in_queue milliseconds total wait time for all requests |
Michael Callahan | bdca3c8 | 2018-07-18 04:47:40 -0700 | [diff] [blame] | 40 | discard I/Os requests number of discard I/Os processed |
| 41 | discard merges requests number of discard I/Os merged with in-queue I/O |
| 42 | discard sectors sectors number of sectors discarded |
| 43 | discard ticks milliseconds total wait time for discard requests |
Konstantin Khlebnikov | b686631 | 2019-11-21 13:40:26 +0300 | [diff] [blame] | 44 | flush I/Os requests number of flush I/Os processed |
| 45 | flush ticks milliseconds total wait time for flush requests |
Mauro Carvalho Chehab | 898bd37 | 2019-04-18 19:45:00 -0300 | [diff] [blame] | 46 | =============== ============= ================================================= |
Andy Isaacson | 37a3279 | 2006-01-08 01:04:00 -0800 | [diff] [blame] | 47 | |
Michael Callahan | bdca3c8 | 2018-07-18 04:47:40 -0700 | [diff] [blame] | 48 | read I/Os, write I/Os, discard I/0s |
| 49 | =================================== |
Andy Isaacson | 37a3279 | 2006-01-08 01:04:00 -0800 | [diff] [blame] | 50 | |
| 51 | These values increment when an I/O request completes. |
| 52 | |
Konstantin Khlebnikov | b686631 | 2019-11-21 13:40:26 +0300 | [diff] [blame] | 53 | flush I/Os |
| 54 | ========== |
| 55 | |
| 56 | These values increment when an flush I/O request completes. |
| 57 | |
| 58 | Block layer combines flush requests and executes at most one at a time. |
| 59 | This counts flush requests executed by disk. Not tracked for partitions. |
| 60 | |
Michael Callahan | bdca3c8 | 2018-07-18 04:47:40 -0700 | [diff] [blame] | 61 | read merges, write merges, discard merges |
| 62 | ========================================= |
Andy Isaacson | 37a3279 | 2006-01-08 01:04:00 -0800 | [diff] [blame] | 63 | |
| 64 | These values increment when an I/O request is merged with an |
| 65 | already-queued I/O request. |
| 66 | |
Michael Callahan | bdca3c8 | 2018-07-18 04:47:40 -0700 | [diff] [blame] | 67 | read sectors, write sectors, discard_sectors |
| 68 | ============================================ |
Andy Isaacson | 37a3279 | 2006-01-08 01:04:00 -0800 | [diff] [blame] | 69 | |
Michael Callahan | bdca3c8 | 2018-07-18 04:47:40 -0700 | [diff] [blame] | 70 | These values count the number of sectors read from, written to, or |
| 71 | discarded from this block device. The "sectors" in question are the |
| 72 | standard UNIX 512-byte sectors, not any device- or filesystem-specific |
| 73 | block size. The counters are incremented when the I/O completes. |
Andy Isaacson | 37a3279 | 2006-01-08 01:04:00 -0800 | [diff] [blame] | 74 | |
Konstantin Khlebnikov | b686631 | 2019-11-21 13:40:26 +0300 | [diff] [blame] | 75 | read ticks, write ticks, discard ticks, flush ticks |
| 76 | =================================================== |
Andy Isaacson | 37a3279 | 2006-01-08 01:04:00 -0800 | [diff] [blame] | 77 | |
| 78 | These values count the number of milliseconds that I/O requests have |
| 79 | waited on this block device. If there are multiple I/O requests waiting, |
| 80 | these values will increase at a rate greater than 1000/second; for |
| 81 | example, if 60 read requests wait for an average of 30 ms, the read_ticks |
| 82 | field will increase by 60*30 = 1800. |
| 83 | |
| 84 | in_flight |
| 85 | ========= |
| 86 | |
| 87 | This value counts the number of I/O requests that have been issued to |
| 88 | the device driver but have not yet completed. It does not include I/O |
| 89 | requests that are in the queue but not yet issued to the device driver. |
| 90 | |
| 91 | io_ticks |
| 92 | ======== |
| 93 | |
| 94 | This value counts the number of milliseconds during which the device has |
| 95 | had I/O requests queued. |
| 96 | |
| 97 | time_in_queue |
| 98 | ============= |
| 99 | |
| 100 | This value counts the number of milliseconds that I/O requests have waited |
| 101 | on this block device. If there are multiple I/O requests waiting, this |
| 102 | value will increase as the product of the number of milliseconds times the |
| 103 | number of requests waiting (see "read ticks" above for an example). |