Skip to content

Commit 336a970

Browse files
committed
zbd/013: Test stacked drivers and queue freezing
Since there is no test yet in the blktests repository for a device mapper driver stacked on top of a zoned block device, add such a test. This test triggers the following deadlock in kernel versions 6.10..6.14: 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 <bvanassche@acm.org>
1 parent 2debbaf commit 336a970

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+
. tests/zbd/rc
6+
. common/null_blk
7+
8+
DESCRIPTION="test stacked drivers and queue freezing"
9+
QUICK=1
10+
11+
requires() {
12+
_have_driver dm-crypt
13+
_have_fio
14+
_have_module null_blk
15+
_have_program cryptsetup
16+
}
17+
18+
# Trigger blk_mq_freeze_queue() repeatedly because there is a bug in the
19+
# Linux kernel 6.10..6.14 zoned block device code that triggers a deadlock
20+
# between zoned writes and queue freezing.
21+
queue_freeze_loop() {
22+
while true; do
23+
echo 4 >"$1"
24+
sleep .1
25+
echo 8 >"$1"
26+
sleep .1
27+
done
28+
}
29+
30+
test() {
31+
set -e
32+
33+
echo "Running ${TEST_NAME}"
34+
35+
_init_null_blk nr_devices=0 queue_mode=2
36+
37+
# A small conventional block device for the LUKS header.
38+
local null_blk_params=(
39+
blocksize=4096
40+
completion_nsec=0
41+
memory_backed=1
42+
size=4 # MiB
43+
submit_queues=1
44+
power=1
45+
)
46+
_configure_null_blk nullb0 "${null_blk_params[@]}"
47+
local hdev=/dev/nullb0
48+
49+
# A larger zoned block device for the data.
50+
local null_blk_params=(
51+
blocksize=4096
52+
completion_nsec=0
53+
memory_backed=1
54+
size=1024 # MiB
55+
submit_queues=1
56+
zoned=1
57+
power=1
58+
)
59+
_configure_null_blk nullb1 "${null_blk_params[@]}"
60+
local zdev=/dev/nullb1
61+
62+
local luks_passphrase=this-passphrase-is-not-secret
63+
{ echo "${luks_passphrase}" |
64+
cryptsetup luksFormat --batch-mode ${zdev} \
65+
--header ${hdev}; }
66+
local luks_vol_name=zbd-013
67+
{ echo "${luks_passphrase}" |
68+
cryptsetup luksOpen \
69+
--batch-mode "${zdev}" "${luks_vol_name}" \
70+
--header ${hdev}; }
71+
local luksdev="/dev/mapper/${luks_vol_name}"
72+
local dmdev
73+
dmdev="$(basename "$(readlink "${luksdev}")")"
74+
ls -ld "${hdev}" "${zdev}" "${luksdev}" "/dev/${dmdev}" >>"${FULL}"
75+
local zdev_basename
76+
zdev_basename=$(basename "$zdev")
77+
local max_sectors_zdev
78+
max_sectors_zdev=/sys/block/"${zdev_basename}"/queue/max_sectors_kb
79+
echo 4 > "${max_sectors_zdev}"
80+
echo "${zdev_basename}: max_sectors_kb=$(<"${max_sectors_zdev}")" >>"${FULL}"
81+
local max_sectors_dm
82+
max_sectors_dm=/sys/block/"${dmdev}"/queue/max_sectors_kb
83+
echo "${dmdev}: max_sectors_kb=$(<"${max_sectors_dm}")" >>"${FULL}"
84+
queue_freeze_loop /sys/block/"$dmdev"/queue/read_ahead_kb &
85+
local loop_pid=$!
86+
local fio_args=(
87+
--bs=64M
88+
--direct=1
89+
--filename="${luksdev}"
90+
--runtime="$TIMEOUT"
91+
--time_based
92+
--zonemode=zbd
93+
)
94+
if ! _run_fio_verify_io "${fio_args[@]}" >>"${FULL}" 2>&1; then
95+
fail=true
96+
fi
97+
98+
set +e
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)