Skip to content

Commit 0e4237a

Browse files
Ming Leiaxboe
authored andcommitted
blk-mq: don't count completed flush data request as inflight in case of quiesce
Request queue quiesce may interrupt flush sequence, and the original request may have been marked as COMPLETE, but can't get finished because of queue quiesce. This way is fine from driver viewpoint, because flush sequence is block layer concept, and it isn't related with driver. However, driver(such as dm-rq) can call blk_mq_queue_inflight() to count & drain inflight requests, then the wait & drain never gets done because the completed & not-finished flush request is counted as inflight. Fix this issue by not counting completed flush data request as inflight in case of quiesce. Cc: Mike Snitzer <snitzer@kernel.org> Cc: David Jeffery <djeffery@redhat.com> Cc: John Pittman <jpittman@redhat.com> Signed-off-by: Ming Lei <ming.lei@redhat.com> Link: https://lore.kernel.org/r/20231201085605.577730-1-ming.lei@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 3649ff0 commit 0e4237a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

block/blk-mq.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1512,14 +1512,26 @@ void blk_mq_delay_kick_requeue_list(struct request_queue *q,
15121512
}
15131513
EXPORT_SYMBOL(blk_mq_delay_kick_requeue_list);
15141514

1515+
static bool blk_is_flush_data_rq(struct request *rq)
1516+
{
1517+
return (rq->rq_flags & RQF_FLUSH_SEQ) && !is_flush_rq(rq);
1518+
}
1519+
15151520
static bool blk_mq_rq_inflight(struct request *rq, void *priv)
15161521
{
15171522
/*
15181523
* If we find a request that isn't idle we know the queue is busy
15191524
* as it's checked in the iter.
15201525
* Return false to stop the iteration.
1526+
*
1527+
* In case of queue quiesce, if one flush data request is completed,
1528+
* don't count it as inflight given the flush sequence is suspended,
1529+
* and the original flush data request is invisible to driver, just
1530+
* like other pending requests because of quiesce
15211531
*/
1522-
if (blk_mq_request_started(rq)) {
1532+
if (blk_mq_request_started(rq) && !(blk_queue_quiesced(rq->q) &&
1533+
blk_is_flush_data_rq(rq) &&
1534+
blk_mq_request_completed(rq))) {
15231535
bool *busy = priv;
15241536

15251537
*busy = true;

0 commit comments

Comments
 (0)