From patchwork Mon Feb 15 07:04:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 8310431 Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A5A6C9F2F0 for ; Mon, 15 Feb 2016 07:05:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CBAC52051C for ; Mon, 15 Feb 2016 07:05:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E8F7420114 for ; Mon, 15 Feb 2016 07:04:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752169AbcBOHE7 (ORCPT ); Mon, 15 Feb 2016 02:04:59 -0500 Received: from mail-pa0-f66.google.com ([209.85.220.66]:33373 "EHLO mail-pa0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752161AbcBOHE6 (ORCPT ); Mon, 15 Feb 2016 02:04:58 -0500 Received: by mail-pa0-f66.google.com with SMTP id gc2so102338pab.0; Sun, 14 Feb 2016 23:04:58 -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; bh=7nvPdC2DCKWUJkpzgfGSvjWmn9PvAxiFWgo1/pchF2k=; b=dpm9Sdf8f4B+a9zGQ1pILyQ8zPkURptv+LI9mcIJj/TEfxfjnJdWVq32esZyO5/qg7 zjOVsj30XPH930a12U0M9tZFL9+VimuPibU1kehcFsvlmBvSIXE1Dj15CvRi84wWgTE2 B4IPXewzepN6Jw9Ns2N88YLLRNj6DSmiKsjnvHkzlkqGHelY3gS7jfQFwkizyQ+r3eAx 0TyO62a2yHVSC46rkogyklZ2Cjf/9VFTfvH/DHlLMxuO4upmBtkqvxBS9NbLGYJMcZoA 1NkcY4FXAA1BnKgZ6j8Q70f5aaO5q2VoRzXeNtsTQGt9jIOEQTwUFYIrnu7PpfDr+iRt Ewag== X-Gm-Message-State: AG10YOQoNV2vqMYMXP5af4JjUlN9RPb0GNYVCSQyifRQdg4toLQdrtPMw/NvPhr2kA1XqA== X-Received: by 10.66.142.200 with SMTP id ry8mr21611228pab.31.1455519898287; Sun, 14 Feb 2016 23:04:58 -0800 (PST) Received: from localhost ([116.251.208.106]) by smtp.gmail.com with ESMTPSA id t87sm35851790pfa.14.2016.02.14.23.04.57 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Sun, 14 Feb 2016 23:04:57 -0800 (PST) From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, Christoph Hellwig , Sagi Grimberg , Ming Lei , stable@vger.kernel.org Subject: [PATCH 3/4] block: get the 1st and last bvec via helpers Date: Mon, 15 Feb 2016 15:04:42 +0800 Message-Id: <1455519890-24093-1-git-send-email-ming.lei@canonical.com> X-Mailer: git-send-email 1.9.1 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 # v4.3+ Reported-by: Sagi Grimberg Cc: Christoph Hellwig Signed-off-by: Ming Lei --- 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 b8ff6a3..7152102 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1388,11 +1388,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)