aboutsummaryrefslogtreecommitdiffstats
path: root/fs/bio.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/bio.c')
-rw-r--r--fs/bio.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/fs/bio.c b/fs/bio.c
index 75c49a382239..8754e7b6eb49 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -611,7 +611,6 @@ EXPORT_SYMBOL(bio_clone_fast);
611struct bio *bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask, 611struct bio *bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask,
612 struct bio_set *bs) 612 struct bio_set *bs)
613{ 613{
614 unsigned nr_iovecs = 0;
615 struct bvec_iter iter; 614 struct bvec_iter iter;
616 struct bio_vec bv; 615 struct bio_vec bv;
617 struct bio *bio; 616 struct bio *bio;
@@ -638,10 +637,7 @@ struct bio *bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask,
638 * __bio_clone_fast() anyways. 637 * __bio_clone_fast() anyways.
639 */ 638 */
640 639
641 bio_for_each_segment(bv, bio_src, iter) 640 bio = bio_alloc_bioset(gfp_mask, bio_segments(bio_src), bs);
642 nr_iovecs++;
643
644 bio = bio_alloc_bioset(gfp_mask, nr_iovecs, bs);
645 if (!bio) 641 if (!bio)
646 return NULL; 642 return NULL;
647 643
@@ -650,9 +646,18 @@ struct bio *bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask,
650 bio->bi_iter.bi_sector = bio_src->bi_iter.bi_sector; 646 bio->bi_iter.bi_sector = bio_src->bi_iter.bi_sector;
651 bio->bi_iter.bi_size = bio_src->bi_iter.bi_size; 647 bio->bi_iter.bi_size = bio_src->bi_iter.bi_size;
652 648
649 if (bio->bi_rw & REQ_DISCARD)
650 goto integrity_clone;
651
652 if (bio->bi_rw & REQ_WRITE_SAME) {
653 bio->bi_io_vec[bio->bi_vcnt++] = bio_src->bi_io_vec[0];
654 goto integrity_clone;
655 }
656
653 bio_for_each_segment(bv, bio_src, iter) 657 bio_for_each_segment(bv, bio_src, iter)
654 bio->bi_io_vec[bio->bi_vcnt++] = bv; 658 bio->bi_io_vec[bio->bi_vcnt++] = bv;
655 659
660integrity_clone:
656 if (bio_integrity(bio_src)) { 661 if (bio_integrity(bio_src)) {
657 int ret; 662 int ret;
658 663