mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] block: fix update first/last mergeable segment sizes
@ 2015-08-05  8:51 Wanpeng Li
  2015-08-07 15:53 ` Jeff Moyer
  0 siblings, 1 reply; 2+ messages in thread
From: Wanpeng Li @ 2015-08-05  8:51 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-kernel, Wanpeng Li

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


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

* Re: [PATCH] block: fix update first/last mergeable segment sizes
  2015-08-05  8:51 [PATCH] block: fix update first/last mergeable segment sizes Wanpeng Li
@ 2015-08-07 15:53 ` Jeff Moyer
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Moyer @ 2015-08-07 15:53 UTC (permalink / raw)
  To: Wanpeng Li; +Cc: Jens Axboe, linux-kernel

Wanpeng Li <wanpeng.li@hotmail.com> writes:

> 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.

Does it matter?  Did you see any incorrect behaviour as a result of the
current code?

Cheers,
Jeff

>
> 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;
>  }

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

end of thread, other threads:[~2015-08-07 15:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-05  8:51 [PATCH] block: fix update first/last mergeable segment sizes Wanpeng Li
2015-08-07 15:53 ` Jeff Moyer

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®