ublk: make sure io cmd handled in submitter task context
authorMing Lei <ming.lei@redhat.com>
Mon, 9 Oct 2023 09:33:17 +0000 (17:33 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 17 Oct 2023 14:27:55 +0000 (08:27 -0600)
commit3421c7f68bba52281bbb38bc76c18dc03cb689e4
tree797f00777984d521a287b39858ba91d53c9b59ac
parent8ed90e370f9b5442a2766b357b92e36bbf6ba82d
ublk: make sure io cmd handled in submitter task context

In well-done ublk server implementation, ublk io command won't be
linked into any link chain. Meantime they are always handled in no-wait
style, so basically io cmd is always handled in submitter task context.

However, the server may set IOSQE_ASYNC, or io command is linked to one
chain mistakenly, then we may still run into io-wq context and
ctx->uring_lock isn't held.

So in case of IO_URING_F_UNLOCKED, schedule this command by
io_uring_cmd_complete_in_task to force running it in submitter task. Then
ublk_ch_uring_cmd_local() is guaranteed to run with context uring_lock held,
and we needn't to worry about sync among submission code path any more.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20231009093324.957829-3-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c