Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2998053imm; Thu, 24 May 2018 20:50:03 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpbILwGMvnv0aci021o9CzC3roVd3UxpfCMsQPsu6n2TmQK4t+ezKwEdir4kz5oICjuFu5t X-Received: by 2002:a62:f80c:: with SMTP id d12-v6mr777411pfh.159.1527220203640; Thu, 24 May 2018 20:50:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527220203; cv=none; d=google.com; s=arc-20160816; b=aSs3XcOGO+1Pw2/j66TO4dKQJUk7WFSD/y/2rhYq9b2S4heftjxH9HrBybg3CDLXZG Msle9zymNB+TSU7klQ6tsWP6o30Hdhg18skdzjYdJOqvKhlbBlFW4vHG9gOz6ww4e3Hi iwnLy29ya+3kBqlKE+HazqTNHcZtq2eysqwJvOQc0llXM0m5NCiSGchd1+7FQWp9RcYD d1/JbEtKjrrXpKBwJCpFWJWspzZE1HaiPTn9d38mzJNU6h4l+FmZyptU+V2hNyT3nzej AP0dRPORj4d8+EtsXpalx50eKsqrFexSGMY2CpFhjhduTD0tNqkRccGTYKva6YZkHDga sm/g== 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=g1Nce4EVHoE7GDykqgSfVWgzqZfe5XWTufisBuK1Lhw=; b=epiVPH8UELeu1zl5AdOcHofVwRdf7drlb6XegCEjHRY408ZL+t5G4gTWn8XRrBV4qs UFKVkQkTYI5eK+9qGc/VFZLu58lUjovly5M8G9DFTF0HCBE8XiVEnscAEBukve85D4n7 gKZOWatF+n4Altbzpk1bfqqTSbNxCcS1R4d3sqr3e3jYLhitmMTKQlobZHFAB00ScoMs PEERwdAfNX0zq/oWPmr1GTysxTLse7e54M9P1HLsbvfMIaYIQiOr5vOol+OwDJVgZRLH uaFnGgdRSsdQgC8U7JYZ8TIdWor6gRjFs89HLFYQLvYGqsbvVfLEhxiXfqbI4tPyXMy7 0GFQ== 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 v5-v6si22993191plo.166.2018.05.24.20.49.49; Thu, 24 May 2018 20:50:03 -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 S934581AbeEYDs7 (ORCPT + 99 others); Thu, 24 May 2018 23:48:59 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41366 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934426AbeEYDs5 (ORCPT ); Thu, 24 May 2018 23:48:57 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DFE43401EF03; Fri, 25 May 2018 03:48:56 +0000 (UTC) Received: from localhost (ovpn-12-30.pek2.redhat.com [10.72.12.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id AABBE2166BB2; Fri, 25 May 2018 03:48:48 +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 , Ming Lei Subject: [RESEND PATCH V5 11/33] block: implement bio_pages_all() via bio_for_each_page_all() Date: Fri, 25 May 2018 11:45:59 +0800 Message-Id: <20180525034621.31147-12-ming.lei@redhat.com> In-Reply-To: <20180525034621.31147-1-ming.lei@redhat.com> References: <20180525034621.31147-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 25 May 2018 03:48:56 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Fri, 25 May 2018 03:48:56 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.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_page_all() to compute the number. 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 3d3795b9a353..08af9272687f 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -334,8 +334,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_page_all(bv, bio, i) + ; + return i; } static inline struct bio_vec *bio_first_bvec_all(struct bio *bio) -- 2.9.5