[PATCH V6 14/30] block: loop: pass multipage chunks to iov_iter

Ming Lei
2018-06-09T12:33:33Z

iov_iter is implemented with bvec itererator, so it is safe to pass
multipage chunks to it, and this way is much more efficient than
passing one page in each bvec.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
drivers/block/loop.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 4838b0dbaad3..c25963a9df00 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -521,7 +521,7 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
struct bio_vec tmp;

__rq_for_each_bio(bio, rq)
- segments += bio_segments(bio);
+ segments += bio_chunks(bio);
bvec = kmalloc(sizeof(struct bio_vec) * segments, GFP_NOIO);
if (!bvec)
return -EIO;
@@ -533,7 +533,7 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
* copy bio->bi_iov_vec to new bvec. The rq_for_each_segment
* API will take care of all details for us.
*/
- rq_for_each_segment(tmp, rq, iter) {
+ rq_for_each_chunk(tmp, rq, iter) {
*bvec = tmp;
bvec++;
}
@@ -547,7 +547,7 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
*/
offset = bio->bi_iter.bi_bvec_done;
bvec = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter);
- segments = bio_segments(bio);
+ segments = bio_chunks(bio);
}
atomic_set(&cmd->ref, 2);

--
2.9.5