ublk: look up ublk task via its pid in timeout handler

Look up ublk process via its pid in timeout handler, so we can avoid to
touch io->task, because it is fragile to touch task structure.

It is fine to kill ublk server process and this way is simpler.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20250713143415.2857561-3-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Ming Lei 2025-07-13 22:33:57 +08:00 committed by Jens Axboe
parent c2c8089f32
commit dd7a850731

View File

@ -1368,14 +1368,23 @@ static void ublk_queue_cmd_list(struct ublk_io *io, struct rq_list *l)
static enum blk_eh_timer_return ublk_timeout(struct request *rq)
{
struct ublk_queue *ubq = rq->mq_hctx->driver_data;
struct ublk_io *io = &ubq->ios[rq->tag];
pid_t tgid = ubq->dev->ublksrv_tgid;
struct task_struct *p;
struct pid *pid;
if (ubq->flags & UBLK_F_UNPRIVILEGED_DEV) {
send_sig(SIGKILL, io->task, 0);
return BLK_EH_DONE;
}
if (!(ubq->flags & UBLK_F_UNPRIVILEGED_DEV))
return BLK_EH_RESET_TIMER;
return BLK_EH_RESET_TIMER;
if (unlikely(!tgid))
return BLK_EH_RESET_TIMER;
rcu_read_lock();
pid = find_vpid(tgid);
p = pid_task(pid, PIDTYPE_PID);
if (p)
send_sig(SIGKILL, p, 0);
rcu_read_unlock();
return BLK_EH_DONE;
}
static blk_status_t ublk_prep_req(struct ublk_queue *ubq, struct request *rq,