@@ -1401,6 +1401,27 @@ void __bio_advance(struct bio *bio, unsigned bytes)
14011401}
14021402EXPORT_SYMBOL (__bio_advance );
14031403
1404+ void bio_copy_data_iter (struct bio * dst , struct bvec_iter * dst_iter ,
1405+ struct bio * src , struct bvec_iter * src_iter )
1406+ {
1407+ while (src_iter -> bi_size && dst_iter -> bi_size ) {
1408+ struct bio_vec src_bv = bio_iter_iovec (src , * src_iter );
1409+ struct bio_vec dst_bv = bio_iter_iovec (dst , * dst_iter );
1410+ unsigned int bytes = min (src_bv .bv_len , dst_bv .bv_len );
1411+ void * src_buf = bvec_kmap_local (& src_bv );
1412+ void * dst_buf = bvec_kmap_local (& dst_bv );
1413+
1414+ memcpy (dst_buf , src_buf , bytes );
1415+
1416+ kunmap_local (dst_buf );
1417+ kunmap_local (src_buf );
1418+
1419+ bio_advance_iter_single (src , src_iter , bytes );
1420+ bio_advance_iter_single (dst , dst_iter , bytes );
1421+ }
1422+ }
1423+ EXPORT_SYMBOL (bio_copy_data_iter );
1424+
14041425/**
14051426 * bio_copy_data - copy contents of data buffers from one bio to another
14061427 * @src: source bio
@@ -1414,21 +1435,7 @@ void bio_copy_data(struct bio *dst, struct bio *src)
14141435 struct bvec_iter src_iter = src -> bi_iter ;
14151436 struct bvec_iter dst_iter = dst -> bi_iter ;
14161437
1417- while (src_iter .bi_size && dst_iter .bi_size ) {
1418- struct bio_vec src_bv = bio_iter_iovec (src , src_iter );
1419- struct bio_vec dst_bv = bio_iter_iovec (dst , dst_iter );
1420- unsigned int bytes = min (src_bv .bv_len , dst_bv .bv_len );
1421- void * src_buf = bvec_kmap_local (& src_bv );
1422- void * dst_buf = bvec_kmap_local (& dst_bv );
1423-
1424- memcpy (dst_buf , src_buf , bytes );
1425-
1426- kunmap_local (dst_buf );
1427- kunmap_local (src_buf );
1428-
1429- bio_advance_iter_single (src , & src_iter , bytes );
1430- bio_advance_iter_single (dst , & dst_iter , bytes );
1431- }
1438+ bio_copy_data_iter (dst , & dst_iter , src , & src_iter );
14321439}
14331440EXPORT_SYMBOL (bio_copy_data );
14341441
0 commit comments