From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk0-f200.google.com (mail-qk0-f200.google.com [209.85.220.200]) by kanga.kvack.org (Postfix) with ESMTP id DB1566B027C for ; Sat, 9 Jun 2018 08:33:28 -0400 (EDT) Received: by mail-qk0-f200.google.com with SMTP id s133-v6so15113687qke.21 for ; Sat, 09 Jun 2018 05:33:28 -0700 (PDT) Received: from mx1.redhat.com (mx3-rdu2.redhat.com. [66.187.233.73]) by mx.google.com with ESMTPS id p47-v6si3893493qtp.296.2018.06.09.05.33.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Jun 2018 05:33:28 -0700 (PDT) From: Ming Lei Subject: [PATCH V6 14/30] block: loop: pass multipage chunks to iov_iter Date: Sat, 9 Jun 2018 20:29:58 +0800 Message-Id: <20180609123014.8861-15-ming.lei@redhat.com> In-Reply-To: <20180609123014.8861-1-ming.lei@redhat.com> References: <20180609123014.8861-1-ming.lei@redhat.com> Sender: owner-linux-mm@kvack.org List-ID: To: Jens Axboe , Christoph Hellwig , Alexander Viro , Kent Overstreet Cc: David Sterba , Huang Ying , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , "Darrick J . Wong" , Coly Li , Filipe Manana , Randy Dunlap , Ming Lei 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 --- 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