From patchwork Mon Feb 15 07:01:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 8310391 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 A10C1C02AA for ; Mon, 15 Feb 2016 07:02:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B4EF92051C for ; Mon, 15 Feb 2016 07:02:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9A96A204DE for ; Mon, 15 Feb 2016 07:02:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752134AbcBOHC0 (ORCPT ); Mon, 15 Feb 2016 02:02:26 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:35882 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752121AbcBOHCH (ORCPT ); Mon, 15 Feb 2016 02:02:07 -0500 Received: by mail-pf0-f195.google.com with SMTP id e127so7133556pfe.3; Sun, 14 Feb 2016 23:02:06 -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=0gU+DpDstDxTQUnCTXJJqf/56bKoLO3nKabbvxyQ1b8=; b=JpOgR4qnJeT2RIywnI51m9WZudR1gqQ/R4+BosIg/gtksPwJk0wQnPcFpjCdKlBFhB AqYbAtTokmhhpfKL0Qk+TVoycteheAY16E6CSPhHdR+h+sMFuIjR1jJ+cAxHvo72/H20 jAjg/NEsKGZW/aW4qmPXlZCTkDN0W9oH0JhwBpKtm/A6bmhuX3jIWuKaox8vF/Ti7qCs 2YfslQs8mu9IJTE4ffc3QDCqjE6jPt8beLnF4Rb3ZGeDz5GBOvwk+bAirZgwtxPO/V86 Y/JlOZkZtzIjiSBS5hoP9cWtJzvbCR5TxnaGED374NYPSGuWonbHjVSqq2nOKXnBdD1y xoFw== X-Gm-Message-State: AG10YORnmAbaRz4/kOfMQAq1epcrQnOje20NepCbD8h/yF68SSb69nd1snlmPERMqJ6hlQ== X-Received: by 10.98.87.141 with SMTP id i13mr21309227pfj.72.1455519726658; Sun, 14 Feb 2016 23:02:06 -0800 (PST) Received: from localhost ([103.192.227.7]) by smtp.gmail.com with ESMTPSA id g25sm35819770pfg.35.2016.02.14.23.02.05 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Sun, 14 Feb 2016 23:02:05 -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 1/4] block: bio: introduce helpers to get the 1st and last bvec Date: Mon, 15 Feb 2016 15:01:24 +0800 Message-Id: <1455519687-23873-2-git-send-email-ming.lei@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1455519687-23873-1-git-send-email-ming.lei@canonical.com> References: <1455519687-23873-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 After bio splitting is introduced, the splitted bio can be fast-cloned, which is correct because biovecs has become immutable since v3.13. Unfortunately bio_will_gap() isn't ready for this kind of change, because it figures out the last bvec via 'bi_io_vec[prev->bi_vcnt - 1]'. This patch introduces two helpers for getting the first and last bvec of one bio. Cc: stable@vger.kernel.org # v4.3+ Reported-by: Sagi Grimberg Cc: Christoph Hellwig Signed-off-by: Ming Lei --- include/linux/bio.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/bio.h b/include/linux/bio.h index 5349e68..56d2db8 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -265,6 +265,26 @@ static inline unsigned bio_segments(struct bio *bio) return segs; } +static inline void bio_get_first_bvec(struct bio *bio, struct bio_vec *bv) +{ + *bv = bio_iovec(bio); +} + +/* + * bio_get_last_bvec() is introduced to get the last bvec of one + * bio for bio_will_gap(). + * + * TODO: make it more efficient. + */ +static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv) +{ + struct bvec_iter iter; + + bio_for_each_segment(*bv, bio, iter) + if (bv->bv_len == iter.bi_size) + break; +} + /* * get a reference to a bio, so it won't disappear. the intended use is * something like: