Patch "blk-mq: avoid sleep in blk_mq_alloc_request_hctx" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    blk-mq: avoid sleep in blk_mq_alloc_request_hctx

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     blk-mq-avoid-sleep-in-blk_mq_alloc_request_hctx.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 8978599ee07cf4496bda8f54fba435205ce3085a
Author: Kemeng Shi <shikemeng@xxxxxxxxxxxxxxx>
Date:   Wed Jan 18 17:37:13 2023 +0800

    blk-mq: avoid sleep in blk_mq_alloc_request_hctx
    
    [ Upstream commit 6ee858a3d3270a68902d66bb47c151a83622535c ]
    
    Commit 1f5bd336b9150 ("blk-mq: add blk_mq_alloc_request_hctx") add
    blk_mq_alloc_request_hctx to send commands to a specific queue. If
    BLK_MQ_REQ_NOWAIT is not set in tag allocation, we may change to different
    hctx after sleep and get tag from unexpected hctx. So BLK_MQ_REQ_NOWAIT
    must be set in flags for blk_mq_alloc_request_hctx.
    After commit 600c3b0cea784 ("blk-mq: open code __blk_mq_alloc_request in
    blk_mq_alloc_request_hctx"), blk_mq_alloc_request_hctx return -EINVAL
    if both BLK_MQ_REQ_NOWAIT and BLK_MQ_REQ_RESERVED are not set instead of
    if BLK_MQ_REQ_NOWAIT is not set. So if BLK_MQ_REQ_NOWAIT is not set and
    BLK_MQ_REQ_RESERVED is set, blk_mq_alloc_request_hctx could alloc tag
    from unexpected hctx. I guess what we need here is that return -EINVAL
    if either BLK_MQ_REQ_NOWAIT or BLK_MQ_REQ_RESERVED is not set.
    
    Currently both BLK_MQ_REQ_NOWAIT and BLK_MQ_REQ_RESERVED will be set if
    specific hctx is needed in nvme_auth_submit, nvmf_connect_io_queue
    and nvmf_connect_admin_queue. Fix the potential BLK_MQ_REQ_NOWAIT missed
    case in future.
    
    Fixes: 600c3b0cea78 ("blk-mq: open code __blk_mq_alloc_request in blk_mq_alloc_request_hctx")
    Reviewed-by: Christoph Hellwig <hch@xxxxxx>
    Signed-off-by: Kemeng Shi <shikemeng@xxxxxxxxxxxxxxx>
    Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/block/blk-mq.c b/block/blk-mq.c
index 83fbc7c546172..2983ace812667 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -626,7 +626,8 @@ struct request *blk_mq_alloc_request_hctx(struct request_queue *q,
 	 * allocator for this for the rare use case of a command tied to
 	 * a specific queue.
 	 */
-	if (WARN_ON_ONCE(!(flags & (BLK_MQ_REQ_NOWAIT | BLK_MQ_REQ_RESERVED))))
+	if (WARN_ON_ONCE(!(flags & BLK_MQ_REQ_NOWAIT)) ||
+	    WARN_ON_ONCE(!(flags & BLK_MQ_REQ_RESERVED)))
 		return ERR_PTR(-EINVAL);
 
 	if (hctx_idx >= q->nr_hw_queues)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux