diff options
author | Kent Overstreet | 2014-02-11 02:45:50 +0100 |
---|---|---|
committer | Jens Axboe | 2014-02-11 16:40:45 +0100 |
commit | 8423ae3d7a3cfe084865262cfaeba1359d405182 (patch) | |
tree | e8e6f9c31f5622e66ff176b600cf3b3c951eb4d8 /fs/bio.c | |
parent | Merge branch 'stable/for-jens-3.14' of git://git.kernel.org/pub/scm/linux/ker... (diff) | |
download | kernel-qcow2-linux-8423ae3d7a3cfe084865262cfaeba1359d405182.tar.gz kernel-qcow2-linux-8423ae3d7a3cfe084865262cfaeba1359d405182.tar.xz kernel-qcow2-linux-8423ae3d7a3cfe084865262cfaeba1359d405182.zip |
block: Fix cloning of discard/write same bios
Immutable biovecs changed the way bio segments are treated in such a way that
bio_for_each_segment() cannot now do what we want for discard/write same bios,
since bi_size means something completely different for them.
Fortunately discard and write same bios never have more than a single biovec, so
bio_for_each_segment() is unnecessary and not terribly meaningful for them, but
we still have to special case them in a few places.
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Tested-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'fs/bio.c')
-rw-r--r-- | fs/bio.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -611,7 +611,6 @@ EXPORT_SYMBOL(bio_clone_fast); struct bio *bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask, struct bio_set *bs) { - unsigned nr_iovecs = 0; struct bvec_iter iter; struct bio_vec bv; struct bio *bio; @@ -638,10 +637,7 @@ struct bio *bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask, * __bio_clone_fast() anyways. */ - bio_for_each_segment(bv, bio_src, iter) - nr_iovecs++; - - bio = bio_alloc_bioset(gfp_mask, nr_iovecs, bs); + bio = bio_alloc_bioset(gfp_mask, bio_segments(bio_src), bs); if (!bio) return NULL; @@ -650,9 +646,18 @@ struct bio *bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask, bio->bi_iter.bi_sector = bio_src->bi_iter.bi_sector; bio->bi_iter.bi_size = bio_src->bi_iter.bi_size; + if (bio->bi_rw & REQ_DISCARD) + goto integrity_clone; + + if (bio->bi_rw & REQ_WRITE_SAME) { + bio->bi_io_vec[bio->bi_vcnt++] = bio_src->bi_io_vec[0]; + goto integrity_clone; + } + bio_for_each_segment(bv, bio_src, iter) bio->bi_io_vec[bio->bi_vcnt++] = bv; +integrity_clone: if (bio_integrity(bio_src)) { int ret; |