Skip to content

Commit 26f5445

Browse files
committed
block: add test for race between set_blocksize and read paths
The new large sector support in the kernel version 6.15-rcX caused kernel crash due to race between set_blocksize and read paths [1]. Add a test case to trigger the crash and confirm its fix. The fix commit is c0e473a0d226 ("block: fix race between set_blocksize and read paths"). Link: [1] https://lore.kernel.org/linux-block/20250415001405.GA25659@frogsfrogsfrogs/ Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
1 parent 9aa2023 commit 26f5445

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

tests/block/039

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-3.0+
3+
# Copyright (C) 2025 Western Digital Corporation or its affiliates.
4+
#
5+
# Confirm that concurrent set_blocksize() calls and read paths do not race.
6+
# This is the regression test to confirm the fix by the commit c0e473a0d226
7+
# ("block: fix race between set_blocksize and read paths").
8+
9+
. tests/block/rc
10+
. common/null_blk
11+
12+
DESCRIPTION="test race between set_blocksize and read paths"
13+
TIMED=1
14+
CAN_BE_ZONED=1
15+
16+
requires() {
17+
_have_fio
18+
}
19+
20+
change_blocksize() {
21+
local deadline
22+
23+
deadline=$(( $(_uptime_s) + TIMEOUT))
24+
25+
while (($(_uptime_s) < deadline)); do
26+
blockdev --setbsz 4096 /dev/nullb1
27+
sleep .1
28+
blockdev --setbsz 8192 /dev/nullb1
29+
sleep .1
30+
done
31+
}
32+
33+
test() {
34+
echo "Running ${TEST_NAME}"
35+
36+
if ! _configure_null_blk nullb1 power=1; then
37+
return 1
38+
fi
39+
40+
if ! blockdev --setbsz 8192 /dev/nullb1; then
41+
SKIP_REASONS+=("kernel does not support block size larger than 4kb")
42+
_exit_null_blk
43+
return
44+
fi
45+
46+
: "${TIMEOUT:=10}"
47+
change_blocksize &
48+
_run_fio --rw=randread --bs=4K --filename=/dev/nullb1 --name=nullb1
49+
wait
50+
51+
_exit_null_blk
52+
53+
echo "Test complete"
54+
}

tests/block/039.out

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

0 commit comments

Comments
 (0)