From patchwork Tue Dec 27 16:04:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9489621 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 C53F8601D2 for ; Tue, 27 Dec 2016 16:14:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7170201BC for ; Tue, 27 Dec 2016 16:14:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABC6D25D99; Tue, 27 Dec 2016 16:14:19 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 469F6201BC for ; Tue, 27 Dec 2016 16:14:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932679AbcL0QOS (ORCPT ); Tue, 27 Dec 2016 11:14:18 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33678 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752721AbcL0QFl (ORCPT ); Tue, 27 Dec 2016 11:05:41 -0500 Received: by mail-pf0-f195.google.com with SMTP id 127so8380077pfg.0; Tue, 27 Dec 2016 08:05:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GcxirtDcxXM3hjzf+3+YV4vO4jL6pdXXfskj330KSp4=; b=CO0oSPtjfF9aW0OAM8ctiy47DRQbQCzWJDb22TAYI9UvWMG3C5FsdXD4Mg0+NIJl2g +q4YoKOns6bDlmXvHSAqjFFV+uD3E6avmW5A/dGvmMYLn6dnFDmu79UwVZk/Cg2E6RC5 G/tYM1b3odkrhdeo5+AQVfyK4M57hCEVVr3d3wnfkXruHKM3Xxw1RFI92yqUQ0osh0zl uFa0AoC6/afH03HIlwT2Tb3PWX9LgYwl9Hu0JiIRIkqD2XvhQLh394Xs/WSoMcJRwlVo CJsVGSV1qUnaqbizfVuVZXWGWIU6oymyDQSm5pq1GJl1eVDzKseqNhnOo/+F1o4LTa8S MDnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GcxirtDcxXM3hjzf+3+YV4vO4jL6pdXXfskj330KSp4=; b=CWk8iiV1EA/HUYgbf+gzKzpw8v+60IQHSfeX3H0RQizmu1yonBNIUZY3ZGgymJznzJ T+IdVGBIWfeaIpI+1SMKnWDTNS7Uk+9Qn3to7j75A+xX2KBQu5kUTtgyl/gp/mh8cLj+ r6R/Kfqfa6ql2zQcNFwQ5grQWTaTeP/XXkVKvLMT3BcVnOga/cS0siz7XTdWQEf5Gkqf RXoRDPjGKs4BCB/aSBhPzhfbyHRyPvuO+AJhS+84By1+ApF5DdqYy89vUAeYdF4Xl8t4 tHrhw3m4swMwjrOlax9hC1okEkb5QdxD6VIvj5SOpcrHuSQGLqBIvkoVPw9j2UsGS+Cf N8Sw== X-Gm-Message-State: AIkVDXLNiUM7nNQZ+ivQIgzAIHzCSPMKzoTCz8lUivALQKe1m4d9ugc8ue+N5bVgfqQh7A== X-Received: by 10.99.106.200 with SMTP id f191mr59475825pgc.143.1482854740487; Tue, 27 Dec 2016 08:05:40 -0800 (PST) Received: from localhost ([45.35.47.137]) by smtp.gmail.com with ESMTPSA id 65sm90709149pfl.21.2016.12.27.08.05.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Dec 2016 08:05:39 -0800 (PST) From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, Christoph Hellwig , Ming Lei , Jens Axboe Subject: [PATCH v1 34/54] block: convert to singe/multi page version of bio_for_each_segment_all() Date: Wed, 28 Dec 2016 00:04:43 +0800 Message-Id: <1482854706-14128-3-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482854706-14128-1-git-send-email-tom.leiming@gmail.com> References: <1482854706-14128-1-git-send-email-tom.leiming@gmail.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Ming Lei --- block/bio.c | 17 +++++++++++------ block/blk-zoned.c | 5 +++-- block/bounce.c | 6 ++++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/block/bio.c b/block/bio.c index e65de53acb9f..9acc3db0f2df 100644 --- a/block/bio.c +++ b/block/bio.c @@ -992,7 +992,7 @@ int bio_alloc_pages(struct bio *bio, gfp_t gfp_mask) int i; struct bio_vec *bv; - bio_for_each_segment_all(bv, bio, i) { + bio_for_each_segment_all_mp(bv, bio, i) { bv->bv_page = alloc_page(gfp_mask); if (!bv->bv_page) { while (--bv >= bio->bi_io_vec) @@ -1093,8 +1093,9 @@ static int bio_copy_from_iter(struct bio *bio, struct iov_iter iter) { int i; struct bio_vec *bvec; + struct bvec_iter_all bia; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all_sp(bvec, bio, i, bia) { ssize_t ret; ret = copy_page_from_iter(bvec->bv_page, @@ -1124,8 +1125,9 @@ static int bio_copy_to_iter(struct bio *bio, struct iov_iter iter) { int i; struct bio_vec *bvec; + struct bvec_iter_all bia; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all_sp(bvec, bio, i, bia) { ssize_t ret; ret = copy_page_to_iter(bvec->bv_page, @@ -1147,8 +1149,9 @@ void bio_free_pages(struct bio *bio) { struct bio_vec *bvec; int i; + struct bvec_iter_all bia; - bio_for_each_segment_all(bvec, bio, i) + bio_for_each_segment_all_sp(bvec, bio, i, bia) __free_page(bvec->bv_page); } EXPORT_SYMBOL(bio_free_pages); @@ -1448,11 +1451,12 @@ static void __bio_unmap_user(struct bio *bio) { struct bio_vec *bvec; int i; + struct bvec_iter_all bia; /* * make sure we dirty pages we wrote to */ - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all_sp(bvec, bio, i, bia) { if (bio_data_dir(bio) == READ) set_page_dirty_lock(bvec->bv_page); @@ -1544,8 +1548,9 @@ static void bio_copy_kern_endio_read(struct bio *bio) char *p = bio->bi_private; struct bio_vec *bvec; int i; + struct bvec_iter_all bia; - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all_sp(bvec, bio, i, bia) { memcpy(p, page_address(bvec->bv_page), bvec->bv_len); p += bvec->bv_len; } diff --git a/block/blk-zoned.c b/block/blk-zoned.c index 472211fa183a..68cf3054296c 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c @@ -81,6 +81,7 @@ int blkdev_report_zones(struct block_device *bdev, unsigned int ofst; void *addr; int ret; + struct bvec_iter_all bia; if (!q) return -ENXIO; @@ -148,7 +149,7 @@ int blkdev_report_zones(struct block_device *bdev, n = 0; nz = 0; nr_rep = 0; - bio_for_each_segment_all(bv, bio, i) { + bio_for_each_segment_all_sp(bv, bio, i, bia) { if (!bv->bv_page) break; @@ -181,7 +182,7 @@ int blkdev_report_zones(struct block_device *bdev, *nr_zones = nz; out: - bio_for_each_segment_all(bv, bio, i) + bio_for_each_segment_all_sp(bv, bio, i, bia) __free_page(bv->bv_page); bio_put(bio); diff --git a/block/bounce.c b/block/bounce.c index 08841ed4cdae..871bb12be0c4 100644 --- a/block/bounce.c +++ b/block/bounce.c @@ -135,11 +135,12 @@ static void bounce_end_io(struct bio *bio, mempool_t *pool) struct bio_vec *bvec, orig_vec; int i; struct bvec_iter orig_iter = bio_orig->bi_iter; + struct bvec_iter_all bia; /* * free up bounce indirect pages used */ - bio_for_each_segment_all(bvec, bio, i) { + bio_for_each_segment_all_sp(bvec, bio, i, bia) { orig_vec = bio_iter_iovec(bio_orig, orig_iter); if (bvec->bv_page == orig_vec.bv_page) @@ -209,13 +210,14 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig, int rw = bio_data_dir(*bio_orig); struct bio_vec *to; unsigned i; + struct bvec_iter_all bia; if (!need_bounce(q, *bio_orig)) return; bio = bio_clone_bioset_sp(*bio_orig, GFP_NOIO, fs_bio_set); - bio_for_each_segment_all(to, bio, i) { + bio_for_each_segment_all_sp(to, bio, i, bia) { struct page *page = to->bv_page; if (page_to_pfn(page) <= queue_bounce_pfn(q))