Commit 02f3939e1a9357b7c370a4a69717cf9c02452737

Authored by Shaohua Li
Committed by Jens Axboe
1 parent 232f1b5106

block: makes bio_split support bio without data

discard bio hasn't data attached. We hit a BUG_ON with such bio. This makes
bio_split works for such bio.

Signed-off-by: Shaohua Li <shli@fusionio.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

Showing 1 changed file with 14 additions and 12 deletions Side-by-side Diff

... ... @@ -1475,7 +1475,7 @@
1475 1475 trace_block_split(bdev_get_queue(bi->bi_bdev), bi,
1476 1476 bi->bi_sector + first_sectors);
1477 1477  
1478   - BUG_ON(bi->bi_vcnt != 1);
  1478 + BUG_ON(bi->bi_vcnt != 1 && bi->bi_vcnt != 0);
1479 1479 BUG_ON(bi->bi_idx != 0);
1480 1480 atomic_set(&bp->cnt, 3);
1481 1481 bp->error = 0;
1482 1482  
1483 1483  
1484 1484  
... ... @@ -1485,20 +1485,22 @@
1485 1485 bp->bio2.bi_size -= first_sectors << 9;
1486 1486 bp->bio1.bi_size = first_sectors << 9;
1487 1487  
1488   - bp->bv1 = bi->bi_io_vec[0];
1489   - bp->bv2 = bi->bi_io_vec[0];
  1488 + if (bi->bi_vcnt != 0) {
  1489 + bp->bv1 = bi->bi_io_vec[0];
  1490 + bp->bv2 = bi->bi_io_vec[0];
1490 1491  
1491   - if (bio_is_rw(bi)) {
1492   - bp->bv2.bv_offset += first_sectors << 9;
1493   - bp->bv2.bv_len -= first_sectors << 9;
1494   - bp->bv1.bv_len = first_sectors << 9;
1495   - }
  1492 + if (bio_is_rw(bi)) {
  1493 + bp->bv2.bv_offset += first_sectors << 9;
  1494 + bp->bv2.bv_len -= first_sectors << 9;
  1495 + bp->bv1.bv_len = first_sectors << 9;
  1496 + }
1496 1497  
1497   - bp->bio1.bi_io_vec = &bp->bv1;
1498   - bp->bio2.bi_io_vec = &bp->bv2;
  1498 + bp->bio1.bi_io_vec = &bp->bv1;
  1499 + bp->bio2.bi_io_vec = &bp->bv2;
1499 1500  
1500   - bp->bio1.bi_max_vecs = 1;
1501   - bp->bio2.bi_max_vecs = 1;
  1501 + bp->bio1.bi_max_vecs = 1;
  1502 + bp->bio2.bi_max_vecs = 1;
  1503 + }
1502 1504  
1503 1505 bp->bio1.bi_end_io = bio_pair_end_1;
1504 1506 bp->bio2.bi_end_io = bio_pair_end_2;