From patchwork Sat Oct 29 08:08:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9403335 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 90D81606DC for ; Sat, 29 Oct 2016 08:23:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 789E22A13D for ; Sat, 29 Oct 2016 08:23:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6DA352A5F2; Sat, 29 Oct 2016 08:23:53 +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 194072A5ED for ; Sat, 29 Oct 2016 08:23:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1034356AbcJ2IPE (ORCPT ); Sat, 29 Oct 2016 04:15:04 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:33805 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1034180AbcJ2IOs (ORCPT ); Sat, 29 Oct 2016 04:14:48 -0400 Received: by mail-pf0-f196.google.com with SMTP id u84so3380515pfj.1; Sat, 29 Oct 2016 01:14:48 -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=rscJwhEcIChbae7Q4k9NKpYAMsMTlPaWY3x5g0XUHis=; b=lhbYA69eMTl+ebXpKG6TGwziTQ6GN6wcUkXJi2h9ON5LepaqOjV/D/waUW88yRbTcs 0l6uqn0MsQoNCJa9DCU+uz+xINlBokG7c1cl0BQnuE7m1mZygIX0WpHM8UFKHioq9CON Pf/jDEs+E9PXmfRGdkWNrVRfkZ2md9QliTrNHl+z9mafkvb07JW1XVb5/rvnjUzETu6t +86euDYdixWkt5DZ6k/zGrQ6owoK92ccg/3tKRm2tgEEy4orAHw0yKYak3/HfceiwNjS H6t9Khg6PG64XMaqzRBwvmnrQlNhJTnmrMXHr38Bq0pJRNtn/kkQ9CXB5CYBFvkPaLYj I8fw== 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=rscJwhEcIChbae7Q4k9NKpYAMsMTlPaWY3x5g0XUHis=; b=OoKHa9eD/HHlq0PQ8oMBeRvbxOeMiEfqnr+oo2LT/0JSEQYpo1KQbuci4BV1nRUjCc ZV4d8bYCHn9vG0TGqt1WIsp4cQR8sWKl6R9pK1aFHOtPKf7D9SFn4D5k7FRvsdqoGl/3 RKNIyaY8abwoznvaYLocxh/gRJRJnNWddHMda9AT8XPsZvCFYK4JC8RWDg9ew3suwtT7 Y3pTk8iU5oE7l1NNrK5vZBwEe6uvpJ7QOZkYls4Buy4mYM2H0w24G+TiyaSK1vc6ARUT W25TOSbPkBE5da1JkOATQA3geRX97SlnZOOsq8zyConIWxIDFnli0lF2xezLd8Zzm296 ELzQ== X-Gm-Message-State: ABUngvcSQ136dl8eO5tpwKHFpoQMDXt9jIeC+oxpD+vc0et7gKHwKHM1yJh5ULFgv3VUTA== X-Received: by 10.98.70.29 with SMTP id t29mr32100647pfa.185.1477728887853; Sat, 29 Oct 2016 01:14:47 -0700 (PDT) Received: from localhost ([45.34.23.101]) by smtp.gmail.com with ESMTPSA id d89sm23539045pfe.32.2016.10.29.01.14.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 29 Oct 2016 01:14:47 -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 36/60] block: bounce: avoid direct access to bvec from bio->bi_io_vec Date: Sat, 29 Oct 2016 16:08:35 +0800 Message-Id: <1477728600-12938-37-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 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;