From patchwork Wed Jun 27 12:45:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10491439 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2925360325 for ; Wed, 27 Jun 2018 12:49:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1795B28C9A for ; Wed, 27 Jun 2018 12:49:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 09A8828D80; Wed, 27 Jun 2018 12:49:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BFC628C9A for ; Wed, 27 Jun 2018 12:49:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AF8CA6B028C; Wed, 27 Jun 2018 08:49:47 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AA7566B028E; Wed, 27 Jun 2018 08:49:47 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 997CA6B028F; Wed, 27 Jun 2018 08:49:47 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt0-f198.google.com (mail-qt0-f198.google.com [209.85.216.198]) by kanga.kvack.org (Postfix) with ESMTP id 6AB0F6B028C for ; Wed, 27 Jun 2018 08:49:47 -0400 (EDT) Received: by mail-qt0-f198.google.com with SMTP id n10-v6so1786814qtp.11 for ; Wed, 27 Jun 2018 05:49:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=5ZBNt58hf1SD5wVcC/xHS38Iko7a929ZeiycD4fV5mE=; b=CnB1l3q0nihqli1+YkpQOzE2XeGA5FnwLi9GP/CzNyFW+XP0QN0i8XRavDMjcpzBTj D380q6JHRDU0SfSpN/yZVfJRWdhjNWUxdV/o8V64RjZF53EORVISAmgwweRbNhhRZ0Ce FKaRf591Lw6/xMrP8Ilc9mOI6jTDTTzqt9xrSu6kjxkf6KcYoo5fmR4pQALtavJFKJqF laNUEjm9wfnk6OnJXTANBjq79V5oWBLDktqZesnFS97auOnxqxtHhcrp49qcrXTbtD0h DeLeT6+tN6WOPfX6ZNkpfTuuuu+HYxbltk9WUZlfeDCssQl5FDyhql1501GpGe+OavEy c/RQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APt69E0f5SB117YMx9DIp3YoEjjiZotn1Oa7oBfIpswDtmNhxTmf/Icf 0m0e76FzGxcd3NdViRAyPWb3HL1agm3ZkLvzUl7+jCkh/+4lg6KVF7aZcH3hTgWQ2lPISnZyH0K kF18O/7YjehOT2K7vdqV3/mXioFfE7kq0bKFeCyvETVNEfASFV2365y1BvmnRaXXw1g== X-Received: by 2002:a0c:8305:: with SMTP id j5-v6mr5020080qva.53.1530103787234; Wed, 27 Jun 2018 05:49:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcUZsuMSWFsdpv6LI1XRFEVxV4V3uZPAG27LALWUp3Gu2NazO41oMtY2JtfGo8LKSERzoxu X-Received: by 2002:a0c:8305:: with SMTP id j5-v6mr5020053qva.53.1530103786674; Wed, 27 Jun 2018 05:49:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530103786; cv=none; d=google.com; s=arc-20160816; b=ANFYo4uV1q06WkI6nW9X0sv5VHj/gP4hTETZuuTVpBsJd9Ewjnz0fJcvUYHGisxUvC YO/3nqlrBM0alXTroICXf/s5Rr+/03Oo2FKlXj00snEBu6Ra8L0EN5jCidQp9QCYmARO mEBx+q8drK4FGkVJKLjz5jyldZVmSXxmXlfOQZAm8fsJdPzo6kWxOF9lZF2sDubShA69 t/q4vqVIR5R4Q1ln06ZR/h5fXv36SWj5q+DBE7kEqPNJXvtie1hnVr5RLPB3LM3tDoMg YqfoPskS5HABXTmy34n/c5JXvEEMckp1ypy2qFyxxALbh6zBf03LOUqjV6iVrlQPdAYt AmhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=5ZBNt58hf1SD5wVcC/xHS38Iko7a929ZeiycD4fV5mE=; b=mgFJbkNh8q+aN58tX6SH31G31vUa/9rP2f7GXIueDmThAwuJv6c/rCYZkCjmjdqpih jiCBjz5XJ2Bl1eneshsE4R796yPRTvXCyEFE/GMG1sXJ6ngxEB71wr9wTvIgLLJYn1fB 6eaBtnuxaqyQkJk6g4CIEZY5EjUPaeuohlJVi+k4TIiI9KvYfPokrU+sah8//Qg9MIeQ iLjzYRt0uN/ewVdaQmfb8Qj/KkBzuKWo/SyvXBDtGVWAfeY4atHnoHuu1n16n6LMTFmz ABqAx4A092uFZzi+/liADJj02vx34L7bCVP1J19mdG0WOqDFAz4zRl8F/uj/tCT94DgY y/2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx3-rdu2.redhat.com. [66.187.233.73]) by mx.google.com with ESMTPS id x6-v6si1938217qvl.93.2018.06.27.05.49.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 05:49:46 -0700 (PDT) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 as permitted sender) client-ip=66.187.233.73; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 530604021CC1; Wed, 27 Jun 2018 12:49:46 +0000 (UTC) Received: from localhost (ovpn-12-44.pek2.redhat.com [10.72.12.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC2B72156888; Wed, 27 Jun 2018 12:49:37 +0000 (UTC) From: Ming Lei To: Jens Axboe , Christoph Hellwig , Kent Overstreet Cc: David Sterba , Huang Ying , Mike Snitzer , 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 Subject: [PATCH V7 19/24] block: loop: pass multipage bvec to iov_iter Date: Wed, 27 Jun 2018 20:45:43 +0800 Message-Id: <20180627124548.3456-20-ming.lei@redhat.com> In-Reply-To: <20180627124548.3456-1-ming.lei@redhat.com> References: <20180627124548.3456-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 27 Jun 2018 12:49:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Wed, 27 Jun 2018 12:49:46 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'ming.lei@redhat.com' RCPT:'' X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP iov_iter is implemented with bvec itererator, so it is safe to pass multipage bvec 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 | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index d6b6f434fd4b..a350b323e891 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -515,16 +515,16 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, struct bio *bio = rq->bio; struct file *file = lo->lo_backing_file; unsigned int offset; - int segments = 0; + int nr_bvec = 0; int ret; if (rq->bio != rq->biotail) { - struct req_iterator iter; + struct bvec_iter iter; struct bio_vec tmp; __rq_for_each_bio(bio, rq) - segments += bio_segments(bio); - bvec = kmalloc_array(segments, sizeof(struct bio_vec), + nr_bvec += bio_bvecs(bio); + bvec = kmalloc_array(nr_bvec, sizeof(struct bio_vec), GFP_NOIO); if (!bvec) return -EIO; @@ -533,13 +533,14 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, /* * The bios of the request may be started from the middle of * the 'bvec' because of bio splitting, so we can't directly - * copy bio->bi_iov_vec to new bvec. The rq_for_each_segment + * copy bio->bi_iov_vec to new bvec. The bio_for_each_bvec * API will take care of all details for us. */ - rq_for_each_segment(tmp, rq, iter) { - *bvec = tmp; - bvec++; - } + __rq_for_each_bio(bio, rq) + bio_for_each_bvec(tmp, bio, iter) { + *bvec = tmp; + bvec++; + } bvec = cmd->bvec; offset = 0; } else { @@ -550,12 +551,11 @@ 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); + nr_bvec = bio_bvecs(bio); } atomic_set(&cmd->ref, 2); - iov_iter_bvec(&iter, ITER_BVEC | rw, bvec, - segments, blk_rq_bytes(rq)); + iov_iter_bvec(&iter, ITER_BVEC | rw, bvec, nr_bvec, blk_rq_bytes(rq)); iter.iov_offset = offset; cmd->iocb.ki_pos = pos;