diff options
| author | Kent Overstreet <koverstreet@google.com> | 2012-09-06 18:35:02 -0400 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2012-09-09 04:35:39 -0400 |
| commit | bf800ef1816b4283a885e55ad38068aec9711e4d (patch) | |
| tree | c99cbe70b68ede65b478b3006a7ed7e34b453f3d /drivers/md | |
| parent | 3f86a82aeb03e6100f7ab39f4702e033a5e38166 (diff) | |
block: Add bio_clone_bioset(), bio_clone_kmalloc()
Previously, there was bio_clone() but it only allocated from the fs bio
set; as a result various users were open coding it and using
__bio_clone().
This changes bio_clone() to become bio_clone_bioset(), and then we add
bio_clone() and bio_clone_kmalloc() as wrappers around it, making use of
the functionality the last patch adedd.
This will also help in a later patch changing how bio cloning works.
Signed-off-by: Kent Overstreet <koverstreet@google.com>
CC: Jens Axboe <axboe@kernel.dk>
CC: NeilBrown <neilb@suse.de>
CC: Alasdair Kergon <agk@redhat.com>
CC: Boaz Harrosh <bharrosh@panasas.com>
CC: Jeff Garzik <jeff@garzik.org>
Acked-by: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/md')
| -rw-r--r-- | drivers/md/dm-crypt.c | 7 | ||||
| -rw-r--r-- | drivers/md/dm.c | 4 | ||||
| -rw-r--r-- | drivers/md/md.c | 20 |
3 files changed, 4 insertions, 27 deletions
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 3c0acba042b6..bbf459bca61d 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
| @@ -979,19 +979,14 @@ static int kcryptd_io_read(struct dm_crypt_io *io, gfp_t gfp) | |||
| 979 | * copy the required bvecs because we need the original | 979 | * copy the required bvecs because we need the original |
| 980 | * one in order to decrypt the whole bio data *afterwards*. | 980 | * one in order to decrypt the whole bio data *afterwards*. |
| 981 | */ | 981 | */ |
| 982 | clone = bio_alloc_bioset(gfp, bio_segments(base_bio), cc->bs); | 982 | clone = bio_clone_bioset(base_bio, gfp, cc->bs); |
| 983 | if (!clone) | 983 | if (!clone) |
| 984 | return 1; | 984 | return 1; |
| 985 | 985 | ||
| 986 | crypt_inc_pending(io); | 986 | crypt_inc_pending(io); |
| 987 | 987 | ||
| 988 | clone_init(io, clone); | 988 | clone_init(io, clone); |
| 989 | clone->bi_idx = 0; | ||
| 990 | clone->bi_vcnt = bio_segments(base_bio); | ||
| 991 | clone->bi_size = base_bio->bi_size; | ||
| 992 | clone->bi_sector = cc->start + io->sector; | 989 | clone->bi_sector = cc->start + io->sector; |
| 993 | memcpy(clone->bi_io_vec, bio_iovec(base_bio), | ||
| 994 | sizeof(struct bio_vec) * clone->bi_vcnt); | ||
| 995 | 990 | ||
| 996 | generic_make_request(clone); | 991 | generic_make_request(clone); |
| 997 | return 0; | 992 | return 0; |
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 33470f01ea5e..837879716889 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
| @@ -1129,8 +1129,8 @@ static void __issue_target_request(struct clone_info *ci, struct dm_target *ti, | |||
| 1129 | * ci->bio->bi_max_vecs is BIO_INLINE_VECS anyway, for both flush | 1129 | * ci->bio->bi_max_vecs is BIO_INLINE_VECS anyway, for both flush |
| 1130 | * and discard, so no need for concern about wasted bvec allocations. | 1130 | * and discard, so no need for concern about wasted bvec allocations. |
| 1131 | */ | 1131 | */ |
| 1132 | clone = bio_alloc_bioset(GFP_NOIO, ci->bio->bi_max_vecs, ci->md->bs); | 1132 | clone = bio_clone_bioset(ci->bio, GFP_NOIO, ci->md->bs); |
| 1133 | __bio_clone(clone, ci->bio); | 1133 | |
| 1134 | if (len) { | 1134 | if (len) { |
| 1135 | clone->bi_sector = ci->sector; | 1135 | clone->bi_sector = ci->sector; |
| 1136 | clone->bi_size = to_bytes(len); | 1136 | clone->bi_size = to_bytes(len); |
diff --git a/drivers/md/md.c b/drivers/md/md.c index 457ca8451ddb..7a2b0793f66e 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
| @@ -173,28 +173,10 @@ EXPORT_SYMBOL_GPL(bio_alloc_mddev); | |||
| 173 | struct bio *bio_clone_mddev(struct bio *bio, gfp_t gfp_mask, | 173 | struct bio *bio_clone_mddev(struct bio *bio, gfp_t gfp_mask, |
| 174 | struct mddev *mddev) | 174 | struct mddev *mddev) |
| 175 | { | 175 | { |
| 176 | struct bio *b; | ||
| 177 | |||
| 178 | if (!mddev || !mddev->bio_set) | 176 | if (!mddev || !mddev->bio_set) |
| 179 | return bio_clone(bio, gfp_mask); | 177 | return bio_clone(bio, gfp_mask); |
| 180 | 178 | ||
| 181 | b = bio_alloc_bioset(gfp_mask, bio->bi_max_vecs, mddev->bio_set); | 179 | return bio_clone_bioset(bio, gfp_mask, mddev->bio_set); |
| 182 | if (!b) | ||
| 183 | return NULL; | ||
| 184 | |||
| 185 | __bio_clone(b, bio); | ||
| 186 | if (bio_integrity(bio)) { | ||
| 187 | int ret; | ||
| 188 | |||
| 189 | ret = bio_integrity_clone(b, bio, gfp_mask); | ||
| 190 | |||
| 191 | if (ret < 0) { | ||
| 192 | bio_put(b); | ||
| 193 | return NULL; | ||
| 194 | } | ||
| 195 | } | ||
| 196 | |||
| 197 | return b; | ||
| 198 | } | 180 | } |
| 199 | EXPORT_SYMBOL_GPL(bio_clone_mddev); | 181 | EXPORT_SYMBOL_GPL(bio_clone_mddev); |
| 200 | 182 | ||
