From: Wanpeng Li <wanpeng.li@hotmail.com>
To: Jens Axboe <axboe@fb.com>
Cc: linux-kernel@vger.kernel.org, Wanpeng Li <wanpeng.li@hotmail.com>
Subject: [PATCH] block: fix update first/last mergeable segment sizes
Date: Wed, 5 Aug 2015 16:51:16 +0800 [thread overview]
Message-ID: <BLU436-SMTP5775068424CF597BA8980D80750@phx.gbl> (raw)
To keep track of the max segment size, the sizes of the first and last
mergeable segments in the bio are accounted, prev->bio->bi_seg_front_size
and next->biotail->bi_seg_back_size will be updated if blk_phys_contig_segment
is true, however, there are still some scenarios such like nonconsistent
blk integrity which leads to merge fail, in addtion, futher merge fail is
incurred due to bio->bi_seg_back_size + next->bi_seg_front_size >
queue_max_segment_size(q) check in function blk_phys_contig_segment(). This
patch fix it by updating first/last mergeable segments size iff all the
conditions of merging are meet.
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
---
block/blk-merge.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/block/blk-merge.c b/block/blk-merge.c
index 30a0d9f..7e7bda4 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -367,6 +367,7 @@ static int req_gap_to_prev(struct request *req, struct request *next)
static int ll_merge_requests_fn(struct request_queue *q, struct request *req,
struct request *next)
{
+ bool update_segment_size = false;
int total_phys_segments;
unsigned int seg_size =
req->biotail->bi_seg_back_size + next->bio->bi_seg_front_size;
@@ -391,10 +392,7 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req,
total_phys_segments = req->nr_phys_segments + next->nr_phys_segments;
if (blk_phys_contig_segment(q, req->biotail, next->bio)) {
- if (req->nr_phys_segments == 1)
- req->bio->bi_seg_front_size = seg_size;
- if (next->nr_phys_segments == 1)
- next->biotail->bi_seg_back_size = seg_size;
+ update_segment_size = true;
total_phys_segments--;
}
@@ -405,6 +403,12 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req,
return 0;
/* Merge is OK... */
+ if (update_segment_size) {
+ if (req->nr_phys_segments == 1)
+ req->bio->bi_seg_front_size = seg_size;
+ if (next->nr_phys_segments == 1)
+ next->biotail->bi_seg_back_size = seg_size;
+ }
req->nr_phys_segments = total_phys_segments;
return 1;
}
--
1.9.1
next reply other threads:[~2015-08-05 8:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-05 8:51 Wanpeng Li [this message]
2015-08-07 15:53 ` Jeff Moyer
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=BLU436-SMTP5775068424CF597BA8980D80750@phx.gbl \
--to=wanpeng.li@hotmail.com \
--cc=axboe@fb.com \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®