Skip to content

Commit 9eae120

Browse files
committed
zbd/013: Test stacked drivers and queue freezing
Add a test that triggers the following deadlock between queue freezing and zoned block device writes in kernel versions 6.10..6.15: Call Trace: <TASK> __schedule+0x43f/0x12f0 schedule+0x27/0xf0 __bio_queue_enter+0x10e/0x230 __submit_bio+0xf0/0x280 submit_bio_noacct_nocheck+0x185/0x3d0 blk_zone_wplug_bio_work+0x1ad/0x1f0 process_one_work+0x17b/0x330 worker_thread+0x2ce/0x3f0 kthread+0xec/0x220 ret_from_fork+0x31/0x50 ret_from_fork_asm+0x1a/0x30 </TASK> Call Trace: <TASK> __schedule+0x43f/0x12f0 schedule+0x27/0xf0 blk_mq_freeze_queue_wait+0x6f/0xa0 queue_attr_store+0x14f/0x1b0 kernfs_fop_write_iter+0x13b/0x1f0 vfs_write+0x253/0x420 ksys_write+0x64/0xe0 do_syscall_64+0x82/0x160 entry_SYSCALL_64_after_hwframe+0x76/0x7e </TASK> Signed-off-by: Bart Van Assche <[email protected]>
1 parent 9d5f69e commit 9eae120

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed

tests/zbd/013

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-3.0+
3+
# Copyright (C) 2025 Google LLC
4+
#
5+
# There is a bug in the Linux kernel 6.10..6.15 zoned block device code that
6+
# triggers a deadlock between zoned writes and queue freezing. This test
7+
# triggers that deadlock. This deadlock has been fixed by commit cf625013d874
8+
# ("block: don't use submit_bio_noacct_nocheck in blk_zone_wplug_bio_work").
9+
10+
11+
. tests/zbd/rc
12+
. common/null_blk
13+
14+
DESCRIPTION="test stacked drivers and queue freezing"
15+
TIMED=1
16+
17+
requires() {
18+
_have_driver dm-crypt
19+
_have_driver null_blk
20+
_have_fio
21+
_have_program cryptsetup
22+
}
23+
24+
# Trigger blk_mq_freeze_queue() repeatedly. "$1" must be a block device sysfs
25+
# attribute that triggers queue freezing. "$2" and "$3" are the values that will
26+
# be written into that sysfs attribute.
27+
queue_freeze_loop() {
28+
while true; do
29+
echo "$2" >"$1"
30+
sleep .1
31+
echo "$3" >"$1"
32+
sleep .1
33+
done
34+
}
35+
36+
test() {
37+
echo "Running ${TEST_NAME}"
38+
39+
_remove_null_blk_devices
40+
41+
# A small conventional block device for the LUKS header.
42+
local null_blk_params=(
43+
blocksize=4096
44+
completion_nsec=0
45+
memory_backed=1
46+
size=4 # MiB
47+
submit_queues=1
48+
power=1
49+
)
50+
_configure_null_blk nullb1 "${null_blk_params[@]}"
51+
local hdev=/dev/nullb1
52+
53+
# A larger zoned block device for the data.
54+
local null_blk_params=(
55+
blocksize=4096
56+
completion_nsec=1000000
57+
irqmode=2
58+
max_sectors=$(((1 << 32) - 1))
59+
memory_backed=1
60+
size=1024 # MiB
61+
submit_queues=1
62+
zoned=1
63+
power=1
64+
)
65+
_configure_null_blk nullb2 "${null_blk_params[@]}"
66+
local zdev_basename=nullb2
67+
local zdev=/dev/${zdev_basename}
68+
69+
local luks_passphrase=this-passphrase-is-not-secret
70+
{ echo "${luks_passphrase}" |
71+
cryptsetup luksFormat --batch-mode ${zdev} \
72+
--header ${hdev}; }
73+
local luks_vol_name=zbd-013
74+
{ echo "${luks_passphrase}" |
75+
cryptsetup luksOpen \
76+
--batch-mode "${zdev}" "${luks_vol_name}" \
77+
--header ${hdev}; }
78+
local luksdev="/dev/mapper/${luks_vol_name}"
79+
local dmdev
80+
dmdev="$(basename "$(readlink "${luksdev}")")"
81+
ls -ld "${hdev}" "${zdev}" "${luksdev}" "/dev/${dmdev}" >>"${FULL}" 2>&1
82+
local max_sectors_zdev
83+
max_sectors_zdev=/sys/block/"${zdev_basename}"/queue/max_sectors_kb
84+
echo 4 > "${max_sectors_zdev}"
85+
echo "${zdev_basename}: max_sectors_kb=$(<"${max_sectors_zdev}")" >>"${FULL}"
86+
queue_freeze_loop /sys/block/"$dmdev"/queue/read_ahead_kb 4 8 &
87+
local loop_pid=$!
88+
local fio_args=(
89+
--bs=64M
90+
--direct=1
91+
--filename="${luksdev}"
92+
--runtime="$TIMEOUT"
93+
--time_based
94+
--zonemode=zbd
95+
)
96+
if ! _run_fio_verify_io "${fio_args[@]}" >>"${FULL}" 2>&1; then
97+
fail=true
98+
fi
99+
100+
kill "${loop_pid}"
101+
cryptsetup luksClose "${luks_vol_name}"
102+
_exit_null_blk
103+
104+
if [ -z "$fail" ]; then
105+
echo "Test complete"
106+
else
107+
echo "Test failed"
108+
return 1
109+
fi
110+
}

tests/zbd/013.out

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

0 commit comments

Comments
 (0)