* [PATCH] blk-mq: don't handle non-flush requests in blk_insert_flush
@ 2021-10-19 12:25 Christoph Hellwig
2021-10-19 17:10 ` Jens Axboe
2021-10-19 17:11 ` Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Christoph Hellwig @ 2021-10-19 12:25 UTC (permalink / raw)
To: axboe; +Cc: linux-block
Return to the normal blk_mq_submit_bio flow if the bio did not end up
actually being a flush because the device didn't support it. Note that
this is basically impossible to hit without special instrumentation given
that submit_bio_checks already clears these flags usually, so we'd need a
tight race to actually hit this code path.
With this the call to blk_mq_run_hw_queue for the flush requests can be
removed given that the actual flush requests are always issued via the
requeue workqueue which runs the queue unconditionally.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/blk-flush.c | 12 ++++++------
block/blk-mq.c | 14 ++++++--------
block/blk.h | 2 +-
3 files changed, 13 insertions(+), 15 deletions(-)
diff --git a/block/blk-flush.c b/block/blk-flush.c
index e9c0b300a1771..ebb11a87c6e30 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -382,7 +382,7 @@ static void mq_flush_data_end_io(struct request *rq, blk_status_t error)
* @rq is being submitted. Analyze what needs to be done and put it on the
* right queue.
*/
-void blk_insert_flush(struct request *rq)
+bool blk_insert_flush(struct request *rq)
{
struct request_queue *q = rq->q;
unsigned long fflags = q->queue_flags; /* may change, cache */
@@ -412,7 +412,7 @@ void blk_insert_flush(struct request *rq)
*/
if (!policy) {
blk_mq_end_request(rq, 0);
- return;
+ return true;
}
BUG_ON(rq->bio != rq->biotail); /*assumes zero or single bio rq */
@@ -423,10 +423,8 @@ void blk_insert_flush(struct request *rq)
* for normal execution.
*/
if ((policy & REQ_FSEQ_DATA) &&
- !(policy & (REQ_FSEQ_PREFLUSH | REQ_FSEQ_POSTFLUSH))) {
- blk_mq_request_bypass_insert(rq, false, false);
- return;
- }
+ !(policy & (REQ_FSEQ_PREFLUSH | REQ_FSEQ_POSTFLUSH)))
+ return false;
/*
* @rq should go through flush machinery. Mark it part of flush
@@ -442,6 +440,8 @@ void blk_insert_flush(struct request *rq)
spin_lock_irq(&fq->mq_flush_lock);
blk_flush_complete_seq(rq, fq, REQ_FSEQ_ACTIONS & ~policy, 0);
spin_unlock_irq(&fq->mq_flush_lock);
+
+ return true;
}
/**
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 9248edd8a7d3b..428e0e0fd5504 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2491,14 +2491,12 @@ void blk_mq_submit_bio(struct bio *bio)
return;
}
- if (unlikely(is_flush_fua)) {
- struct blk_mq_hw_ctx *hctx = rq->mq_hctx;
- /* Bypass scheduler for flush requests */
- blk_insert_flush(rq);
- blk_mq_run_hw_queue(hctx, true);
- } else if (plug && (q->nr_hw_queues == 1 ||
- blk_mq_is_shared_tags(rq->mq_hctx->flags) ||
- q->mq_ops->commit_rqs || !blk_queue_nonrot(q))) {
+ if (is_flush_fua && blk_insert_flush(rq))
+ return;
+
+ if (plug && (q->nr_hw_queues == 1 ||
+ blk_mq_is_shared_tags(rq->mq_hctx->flags) ||
+ q->mq_ops->commit_rqs || !blk_queue_nonrot(q))) {
/*
* Use plugging if we have a ->commit_rqs() hook as well, as
* we know the driver uses bd->last in a smart fashion.
diff --git a/block/blk.h b/block/blk.h
index e80350327e6dc..cb98a10a119c8 100644
--- a/block/blk.h
+++ b/block/blk.h
@@ -236,7 +236,7 @@ void __blk_account_io_done(struct request *req, u64 now);
*/
#define ELV_ON_HASH(rq) ((rq)->rq_flags & RQF_HASHED)
-void blk_insert_flush(struct request *rq);
+bool blk_insert_flush(struct request *rq);
int elevator_switch_mq(struct request_queue *q,
struct elevator_type *new_e);
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] blk-mq: don't handle non-flush requests in blk_insert_flush
2021-10-19 12:25 [PATCH] blk-mq: don't handle non-flush requests in blk_insert_flush Christoph Hellwig
@ 2021-10-19 17:10 ` Jens Axboe
2021-10-19 17:11 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2021-10-19 17:10 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: linux-block
On 10/19/21 6:25 AM, Christoph Hellwig wrote:
> Return to the normal blk_mq_submit_bio flow if the bio did not end up
> actually being a flush because the device didn't support it. Note that
> this is basically impossible to hit without special instrumentation given
> that submit_bio_checks already clears these flags usually, so we'd need a
> tight race to actually hit this code path.
>
> With this the call to blk_mq_run_hw_queue for the flush requests can be
> removed given that the actual flush requests are always issued via the
> requeue workqueue which runs the queue unconditionally.
This looks great, thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] blk-mq: don't handle non-flush requests in blk_insert_flush
2021-10-19 12:25 [PATCH] blk-mq: don't handle non-flush requests in blk_insert_flush Christoph Hellwig
2021-10-19 17:10 ` Jens Axboe
@ 2021-10-19 17:11 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2021-10-19 17:11 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: Jens Axboe, linux-block
On Tue, 19 Oct 2021 14:25:53 +0200, Christoph Hellwig wrote:
> Return to the normal blk_mq_submit_bio flow if the bio did not end up
> actually being a flush because the device didn't support it. Note that
> this is basically impossible to hit without special instrumentation given
> that submit_bio_checks already clears these flags usually, so we'd need a
> tight race to actually hit this code path.
>
> With this the call to blk_mq_run_hw_queue for the flush requests can be
> removed given that the actual flush requests are always issued via the
> requeue workqueue which runs the queue unconditionally.
>
> [...]
Applied, thanks!
[1/1] blk-mq: don't handle non-flush requests in blk_insert_flush
commit: d92ca9d8348fb12c89eac5928bd651c3a485d7b9
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-10-19 17:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-19 12:25 [PATCH] blk-mq: don't handle non-flush requests in blk_insert_flush Christoph Hellwig
2021-10-19 17:10 ` Jens Axboe
2021-10-19 17:11 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).