Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 115483
b: refs/heads/master
c: 8677142
h: refs/heads/master
i:
  115481: 31dd883
  115479: d213e5f
v: v3
  • Loading branch information
FUJITA Tomonori authored and Jens Axboe committed Oct 17, 2008
1 parent 58e6dd2 commit 1a5239c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0fc71e3d6520ba7abad5cfbc9a33db0190e4d5b8
refs/heads/master: 8677142710516d986d932d6f1fba7be8382c1fec
20 changes: 18 additions & 2 deletions trunk/block/blk-merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,20 @@ void blk_recalc_rq_segments(struct request *rq)
continue;
}
new_segment:
if (nr_phys_segs == 1 && seg_size > rq->bio->bi_seg_front_size)
rq->bio->bi_seg_front_size = seg_size;

nr_phys_segs++;
bvprv = bv;
seg_size = bv->bv_len;
highprv = high;
}

if (nr_phys_segs == 1 && seg_size > rq->bio->bi_seg_front_size)
rq->bio->bi_seg_front_size = seg_size;
if (seg_size > rq->biotail->bi_seg_back_size)
rq->biotail->bi_seg_back_size = seg_size;

rq->nr_phys_segments = nr_phys_segs;
}

Expand All @@ -106,7 +114,8 @@ static int blk_phys_contig_segment(struct request_queue *q, struct bio *bio,
if (!test_bit(QUEUE_FLAG_CLUSTER, &q->queue_flags))
return 0;

if (bio->bi_size + nxt->bi_size > q->max_segment_size)
if (bio->bi_seg_back_size + nxt->bi_seg_front_size >
q->max_segment_size)
return 0;

if (!bio_has_data(bio))
Expand Down Expand Up @@ -309,6 +318,8 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req,
struct request *next)
{
int total_phys_segments;
unsigned int seg_size =
req->biotail->bi_seg_back_size + next->bio->bi_seg_front_size;

/*
* First check if the either of the requests are re-queued
Expand All @@ -324,8 +335,13 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req,
return 0;

total_phys_segments = req->nr_phys_segments + next->nr_phys_segments;
if (blk_phys_contig_segment(q, req->biotail, next->bio))
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;
total_phys_segments--;
}

if (total_phys_segments > q->max_phys_segments)
return 0;
Expand Down
7 changes: 7 additions & 0 deletions trunk/include/linux/bio.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ struct bio {

unsigned int bi_size; /* residual I/O count */

/*
* To keep track of the max segment size, we account for the
* sizes of the first and last mergeable segments in this bio.
*/
unsigned int bi_seg_front_size;
unsigned int bi_seg_back_size;

unsigned int bi_max_vecs; /* max bvl_vecs we can hold */

unsigned int bi_comp_cpu; /* completion CPU */
Expand Down

0 comments on commit 1a5239c

Please sign in to comment.