Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
Browse files Browse the repository at this point in the history
Pull block layer fix from Jens Axboe:
 "This just contains the fix for the split issue that we had in -rc1.

  It's been well tested at this point, so let's get it in mainline so we
  don't have the same split issue for -rc2"

* 'for-linus' of git://git.kernel.dk/linux-block:
  block: fix bio splitting on max sectors
  • Loading branch information
torvalds committed Jan 29, 2016
2 parents b545443 + d0e5fbb commit 13d5699
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions block/blk-merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ static struct bio *blk_bio_write_same_split(struct request_queue *q,
return bio_split(bio, q->limits.max_write_same_sectors, GFP_NOIO, bs);
}

static inline unsigned get_max_io_size(struct request_queue *q,
struct bio *bio)
{
unsigned sectors = blk_max_size_offset(q, bio->bi_iter.bi_sector);
unsigned mask = queue_logical_block_size(q) - 1;

/* aligned to logical block size */
sectors &= ~(mask >> 9);

return sectors;
}

static struct bio *blk_bio_segment_split(struct request_queue *q,
struct bio *bio,
struct bio_set *bs,
Expand All @@ -81,6 +93,7 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
unsigned front_seg_size = bio->bi_seg_front_size;
bool do_split = true;
struct bio *new = NULL;
const unsigned max_sectors = get_max_io_size(q, bio);

bio_for_each_segment(bv, bio, iter) {
/*
Expand All @@ -90,20 +103,19 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
if (bvprvp && bvec_gap_to_prev(q, bvprvp, bv.bv_offset))
goto split;

if (sectors + (bv.bv_len >> 9) >
blk_max_size_offset(q, bio->bi_iter.bi_sector)) {
if (sectors + (bv.bv_len >> 9) > max_sectors) {
/*
* Consider this a new segment if we're splitting in
* the middle of this vector.
*/
if (nsegs < queue_max_segments(q) &&
sectors < blk_max_size_offset(q,
bio->bi_iter.bi_sector)) {
sectors < max_sectors) {
nsegs++;
sectors = blk_max_size_offset(q,
bio->bi_iter.bi_sector);
sectors = max_sectors;
}
goto split;
if (sectors)
goto split;
/* Make this single bvec as the 1st segment */
}

if (bvprvp && blk_queue_cluster(q)) {
Expand Down

0 comments on commit 13d5699

Please sign in to comment.