Skip to content

Commit d80b8bb

Browse files
committed
zbd/013: Test bio splitting for stacked drivers
Since there is no test yet in the blktests repository for dm-crypt, 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. Signed-off-by: Bart Van Assche <[email protected]>
1 parent 613b837 commit d80b8bb

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

tests/zbd/013

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash -x
2+
# SPDX-License-Identifier: GPL-3.0+
3+
# Copyright (C) 2025 Google LLC
4+
5+
. tests/zbd/rc
6+
. common/null_blk
7+
. common/scsi_debug
8+
9+
DESCRIPTION="test bio splitting for stacked drivers"
10+
QUICK=1
11+
12+
requires() {
13+
_have_driver dm-crypt
14+
_have_driver f2fs
15+
_have_fio
16+
_have_module null_blk
17+
_have_module scsi_debug
18+
_have_program cryptsetup
19+
_have_program mkfs.f2fs
20+
}
21+
22+
test() {
23+
echo "Running ${TEST_NAME}"
24+
25+
local mount_dir="$TMPDIR/mnt"
26+
27+
local null_blk_params=(
28+
blocksize=4096
29+
completion_nsec=0
30+
memory_backed=1
31+
size=1024 # MB
32+
submit_queues=1
33+
power=1
34+
)
35+
_init_null_blk nr_devices=0 queue_mode=2 &&
36+
_configure_null_blk nullb0 "${null_blk_params[@]}" || return $?
37+
local cdev=/dev/nullb0
38+
_configure_null_blk nullb1 "${null_blk_params[@]}" || return $?
39+
local hdev=/dev/nullb1
40+
41+
local scsi_debug_params=(
42+
delay=0
43+
dev_size_mb=1024
44+
sector_size=4096
45+
zbc=host-managed
46+
zone_nr_conv=0
47+
zone_size_mb=2
48+
)
49+
_init_scsi_debug "${scsi_debug_params[@]}" &&
50+
local zdev="/dev/${SCSI_DEBUG_DEVICES[0]}" fail &&
51+
echo 4 > /sys/block/"$(basename "$zdev")"/queue/max_sectors_kb &&
52+
local luks_passphrase=this-passphrase-is-not-secret &&
53+
{ echo "${luks_passphrase}" |
54+
cryptsetup luksFormat --batch-mode "${zdev}" \
55+
--header $hdev; } &&
56+
local luks_vol_name=zbd-013 &&
57+
{ echo "${luks_passphrase}" |
58+
cryptsetup luksOpen \
59+
--batch-mode "${zdev}" "${luks_vol_name}" \
60+
--header $hdev; } &&
61+
local luksdev="/dev/mapper/${luks_vol_name}" &&
62+
ls -ld "${cdev}" "${zdev}" "${luksdev}" >>"${FULL}" &&
63+
mkfs.f2fs -m "${cdev}" -c "${luksdev}" >>"${FULL}" 2>&1 &&
64+
mkdir -p "${mount_dir}" &&
65+
mount -t f2fs "${cdev}" "${mount_dir}" &&
66+
local fio_args=(
67+
--bs=64M
68+
--size=256M
69+
--directory="${mount_dir}"
70+
--time_based
71+
--runtime=30
72+
) &&
73+
_run_fio_verify_io "${fio_args[@]}" >>"${FULL}" 2>&1 ||
74+
fail=true
75+
76+
umount "${mount_dir}" >>"${FULL}" 2>&1
77+
cryptsetup luksClose "${luks_vol_name}"
78+
_exit_scsi_debug
79+
_exit_null_blk
80+
81+
if [ -z "$fail" ]; then
82+
echo "Test complete"
83+
else
84+
echo "Test failed"
85+
return 1
86+
fi
87+
}

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)