From patchwork Tue Dec 27 15:56:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 9489557 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 B181762AB0 for ; Tue, 27 Dec 2016 16:10:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4217200E7 for ; Tue, 27 Dec 2016 16:10:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9876025F3E; Tue, 27 Dec 2016 16:10:53 +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 524C1201BC for ; Tue, 27 Dec 2016 16:10:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932862AbcL0QKs (ORCPT ); Tue, 27 Dec 2016 11:10:48 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:35422 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933378AbcL0QKf (ORCPT ); Tue, 27 Dec 2016 11:10:35 -0500 Received: by mail-pg0-f68.google.com with SMTP id i5so12811951pgh.2; Tue, 27 Dec 2016 08:10:35 -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=9MGkS9y+2IQIJVPjqeSzbdrnMyEupO07f5ply7ULB5k=; b=qaPtg/2YXKdmMwSgscaFvjQzbCFdVfXeNPs2FmmeVO+1X3Dp/yEIPKeGJgs+jU3oUX Hq0t9IXCyGGEjhvSO7sD32cnZwEA/pKobQXHJxlQAv1EycAlLz309ykf1gjjYvqVFF+3 PPN2Lq0K5rGGQRBRpDsIBQXgzsG0ADzIdSHOdwGb14yDw76OiyWiqf0I6nGu/RWyq6JE gXZS4Bc9lQ2AJDIHOWkvl+t4TJU4NFVYVOoV0v1kCjdt8yFgpEOh20btTB7qxluHackz D+U9xg/cutETKZ3MWEs+zB2c24V1YQIooUcybrXEWV3T3BzYhB+PjyKkqOKdZQwWaR0f 1jaw== 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=9MGkS9y+2IQIJVPjqeSzbdrnMyEupO07f5ply7ULB5k=; b=KLBvqL5m8ch3Mlx57d5E4/th0ZFBh8JhpJm57iEYCcklcGYJACd9iu+GzrpCaT/c15 XYsZt5sV2ktN8rF7UvpPx64q0cXRbnqIzULDwRYkpinPXRwayUUf74BEV62DbzzINBVp mLgkea9RpVKdgygvDlQtWrJxDbRwvutZ/oTpefCJVDyzaHSe0rnVQIxv23QYsRTa7T0r j6EYwAXIxQ92KGqAtB8hswKW/LDKoDZQMq+lWKQkd0uMsJAk/EYLEPq24jVjvBDDR3ps NKFS3LwU13A09Klkncgd3D6cBXCRQwAEj2NLj4xATBu96zRQck5ot6GNuAcVWmLb5RVQ MYKQ== X-Gm-Message-State: AIkVDXJxJUG6DqgbfKCrOoKRG1moe5y0zGbfzb8t4abyYgLmOriwInOBcWXiyxZDs2gGOw== X-Received: by 10.98.106.9 with SMTP id f9mr23815706pfc.126.1482854523089; Tue, 27 Dec 2016 08:02:03 -0800 (PST) Received: from localhost ([45.35.47.137]) by smtp.gmail.com with ESMTPSA id f132sm90612507pfa.72.2016.12.27.08.02.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Dec 2016 08:02:01 -0800 (PST) From: Ming Lei To: Jens Axboe , linux-kernel@vger.kernel.org Cc: linux-block@vger.kernel.org, Christoph Hellwig , Ming Lei , Mike Christie , Kent Overstreet , Hannes Reinecke , Chaitanya Kulkarni Subject: [PATCH v1 31/54] block: introduce bio_segments_all() Date: Tue, 27 Dec 2016 23:56:20 +0800 Message-Id: <1482854250-13481-32-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 There are still several direct access to .bi_vcnt, so introduce this helper to replace that usage for supporting multipage bvec. Signed-off-by: Ming Lei --- include/linux/bio.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/linux/bio.h b/include/linux/bio.h index efa0b3627735..b0929cf8c7fe 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -391,6 +391,27 @@ static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv) bv->bv_len = iter.bi_bvec_done; } +/* + * Return how many singlepage bvecs included in this bio, + * and this helper is only used for some fs to replace + * bio->bi_vcnt. + */ +static inline unsigned bio_segments_all(struct bio *bio) +{ + unsigned segs = 0; + int i; + struct bio_vec *bv; + struct bvec_iter_all bia; + + WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)); + + bio_for_each_segment_all_sp(bv, bio, i, bia) + segs++; + + return segs; +} + + enum bip_flags { BIP_BLOCK_INTEGRITY = 1 << 0, /* block layer owns integrity data */ BIP_MAPPED_INTEGRITY = 1 << 1, /* ref tag has been remapped */