On 2022/7/15 10:04, Ming Lei wrote: > On Thu, Jul 14, 2022 at 09:23:40PM +0800, Ziyang Zhang wrote: >> On 2022/7/14 18:48, Ming Lei wrote: >>> On Thu, Jul 14, 2022 at 06:20:38PM +0800, Ziyang Zhang wrote: >>>> On 2022/7/13 22:07, Ming Lei wrote: >>>>> This is the driver part of userspace block driver(ublk driver), the other >>>>> part is userspace daemon part(ublksrv)[1]. >>>>> ... >> >> Put it together: >> >> When daemon is PF_EXITING: >> >> 1) current ublk_io: aborted immediately in task_work > > Precisely it is just that ublk io request is ended immediately, so io->flags > won't be touched. > >> >> 2) UBLK_IO_FLAG_ACTIVE set: aborted in ublk_daemon_monitor_work > > This part is important for making forward progress, that is why it has > to be done in a wq context. > >> >> 3) UBLK_IO_FLAG_ACTIVE unset: send cqe with UBLK_IO_RES_ABORT Oh... sorry for one mistake. case 2) and 3) should be swapped: ublk_daemon_monitor_work(): abort blk-mq IOs if UBLK_IO_FLAG_ACTIVE is unset ublk_cancel_queue(): send cqes with UBLK_IO_RES_ABORT if UBLK_IO_FLAG_ACTIVE is set