Skip to content

Commit 81a0338

Browse files
ChaitanayaKulkarnikawasaki
authored andcommitted
blktrace: add blktrace zone management regression test
Create a new blktrace test group and add a regression test for a blktrace false positive WARNING that occurs when zone management commands are traced with blktrace on V1 version. Bug: https://syzkaller.appspot.com/bug?extid=153e64c0aa875d7e4c37 Location: kernel/trace/blktrace.c:367-368 The test: 1. Creates a zoned null_blk device (8 zones, 1GB, no conventional zones) 2. Starts blktrace on the device 3. Issues zone open command for all zones 4. Checks dmesg for the false positive WARNING Device configuration: - Total size: 1GB - Zone size: 128MB - Number of zones: 8 - Conventional zones: 0 If the WARNING is found, the bug is present and logged to the full output. If no WARNING appears, the bug is fixed. Note: The bug uses WARN_ON_ONCE, so it triggers only once per boot. Subsequent runs after the first trigger will not show the WARNING: commit 4a0940bdcac260be1e3460e99464fa63d317c6a2 Author: Chaitanya Kulkarni <[email protected]> Date: Mon Oct 27 19:46:19 2025 -0700 blktrace: use debug print to report dropped events https://lore.kernel.org/linux-block/[email protected]/ Signed-off-by: Chaitanya Kulkarni <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
1 parent 4badb27 commit 81a0338

3 files changed

Lines changed: 105 additions & 0 deletions

File tree

tests/blktrace/001

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-3.0+
3+
# Copyright (C) 2025 Chaitanya Kulkarni <[email protected]>
4+
#
5+
# Regression test for blktrace false positive WARNING on zone management
6+
# commands.
7+
#
8+
# Bug: https://syzkaller.appspot.com/bug?extid=153e64c0aa875d7e4c37
9+
# Location: kernel/trace/blktrace.c:367-368
10+
#
11+
# The bug triggers a WARNING when zone management commands (zone open/close/
12+
# finish/reset) are traced with blktrace on V1 version. This is a false
13+
# positive that should be fixed.
14+
15+
. tests/blktrace/rc
16+
. common/null_blk
17+
18+
DESCRIPTION="blktrace zone management command tracing"
19+
QUICK=1
20+
21+
requires() {
22+
_have_program blkzone
23+
_have_null_blk
24+
_have_module_param null_blk zoned
25+
}
26+
27+
test() {
28+
echo "Running ${TEST_NAME}"
29+
30+
local blktrace_pid
31+
local warning_count
32+
local device
33+
34+
# Create zoned null_blk device via configfs
35+
# 8 zones, 1GB total, 128MB per zone, no conventional zones
36+
if ! _configure_null_blk nullb1 \
37+
memory_backed=1 \
38+
zone_size=128 \
39+
zone_nr_conv=0 \
40+
size=1024 \
41+
zoned=1 \
42+
power=1; then
43+
return 1
44+
fi
45+
46+
device=/dev/nullb1
47+
48+
# Verify it's a zoned device
49+
local zoned_mode
50+
zoned_mode=$(cat /sys/block/nullb1/queue/zoned)
51+
if [[ "$zoned_mode" != "host-managed" ]]; then
52+
echo "Device is not zoned (mode: $zoned_mode)"
53+
_exit_null_blk
54+
return 1
55+
fi
56+
57+
# Start blktrace
58+
blktrace --dev="${device}" --output=trace --output-dir="$TMPDIR" \
59+
>> "$FULL" 2>&1 &
60+
blktrace_pid=$!
61+
sleep 2
62+
63+
# Verify blktrace started
64+
if ! ps -p $blktrace_pid > /dev/null 2>&1; then
65+
echo "blktrace failed to start"
66+
_exit_null_blk
67+
return 1
68+
fi
69+
70+
# Issue zone open command for all zones (triggers bug if present)
71+
blkzone open "${device}" >> "$FULL" 2>&1
72+
73+
sleep 1
74+
75+
# Stop blktrace
76+
kill $blktrace_pid 2>/dev/null
77+
wait $blktrace_pid 2>/dev/null
78+
79+
# Check for WARNING (bug present if WARNING found)
80+
warning_count=$(_dmesg_since_test_start | grep -c "WARNING.*blktrace.c:367" || true)
81+
82+
if [[ $warning_count -gt 0 ]]; then
83+
echo "WARNING: blktrace bug detected at blktrace.c:367"
84+
_dmesg_since_test_start | grep -A 10 "WARNING.*blktrace.c:367" >> "$FULL"
85+
fi
86+
87+
_exit_null_blk
88+
89+
echo "Test complete"
90+
}

tests/blktrace/001.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Running blktrace/001
2+
Test complete

tests/blktrace/rc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-3.0+
3+
# Copyright (C) 2025 Chaitanya Kulkarni <[email protected]>
4+
#
5+
# Tests for blktrace infrastructure
6+
7+
. common/rc
8+
9+
group_requires() {
10+
_have_root
11+
_have_blktrace
12+
_have_program blkparse
13+
}

0 commit comments

Comments
 (0)