ublk: check UBLK_IO_FLAG_OWNED_BY_SRV in ublk_abort_queue()
authorCaleb Sander Mateos <csander@purestorage.com>
Wed, 30 Apr 2025 22:52:33 +0000 (16:52 -0600)
committerJens Axboe <axboe@kernel.dk>
Fri, 2 May 2025 15:22:30 +0000 (09:22 -0600)
ublk_abort_queue() currently checks whether the UBLK_IO_FLAG_ACTIVE flag
is cleared to tell whether to abort each ublk_io in the queue. But it's
possible for a ublk_io to not be ACTIVE but also not have a request in
flight, such as when no fetch request has yet been submitted for a tag
or when a fetch request is cancelled. So ublk_abort_queue() must
additionally check for an inflight request.

Simplify this code by checking for UBLK_IO_FLAG_OWNED_BY_SRV instead,
which indicates precisely whether a request is currently inflight.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20250430225234.2676781-9-csander@purestorage.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/ublk_drv.c

index 483205a0dfe871baeaf6f5db6c5081c0e364a689..97c61c0bf964c90085423a5012e308a84c3e441a 100644 (file)
@@ -1611,16 +1611,11 @@ static void ublk_abort_queue(struct ublk_device *ub, struct ublk_queue *ubq)
        for (i = 0; i < ubq->q_depth; i++) {
                struct ublk_io *io = &ubq->ios[i];
 
-               if (!(io->flags & UBLK_IO_FLAG_ACTIVE)) {
+               if (io->flags & UBLK_IO_FLAG_OWNED_BY_SRV) {
                        struct request *rq;
 
-                       /*
-                        * Either we fail the request or ublk_rq_task_work_cb
-                        * will do it
-                        */
                        rq = blk_mq_tag_to_rq(ub->tag_set.tags[ubq->q_id], i);
-                       if (rq && blk_mq_request_started(rq))
-                               __ublk_fail_req(ubq, io, rq);
+                       __ublk_fail_req(ubq, io, rq);
                }
        }
 }