]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
ublk: move ublk_mark_io_ready() out of __ublk_fetch()
authorMing Lei <ming.lei@redhat.com>
Fri, 23 Jan 2026 09:15:42 +0000 (17:15 +0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 23 Jan 2026 12:11:02 +0000 (05:11 -0700)
commitdbc635c4be7eba1d0e0fe0275a289ee3ccc63d72
tree4d83cd5710b2f58559670e89bf1d68c8bef0d011
parente8cd481cc665d5db8e918e84740db22bc213059e
ublk: move ublk_mark_io_ready() out of __ublk_fetch()

ublk_batch_prep_io() calls __ublk_fetch() while holding io->lock
spinlock. When the last IO makes the device ready, ublk_mark_io_ready()
tries to acquire ub->cancel_mutex which can sleep, causing a
sleeping-while-atomic bug.

Fix by moving ublk_mark_io_ready() out of __ublk_fetch() and into the
callers (ublk_fetch and ublk_batch_prep_io) after the spinlock is
released.

Reported-by: Jens Axboe <axboe@kernel.dk>
Fixes: b256795b3606 ("ublk: handle UBLK_U_IO_PREP_IO_CMDS")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c