From patchwork Sat Oct 29 08:08:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9403347 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 AC01D60587 for ; Sat, 29 Oct 2016 08:24:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9865A2A13D for ; Sat, 29 Oct 2016 08:24:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D1282A60D; Sat, 29 Oct 2016 08:24:31 +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 304C62A13D for ; Sat, 29 Oct 2016 08:24:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1034289AbcJ2IPA (ORCPT ); Sat, 29 Oct 2016 04:15:00 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:36774 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754305AbcJ2IO5 (ORCPT ); Sat, 29 Oct 2016 04:14:57 -0400 Received: by mail-pf0-f194.google.com with SMTP id n85so3388846pfi.3; Sat, 29 Oct 2016 01:14:57 -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=1/RBK0aqT2YNrE5sBAlyvdX8hjo0Fi+Yv+3ax4sqcIo=; b=UslzTwir9EiW3y45iIkF/2lDxC838pj6gJyJwvydgfy6pYzAmm7Y87yA4JTbaGllkF MUum30uWyEF7sUADVvlgxuKxxDTBx/SGOu4DcX0YkJ6Jke/BvJzGEVdIeJ/rtQ6UayZy TPBsyxSfuGVpDdAbQm8BEYOfFABPScZBNQdfNYcDWqo7lD6R/KvbzrmuOAs/eAtVUzDl 4JpOLKBA1lpyd2GDSL0YRTnYbnX3ijEr0uGEy8/cc/E0hrz76pQMzEAWdCmgjvO8hodi PeGmqkK8iFNw/PlSUf/ktmFVeraukQFEFeQi60+3vL6it2+1k2Bwn+dK8OwigDt1jxdm TnwA== 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=1/RBK0aqT2YNrE5sBAlyvdX8hjo0Fi+Yv+3ax4sqcIo=; b=iQwgrdsuaAiHRJtTx+uJoLci4GgqSODr+xevq2pc1ovNLJLSFBWgrTUT6teUo7SV0/ 3DNDtZR+lPvvbbPeTbANk/wYQK7fMj4lF2LnReISDw23rV5wdkiQNRDXEnwUorladGB6 Y2GxJkrjz7/6jXIvls5TAYZ4E305m4swo4hRBWGNnek+JBhdVyWYCcL2e6sU4cP+k/pi h0ODUvxQclDEcnreMiRkV2GNg2Q5aLF8FmBi19DFTfycClrqJDHL57U1jO655+lu9GCS kK6Pkh7FojwPwzZ4JM7kkrRkZJguIDrgtuQyAF2MBm7srvh5/fOPJ/gNUk755E5RV1It Z60A== X-Gm-Message-State: ABUngvfJpQt2OWAq5MmHIVJqQwYkFOA70LlrelQndl5Vtp1Xpfgv+wp1Jc4bHr5BfytQ7g== X-Received: by 10.98.26.200 with SMTP id a191mr8898205pfa.50.1477728891976; Sat, 29 Oct 2016 01:14:51 -0700 (PDT) Received: from localhost ([45.34.23.101]) by smtp.gmail.com with ESMTPSA id y189sm23541549pfy.34.2016.10.29.01.14.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 29 Oct 2016 01:14:51 -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 37/60] block: bounce: don't access bio->bi_io_vec in copy_to_high_bio_irq Date: Sat, 29 Oct 2016 16:08:36 +0800 Message-Id: <1477728600-12938-38-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-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As we need to support multipage bvecs, so don't access bio->bi_io_vec in copy_to_high_bio_irq(), and just use the standard iterator to do that. Signed-off-by: Ming Lei --- block/bounce.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/block/bounce.c b/block/bounce.c index babd3f224ca0..a42f7b98b7e6 100644 --- a/block/bounce.c +++ b/block/bounce.c @@ -102,24 +102,30 @@ int init_emergency_isa_pool(void) static void copy_to_high_bio_irq(struct bio *to, struct bio *from) { unsigned char *vfrom; - struct bio_vec tovec, *fromvec = from->bi_io_vec; + struct bio_vec tovec, fromvec; struct bvec_iter iter; + /* + * @from bio is created by bounce, so we can iterate from + * start and can't trust @from->bi_iter because it might be + * changed by splitting. + */ + struct bvec_iter from_iter = BVEC_ITER_ALL_INIT; bio_for_each_segment(tovec, to, iter) { - if (tovec.bv_page != fromvec->bv_page) { + fromvec = bio_iter_iovec(from, from_iter); + if (tovec.bv_page != fromvec.bv_page) { /* * fromvec->bv_offset and fromvec->bv_len might have * been modified by the block layer, so use the original * copy, bounce_copy_vec already uses tovec->bv_len */ - vfrom = page_address(fromvec->bv_page) + + vfrom = page_address(fromvec.bv_page) + tovec.bv_offset; bounce_copy_vec(&tovec, vfrom); flush_dcache_page(tovec.bv_page); } - - fromvec++; + bio_advance_iter(from, &from_iter, tovec.bv_len); } }