]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
block: makes bio_split support bio without data
authorShaohua Li <shli@fusionio.com>
Mon, 24 Sep 2012 06:41:25 +0000 (16:41 +1000)
committerNeilBrown <neilb@suse.de>
Mon, 24 Sep 2012 06:41:25 +0000 (16:41 +1000)
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>
fs/bio.c

index 71072ab99128aadf1090e2ceab32bae67827dc9c..dbb7a6c34ebe19dfdc7ca5e024d5bb82ba1786d3 100644 (file)
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -1501,7 +1501,7 @@ struct bio_pair *bio_split(struct bio *bi, int first_sectors)
        trace_block_split(bdev_get_queue(bi->bi_bdev), bi,
                                bi->bi_sector + first_sectors);
 
-       BUG_ON(bi->bi_vcnt != 1);
+       BUG_ON(bi->bi_vcnt != 1 && bi->bi_vcnt != 0);
        BUG_ON(bi->bi_idx != 0);
        atomic_set(&bp->cnt, 3);
        bp->error = 0;
@@ -1511,17 +1511,19 @@ struct bio_pair *bio_split(struct bio *bi, int first_sectors)
        bp->bio2.bi_size -= first_sectors << 9;
        bp->bio1.bi_size = first_sectors << 9;
 
-       bp->bv1 = bi->bi_io_vec[0];
-       bp->bv2 = bi->bi_io_vec[0];
-       bp->bv2.bv_offset += first_sectors << 9;
-       bp->bv2.bv_len -= first_sectors << 9;
-       bp->bv1.bv_len = first_sectors << 9;
+       if (bi->bi_vcnt != 0) {
+               bp->bv1 = bi->bi_io_vec[0];
+               bp->bv2 = bi->bi_io_vec[0];
+               bp->bv2.bv_offset += first_sectors << 9;
+               bp->bv2.bv_len -= first_sectors << 9;
+               bp->bv1.bv_len = first_sectors << 9;
 
-       bp->bio1.bi_io_vec = &bp->bv1;
-       bp->bio2.bi_io_vec = &bp->bv2;
+               bp->bio1.bi_io_vec = &bp->bv1;
+               bp->bio2.bi_io_vec = &bp->bv2;
 
-       bp->bio1.bi_max_vecs = 1;
-       bp->bio2.bi_max_vecs = 1;
+               bp->bio1.bi_max_vecs = 1;
+               bp->bio2.bi_max_vecs = 1;
+       }
 
        bp->bio1.bi_end_io = bio_pair_end_1;
        bp->bio2.bi_end_io = bio_pair_end_2;