]> git.ipfire.org Git - thirdparty/linux.git/commit
selftests/ublk: add test for async partition scan
authorMing Lei <ming.lei@redhat.com>
Tue, 23 Dec 2025 03:27:41 +0000 (11:27 +0800)
committerJens Axboe <axboe@kernel.dk>
Sun, 28 Dec 2025 16:25:26 +0000 (09:25 -0700)
commit60cf863720308ab89ce2fdafea7fcb2cefd9c144
tree2d522baaa3c23d077cedbf1dbdadafbf5dd58c00
parent7fc4da6a304bdcd3de14fc946dc2c19437a9cc5a
selftests/ublk: add test for async partition scan

Add test_generic_15.sh to verify that async partition scan prevents
IO hang when reading partition tables.

The test creates ublk devices with fault_inject target and very large
delay (60s) to simulate blocked partition table reads, then kills the
daemon to verify proper state transitions without hanging:

1. Without recovery support:
   - Create device with fault_inject and 60s delay
   - Kill daemon while partition scan may be blocked
   - Verify device transitions to DEAD state

2. With recovery support (-r 1):
   - Create device with fault_inject, 60s delay, and recovery
   - Kill daemon while partition scan may be blocked
   - Verify device transitions to QUIESCED state

Before the async partition scan fix, killing the daemon during
partition scan would cause deadlock as partition scan held ub->mutex
while waiting for IO. With the async fix, partition scan happens in
a work function and flush_work() ensures proper synchronization.

Add _add_ublk_dev_no_settle() helper function to skip udevadm settle,
which would otherwise hang waiting for partition scan events to
complete when partition table read is delayed.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
tools/testing/selftests/ublk/Makefile
tools/testing/selftests/ublk/test_common.sh
tools/testing/selftests/ublk/test_generic_15.sh [new file with mode: 0755]