diff options
| author | Shaohua Li <shli@kernel.org> | 2012-09-28 04:38:48 -0400 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2012-09-28 04:38:48 -0400 |
| commit | 02f3939e1a9357b7c370a4a69717cf9c02452737 (patch) | |
| tree | e7cc574ca11f44ccdf6a685dc45a9a1eede1f2cd | |
| parent | 232f1b51062553b7cf49f99719fbd1b8a8d80f29 (diff) | |
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>
| -rw-r--r-- | fs/bio.c | 26 |
1 files changed, 14 insertions, 12 deletions
| @@ -1475,7 +1475,7 @@ struct bio_pair *bio_split(struct bio *bi, int first_sectors) | |||
| 1475 | trace_block_split(bdev_get_queue(bi->bi_bdev), bi, | 1475 | trace_block_split(bdev_get_queue(bi->bi_bdev), bi, |
| 1476 | bi->bi_sector + first_sectors); | 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 | BUG_ON(bi->bi_idx != 0); | 1479 | BUG_ON(bi->bi_idx != 0); |
| 1480 | atomic_set(&bp->cnt, 3); | 1480 | atomic_set(&bp->cnt, 3); |
| 1481 | bp->error = 0; | 1481 | bp->error = 0; |
| @@ -1485,20 +1485,22 @@ struct bio_pair *bio_split(struct bio *bi, int first_sectors) | |||
| 1485 | bp->bio2.bi_size -= first_sectors << 9; | 1485 | bp->bio2.bi_size -= first_sectors << 9; |
| 1486 | bp->bio1.bi_size = first_sectors << 9; | 1486 | bp->bio1.bi_size = first_sectors << 9; |
| 1487 | 1487 | ||
| 1488 | bp->bv1 = bi->bi_io_vec[0]; | 1488 | if (bi->bi_vcnt != 0) { |
| 1489 | bp->bv2 = bi->bi_io_vec[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 | if (bio_is_rw(bi)) { |
| 1492 | bp->bv2.bv_offset += first_sectors << 9; | 1493 | bp->bv2.bv_offset += first_sectors << 9; |
| 1493 | bp->bv2.bv_len -= first_sectors << 9; | 1494 | bp->bv2.bv_len -= first_sectors << 9; |
| 1494 | bp->bv1.bv_len = first_sectors << 9; | 1495 | bp->bv1.bv_len = first_sectors << 9; |
| 1495 | } | 1496 | } |
| 1496 | 1497 | ||
| 1497 | bp->bio1.bi_io_vec = &bp->bv1; | 1498 | bp->bio1.bi_io_vec = &bp->bv1; |
| 1498 | bp->bio2.bi_io_vec = &bp->bv2; | 1499 | bp->bio2.bi_io_vec = &bp->bv2; |
| 1499 | 1500 | ||
| 1500 | bp->bio1.bi_max_vecs = 1; | 1501 | bp->bio1.bi_max_vecs = 1; |
| 1501 | bp->bio2.bi_max_vecs = 1; | 1502 | bp->bio2.bi_max_vecs = 1; |
| 1503 | } | ||
| 1502 | 1504 | ||
| 1503 | bp->bio1.bi_end_io = bio_pair_end_1; | 1505 | bp->bio1.bi_end_io = bio_pair_end_1; |
| 1504 | bp->bio2.bi_end_io = bio_pair_end_2; | 1506 | bp->bio2.bi_end_io = bio_pair_end_2; |
