]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ublk: move fake timeout logic into __ublk_complete_rq()
authorMing Lei <ming.lei@redhat.com>
Sun, 13 Jul 2025 14:33:58 +0000 (22:33 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 15 Jul 2025 14:04:16 +0000 (08:04 -0600)
Almost every block driver deals with fake timeout logic around real
request completion code.

Also the existing way may cause request reference count leak, so move the
logic into __ublk_complete_rq(), then we can skip the completion in the
last step like other drivers.

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

index 7d1d8bd979c5e66311484d62473af6e0952693d4..73c6c8d3b11712eeef8db083082c2edb18487595 100644 (file)
@@ -1155,7 +1155,7 @@ static inline void __ublk_complete_rq(struct request *req)
 
        if (blk_update_request(req, BLK_STS_OK, io->res))
                blk_mq_requeue_request(req, true);
-       else
+       else if (likely(!blk_should_fake_timeout(req->q)))
                __blk_mq_end_request(req, BLK_STS_OK);
 
        return;
@@ -2237,9 +2237,6 @@ static int ublk_commit_and_fetch(const struct ublk_queue *ubq,
        if (req_op(req) == REQ_OP_ZONE_APPEND)
                req->__sector = ub_cmd->zone_append_lba;
 
-       if (unlikely(blk_should_fake_timeout(req->q)))
-               return 0;
-
        if (ublk_need_req_ref(ubq))
                ublk_sub_req_ref(io, req);
        else