]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ublk: scan partition in async way
authorMing Lei <ming.lei@redhat.com>
Tue, 23 Dec 2025 03:27:40 +0000 (11:27 +0800)
committerJens Axboe <axboe@kernel.dk>
Sun, 28 Dec 2025 16:25:26 +0000 (09:25 -0700)
commit7fc4da6a304bdcd3de14fc946dc2c19437a9cc5a
treef854e9652ad9459f9fc9330ea331448989002016
parent04bdb1a04d8a2a89df504c1e34250cd3c6e31a1c
ublk: scan partition in async way

Implement async partition scan to avoid IO hang when reading partition
tables. Similar to nvme_partition_scan_work(), partition scanning is
deferred to a work queue to prevent deadlocks.

When partition scan happens synchronously during add_disk(), IO errors
can cause the partition scan to wait while holding ub->mutex, which
can deadlock with other operations that need the mutex.

Changes:
- Add partition_scan_work to ublk_device structure
- Implement ublk_partition_scan_work() to perform async scan
- Always suppress sync partition scan during add_disk()
- Schedule async work after add_disk() for trusted daemons
- Add flush_work() in ublk_stop_dev() before grabbing ub->mutex

Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
Reported-by: Yoav Cohen <yoav@nvidia.com>
Closes: https://lore.kernel.org/linux-block/DM4PR12MB63280C5637917C071C2F0D65A9A8A@DM4PR12MB6328.namprd12.prod.outlook.com/
Fixes: 71f28f3136af ("ublk_drv: add io_uring based userspace block driver")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c