From patchwork Tue Dec 27 15:56:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9489409 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 8A8D762AB0 for ; Tue, 27 Dec 2016 16:01:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CC5B223B2 for ; Tue, 27 Dec 2016 16:01:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7170F25F31; Tue, 27 Dec 2016 16:01:42 +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 203F5200E7 for ; Tue, 27 Dec 2016 16:01:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755818AbcL0QBf (ORCPT ); Tue, 27 Dec 2016 11:01:35 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:36489 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755682AbcL0QB3 (ORCPT ); Tue, 27 Dec 2016 11:01:29 -0500 Received: by mail-pg0-f68.google.com with SMTP id n5so12796824pgh.3; Tue, 27 Dec 2016 08:00:44 -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=rscJwhEcIChbae7Q4k9NKpYAMsMTlPaWY3x5g0XUHis=; b=M3GrxyvZtmExH3/pdP7xc1M/OVGMkqjMP8wC4AHn0KCzpFVh8+gfFhgfTeennuM+wb i6PDMD6pQ7r4ZGEXcyj01ghQOkhSYsEwRJGROffwA6HOplL3aVJ8rtygSVNcae4jEV3+ FcbZdvhKU4sxxKnp7GisiGlwu2WKYCvphERa0CZYiyZK89OLa9XhkogEaIwi2hMLDlGj dRAuaz6hPqGnH4Ap/lNzpO2ZkfiHernhXx/HYY9pPmgIBkWtNU1q4YOIXB661glBoISx DuakqX2fxu/Yr8hKuebT16a4gv75F0SeOjY975+54qvEEfhnUsNU7zVYvp5oYISI4yXL 7h6g== 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=rscJwhEcIChbae7Q4k9NKpYAMsMTlPaWY3x5g0XUHis=; b=miUPGHVgBCGiX7l6wXf3mZlWtcTMBVWcSnRZBRZM9kwsqItDtl+/zZv7FFpzofvHjY +5rrq0aL1NvAgpXKecmIf2CNK94vuPiJy0RrrgL4LSaDmCI2AVX4KHbaPUY+aT+I+NYZ R/W6gHdk9lo6fOV6BGbnWonM1TGk0JCy9qCeKsK14oO3+S2zk0nAHMsHBo9wuIzKqhbD 76fogf6XL2hZD9m5sO5HzyAuZ0z0xoEcIluKL+9G8oZhlH+heoZb49vGfMc0/zKcWfBY MBoAfzHzXBZYJWV1mEubw3yrHJaj73cZqyYVTNO4HwPJxPCxtvcSfCSjCP6FwS59AZJ4 cbeA== X-Gm-Message-State: AIkVDXIFLaYNDgPMyedokPQ1rWJzeyP003bMc9yFjwLkDtBpUjzMgdeXs77SR2xYH8F4uw== X-Received: by 10.99.124.20 with SMTP id x20mr59163852pgc.142.1482854439210; Tue, 27 Dec 2016 08:00:39 -0800 (PST) Received: from localhost ([45.35.47.137]) by smtp.gmail.com with ESMTPSA id e6sm72118706pgf.4.2016.12.27.08.00.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Dec 2016 08:00:38 -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 19/54] block: bounce: avoid direct access to bvec table Date: Tue, 27 Dec 2016 23:56:08 +0800 Message-Id: <1482854250-13481-20-git-send-email-tom.leiming@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482854250-13481-1-git-send-email-tom.leiming@gmail.com> References: <1482854250-13481-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 We will support multipage bvecs in the future, so change to iterator way for getting bv_page of bvec from original bio. Signed-off-by: Ming Lei --- block/bounce.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/block/bounce.c b/block/bounce.c index 1cb5dd3a5da1..babd3f224ca0 100644 --- a/block/bounce.c +++ b/block/bounce.c @@ -126,21 +126,23 @@ static void copy_to_high_bio_irq(struct bio *to, struct bio *from) static void bounce_end_io(struct bio *bio, mempool_t *pool) { struct bio *bio_orig = bio->bi_private; - struct bio_vec *bvec, *org_vec; + struct bio_vec *bvec, orig_vec; int i; - int start = bio_orig->bi_iter.bi_idx; + struct bvec_iter orig_iter = bio_orig->bi_iter; /* * free up bounce indirect pages used */ bio_for_each_segment_all(bvec, bio, i) { - org_vec = bio_orig->bi_io_vec + i + start; - if (bvec->bv_page == org_vec->bv_page) - continue; + orig_vec = bio_iter_iovec(bio_orig, orig_iter); + if (bvec->bv_page == orig_vec.bv_page) + goto next; dec_zone_page_state(bvec->bv_page, NR_BOUNCE); mempool_free(bvec->bv_page, pool); + next: + bio_advance_iter(bio_orig, &orig_iter, orig_vec.bv_len); } bio_orig->bi_error = bio->bi_error;