From: chengming.zhou@linux.dev
To: axboe@kernel.dk, hch@lst.de, ming.lei@redhat.com
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
zhouchengming@bytedance.com
Subject: [PATCH v2 4/4] blk-flush: don't need to end rq twice for non postflush
Date: Tue, 25 Jul 2023 21:01:02 +0800 [thread overview]
Message-ID: <20230725130102.3030032-5-chengming.zhou@linux.dev> (raw)
In-Reply-To: <20230725130102.3030032-1-chengming.zhou@linux.dev>
From: Chengming Zhou <zhouchengming@bytedance.com>
Now we unconditionally blk_rq_init_flush() to replace rq->end_io to
make rq return twice back to the flush state machine for post-flush.
Obviously, non post-flush requests don't need it, they don't need to
end request twice, so they don't need to replace rq->end_io callback.
And the same for requests with the FUA bit on hardware with FUA support.
There are also some other good points:
1. all requests on hardware with FUA support won't have post-flush, so
all of them don't need to end twice.
2. non post-flush requests won't have RQF_FLUSH_SEQ rq_flags set, so
they can merge like normal requests.
3. we don't account non post-flush requests in flush_data_in_flight,
since there is no point to defer pending flush for these requests.
Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
---
block/blk-flush.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/block/blk-flush.c b/block/blk-flush.c
index ed195c760617..a299dae65350 100644
--- a/block/blk-flush.c
+++ b/block/blk-flush.c
@@ -178,7 +178,8 @@ static void blk_end_flush(struct request *rq, struct blk_flush_queue *fq,
* normal completion and end it.
*/
list_del_init(&rq->queuelist);
- blk_flush_restore_request(rq);
+ if (rq->rq_flags & RQF_FLUSH_SEQ)
+ blk_flush_restore_request(rq);
blk_mq_end_request(rq, error);
blk_kick_flush(q, fq);
@@ -461,7 +462,8 @@ bool blk_insert_flush(struct request *rq)
* Mark the request as part of a flush sequence and submit it
* for further processing to the flush state machine.
*/
- blk_rq_init_flush(rq);
+ if (policy & REQ_FSEQ_POSTFLUSH)
+ blk_rq_init_flush(rq);
spin_lock_irq(&fq->mq_flush_lock);
blk_enqueue_preflush(rq, fq);
spin_unlock_irq(&fq->mq_flush_lock);
--
2.41.0
next prev parent reply other threads:[~2023-07-25 13:19 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-25 13:00 [PATCH v2 0/4] blk-flush: optimize non-postflush requests chengming.zhou
2023-07-25 13:00 ` [PATCH v2 1/4] blk-flush: flush_rq should inherit first_rq's cmd_flags chengming.zhou
2023-07-31 6:09 ` Christoph Hellwig
2023-07-31 14:02 ` Chengming Zhou
2023-07-31 14:09 ` Christoph Hellwig
2023-07-31 16:28 ` Hannes Reinecke
2023-08-01 11:04 ` Christoph Hellwig
2023-08-01 11:06 ` Christoph Hellwig
2023-08-03 15:35 ` Chengming Zhou
2023-07-25 13:01 ` [PATCH v2 2/4] blk-flush: split queues for preflush and postflush requests chengming.zhou
2023-07-31 6:15 ` Christoph Hellwig
2023-07-31 14:15 ` Chengming Zhou
2023-07-25 13:01 ` [PATCH v2 3/4] blk-flush: kill the flush state machine chengming.zhou
2023-07-31 6:19 ` Christoph Hellwig
2023-07-31 14:27 ` Chengming Zhou
2023-07-25 13:01 ` chengming.zhou [this message]
2023-07-31 6:20 ` [PATCH v2 4/4] blk-flush: don't need to end rq twice for non postflush Christoph Hellwig
2023-08-10 14:25 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230725130102.3030032-5-chengming.zhou@linux.dev \
--to=chengming.zhou@linux.dev \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ming.lei@redhat.com \
--cc=zhouchengming@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox