[PATCH 1/4] blk-mq: check rq->state explicitly in blk_mq_tagset_count_completed_rqs
Ming Lei
ming.lei at redhat.com
Fri Oct 16 10:28:08 EDT 2020
blk_mq_tagset_count_completed_rqs() is called from
blk_mq_tagset_wait_completed_request() for draining requests to be
completed remotely. What we need to do is to see request->state to
switch to non-MQ_RQ_COMPLETE.
So check MQ_RQ_COMPLETE explicitly in blk_mq_tagset_count_completed_rqs().
Meantime mark flush request as IDLE in its .end_io() for aligning to
end normal request because flush request may stay in inflight tags in case
of !elevator, so we need to change its state into IDLE.
Cc: Chao Leng <lengchao at huawei.com>
Cc: Sagi Grimberg <sagi at grimberg.me>
Signed-off-by: Ming Lei <ming.lei at redhat.com>
---
block/blk-flush.c | 2 ++
block/blk-mq-tag.c | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/block/blk-flush.c b/block/blk-flush.c
index 53abb5c73d99..31a2ae04d3f0 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -231,6 +231,8 @@ static void flush_end_io(struct request *flush_rq, blk_status_t error)
return;
}
+ WRITE_ONCE(rq->state, MQ_RQ_IDLE);
+
if (fq->rq_status != BLK_STS_OK)
error = fq->rq_status;
diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index 9c92053e704d..10ff8968b93b 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -367,7 +367,7 @@ static bool blk_mq_tagset_count_completed_rqs(struct request *rq,
{
unsigned *count = data;
- if (blk_mq_request_completed(rq))
+ if (blk_mq_rq_state(rq) == MQ_RQ_COMPLETE)
(*count)++;
return true;
}
--
2.25.2
More information about the Linux-nvme
mailing list