From patchwork Tue Dec 27 15:56:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9489419 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 CA70762AAD for ; Tue, 27 Dec 2016 16:02:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC02B201BC for ; Tue, 27 Dec 2016 16:02:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B0E7225D99; Tue, 27 Dec 2016 16:02:21 +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 64D34201BC for ; Tue, 27 Dec 2016 16:02:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754576AbcL0QBi (ORCPT ); Tue, 27 Dec 2016 11:01:38 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:35354 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755683AbcL0QB3 (ORCPT ); Tue, 27 Dec 2016 11:01:29 -0500 Received: by mail-pf0-f195.google.com with SMTP id i88so18312024pfk.2; Tue, 27 Dec 2016 08:00:45 -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=1/RBK0aqT2YNrE5sBAlyvdX8hjo0Fi+Yv+3ax4sqcIo=; b=VtvYj3QrFX0aeK+ws1hQ5YgksRABZdglXnMhKi0jx610/P/OIycRI29P9x/NzHcFem X7SRjLh/XQWptOxUZPWPpHW4WkeTyeORXDBNUAQmeAhXUfiesi/PAuMCZFauXac0t6jq X2gATkGf7rllEgs4YtN3y5s0P7bYccbTLfIw2ETGTyfjZao7roB6Cx3st8hRh97mdL8Z 0IqRxgkxlDO12kd0SRjCAADXdSTstt33NaqET4c0X1zYqYshDv8nqdcOgmItz7JGQZFV UsQOtKOB5dey1/BtHRHB9m2YA4W2K4muE5uWIac2PrOUaXRMpRNsSV1WNDwR2/vjfiuI scbg== 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=1/RBK0aqT2YNrE5sBAlyvdX8hjo0Fi+Yv+3ax4sqcIo=; b=V7DJEPsTm/i46d6IL0xHKlkX/PvWTaJMMRCSrYYJxRUl1WM46SmhMaNxPujCedBVPp yjkzW9PoQ0nUh1NAgnXppEHcqVR9uqghe5o4IbmMm1KdsV95++8/cteCj4H7kwncxkMN jTFRsmS8npmyzBbB7DDYT88TAxSENgrvyzqD4WrbAcy/RV5U7BFqSGZHTh8h25fA3oDi AaeFWUOcOg4OGq9j89kWhSjmxGfm9uMh7PxPSlHrXgeoGKrzTW2ldwT/OK13fhsXwqHu XspU+Us1Z1KmGvWi1MBu1DrvfSnmlt13WSMOeSeFK6JJJaG0HxIPhx8z7veRN3HxrFYc FL2g== X-Gm-Message-State: AIkVDXKkH4iu3TYj5Dwx2LEh+LwGEmqzvOqRDuNut8pw/Nmz7O85gPWuG1c57tcfHV/yjw== X-Received: by 10.84.151.7 with SMTP id i7mr15600453pli.67.1482854444425; Tue, 27 Dec 2016 08:00:44 -0800 (PST) Received: from localhost ([45.35.47.137]) by smtp.gmail.com with ESMTPSA id p5sm77549965pgk.23.2016.12.27.08.00.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Dec 2016 08:00:42 -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 20/54] block: bounce: don't access bio->bi_io_vec in copy_to_high_bio_irq Date: Tue, 27 Dec 2016 23:56:09 +0800 Message-Id: <1482854250-13481-21-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 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); } }