All Products
Search
Document Center

Alibaba Cloud Linux:Detect I/O hangs of file systems and block layers

Last Updated:Mar 31, 2026

When time-consuming I/O requests stall, the system can become unstable or go down before you have enough information to diagnose the cause. Alibaba Cloud Linux 2 and Alibaba Cloud Linux 3 extend core kernel data structures to expose per-device hang counts, per-request details, and per-process wait information — all with low overhead. This topic describes the available interfaces and shows how to use them.

How it works

The kernel tracks every I/O request from submission to completion. When a request exceeds the configured hang threshold, the kernel marks it as a hang. Query the interfaces in the following order to diagnose an I/O hang:

  1. Check /sys/block/<device>/hang — confirm whether I/O hangs have occurred on the device.

  2. Check /sys/kernel/debug/block/<device>/rq_hang — get details about each hanging request.

  3. Check /proc/<pid>/wait_res or /proc/<pid>/task/<tid>/wait_res — identify which process or thread is blocked and what it is waiting for.

Interfaces

InterfaceDescriptionUnit
/sys/block/<device>/queue/hang_thresholdQuery or set the threshold for I/O hangs. Default: 5000.ms
/sys/block/<device>/hangQuery the count of I/O operations that exceeded the hang threshold. Output format: <read_count> <write_count>.
/sys/kernel/debug/block/<device>/rq_hangQuery details about hanging I/O requests.
/proc/<pid>/wait_resQuery the resources a process is waiting for.
/proc/<pid>/task/<tid>/wait_resQuery the resources a thread is waiting for.

The following table describes the variables in the interface paths.

VariableDescription
<device>Name of the block storage device
<pid>Process ID
<tid>Thread ID

Set the hang threshold

The default hang threshold is 5,000 ms. Adjust it to match your workload's expected I/O latency.

  1. Write the new threshold to the interface. This example sets the threshold on the vdb disk to 10,000 ms.

    echo 10000 > /sys/block/vdb/queue/hang_threshold
  2. Verify the change.

    cat /sys/block/vdb/queue/hang_threshold

    Expected output:

    10000

Check the hang count

Read the hang interface to see how many read and write operations have exceeded the threshold on a device. This example uses the vdb disk.

cat /sys/block/vdb/hang

Sample output:

0        1

The output contains two values separated by whitespace:

FieldDescription
Left valueNumber of read operations that caused I/O hangs
Right valueNumber of write operations that caused I/O hangs

In this output, 0 read hangs and 1 write hang have been recorded.

Inspect hanging requests

Read the rq_hang interface to get details about each hanging request. This example uses the vdb disk.

cat /sys/kernel/debug/block/vdb/rq_hang

Sample output:

ffff9e50162fc600 {.op=WRITE, .cmd_flags=SYNC, .rq_flags=STARTED|ELVPRIV|IO_STAT|STATS, .state=in_flight, .tag=118, .internal_tag=67, .start_time_ns=1260981417094, .io_start_time_ns=1260981436160, .current_time=1268458297417, .bio = ffff9e4907c31c00, .bio_pages = { ffffc85960686740 }, .bio = ffff9e4907c31500, .bio_pages = { ffffc85960639000 }, .bio = ffff9e4907c30300, .bio_pages = { ffffc85960651700 }, .bio = ffff9e4907c31900, .bio_pages = { ffffc85960608b00 }}

Each entry represents one hanging I/O request. The key fields are:

FieldDescription
.opI/O operation type, such as READ or WRITE
.cmd_flagsCommand flags for the request, such as SYNC
.rq_flagsRequest state flags, such as STARTED and IO_STAT
.stateCurrent state of the request in the block layer, such as in_flight
.tagHardware queue tag assigned to the request
.internal_tagSoftware queue tag assigned internally
start_time_nsTime the request was submitted to the block layer (nanoseconds)
io_start_time_nsStart time of the I/O request (nanoseconds). A non-zero value means the I/O request was not processed in a timely manner, indicating a prolonged I/O time.
current_timeTime of the snapshot (nanoseconds). Subtract io_start_time_ns from current_time to get the elapsed hang duration.
.bioAddress of the associated bio structure
.bio_pagesAddresses of the pages referenced by the bio

Identify blocked processes

Read /proc/<pid>/wait_res to find out what resources a process is waiting for. This example checks process 577.

cat /proc/577/wait_res

Sample output:

1 0000000000000000 4310058496 4310061448

The output contains four space-separated fields:

FieldDescription
Field 1Type of resource the process is waiting for. 1 = page cache in the file system. 2 = block I/O layer.
Field 2Address of the resource (page cache entry or block I/O layer) the process is waiting for
Field 3Time at which the process started waiting for the resource
Field 4Current time when the file is read. Subtract Field 3 from Field 4 to get the total wait time.

To check a specific thread, use /proc/<pid>/task/<tid>/wait_res with the same output format.