diff options
| -rw-r--r-- | block/blk-core.c | 8 | ||||
| -rw-r--r-- | drivers/block/osdblk.c | 3 | ||||
| -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 | ||||
| -rw-r--r-- | fs/bio.c | 11 | ||||
| -rw-r--r-- | fs/exofs/ore.c | 5 | ||||
| -rw-r--r-- | include/linux/bio.h | 17 |
8 files changed, 29 insertions, 46 deletions
diff --git a/block/blk-core.c b/block/blk-core.c index b776cc90a4e7..82aab2815858 100644 --- a/block/blk-core.c +++ b/block/blk-core.c | |||
| @@ -2781,16 +2781,10 @@ int blk_rq_prep_clone(struct request *rq, struct request *rq_src, | |||
| 2781 | blk_rq_init(NULL, rq); | 2781 | blk_rq_init(NULL, rq); |
| 2782 | 2782 | ||
| 2783 | __rq_for_each_bio(bio_src, rq_src) { | 2783 | __rq_for_each_bio(bio_src, rq_src) { |
| 2784 | bio = bio_alloc_bioset(gfp_mask, bio_src->bi_max_vecs, bs); | 2784 | bio = bio_clone_bioset(bio_src, gfp_mask, bs); |
| 2785 | if (!bio) | 2785 | if (!bio) |
| 2786 | goto free_and_out; | 2786 | goto free_and_out; |
| 2787 | 2787 | ||
| 2788 | __bio_clone(bio, bio_src); | ||
| 2789 | |||
| 2790 | if (bio_integrity(bio_src) && | ||
| 2791 | bio_integrity_clone(bio, bio_src, gfp_mask)) | ||
| 2792 | goto free_and_out; | ||
| 2793 | |||
| 2794 | if (bio_ctr && bio_ctr(bio, bio_src, data)) | 2788 | if (bio_ctr && bio_ctr(bio, bio_src, data)) |
| 2795 | goto free_and_out; | 2789 | goto free_and_out; |
| 2796 | 2790 | ||
diff --git a/drivers/block/osdblk.c b/drivers/block/osdblk.c index 87311ebac0db..1bbc681688e4 100644 --- a/drivers/block/osdblk.c +++ b/drivers/block/osdblk.c | |||
| @@ -266,11 +266,10 @@ static struct bio *bio_chain_clone(struct bio *old_chain, gfp_t gfpmask) | |||
| 266 | struct bio *tmp, *new_chain = NULL, *tail = NULL; | 266 | struct bio *tmp, *new_chain = NULL, *tail = NULL; |
| 267 | 267 | ||
| 268 | while (old_chain) { | 268 | while (old_chain) { |
| 269 | tmp = bio_kmalloc(gfpmask, old_chain->bi_max_vecs); | 269 | tmp = bio_clone_kmalloc(old_chain, gfpmask); |
| 270 | if (!tmp) | 270 | if (!tmp) |
| 271 | goto err_out; | 271 | goto err_out; |
| 272 | 272 | ||
| 273 | __bio_clone(tmp, old_chain); | ||
| 274 | tmp->bi_bdev = NULL; | 273 | tmp->bi_bdev = NULL; |
| 275 | gfpmask &= ~__GFP_WAIT; | 274 | gfpmask &= ~__GFP_WAIT; |
| 276 | tmp->bi_next = NULL; | 275 | tmp->bi_next = NULL; |
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 | ||
| @@ -438,16 +438,19 @@ void __bio_clone(struct bio *bio, struct bio *bio_src) | |||
| 438 | EXPORT_SYMBOL(__bio_clone); | 438 | EXPORT_SYMBOL(__bio_clone); |
| 439 | 439 | ||
| 440 | /** | 440 | /** |
| 441 | * bio_clone - clone a bio | 441 | * bio_clone_bioset - clone a bio |
| 442 | * @bio: bio to clone | 442 | * @bio: bio to clone |
| 443 | * @gfp_mask: allocation priority | 443 | * @gfp_mask: allocation priority |
| 444 | * @bs: bio_set to allocate from | ||
| 444 | * | 445 | * |
| 445 | * Like __bio_clone, only also allocates the returned bio | 446 | * Like __bio_clone, only also allocates the returned bio |
| 446 | */ | 447 | */ |
| 447 | struct bio *bio_clone(struct bio *bio, gfp_t gfp_mask) | 448 | struct bio *bio_clone_bioset(struct bio *bio, gfp_t gfp_mask, |
| 449 | struct bio_set *bs) | ||
| 448 | { | 450 | { |
| 449 | struct bio *b = bio_alloc(gfp_mask, bio->bi_max_vecs); | 451 | struct bio *b; |
| 450 | 452 | ||
| 453 | b = bio_alloc_bioset(gfp_mask, bio->bi_max_vecs, bs); | ||
| 451 | if (!b) | 454 | if (!b) |
| 452 | return NULL; | 455 | return NULL; |
| 453 | 456 | ||
| @@ -466,7 +469,7 @@ struct bio *bio_clone(struct bio *bio, gfp_t gfp_mask) | |||
| 466 | 469 | ||
| 467 | return b; | 470 | return b; |
| 468 | } | 471 | } |
| 469 | EXPORT_SYMBOL(bio_clone); | 472 | EXPORT_SYMBOL(bio_clone_bioset); |
| 470 | 473 | ||
| 471 | /** | 474 | /** |
| 472 | * bio_get_nr_vecs - return approx number of vecs | 475 | * bio_get_nr_vecs - return approx number of vecs |
diff --git a/fs/exofs/ore.c b/fs/exofs/ore.c index 1585db1aa365..f936cb50dc0d 100644 --- a/fs/exofs/ore.c +++ b/fs/exofs/ore.c | |||
| @@ -814,8 +814,8 @@ static int _write_mirror(struct ore_io_state *ios, int cur_comp) | |||
| 814 | struct bio *bio; | 814 | struct bio *bio; |
| 815 | 815 | ||
| 816 | if (per_dev != master_dev) { | 816 | if (per_dev != master_dev) { |
| 817 | bio = bio_kmalloc(GFP_KERNEL, | 817 | bio = bio_clone_kmalloc(master_dev->bio, |
| 818 | master_dev->bio->bi_max_vecs); | 818 | GFP_KERNEL); |
| 819 | if (unlikely(!bio)) { | 819 | if (unlikely(!bio)) { |
| 820 | ORE_DBGMSG( | 820 | ORE_DBGMSG( |
| 821 | "Failed to allocate BIO size=%u\n", | 821 | "Failed to allocate BIO size=%u\n", |
| @@ -824,7 +824,6 @@ static int _write_mirror(struct ore_io_state *ios, int cur_comp) | |||
| 824 | goto out; | 824 | goto out; |
| 825 | } | 825 | } |
| 826 | 826 | ||
| 827 | __bio_clone(bio, master_dev->bio); | ||
| 828 | bio->bi_bdev = NULL; | 827 | bio->bi_bdev = NULL; |
| 829 | bio->bi_next = NULL; | 828 | bio->bi_next = NULL; |
| 830 | per_dev->offset = master_dev->offset; | 829 | per_dev->offset = master_dev->offset; |
diff --git a/include/linux/bio.h b/include/linux/bio.h index fbe35b175555..52b9cbc3e4da 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h | |||
| @@ -215,6 +215,9 @@ extern void bioset_free(struct bio_set *); | |||
| 215 | extern struct bio *bio_alloc_bioset(gfp_t, int, struct bio_set *); | 215 | extern struct bio *bio_alloc_bioset(gfp_t, int, struct bio_set *); |
| 216 | extern void bio_put(struct bio *); | 216 | extern void bio_put(struct bio *); |
| 217 | 217 | ||
| 218 | extern void __bio_clone(struct bio *, struct bio *); | ||
| 219 | extern struct bio *bio_clone_bioset(struct bio *, gfp_t, struct bio_set *bs); | ||
| 220 | |||
| 218 | extern struct bio_set *fs_bio_set; | 221 | extern struct bio_set *fs_bio_set; |
| 219 | 222 | ||
| 220 | static inline struct bio *bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs) | 223 | static inline struct bio *bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs) |
| @@ -222,18 +225,26 @@ static inline struct bio *bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs) | |||
| 222 | return bio_alloc_bioset(gfp_mask, nr_iovecs, fs_bio_set); | 225 | return bio_alloc_bioset(gfp_mask, nr_iovecs, fs_bio_set); |
| 223 | } | 226 | } |
| 224 | 227 | ||
| 228 | static inline struct bio *bio_clone(struct bio *bio, gfp_t gfp_mask) | ||
| 229 | { | ||
| 230 | return bio_clone_bioset(bio, gfp_mask, fs_bio_set); | ||
| 231 | } | ||
| 232 | |||
| 225 | static inline struct bio *bio_kmalloc(gfp_t gfp_mask, unsigned int nr_iovecs) | 233 | static inline struct bio *bio_kmalloc(gfp_t gfp_mask, unsigned int nr_iovecs) |
| 226 | { | 234 | { |
| 227 | return bio_alloc_bioset(gfp_mask, nr_iovecs, NULL); | 235 | return bio_alloc_bioset(gfp_mask, nr_iovecs, NULL); |
| 228 | } | 236 | } |
| 229 | 237 | ||
| 238 | static inline struct bio *bio_clone_kmalloc(struct bio *bio, gfp_t gfp_mask) | ||
| 239 | { | ||
| 240 | return bio_clone_bioset(bio, gfp_mask, NULL); | ||
| 241 | |||
| 242 | } | ||
| 243 | |||
| 230 | extern void bio_endio(struct bio *, int); | 244 | extern void bio_endio(struct bio *, int); |
| 231 | struct request_queue; | 245 | struct request_queue; |
| 232 | extern int bio_phys_segments(struct request_queue *, struct bio *); | 246 | extern int bio_phys_segments(struct request_queue *, struct bio *); |
| 233 | 247 | ||
| 234 | extern void __bio_clone(struct bio *, struct bio *); | ||
| 235 | extern struct bio *bio_clone(struct bio *, gfp_t); | ||
| 236 | |||
| 237 | extern void bio_init(struct bio *); | 248 | extern void bio_init(struct bio *); |
| 238 | extern void bio_reset(struct bio *); | 249 | extern void bio_reset(struct bio *); |
| 239 | 250 | ||
