From patchwork Fri Feb 19 03:20:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 8355891 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 A95B3C0553 for ; Fri, 19 Feb 2016 03:21:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C5C95203E9 for ; Fri, 19 Feb 2016 03:21:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DD8A020357 for ; Fri, 19 Feb 2016 03:21:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422949AbcBSDVT (ORCPT ); Thu, 18 Feb 2016 22:21:19 -0500 Received: from mail-pa0-f52.google.com ([209.85.220.52]:33009 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422649AbcBSDVQ (ORCPT ); Thu, 18 Feb 2016 22:21:16 -0500 Received: by mail-pa0-f52.google.com with SMTP id fl4so42385364pad.0; Thu, 18 Feb 2016 19:21:16 -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=YtFhGb//MZCFhGPzd71l2uLsN0arLtXLeGyYQ9HWIFY=; b=bqmRZATtKqaOEyxSBaKbxW2XJIdd+nwbMcaOl2VgD3cZsne73BDSG0nt9AsS7qilM8 XSZoPazzc1rLKCqRxMV31Dp5uncZJDqTYtXgHb71sHDtyYoYncalICoLMLA9b//WzFnM XDzpVBmXnW+FkdM/AvDVFovwim3OdxjXY4YcWCPXNDeVRcq7AJcUA3gioRkwTXsFai02 WzjkW6noKHIaFUxT2RYZWaQaxikdjBZpUYmCc3fNIsE+hwP8XYbcZUIPl+tDykhDCFzF QGDKVPKlmKxwNykDX/chyt3ErZtXKJmHnrHa1MA73KrDdyIL5KrdNaE12I2pJCTJ0Opj 9S3A== X-Gm-Message-State: AG10YOTIHQGtG9IKvzsmeQxrHMaGRAnTb/lWcnZRdCGN3NHPaBVuCJItfu2+J2BFI5s6FA== X-Received: by 10.67.7.169 with SMTP id dd9mr15071673pad.105.1455852076389; Thu, 18 Feb 2016 19:21:16 -0800 (PST) Received: from localhost ([116.251.208.106]) by smtp.gmail.com with ESMTPSA id yj1sm13526758pac.16.2016.02.18.19.21.15 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Thu, 18 Feb 2016 19:21:15 -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 v1 3/4] block: get the 1st and last bvec via helpers Date: Fri, 19 Feb 2016 11:20:21 +0800 Message-Id: <1455852022-14188-4-git-send-email-ming.lei@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455852022-14188-1-git-send-email-ming.lei@canonical.com> References: <1455852022-14188-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 Cc: Christoph Hellwig Signed-off-by: Ming Lei Reviewed-by: Sagi Grimberg Reviewed-by: Christoph Hellwig --- include/linux/blkdev.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 5023401..de4fc002 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)) + if (!bio_has_data(prev) || !queue_virt_boundary(q)) { return false; + } else { + struct bio_vec pb, nb; - return bvec_gap_to_prev(q, &prev->bi_io_vec[prev->bi_vcnt - 1], - next->bi_io_vec[0].bv_offset); + bio_get_last_bvec(prev, &pb); + bio_get_first_bvec(next, &nb); + + return __bvec_gap_to_prev(q, &pb, nb.bv_offset); + } } static inline bool req_gap_back_merge(struct request *req, struct bio *bio)