Skip to content

Commit 2341aa0

Browse files
bvanasschekawasaki
authored andcommitted
scsi/011: Test whether block and SCSI propagate filesystem data lifetime information
Test whether data lifetime (write hint) information is passed by the block layer and SCSI core from filesystems to block devices. Signed-off-by: Bart Van Assche <[email protected]> [Shin'ichiro: renumbered the test case from 010 to 011] Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
1 parent ee4bcd0 commit 2341aa0

2 files changed

Lines changed: 77 additions & 0 deletions

File tree

tests/scsi/011

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-3.0+
3+
# Copyright (C) 2025 Google LLC
4+
5+
. tests/scsi/rc
6+
. common/null_blk
7+
. common/scsi_debug
8+
9+
DESCRIPTION="test data lifetime propagation"
10+
QUICK=1
11+
12+
requires() {
13+
_have_fio
14+
_have_driver f2fs
15+
# See also commit 7643f3fe2772 ("f2fs: assign the write hint per stream
16+
# by default"; v6.10).
17+
_have_kver 6 10
18+
_have_program mkfs.f2fs
19+
_have_scsi_debug_group_number_stats
20+
}
21+
22+
run_test() {
23+
set -e
24+
25+
local scsi_debug_params=(
26+
delay=0
27+
dev_size_mb=1024
28+
sector_size=4096
29+
)
30+
_configure_scsi_debug "${scsi_debug_params[@]}"
31+
local dev="/dev/${SCSI_DEBUG_DEVICES[0]}" fail
32+
ls -ld "${dev}" >>"${FULL}"
33+
mkfs.f2fs "${dev}" >>"${FULL}" 2>&1
34+
mkdir -p "${mount_dir}"
35+
mount -t f2fs "${dev}" "${mount_dir}"
36+
local fio_args=(
37+
--size=1M
38+
--directory="${mount_dir}"
39+
--time_based
40+
--runtime=10
41+
)
42+
43+
set +e
44+
45+
_run_fio_verify_io "${fio_args[@]}" >>"${FULL}" 2>&1
46+
}
47+
48+
test() {
49+
echo "Running ${TEST_NAME}"
50+
51+
# A global variable because it is also used in run_test().
52+
mount_dir="$TMPDIR/mnt"
53+
54+
(
55+
run_test
56+
) || fail=true
57+
58+
umount "${mount_dir}" >>"${FULL}" 2>&1
59+
head -n 999 /sys/bus/pseudo/drivers/scsi_debug/group_number_stats >> "${FULL}"
60+
while read -r group count; do
61+
if [ "$count" -gt 0 ]; then echo "$group"; fi
62+
done < /sys/bus/pseudo/drivers/scsi_debug/group_number_stats
63+
_exit_scsi_debug
64+
65+
if [ -z "$fail" ]; then
66+
echo "Test complete"
67+
else
68+
echo "Test failed"
69+
return 1
70+
fi
71+
}

tests/scsi/011.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Running scsi/011
2+
0
3+
1
4+
2
5+
3
6+
Test complete

0 commit comments

Comments
 (0)