Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1976293imm; Sat, 9 Jun 2018 05:34:23 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJl7yT1DBOfX64A9tnntLEuczDN3SOYrup/T85YDviYydBMelWTvGrZZ5cYgoCjrmwKxyIi X-Received: by 2002:a17:902:e10f:: with SMTP id cc15-v6mr117045plb.100.1528547662947; Sat, 09 Jun 2018 05:34:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528547662; cv=none; d=google.com; s=arc-20160816; b=EJeSbVlK47L0LiaW5srIPmBOruOHRlgspRGkGDAGnNs9VN2Z+qNnz0AMpMsRO/gzLD Hd0ADTW3r00Qns295I4afL7U1h2uC/N4BAGdBKV0sGDjI0QkAOauoRKGotOgXdW0bQOF MfpH3yc8t5gqqDHS9elYnfXlqgp9HRpBVBaUV92jmq01Etgk0mNFnv4LsKEwSgBwc1GP AU39k66AVyXt2lUwg406PpRGUcV3XIwqkxNhS/sMeZi6VdsQb5vlOC3TktfWuvxUw0c6 CjAxfRCxX8HEPoH7wxx3rIsAAU85yYCYQEcg3wJF3ZY2LlM2xmz0OQc42bgoCdQknhjm ZHpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=uUy2SJisx6we0CGtgtelrVjkM1gHLbJeT2XdukMcoBE=; b=mmTsonJNLZgmzKCtZJHh9ZeF3jWbfeKONg/EM4YkmFd7Koy025V8oChvYOVy2G8Ggz SPjvn0Pe+B/pGpsObuAYTh1O7/yLoI3BvpAx33Wu6+WW9Q3pP4KPyNKf1EaE4No+L3z4 snAQliTn49VEYm21psTpXn3TiVJVFaIrIrGCAkDmh4BigdQX10Iex9AauAJcJ2laMHx/ DxRFD/TSwgWs++DuMulAdae1igvrB0XP0omeyHa3PF7dMf7v/sdO1UP8028tMtY0AaOD KGdkjjCVyyUP4oTtyZKAwnO1NuFM7SD3N8S4RbaFftPpNDCQ9EqT8jfFdvazzSI8uM5R 8kXw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n21-v6si12267455plp.130.2018.06.09.05.34.08; Sat, 09 Jun 2018 05:34:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753446AbeFIMc4 (ORCPT + 99 others); Sat, 9 Jun 2018 08:32:56 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36016 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753176AbeFIMcy (ORCPT ); Sat, 9 Jun 2018 08:32:54 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 02749859A5; Sat, 9 Jun 2018 12:32:54 +0000 (UTC) Received: from localhost (ovpn-12-40.pek2.redhat.com [10.72.12.40]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1FE2A42236; Sat, 9 Jun 2018 12:32:42 +0000 (UTC) From: Ming Lei To: Jens Axboe , Christoph Hellwig , Alexander Viro , Kent Overstreet Cc: David Sterba , Huang Ying , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , "Darrick J . Wong" , Coly Li , Filipe Manana , Randy Dunlap , Ming Lei Subject: [PATCH V6 11/30] block: implement bio_pages_all() via bio_for_each_segment_all() Date: Sat, 9 Jun 2018 20:29:55 +0800 Message-Id: <20180609123014.8861-12-ming.lei@redhat.com> In-Reply-To: <20180609123014.8861-1-ming.lei@redhat.com> References: <20180609123014.8861-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Sat, 09 Jun 2018 12:32:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Sat, 09 Jun 2018 12:32:54 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'ming.lei@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As multipage bvec will be enabled soon, bio->bi_vcnt isn't same with page count in the bio any more, so use bio_for_each_segment_all() to compute the number because we will keep bio_for_each_segment_all() to iterate each page. Signed-off-by: Ming Lei --- include/linux/bio.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/linux/bio.h b/include/linux/bio.h index e9f74c73bbe6..c17b8f80d650 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -339,8 +339,14 @@ static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv) static inline unsigned bio_pages_all(struct bio *bio) { + unsigned i; + struct bio_vec *bv; + WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)); - return bio->bi_vcnt; + + bio_for_each_segment_all(bv, bio, i) + ; + return i; } static inline struct bio_vec *bio_first_bvec_all(struct bio *bio) -- 2.9.5