Skip to content

Commit f50e16c

Browse files
axboekernel-patches-daemon
authored andcommitted
ublk: don't issue uring_cmd from fallback task work
When ublk_ch_uring_cmd_cb() runs as fallback task work (e.g., because the submitting task is exiting), the command should not be issued as current is a kworker, not the daemon task. This can cause io->task to capture the wrong task in __ublk_fetch(), leading to a task mismatch warning in ublk_uring_cmd_cancel_fn(). Check tw.cancel and return -ECANCELED instead of issuing the command from fallback context. Fixes: 3421c7f ("ublk: make sure io cmd handled in submitter task context") Signed-off-by: Ming Lei <[email protected]>
1 parent 5a9f7c7 commit f50e16c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/block/ublk_drv.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3496,8 +3496,10 @@ static void ublk_ch_uring_cmd_cb(struct io_tw_req tw_req, io_tw_token_t tw)
34963496
{
34973497
unsigned int issue_flags = IO_URING_CMD_TASK_WORK_ISSUE_FLAGS;
34983498
struct io_uring_cmd *cmd = io_uring_cmd_from_tw(tw_req);
3499-
int ret = ublk_ch_uring_cmd_local(cmd, issue_flags);
3499+
int ret = -ECANCELED;
35003500

3501+
if (!tw.cancel)
3502+
ret = ublk_ch_uring_cmd_local(cmd, issue_flags);
35013503
if (ret != -EIOCBQUEUED)
35023504
io_uring_cmd_done(cmd, ret, issue_flags);
35033505
}

0 commit comments

Comments
 (0)