Skip to content

Commit 8f2df75

Browse files
committed
zbd/013: Test stacked drivers and bio splitting
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. max_sectors_kb is set to a small value to enforce bio splitting. This test not only tests dm-crypt zoned storage support but also tests whether split bios are submitted in LBA order. 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 <[email protected]>
1 parent 2debbaf commit 8f2df75

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed

tests/zbd/013

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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 bio splitting"
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+
# A small conventional block device for the LUKS header.
36+
local null_blk_params=(
37+
blocksize=4096
38+
completion_nsec=0
39+
memory_backed=1
40+
size=4 # MiB
41+
submit_queues=1
42+
power=1
43+
)
44+
_init_null_blk nr_devices=0 queue_mode=2
45+
_configure_null_blk nullb0 "${null_blk_params[@]}"
46+
local hdev=/dev/nullb0
47+
48+
# A larger zoned block device for the data.
49+
local null_blk_params=(
50+
blocksize=4096
51+
completion_nsec=0
52+
memory_backed=1
53+
size=1024 # MiB
54+
submit_queues=1
55+
zoned=1
56+
power=1
57+
)
58+
_configure_null_blk nullb1 "${null_blk_params[@]}"
59+
local zdev=/dev/nullb1
60+
61+
local luks_passphrase=this-passphrase-is-not-secret
62+
{ echo "${luks_passphrase}" |
63+
cryptsetup luksFormat --batch-mode ${zdev} \
64+
--header ${hdev}; }
65+
local luks_vol_name=zbd-013
66+
{ echo "${luks_passphrase}" |
67+
cryptsetup luksOpen \
68+
--batch-mode "${zdev}" "${luks_vol_name}" \
69+
--header ${hdev}; }
70+
local luksdev="/dev/mapper/${luks_vol_name}"
71+
local dmdev
72+
dmdev="$(basename "$(readlink "${luksdev}")")"
73+
ls -ld "${hdev}" "${zdev}" "${luksdev}" "/dev/${dmdev}" >>"${FULL}"
74+
local max_sectors_zdev
75+
max_sectors_zdev=/sys/block/"$(basename "$zdev")"/queue/max_sectors_kb
76+
echo 4 > "${max_sectors_zdev}"
77+
echo "zdev max_sectors_kb=$(<"${max_sectors_zdev}")" >>"${FULL}"
78+
local max_sectors_dm
79+
max_sectors_dm=/sys/block/"${dmdev}"/queue/max_sectors_kb
80+
echo "dmdev max_sectors_kb=$(<"${max_sectors_dm}")" >>"${FULL}"
81+
queue_freeze_loop /sys/block/"$dmdev"/queue/read_ahead_kb &
82+
local loop_pid=$!
83+
local fio_args=(
84+
--bs=64M
85+
--direct=1
86+
--filename="${luksdev}"
87+
--runtime="$TIMEOUT"
88+
--time_based
89+
--zonemode=zbd
90+
)
91+
if ! _run_fio_verify_io "${fio_args[@]}" >>"${FULL}" 2>&1; then
92+
fail=true
93+
fi
94+
95+
set +e
96+
97+
kill "${loop_pid}"
98+
cryptsetup luksClose "${luks_vol_name}"
99+
_exit_null_blk
100+
101+
if [ -z "$fail" ]; then
102+
echo "Test complete"
103+
else
104+
echo "Test failed"
105+
return 1
106+
fi
107+
}

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)