From patchwork Thu Nov 15 08:52:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10683799 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ECE8E14D6 for ; Thu, 15 Nov 2018 08:56:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DAC32299C2 for ; Thu, 15 Nov 2018 08:56:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD7E92B334; Thu, 15 Nov 2018 08:56:01 +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 4BAC7299C2 for ; Thu, 15 Nov 2018 08:56:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D0736B027F; Thu, 15 Nov 2018 03:56:00 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5A5FB6B0280; Thu, 15 Nov 2018 03:56:00 -0500 (EST) 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 46EF96B0281; Thu, 15 Nov 2018 03:56:00 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by kanga.kvack.org (Postfix) with ESMTP id 1EDB76B027F for ; Thu, 15 Nov 2018 03:56:00 -0500 (EST) Received: by mail-qk1-f199.google.com with SMTP id h68so43884259qke.3 for ; Thu, 15 Nov 2018 00:56:00 -0800 (PST) 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=E2rITT6VB8lacRXi3Hmi4VFiydk50DyJ1y8Nm3m92Ew=; b=qV8YhNfuYKFAmpW8rs0FjRlwViKLMc8wZl4H6Dw3J2j8AXvFUq8IE+zHotqatCWXTY 59VYP9sE7AcFdvAa/0srEziDvekbVDGLT8thN6CMrti+45K+uOZqwN7FBfDPhr0iT5/Y Sap8bKTb1+//C0XWfJrL6F49S69yiao+16iskX6LFCuUpWh3g5QALWglATV7Ha5O8lK3 xqmaTpgyYFpiRkWaM4lZwaYg4cG6MOSUH8Cf9fHjLLxn7VRajoK5VuTfgexscSVnlUHq HexVgYGlJKN5dDj804mKjX98ujzK5j03islTAxtJpIdBIB+gCqxbpi33Nyj3HCpxSLu7 snMQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 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: AGRZ1gJKT7oILrB45hESWQO9EWrENA0bDSiExvs2LIzTjlaR3WU/Jh6w z75TjZdzQ9qTSq+P+RD4pcZ2K9Uv95XcTYsDnrXiz6tlxAhybZD7EcPT7SFz0wMgT2JamkOpaiM l1kDK0HflAGVTvMdJLHsb/nGYCmOzMCBKwPsD3iZh+aECVr4HGKyz1znHLbf7srBCCw== X-Received: by 2002:a0c:f4c2:: with SMTP id o2mr5233939qvm.236.1542272159892; Thu, 15 Nov 2018 00:55:59 -0800 (PST) X-Google-Smtp-Source: AJdET5fz+Ap3oA7vQLWvGE6G0KHVJit8J0Day4SHxOZKa6oRB2ZBiLHnalTVeSD7KEWPv3/wq23u X-Received: by 2002:a0c:f4c2:: with SMTP id o2mr5233916qvm.236.1542272159398; Thu, 15 Nov 2018 00:55:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272159; cv=none; d=google.com; s=arc-20160816; b=nuBpZdZkQsXARp35vMkHSkRK/2smBAccs/c7XfKn8iinnwuN4ICxckkQA3I/0svysX Wzu7zX3NeJIp7FEBOrA4b7x0qe31SKlYJkuLScQFExINKo71XRCec8EkQmYu0x7FW3B5 9W6+R3esgZPwyDWpc4SIEsqyIqgSqIqJFGZMqeJyQ5P4WTCRbBi0N808AmXhcSMiaLW2 PnMC5+ME2IjpXjFCS3zmx9x4oHmU5PlBn0/+MpCCaDG9HDqQUSeNOOejh8YuWlO1qEF0 CH4CpnfKZV4nercT7HMN2zpqNbPY1exUMlfu0V7gsN+0IXu9w+ezLSs7aZqK4Wr/Oile Mmow== 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; bh=E2rITT6VB8lacRXi3Hmi4VFiydk50DyJ1y8Nm3m92Ew=; b=0fz0kDtLblQt7t6KvpAgmUFeu63EXdvjXGqMcW6WqxOQqGXl7sdisLCcRlkn+5egM6 IcDYltGDq8bIQClnIgOVgqtvxfc7zm4WdNVGGn0+vGMaztpOvyBCGcuDFcXzMkD2OxDo vN30Y0h9mQrCW2nUuxzahnFctjGZMh9rrDZQDeSwwVO4JpG/H+TMFJxUsIgdYdps5Fqj McTsvt7s6Y+0yNpTRkF+Q1cDWl13aUk2HIUBRZYBs2z3eRdZRnsViKB1UN33RoaYXGqe urwhTk7jqU2TIZbR81b3tdoY17k+2MscBAw9aG4fcnsZ0suM/X1TjoCCZo4VJhYil8g5 HKNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 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 (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id 42si7087020qvd.29.2018.11.15.00.55.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:55:59 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 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.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0C7F23099F9E; Thu, 15 Nov 2018 08:55:58 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC3145D9D1; Thu, 15 Nov 2018 08:55:48 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 10/19] block: loop: pass multi-page bvec to iov_iter Date: Thu, 15 Nov 2018 16:52:57 +0800 Message-Id: <20181115085306.9910-11-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 15 Nov 2018 08:55:58 +0000 (UTC) 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. Cc: Dave Chinner Cc: Kent Overstreet Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Cc: Darrick J. Wong Cc: linux-xfs@vger.kernel.org Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei Reviewed-by: Omar Sandoval --- drivers/block/loop.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index bf6bc35aaf88..a3fd418ec637 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,11 +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, rw, bvec, segments, blk_rq_bytes(rq)); + iov_iter_bvec(&iter, rw, bvec, nr_bvec, blk_rq_bytes(rq)); iter.iov_offset = offset; cmd->iocb.ki_pos = pos;