Skip to content

Commit 2b504bd

Browse files
Ming Leiaxboe
authored andcommitted
blk-mq: don't insert FUA request with data into scheduler queue
We never insert flush request into scheduler queue before. Recently commit d92ca9d ("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. [1] https://lore.kernel.org/linux-block/CAHj4cs-_vkTW=dAzbZYGxpEWSpzpcmaNeY1R=vH311+9vMUSdg@mail.gmail.com/ Reported-by: Yi Zhang <yi.zhang@redhat.com> Fixes: d92ca9d ("blk-mq: don't handle non-flush requests in blk_insert_flush") Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Link: https://lore.kernel.org/r/20211118153041.2163228-1-ming.lei@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 15c3010 commit 2b504bd

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

block/blk-flush.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ static void mq_flush_data_end_io(struct request *rq, blk_status_t error)
379379
* @rq is being submitted. Analyze what needs to be done and put it on the
380380
* right queue.
381381
*/
382-
bool blk_insert_flush(struct request *rq)
382+
void blk_insert_flush(struct request *rq)
383383
{
384384
struct request_queue *q = rq->q;
385385
unsigned long fflags = q->queue_flags; /* may change, cache */
@@ -409,7 +409,7 @@ bool blk_insert_flush(struct request *rq)
409409
*/
410410
if (!policy) {
411411
blk_mq_end_request(rq, 0);
412-
return true;
412+
return;
413413
}
414414

415415
BUG_ON(rq->bio != rq->biotail); /*assumes zero or single bio rq */
@@ -420,8 +420,10 @@ bool blk_insert_flush(struct request *rq)
420420
* for normal execution.
421421
*/
422422
if ((policy & REQ_FSEQ_DATA) &&
423-
!(policy & (REQ_FSEQ_PREFLUSH | REQ_FSEQ_POSTFLUSH)))
424-
return false;
423+
!(policy & (REQ_FSEQ_PREFLUSH | REQ_FSEQ_POSTFLUSH))) {
424+
blk_mq_request_bypass_insert(rq, false, true);
425+
return;
426+
}
425427

426428
/*
427429
* @rq should go through flush machinery. Mark it part of flush
@@ -437,8 +439,6 @@ bool blk_insert_flush(struct request *rq)
437439
spin_lock_irq(&fq->mq_flush_lock);
438440
blk_flush_complete_seq(rq, fq, REQ_FSEQ_ACTIONS & ~policy, 0);
439441
spin_unlock_irq(&fq->mq_flush_lock);
440-
441-
return true;
442442
}
443443

444444
/**

block/blk-mq.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2647,8 +2647,10 @@ void blk_mq_submit_bio(struct bio *bio)
26472647
return;
26482648
}
26492649

2650-
if (op_is_flush(bio->bi_opf) && blk_insert_flush(rq))
2650+
if (op_is_flush(bio->bi_opf)) {
2651+
blk_insert_flush(rq);
26512652
return;
2653+
}
26522654

26532655
if (plug && (q->nr_hw_queues == 1 ||
26542656
blk_mq_is_shared_tags(rq->mq_hctx->flags) ||

block/blk.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ void __blk_account_io_done(struct request *req, u64 now);
271271
*/
272272
#define ELV_ON_HASH(rq) ((rq)->rq_flags & RQF_HASHED)
273273

274-
bool blk_insert_flush(struct request *rq);
274+
void blk_insert_flush(struct request *rq);
275275

276276
int elevator_switch_mq(struct request_queue *q,
277277
struct elevator_type *new_e);

0 commit comments

Comments
 (0)