From patchwork Fri May 25 03:46:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10426075 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 01933602D8 for ; Fri, 25 May 2018 03:49:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E55E42959E for ; Fri, 25 May 2018 03:49:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D9C77295A4; Fri, 25 May 2018 03:49:34 +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=ham 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 6BC4D2959E for ; Fri, 25 May 2018 03:49:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D0976B02A6; Thu, 24 May 2018 23:49:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 657D66B02A8; Thu, 24 May 2018 23:49:33 -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 4F8FE6B02A9; Thu, 24 May 2018 23:49:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f198.google.com (mail-qk0-f198.google.com [209.85.220.198]) by kanga.kvack.org (Postfix) with ESMTP id 1BB876B02A6 for ; Thu, 24 May 2018 23:49:33 -0400 (EDT) Received: by mail-qk0-f198.google.com with SMTP id z1-v6so2916963qki.10 for ; Thu, 24 May 2018 20:49:33 -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=iQEhvj9cKtXOp1ca0PlPGgwGBqGfNYfipmXuWOHqDrM=; b=gih8o9KRZBOwejgQr9JG1jvgXn2vWv17T1dFnNB9F3XnTD1yAokLJoE8edjKC9n3Lo 1sa/kRnIzL9/K8Pene9w6AIxdxoE2dxj7tj5so69Eb4W+ZMOvJ2+BUTO0SWJC7CQ6ygC P6HVW5GDTceOXD0aOX3WwxG6Gx7MxLntVndzTByvj6VtQUj/0GT4pAa4k9z875OJVS/D V3QvjGBYHwm5yCkCnP92AAYw6RCVij7o8KyplEybzReCpBz68hztum27Fhnsv1eDlDtD 1UQlxfnaISYb2xKZZj9OcTbL0OIYZHqIHxAqYirOFTgQzwYSRtq859jaFaT7+62ks7JN NS/A== 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: ALKqPweELXu0/pg6yvAsu4k9yRkbzKp7/uHDtvaupP4ZRNDm4pwddTC+ bPBUZBtdr+4K56XR/RicnHxm/BUcf5boAbwEwMixlrmmEkkGv/rZE4VQrTcTsnYUPLTARfMvPe4 XnbTvZ7QZc83lH0d4M9Lxn3tTAhALe1RpHKbBmTKnz0UJb6vGotv/vYMlMCvlPhMJTw== X-Received: by 2002:a0c:d108:: with SMTP id a8-v6mr592167qvh.159.1527220172926; Thu, 24 May 2018 20:49:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJGEvC6FoPco5JM8DgtsZjzkwR1Ie3sfMENjqWxADqERCE7Uxh+m+3uEx02T9t9IXkktCYB X-Received: by 2002:a0c:d108:: with SMTP id a8-v6mr592155qvh.159.1527220172449; Thu, 24 May 2018 20:49:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527220172; cv=none; d=google.com; s=arc-20160816; b=ECbq2ml8GGxkoSPmXfdAvPJXa2jT/Hyu+k9l7iXLTSsjwYiAfRZvZWwoc+MiygP5nM ga8eY/yF+7louVxwxYHipF+O/oNdMtsLTD84Ekn3Ng1NKEf78iDBdu1mcei61Iu75CIM 5Zn/cp4O5oP+nVeTe3kWYORPF1EqgkZkrZjmC2cvvAOUo5brkev4uW8Hc49mX4itYylY leTq2+E1jt8j+L3fAi3Y13FmUHaqWDXWxhlVJi11ruF9g2hWsP5CEqUoI9kgCCuIUbBq mg4P4/hGl3oSrHsuE09pHDTtXZ6h5niWOQxsAN8K+Zw/TDJrSttTRcGc0gTVQV/MqoCj WEpg== 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=iQEhvj9cKtXOp1ca0PlPGgwGBqGfNYfipmXuWOHqDrM=; b=tqecLr0vIIENreWZtcIDNSRHk5DhNkM7jdDtHVxSNapO8c+bPqeeWxTqBUAVw9728j Vf4e4ToLmMFHeE+JXAzbpNS9EU1oAoz3cL+ElILcWxobR14YKL0TAZCEJnHYw+uAIYKb wb2M6RaELo19V7eS5KgUD1h3gsiRRoWWnAAnesJ5Qb9/Evu49MXLcZ+sRsUiRw4cng0l mKpdKfTuwsqVbXdEn/KdhLKApPSk5bDOQ4q85vzhBSNrVOOm1fghs8W76iy2SxPZ5svA yNOyW+uMeKDxdvlo/jRj8/KIBmg/SCWATRX7J0vp+zrEgQivTtBrCZod8rN5NlWTw6j8 XVqg== 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 k46-v6si7659619qta.9.2018.05.24.20.49.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 20:49:32 -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-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 20619401EF03; Fri, 25 May 2018 03:49:32 +0000 (UTC) Received: from localhost (ovpn-12-30.pek2.redhat.com [10.72.12.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5234202345C; Fri, 25 May 2018 03:49:24 +0000 (UTC) From: Ming Lei 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 , Ming Lei Subject: [RESEND PATCH V5 14/33] block: loop: pass segments to iov_iter Date: Fri, 25 May 2018 11:46:02 +0800 Message-Id: <20180525034621.31147-15-ming.lei@redhat.com> In-Reply-To: <20180525034621.31147-1-ming.lei@redhat.com> References: <20180525034621.31147-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 25 May 2018 03:49:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 25 May 2018 03:49:32 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.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 segment 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 8d7d5581ca9c..e709c0380566 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_pages(bio); + segments += bio_segments(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_page * API will take care of all details for us. */ - rq_for_each_page(tmp, rq, iter) { + rq_for_each_segment(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_pages(bio); + segments = bio_segments(bio); } atomic_set(&cmd->ref, 2);