diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2015-05-17 18:50:32 -0700 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2017-01-18 20:57:09 -0900 |
commit | 02a63d7c5f97203a97eb11a993c697d1470551d1 (patch) | |
tree | 023ed74adcb7692f29ff679e33af39794b045985 | |
parent | a427d37c0eac489cbeaa1914b672e6ea7d358d62 (diff) |
block: Add bio_copy_data_iter()
-rw-r--r-- | block/bio.c | 37 | ||||
-rw-r--r-- | include/linux/bio.h | 2 |
2 files changed, 22 insertions, 17 deletions
diff --git a/block/bio.c b/block/bio.c index 48cdd66c9d52..c1e4faa91d59 100644 --- a/block/bio.c +++ b/block/bio.c @@ -927,28 +927,13 @@ int bio_alloc_pages(struct bio *bio, gfp_t gfp_mask) } EXPORT_SYMBOL(bio_alloc_pages); -/** - * bio_copy_data - copy contents of data buffers from one chain of bios to - * another - * @src: source bio list - * @dst: destination bio list - * - * If @src and @dst are single bios, bi_next must be NULL - otherwise, treats - * @src and @dst as linked lists of bios. - * - * Stops when it reaches the end of either @src or @dst - that is, copies - * min(src->bi_size, dst->bi_size) bytes (or the equivalent for lists of bios). - */ -void bio_copy_data(struct bio *dst, struct bio *src) +void bio_copy_data_iter(struct bio *dst, struct bvec_iter dst_iter, + struct bio *src, struct bvec_iter src_iter) { - struct bvec_iter src_iter, dst_iter; struct bio_vec src_bv, dst_bv; void *src_p, *dst_p; unsigned bytes; - src_iter = src->bi_iter; - dst_iter = dst->bi_iter; - while (1) { if (!src_iter.bi_size) { src = src->bi_next; @@ -985,6 +970,24 @@ void bio_copy_data(struct bio *dst, struct bio *src) bio_advance_iter(dst, &dst_iter, bytes); } } + +/** + * bio_copy_data - copy contents of data buffers from one chain of bios to + * another + * @src: source bio list + * @dst: destination bio list + * + * If @src and @dst are single bios, bi_next must be NULL - otherwise, treats + * @src and @dst as linked lists of bios. + * + * Stops when it reaches the end of either @src or @dst - that is, copies + * min(src->bi_size, dst->bi_size) bytes (or the equivalent for lists of bios). + */ +void bio_copy_data(struct bio *dst, struct bio *src) +{ + bio_copy_data_iter(dst, dst->bi_iter, + src, src->bi_iter); +} EXPORT_SYMBOL(bio_copy_data); struct bio_map_data { diff --git a/include/linux/bio.h b/include/linux/bio.h index ecd70498c7d7..b1bd0864d969 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -449,6 +449,8 @@ static inline void bio_flush_dcache_pages(struct bio *bi) } #endif +extern void bio_copy_data_iter(struct bio *dst, struct bvec_iter dst_iter, + struct bio *src, struct bvec_iter src_iter); extern void bio_copy_data(struct bio *dst, struct bio *src); extern int bio_alloc_pages(struct bio *bio, gfp_t gfp); extern void bio_free_pages(struct bio *bio); |