All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: sync mixed merged request's failfast with 1st bio's
@ 2023-02-09 12:55 Ming Lei
  2023-02-14 15:05 ` Ming Lei
  2023-02-16  3:25 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Ming Lei @ 2023-02-09 12:55 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Ming Lei, Tejun Heo

We support mixed merge for requests/bios with different fastfail
settings. When request fails, each time we only handle the portion
with same failfast setting, then bios with failfast can be failed
immediately, and bios without failfast can be retried.

The idea is pretty good, but the current implementation has several
defects:

1) initially RA bio doesn't set failfast, however bio merge code
doesn't consider this point, and just check its failfast setting for
deciding if mixed merge is required. Fix this issue by adding helper
of bio_failfast().

2) when merging bio to request front, if this request is mixed
merged, we have to sync request's faifast setting with 1st bio's
failfast. Fix it by calling blk_update_mixed_merge().

3) when merging bio to request back, if this request is mixed
merged, we have to mark the bio as failfast, because blk_update_request
simply updates request failfast with 1st bio's failfast. Fix
it by calling blk_update_mixed_merge().

Fixes one normal EXT4 READ IO failure issue, because it is observed
that the normal READ IO is merged with RA IO, and the mixed merged
request has different failfast setting with 1st bio's, so finally
the normal READ IO doesn't get retried.

Cc: Tejun Heo <tj@kernel.org>
Fixes: 80a761fd33cf ("block: implement mixed merge of different failfast requests")
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
 block/blk-merge.c | 35 +++++++++++++++++++++++++++++++++--
 1 file changed, 33 insertions(+), 2 deletions(-)

diff --git a/block/blk-merge.c b/block/blk-merge.c
index b7c193d67185..30e4a99c2276 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -757,6 +757,33 @@ void blk_rq_set_mixed_merge(struct request *rq)
 	rq->rq_flags |= RQF_MIXED_MERGE;
 }
 
+static inline unsigned int bio_failfast(const struct bio *bio)
+{
+	if (bio->bi_opf & REQ_RAHEAD)
+		return REQ_FAILFAST_MASK;
+
+	return bio->bi_opf & REQ_FAILFAST_MASK;
+}
+
+/*
+ * After we are marked as MIXED_MERGE, any new RA bio has to be updated
+ * as failfast, and request's failfast has to be updated in case of
+ * front merge.
+ */
+static inline void blk_update_mixed_merge(struct request *req,
+		struct bio *bio, bool front_merge)
+{
+	if (req->rq_flags & RQF_MIXED_MERGE) {
+		if (bio->bi_opf & REQ_RAHEAD)
+			bio->bi_opf |= REQ_FAILFAST_MASK;
+
+		if (front_merge) {
+			req->cmd_flags &= ~REQ_FAILFAST_MASK;
+			req->cmd_flags |= bio->bi_opf & REQ_FAILFAST_MASK;
+		}
+	}
+}
+
 static void blk_account_io_merge_request(struct request *req)
 {
 	if (blk_do_io_stat(req)) {
@@ -954,7 +981,7 @@ enum bio_merge_status {
 static enum bio_merge_status bio_attempt_back_merge(struct request *req,
 		struct bio *bio, unsigned int nr_segs)
 {
-	const blk_opf_t ff = bio->bi_opf & REQ_FAILFAST_MASK;
+	const blk_opf_t ff = bio_failfast(bio);
 
 	if (!ll_back_merge_fn(req, bio, nr_segs))
 		return BIO_MERGE_FAILED;
@@ -965,6 +992,8 @@ static enum bio_merge_status bio_attempt_back_merge(struct request *req,
 	if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff)
 		blk_rq_set_mixed_merge(req);
 
+	blk_update_mixed_merge(req, bio, false);
+
 	req->biotail->bi_next = bio;
 	req->biotail = bio;
 	req->__data_len += bio->bi_iter.bi_size;
@@ -978,7 +1007,7 @@ static enum bio_merge_status bio_attempt_back_merge(struct request *req,
 static enum bio_merge_status bio_attempt_front_merge(struct request *req,
 		struct bio *bio, unsigned int nr_segs)
 {
-	const blk_opf_t ff = bio->bi_opf & REQ_FAILFAST_MASK;
+	const blk_opf_t ff = bio_failfast(bio);
 
 	if (!ll_front_merge_fn(req, bio, nr_segs))
 		return BIO_MERGE_FAILED;
@@ -989,6 +1018,8 @@ static enum bio_merge_status bio_attempt_front_merge(struct request *req,
 	if ((req->cmd_flags & REQ_FAILFAST_MASK) != ff)
 		blk_rq_set_mixed_merge(req);
 
+	blk_update_mixed_merge(req, bio, true);
+
 	bio->bi_next = req->bio;
 	req->bio = bio;
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] block: sync mixed merged request's failfast with 1st bio's
  2023-02-09 12:55 [PATCH] block: sync mixed merged request's failfast with 1st bio's Ming Lei
@ 2023-02-14 15:05 ` Ming Lei
  2023-02-16  3:25 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Ming Lei @ 2023-02-14 15:05 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Tejun Heo, ming.lei

