요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
===============================================
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 block
device <dev>.
Q.
Why are there multiple statistics in a single file? Doesn't sysfs
normally contain a single value per file?
A.
By having a single file, the kernel can guarantee that the statistics
represent a consistent snapshot of the state of the device. If the
statistics were exported as multiple files containing one statistic
each, it would be impossible to guarantee that a set of readings
represent a single point in time.
The stat file consists of a single line of text containing 17 decimal
values separated by whitespace. The fields are summarized in the
following table, and described in more detail below.
=============== ============= =================================================
Name units description
=============== ============= =================================================
read I/Os requests number of read I/Os processed
read merges requests number of read I/Os merged with in-queue I/O
read sectors sectors number of sectors read
read ticks milliseconds total wait time for read requests
write I/Os requests number of write I/Os processed
write merges requests number of write I/Os merged with in-queue I/O
write sectors sectors number of sectors written
write ticks milliseconds total wait time for write requests
in_flight requests number of I/Os currently in flight
io_ticks milliseconds total time this block device has been active
time_in_queue milliseconds total wait time for all requests
discard I/Os requests number of discard I/Os processed
discard merges requests number of discard I/Os merged with in-queue I/O
discard sectors sectors number of sectors discarded
discard ticks milliseconds total wait time for discard requests
flush I/Os requests number of flush I/Os processed
flush ticks milliseconds total 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 an
already-queued I/O request.
read sectors, write sectors, discard_sectors
============================================
These values count the number of sectors read from, written to, or
discarded from this block device. The "sectors" in question are the
standard UNIX 512-byte sectors, not any device- or filesystem-specific
block 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 have
waited on this block device. If there are multiple I/O requests waiting,
these values will increase at a rate greater than 1000/second; for
example, if 60 read requests wait for an average of 30 ms, the read_ticks
field will increase by 60*30 = 1800.
in_flight
=========
This value counts the number of I/O requests that have been issued to
the device driver but have not yet completed. It does not include I/O
requests 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 has
had I/O requests queued.
time_in_queue
=============
This value counts the number of milliseconds that I/O requests have waited
on this block device. If there are multiple I/O requests waiting, this
value will increase as the product of the number of milliseconds times the
number of requests waiting (see "read ticks" above for an example).
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| Name | units | description |
|---|---|---|
| `read I/Os` | requests | 처리한 read I/O 수 |
| `read merges` | requests | queue 안의 I/O와 merge한 read I/O 수 |
| `read sectors` | sectors | read한 sector 수 |
| `read ticks` | milliseconds | read request의 전체 wait time |
| `write I/Os` | requests | 처리한 write I/O 수 |
| `write merges` | requests | queue 안의 I/O와 merge한 write I/O 수 |
| `write sectors` | sectors | write한 sector 수 |
| `write ticks` | milliseconds | write request의 전체 wait time |
| `in_flight` | requests | 현재 in flight 상태인 I/O 수 |
| `io_ticks` | milliseconds | block device가 active였던 전체 시간 |
| `time_in_queue` | milliseconds | 모든 request의 전체 wait time |
| `discard I/Os` | requests | 처리한 discard I/O 수 |
| `discard merges` | requests | queue 안의 I/O와 merge한 discard I/O 수 |
| `discard sectors` | sectors | discard한 sector 수 |
| `discard ticks` | milliseconds | discard request의 전체 wait time |
| `flush I/Os` | requests | 처리한 flush I/O 수 |
| `flush ticks` | milliseconds | flush 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` 설명을 참조하십시오.
요약과 해설
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보다 빠르게 증가할 수 있습니다.