Patch "blk-mq: avoid to iterate over stale request" has been added to the 5.14-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 to iterate over stale request

to the 5.14-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-to-iterate-over-stale-request.patch
and it can be found in the queue-5.14 subdirectory.

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



commit 30e3a58bc095a519dedb0292655b5eb7b815d27d
Author: Ming Lei <ming.lei@xxxxxxxxxx>
Date:   Mon Sep 6 14:50:03 2021 +0800

    blk-mq: avoid to iterate over stale request
    
    [ Upstream commit 67f3b2f822b7e71cfc9b42dbd9f3144fa2933e0b ]
    
    blk-mq can't run allocating driver tag and updating ->rqs[tag]
    atomically, meantime blk-mq doesn't clear ->rqs[tag] after the driver
    tag is released.
    
    So there is chance to iterating over one stale request just after the
    tag is allocated and before updating ->rqs[tag].
    
    scsi_host_busy_iter() calls scsi_host_check_in_flight() to count scsi
    in-flight requests after scsi host is blocked, so no new scsi command can
    be marked as SCMD_STATE_INFLIGHT. However, driver tag allocation still can
    be run by blk-mq core. One request is marked as SCMD_STATE_INFLIGHT,
    but this request may have been kept in another slot of ->rqs[], meantime
    the slot can be allocated out but ->rqs[] isn't updated yet. Then this
    in-flight request is counted twice as SCMD_STATE_INFLIGHT. This way causes
    trouble in handling scsi error.
    
    Fixes the issue by not iterating over stale request.
    
    Cc: linux-scsi@xxxxxxxxxxxxxxx
    Cc: "Martin K. Petersen" <martin.petersen@xxxxxxxxxx>
    Reported-by: luojiaxing <luojiaxing@xxxxxxxxxx>
    Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20210906065003.439019-1-ming.lei@xxxxxxxxxx
    Signed-off-by: Jens Axboe <axboe@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index 86f87346232a..ff5caeb82542 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -208,7 +208,7 @@ static struct request *blk_mq_find_and_get_req(struct blk_mq_tags *tags,
 
 	spin_lock_irqsave(&tags->lock, flags);
 	rq = tags->rqs[bitnr];
-	if (!rq || !refcount_inc_not_zero(&rq->ref))
+	if (!rq || rq->tag != bitnr || !refcount_inc_not_zero(&rq->ref))
 		rq = NULL;
 	spin_unlock_irqrestore(&tags->lock, flags);
 	return rq;



[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