aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKent Overstreet <koverstreet@google.com>2012-09-04 18:20:38 -0400
committerKent Overstreet <koverstreet@google.com>2013-03-23 17:15:30 -0400
commit5b83636ae3c3b4f87d02a5929ad4dee831534db0 (patch)
tree90b902fe8797c11d4f76d08353e44bbf82a850e1
parentaa8b57aa3d1c06ca53312294ee6dfc767ee3ddb3 (diff)
block: Change bio_split() to respect the current value of bi_idx
In the current code bio_split() won't be seeing partially completed bios so this doesn't change any behaviour, but this makes the code a bit clearer as to what bio_split() actually requires. The immediate purpose of the patch is removing unnecessary bi_idx references, but the end goal is to allow partial completed bios to be submitted, which along with immutable biovecs enables effecient bio splitting. Some of the callers were (double) checking that bios could be split, so update their checks too. Signed-off-by: Kent Overstreet <koverstreet@google.com> CC: Jens Axboe <axboe@kernel.dk> CC: Lars Ellenberg <drbd-dev@lists.linbit.com> CC: Neil Brown <neilb@suse.de> CC: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/md/raid0.c3
-rw-r--r--drivers/md/raid10.c3
-rw-r--r--fs/bio-integrity.c4
-rw-r--r--fs/bio.c7
4 files changed, 7 insertions, 10 deletions
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 23a38afec351..fcf65e512cf5 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -527,8 +527,7 @@ static void raid0_make_request(struct mddev *mddev, struct bio *bio)
527 sector_t sector = bio->bi_sector; 527 sector_t sector = bio->bi_sector;
528 struct bio_pair *bp; 528 struct bio_pair *bp;
529 /* Sanity check -- queue functions should prevent this happening */ 529 /* Sanity check -- queue functions should prevent this happening */
530 if ((bio->bi_vcnt != 1 && bio->bi_vcnt != 0) || 530 if (bio_segments(bio) > 1)
531 bio->bi_idx != 0)
532 goto bad_map; 531 goto bad_map;
533 /* This is a one page bio that upper layers 532 /* This is a one page bio that upper layers
534 * refuse to split for us, so we need to split it. 533 * refuse to split for us, so we need to split it.
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 5ee14ab16a05..2e29df960bf5 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1175,8 +1175,7 @@ static void make_request(struct mddev *mddev, struct bio * bio)
1175 || conf->prev.near_copies < conf->prev.raid_disks))) { 1175 || conf->prev.near_copies < conf->prev.raid_disks))) {
1176 struct bio_pair *bp; 1176 struct bio_pair *bp;
1177 /* Sanity check -- queue functions should prevent this happening */ 1177 /* Sanity check -- queue functions should prevent this happening */
1178 if ((bio->bi_vcnt != 1 && bio->bi_vcnt != 0) || 1178 if (bio_segments(bio) > 1)
1179 bio->bi_idx != 0)
1180 goto bad_map; 1179 goto bad_map;
1181 /* This is a one page bio that upper layers 1180 /* This is a one page bio that upper layers
1182 * refuse to split for us, so we need to split it. 1181 * refuse to split for us, so we need to split it.
diff --git a/fs/bio-integrity.c b/fs/bio-integrity.c
index 8c4c604c840d..ca7b02dbf09d 100644
--- a/fs/bio-integrity.c
+++ b/fs/bio-integrity.c
@@ -661,8 +661,8 @@ void bio_integrity_split(struct bio *bio, struct bio_pair *bp, int sectors)
661 bp->bio1.bi_integrity = &bp->bip1; 661 bp->bio1.bi_integrity = &bp->bip1;
662 bp->bio2.bi_integrity = &bp->bip2; 662 bp->bio2.bi_integrity = &bp->bip2;
663 663
664 bp->iv1 = bip->bip_vec[0]; 664 bp->iv1 = bip->bip_vec[bip->bip_idx];
665 bp->iv2 = bip->bip_vec[0]; 665 bp->iv2 = bip->bip_vec[bip->bip_idx];
666 666
667 bp->bip1.bip_vec = &bp->iv1; 667 bp->bip1.bip_vec = &bp->iv1;
668 bp->bip2.bip_vec = &bp->iv2; 668 bp->bip2.bip_vec = &bp->iv2;
diff --git a/fs/bio.c b/fs/bio.c
index 7edc08d2246c..f1b4c1651089 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -1620,8 +1620,7 @@ struct bio_pair *bio_split(struct bio *bi, int first_sectors)
1620 trace_block_split(bdev_get_queue(bi->bi_bdev), bi, 1620 trace_block_split(bdev_get_queue(bi->bi_bdev), bi,
1621 bi->bi_sector + first_sectors); 1621 bi->bi_sector + first_sectors);
1622 1622
1623 BUG_ON(bi->bi_vcnt != 1 && bi->bi_vcnt != 0); 1623 BUG_ON(bio_segments(bi) > 1);
1624 BUG_ON(bi->bi_idx != 0);
1625 atomic_set(&bp->cnt, 3); 1624 atomic_set(&bp->cnt, 3);
1626 bp->error = 0; 1625 bp->error = 0;
1627 bp->bio1 = *bi; 1626 bp->bio1 = *bi;
@@ -1631,8 +1630,8 @@ struct bio_pair *bio_split(struct bio *bi, int first_sectors)
1631 bp->bio1.bi_size = first_sectors << 9; 1630 bp->bio1.bi_size = first_sectors << 9;
1632 1631
1633 if (bi->bi_vcnt != 0) { 1632 if (bi->bi_vcnt != 0) {
1634 bp->bv1 = bi->bi_io_vec[0]; 1633 bp->bv1 = *bio_iovec(bi);
1635 bp->bv2 = bi->bi_io_vec[0]; 1634 bp->bv2 = *bio_iovec(bi);
1636 1635
1637 if (bio_is_rw(bi)) { 1636 if (bio_is_rw(bi)) {
1638 bp->bv2.bv_offset += first_sectors << 9; 1637 bp->bv2.bv_offset += first_sectors << 9;