From patchwork Fri Feb 26 15:40:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 8438731 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 77F78C0553 for ; Fri, 26 Feb 2016 15:41:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 936212011D for ; Fri, 26 Feb 2016 15:41:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DE640203B6 for ; Fri, 26 Feb 2016 15:41:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933602AbcBZPlk (ORCPT ); Fri, 26 Feb 2016 10:41:40 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:33017 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933521AbcBZPli (ORCPT ); Fri, 26 Feb 2016 10:41:38 -0500 Received: by mail-pf0-f195.google.com with SMTP id t66so582272pfb.0; Fri, 26 Feb 2016 07:41:38 -0800 (PST) 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=+l01F3R7iM+fOBs7JW3unSx/Vi1baROpGRlSWzhRKk8=; b=GuakWB647U381qmNcpbRENajL/NRG8NQDRC1V4fNdvyTUwqcV7Gf8giOCXqVyFe7eW i8bgLGP8j8RmyjvLfrb+NeimB0hzqACiG5hgmIgAwfK/cM98LWurcoWvVJzQlY4KRFLa zNSOFO86TZLleuwUr3Ct9RvjbJq2xJQXy/eEYB7pIXUKIPLHY5Oe3skFajdwQpYeV+yV TLQy3n8hC+RhAcd3c6q7oKTckLQRoCLAMRaAN/+lrHhPvNmTyxr82vik0zpA3WKMJS14 WRHYuENgATShU/alnOba4g4GZ+IehgELXWW2AXvz61RymsXQsIAH6PovE6D2ukmgpbyf rEsg== X-Gm-Message-State: AD7BkJLKWYqBtqaAQTZ/z7lmpDAci/YLd9zaoZIBWZsqVjp9olBKHxDwZybMKfzws6bgjw== X-Received: by 10.98.93.155 with SMTP id n27mr3016851pfj.88.1456501293054; Fri, 26 Feb 2016 07:41:33 -0800 (PST) Received: from localhost ([45.35.47.131]) by smtp.gmail.com with ESMTPSA id q85sm20238940pfq.81.2016.02.26.07.41.31 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 26 Feb 2016 07:41:32 -0800 (PST) From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, Christoph Hellwig , Sagi Grimberg , Kent Overstreet , Keith Busch , Elliott Robert , Ming Lei , stable@vger.kernel.org Subject: [PATCH v2 3/4] block: get the 1st and last bvec via helpers Date: Fri, 26 Feb 2016 23:40:52 +0800 Message-Id: <1456501253-7269-4-git-send-email-ming.lei@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1456501253-7269-1-git-send-email-ming.lei@canonical.com> References: <1456501253-7269-1-git-send-email-ming.lei@canonical.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch applies the two introduced helpers to figure out the 1st and last bvec, and fixes the original way after bio splitting. Cc: stable@vger.kernel.org Reported-by: Sagi Grimberg Reviewed-by: Sagi Grimberg Reviewed-by: Christoph Hellwig Signed-off-by: Ming Lei --- include/linux/blkdev.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index cd06a41..d7f6bca 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1394,11 +1394,16 @@ static inline bool bvec_gap_to_prev(struct request_queue *q, static inline bool bio_will_gap(struct request_queue *q, struct bio *prev, struct bio *next) { - if (!bio_has_data(prev) || !queue_virt_boundary(q)) - return false; + if (bio_has_data(prev) && queue_virt_boundary(q)) { + struct bio_vec pb, nb; + + bio_get_last_bvec(prev, &pb); + bio_get_first_bvec(next, &nb); - return __bvec_gap_to_prev(q, &prev->bi_io_vec[prev->bi_vcnt - 1], - next->bi_io_vec[0].bv_offset); + return __bvec_gap_to_prev(q, &pb, nb.bv_offset); + } + + return false; } static inline bool req_gap_back_merge(struct request *req, struct bio *bio)