← Documents Documentation/block/stat.rst GitHub 원문 ↗

Linux 6.18.37 · Block

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

block device stat file의 17개 누적 field와 completion, merge, sector 및 wait-time 집계 규칙을 설명합니다.

Source pathDocumentation/block/stat.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약과 해설

stat.rst:1-103

`/sys/block/<dev>/stat`은 한 줄에 17개 decimal counter를 제공하며, 한 번의 read로 일관된 device 상태 snapshot을 얻도록 모든 값을 단일 file에 배치합니다.

read·write·discard·flush counter는 완료 또는 merge 시점에 갱신되고 sector counter는 항상 512-byte UNIX sector 기준입니다. `in_flight`는 driver에 실제 발행된 미완료 request만 셉니다.

`io_ticks`는 device에 I/O가 존재한 실제 시간을, `time_in_queue`와 작업별 tick field는 기다린 request 수까지 반영한 누적 wait time을 나타냅니다. 따라서 여러 request가 동시에 기다리면 초당 1000 ms보다 빠르게 증가할 수 있습니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 ===============================================
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
10 Q.
11 Why are there multiple statistics in a single file? Doesn't sysfs
12 normally contain a single value per file?
13
14 A.
15 By having a single file, the kernel can guarantee that the statistics
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
21 The stat file consists of a single line of text containing 17 decimal
22 values separated by whitespace. The fields are summarized in the
23 following table, and described in more detail below.
24
25
26 =============== ============= =================================================
27 Name units description
28 =============== ============= =================================================
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
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
44 flush I/Os requests number of flush I/Os processed
45 flush ticks milliseconds total wait time for flush requests
46 =============== ============= =================================================
47
48 read I/Os, write I/Os, discard I/0s
49 ===================================
50
51 These values increment when an I/O request completes.
52
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
61 read merges, write merges, discard merges
62 =========================================
63
64 These values increment when an I/O request is merged with an
65 already-queued I/O request.
66
67 read sectors, write sectors, discard_sectors
68 ============================================
69
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.
74
75 read ticks, write ticks, discard ticks, flush ticks
76 ===================================================
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).
104

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

Block layer stat 개요

1-23

이 문서는 `/sys/block/<dev>/stat` file의 내용을 설명합니다. stat file은 block device `<dev>`의 상태에 관한 여러 statistic을 제공합니다.

질문: sysfs는 보통 file 하나에 값 하나를 두는데, 왜 statistic 여러 개를 한 file에 넣습니까?

답변: single file을 사용하면 kernel이 statistic 전체가 device 상태의 일관된 snapshot을 나타내도록 보장할 수 있습니다. statistic마다 file을 따로 만들면 여러 값을 읽은 결과가 동일한 시점을 나타낸다고 보장할 수 없습니다.

stat file은 whitespace로 구분한 decimal 값 17개가 한 줄에 들어 있습니다. 각 field는 다음 표에 요약하며 뒤에서 자세히 설명합니다.

17개 stat field

24-46
Nameunitsdescription
`read I/Os`requests처리한 read I/O 수
`read merges`requestsqueue 안의 I/O와 merge한 read I/O 수
`read sectors`sectorsread한 sector 수
`read ticks`millisecondsread request의 전체 wait time
`write I/Os`requests처리한 write I/O 수
`write merges`requestsqueue 안의 I/O와 merge한 write I/O 수
`write sectors`sectorswrite한 sector 수
`write ticks`millisecondswrite request의 전체 wait time
`in_flight`requests현재 in flight 상태인 I/O 수
`io_ticks`millisecondsblock device가 active였던 전체 시간
`time_in_queue`milliseconds모든 request의 전체 wait time
`discard I/Os`requests처리한 discard I/O 수
`discard merges`requestsqueue 안의 I/O와 merge한 discard I/O 수
`discard sectors`sectorsdiscard한 sector 수
`discard ticks`millisecondsdiscard request의 전체 wait time
`flush I/Os`requests처리한 flush I/O 수
`flush ticks`millisecondsflush request의 전체 wait time

I/O 완료와 merge counter

47-65

`read I/Os`, `write I/Os`, `discard I/Os` 값은 I/O request가 완료될 때 증가합니다.

`flush I/Os` 값은 flush I/O request가 완료될 때 증가합니다. Block layer는 flush request를 결합하고 한 번에 최대 하나만 실행합니다. 이 값은 disk가 실행한 flush request를 세며 partition에서는 추적하지 않습니다.

`read merges`, `write merges`, `discard merges` 값은 I/O request가 이미 queue에 있는 I/O request와 merge될 때 증가합니다.

Sector counter

66-73

`read sectors`, `write sectors`, `discard sectors` 값은 이 block device에서 read·write·discard한 sector 수를 셉니다. 여기서 sector는 device 또는 filesystem 고유의 block size가 아니라 표준 UNIX `512-byte` sector입니다. counter는 I/O가 완료될 때 증가합니다.

I/O wait tick counter

74-82

`read ticks`, `write ticks`, `discard ticks`, `flush ticks` 값은 I/O request가 이 block device에서 기다린 millisecond 수를 셉니다.

여러 I/O request가 기다리면 이 값은 `1000/second`보다 빠르게 증가합니다. 예를 들어 read request 60개가 평균 30 ms를 기다리면 `read_ticks` field는 `60*30 = 1800`만큼 증가합니다.

in_flight

83-89

`in_flight` 값은 device driver에 발행됐지만 아직 완료되지 않은 I/O request 수를 셉니다. queue에 있지만 아직 device driver에 발행하지 않은 I/O request는 포함하지 않습니다.

io_ticks

90-95

`io_ticks` 값은 device에 I/O request가 queue되어 있던 millisecond 수를 셉니다.

time_in_queue

96-103

`time_in_queue` 값은 I/O request가 이 block device에서 기다린 millisecond 수를 셉니다. 여러 I/O request가 기다리면 이 값은 millisecond 수와 기다리는 request 수의 곱만큼 증가합니다. 예시는 앞의 `read ticks` 설명을 참조하십시오.