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. Link: [1] https://lore.kernel.org/linux-block/20250415001405.GA25659@frogsfrogsfrogs/ Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@xxxxxxx> --- The test case number block/039 conflicts with the test case in Ming's recent patch. I will renumber this test case or Ming's test case when I apply it, depending on the order of patch application. tests/block/039 | 54 +++++++++++++++++++++++++++++++++++++++++++++ tests/block/039.out | 2 ++ 2 files changed, 56 insertions(+) create mode 100755 tests/block/039 create mode 100644 tests/block/039.out diff --git a/tests/block/039 b/tests/block/039 new file mode 100755 index 0000000..dfe790e --- /dev/null +++ b/tests/block/039 @@ -0,0 +1,54 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2025 Western Digital Corporation or its affiliates. +# +# Confirm that concurrent set_blocksize() calls and read paths do not race. +# This is the regression test to confirm the fix by the commit titled ("block: +# fix race between set_blocksize and read paths"). + +. tests/block/rc +. common/null_blk + +DESCRIPTION="test race between set_blocksize and read paths" +TIMED=1 +CAN_BE_ZONED=1 + +requires() { + _have_fio +} + +change_blocksize() { + local deadline + + deadline=$(( $(_uptime_s) + TIMEOUT)) + + while (($(_uptime_s) < deadline)); do + blockdev --setbsz 4096 /dev/nullb1 + sleep .1 + blockdev --setbsz 8192 /dev/nullb1 + sleep .1 + done +} + +test() { + echo "Running ${TEST_NAME}" + + if ! _configure_null_blk nullb1 power=1; then + return 1 + fi + + if ! blockdev --setbsz 8192 /dev/nullb1; then + SKIP_REASONS+=("kernel does not support block size larger than 4kb") + _exit_null_blk + return + fi + + : "${TIMEOUT:=10}" + change_blocksize & + _run_fio --rw=randread --bs=4K --filename=/dev/nullb1 --name=nullb1 + wait + + _exit_null_blk + + echo "Test complete" +} diff --git a/tests/block/039.out b/tests/block/039.out new file mode 100644 index 0000000..0638940 --- /dev/null +++ b/tests/block/039.out @@ -0,0 +1,2 @@ +Running block/039 +Test complete -- 2.49.0