Re: [PATCH] blk-mq: don't insert FUA request with data into scheduler queue

Ming Lei
2021-11-19T08:08:00Z

On Fri, Nov 19, 2021 at 07:08:58AM +0100, Christoph Hellwig wrote:
> On Thu, Nov 18, 2021 at 11:30:41PM +0800, Ming Lei wrote:
> > We never insert flush request into scheduler queue before.
> >
> > Recently commit d92ca9d8348f ("blk-mq: don't handle non-flush requests in
> > blk_insert_flush") tries to handle FUA data request as normal request.
> > This way has caused warning[1] in mq-deadline dd_exit_sched() or io hang in
> > case of kyber since RQF_ELVPRIV isn't set for flush request, then
> > ->finish_request won't be called.
> >
> > Fix the issue by inserting FUA data request with blk_mq_request_bypass_insert()
> > when the device supports FUA, just like what we did before.
>
> How we did end up with REQ_ELV set for this request?

We set REQ_ELV for any request if q->elevator isn't NULL, see
__blk_mq_alloc_requests(), and REQ_ELV is just for replacing the check on
q->elevator. If we clear REQ_ELV for flush rq, other problem may be caused,
such as blk_mq_rq_ctx_init() may be confused.

Also flush request is always inserted to hctx->dispatch directly, either
before commit d92ca9d8348f or being queued via requeue in current code.

Thanks,
Ming