On Fri, Oct 16, 2020 at 10:28:08PM +0800, Ming Lei wrote: > 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@xxxxxxxxxx> > Cc: Sagi Grimberg <sagi@xxxxxxxxxxx> > Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx> > --- > 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); oops, the above line should have been: WRITE_ONCE(flush_rq->state, MQ_RQ_IDLE); Thanks, Ming