From patchwork Sat Oct 29 08:08:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9403297 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 A149D60587 for ; Sat, 29 Oct 2016 08:20:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E1A629D0F for ; Sat, 29 Oct 2016 08:20:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82ACF2A279; Sat, 29 Oct 2016 08:20:56 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 1CD9A29D0F for ; Sat, 29 Oct 2016 08:20:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966298AbcJ2IUy (ORCPT ); Sat, 29 Oct 2016 04:20:54 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:35388 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966211AbcJ2IPg (ORCPT ); Sat, 29 Oct 2016 04:15:36 -0400 Received: by mail-pf0-f194.google.com with SMTP id s8so3384189pfj.2; Sat, 29 Oct 2016 01:15:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=YMen4DTGFrZ5W9wteaVkosEXnyyIgKnTdp6AIiZ8kHY=; b=v+w1zZo4xV7+tmC128BRRc3L3OZThmHeZ2yfsSdymxquhpFEj6ij+rnJEkcmHmGXk2 7zaweEJLMGbVUsPR9k+2SpE84QY+pLsSKoUlEpAWBe5DdVV7ZBOx+UKnC9mtxnW7mdlH 9rJFDld76MlbJr1DEh3zBy8AN7up4XlQdcbAfHkK32gHleovTwMxC17Rr7Hems2vqzY5 jhG7Hv0a23mNtMWzHfjHZVsz1W+UVvXL0Ag4ogcu59Arg47cltMQDoeVOacMyql7FeA8 DVNx9cUFIH4PbK2biJJ/n3C4s0t+s1ZXpMQoGcOv7/2IcAzugq76BhvB9tduoef4m3Z2 BZbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YMen4DTGFrZ5W9wteaVkosEXnyyIgKnTdp6AIiZ8kHY=; b=bcuhURechSwNSYqrPnLEs1Ef76ojPqCz9VWS7v2+GEQxpw+b2rKlyLkYBEoWmyyEkX uV5qmrKZOfC9EA9H+X5mJBFjfp60vJqiCAeN7ewNkXpH+BBWKg28E30hZSxRaZfUMHMo uCU2JywUZI/xkbt8/ejF8S2z+M8UZOJicp2uYM/ikP36OO9STDn/IfkarRMriEjZEfXw AMb4hYzpg1Qf4Hhnph+kvq9kYSOWpR9EvcbLHRtPiq0vSCBV5p9pInZ4Qtkg3TPG/OM8 WSyllEQ6O2xWSaI22utpcI1gTIxTPftcMGuiXzV+58JSWrUp9wBXd+4A80nDUOGzF4wO HAXw== X-Gm-Message-State: ABUngvc4yf0nmbSTkSZ+AQX0aELTu21R4wnOqzxdtWyA+45AuzuMPnLOcEZiUQl/ail8Rw== X-Received: by 10.98.36.219 with SMTP id k88mr31670384pfk.88.1477728935235; Sat, 29 Oct 2016 01:15:35 -0700 (PDT) Received: from localhost ([45.34.23.101]) by smtp.gmail.com with ESMTPSA id j192sm23517851pfc.60.2016.10.29.01.15.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 29 Oct 2016 01:15:34 -0700 (PDT) From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig , "Kirill A . Shutemov" , Ming Lei , Jens Axboe Subject: [PATCH 47/60] block: convert to bio_for_each_segment_all_rd() Date: Sat, 29 Oct 2016 16:08:46 +0800 Message-Id: <1477728600-12938-48-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477728600-12938-1-git-send-email-tom.leiming@gmail.com> References: <1477728600-12938-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/bounce.c | 6 ++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/block/bio.c b/block/bio.c index 8e5af6e8bba3..c9cf0a81cca3 100644 --- a/block/bio.c +++ b/block/bio.c @@ -934,7 +934,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_wt(bv, bio, i) { bv->bv_page = alloc_page(gfp_mask); if (!bv->bv_page) { while (--bv >= bio->bi_io_vec) @@ -1035,8 +1035,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_rd(bvec, bio, i, bia) { ssize_t ret; ret = copy_page_from_iter(bvec->bv_page, @@ -1066,8 +1067,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_rd(bvec, bio, i, bia) { ssize_t ret; ret = copy_page_to_iter(bvec->bv_page, @@ -1089,8 +1091,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_rd(bvec, bio, i, bia) __free_page(bvec->bv_page); } EXPORT_SYMBOL(bio_free_pages); @@ -1390,11 +1393,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_rd(bvec, bio, i, bia) { if (bio_data_dir(bio) == READ) set_page_dirty_lock(bvec->bv_page); @@ -1486,8 +1490,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_rd(bvec, bio, i, bia) { memcpy(p, page_address(bvec->bv_page), bvec->bv_len); p += bvec->bv_len; } diff --git a/block/bounce.c b/block/bounce.c index da240d1de809..5459127188c1 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_rd(bvec, bio, i, bia) { orig_vec = bio_iter_iovec(bio_orig, orig_iter); if (bvec->bv_page == orig_vec.bv_page) @@ -214,13 +215,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_rd(to, bio, i, bia) { struct page *page = to->bv_page; if (page_to_pfn(page) <= queue_bounce_pfn(q))