On Thu, Feb 09, 2023 at 08:55:27PM +0800, Ming Lei wrote:
> We support mixed merge for requests/bios with different fastfail
> settings. When request fails, each time we only handle the portion
> with same failfast setting, then bios with failfast can be failed
> immediately, and bios without failfast can be retried.
> 
> The idea is pretty good, but the current implementation has several
> defects:
> 
> 1) initially RA bio doesn't set failfast, however bio merge code
> doesn't consider this point, and just check its failfast setting for
> deciding if mixed merge is required. Fix this issue by adding helper
> of bio_failfast().
> 
> 2) when merging bio to request front, if this request is mixed
> merged, we have to sync request's faifast setting with 1st bio's
> failfast. Fix it by calling blk_update_mixed_merge().
> 
> 3) when merging bio to request back, if this request is mixed
> merged, we have to mark the bio as failfast, because blk_update_request
> simply updates request failfast with 1st bio's failfast. Fix
> it by calling blk_update_mixed_merge().
> 
> Fixes one normal EXT4 READ IO failure issue, because it is observed
> that the normal READ IO is merged with RA IO, and the mixed merged
> request has different failfast setting with 1st bio's, so finally
> the normal READ IO doesn't get retried.
> 
> Cc: Tejun Heo <tj@kernel.org>
> Fixes: 80a761fd33cf ("block: implement mixed merge of different failfast requests")
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
>  block/blk-merge.c | 35 +++++++++++++++++++++++++++++++++--
>  1 file changed, 33 insertions(+), 2 deletions(-)

Hi Tejun, Jens and Guys,

Any chance to take a look? The patch addresses one RH customer issue.


Thanks, 
Ming


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] block: sync mixed merged request's failfast with 1st bio's
  2023-02-09 12:55 [PATCH] block: sync mixed merged request's failfast with 1st bio's Ming Lei
  2023-02-14 15:05 ` Ming Lei
@ 2023-02-16  3:25 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2023-02-16  3:25 UTC (permalink / raw)
  To: Ming Lei; +Cc: linux-block, Tejun Heo


On Thu, 09 Feb 2023 20:55:27 +0800, Ming Lei wrote:
> We support mixed merge for requests/bios with different fastfail
> settings. When request fails, each time we only handle the portion
> with same failfast setting, then bios with failfast can be failed
> immediately, and bios without failfast can be retried.
> 
> The idea is pretty good, but the current implementation has several
> defects:
> 
> [...]

Applied, thanks!

[1/1] block: sync mixed merged request's failfast with 1st bio's
      commit: 3481d9424950159b1dbd366a14acab79f1440bbf

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-16  3:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-09 12:55 [PATCH] block: sync mixed merged request's failfast with 1st bio's Ming Lei
2023-02-14 15:05 ` Ming Lei
2023-02-16  3:25 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.