summaryrefslogtreecommitdiff
path: root/fs/bio.c
diff options
context:
space:
mode:
authorKent Overstreet <kmo@daterainc.com>2013-10-11 15:45:43 -0700
committerKent Overstreet <kmo@daterainc.com>2013-11-23 22:33:51 -0800
commit003b5c5719f159f4f4bf97511c4702a0638313dd (patch)
tree1b3cac74e22ae5a87fdb6e3066f2d728913e6e0c /fs/bio.c
parent458b76ed2f9517becb74dcc8eedd70d3068ea6e4 (diff)
block: Convert drivers to immutable biovecs
Now that we've got a mechanism for immutable biovecs - bi_iter.bi_bvec_done - we need to convert drivers to use primitives that respect it instead of using the bvec array directly. Signed-off-by: Kent Overstreet <kmo@daterainc.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: NeilBrown <neilb@suse.de> Cc: Alasdair Kergon <agk@redhat.com> Cc: dm-devel@redhat.com
Diffstat (limited to 'fs/bio.c')
-rw-r--r--fs/bio.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/fs/bio.c b/fs/bio.c
index e32f2ffc3f33..a082ce2d197b 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -525,8 +525,17 @@ EXPORT_SYMBOL(bio_phys_segments);
*/
void __bio_clone(struct bio *bio, struct bio *bio_src)
{
- memcpy(bio->bi_io_vec, bio_src->bi_io_vec,
- bio_src->bi_max_vecs * sizeof(struct bio_vec));
+ if (bio_is_rw(bio_src)) {
+ struct bio_vec bv;
+ struct bvec_iter iter;
+
+ bio_for_each_segment(bv, bio_src, iter)
+ bio->bi_io_vec[bio->bi_vcnt++] = bv;
+ } else if (bio_has_data(bio_src)) {
+ memcpy(bio->bi_io_vec, bio_src->bi_io_vec,
+ bio_src->bi_max_vecs * sizeof(struct bio_vec));
+ bio->bi_vcnt = bio_src->bi_vcnt;
+ }
/*
* most users will be overriding ->bi_bdev with a new target,
@@ -535,7 +544,6 @@ void __bio_clone(struct bio *bio, struct bio *bio_src)
bio->bi_bdev = bio_src->bi_bdev;
bio->bi_flags |= 1 << BIO_CLONED;
bio->bi_rw = bio_src->bi_rw;
- bio->bi_vcnt = bio_src->bi_vcnt;
bio->bi_iter = bio_src->bi_iter;
}
EXPORT_SYMBOL(__bio_clone);