]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ublk: allow buffer registration before device is started
authorMing Lei <tom.leiming@gmail.com>
Thu, 9 Apr 2026 13:30:17 +0000 (21:30 +0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 10 Apr 2026 01:10:44 +0000 (19:10 -0600)
commit365ea7cc62447caac508706b429cdf031cc15a9f
tree073aa6b283332e07cfba16f12200c6c2851dad5b
parent5e864438e2853ef5112d7905fadcc3877e2be70a
ublk: allow buffer registration before device is started

Before START_DEV, there is no disk, no queue, no I/O dispatch, so
the maple tree can be safely modified under ub->mutex alone without
freezing the queue.

Add ublk_lock_buf_tree()/ublk_unlock_buf_tree() helpers that take
ub->mutex first, then freeze the queue if device is started. This
ordering (mutex -> freeze) is safe because ublk_stop_dev_unlocked()
already holds ub->mutex when calling del_gendisk() which freezes
the queue.

Suggested-by: Caleb Sander Mateos <csander@purestorage.com>
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Link: https://patch.msgid.link/20260409133020.3780098-6-tom.leiming@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c