From patchwork Sat Jun 9 12:29:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10455565 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 B6F6C601F7 for ; Sat, 9 Jun 2018 12:32:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A90D9223A4 for ; Sat, 9 Jun 2018 12:32:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DCA6223A6; Sat, 9 Jun 2018 12:32:56 +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=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4603B223A4 for ; Sat, 9 Jun 2018 12:32:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 615CC6B0275; Sat, 9 Jun 2018 08:32:55 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5C4976B0277; Sat, 9 Jun 2018 08:32:55 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 467086B0278; Sat, 9 Jun 2018 08:32:55 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f199.google.com (mail-qk0-f199.google.com [209.85.220.199]) by kanga.kvack.org (Postfix) with ESMTP id 161FA6B0275 for ; Sat, 9 Jun 2018 08:32:55 -0400 (EDT) Received: by mail-qk0-f199.google.com with SMTP id p190-v6so15099096qkc.17 for ; Sat, 09 Jun 2018 05:32:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=uUy2SJisx6we0CGtgtelrVjkM1gHLbJeT2XdukMcoBE=; b=PWSEofoFf/sCVCyFjrwTuwxp/99ZBer+duDhzZTDX0jMIV7qqy1JpwYSPy9ZtbOnZ4 c2iZl0PBo7ybkSg9aedInW5upWDqsqgHbzvpETbWdkOD5465evQ5GgCrhv1w18A580i4 4IS8lWZuG1BI07h2whfTI2QXHGYH5WrPvXHbvYMfOU7t7HG7LosiU8BCleDxJDgvitcb +V035UYEwSePvv/Q0RJhprGsIjA3RHlBKZ0TbX1QFGi+FcUd5bT1rYP11MLcljAVsS8I CMrsZywTdD1J2Q/3obZ1zc9lNy2ul5yFnVYEpNt6FPR4xUmINqCX1VPjINKGOR56/rB4 cTRw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APt69E1osTPLguhwo8tUIB+9EOsEfLff/I4eYh9S5IyESZ20F2bCVURj 54yb0c99MweSrMPzWkiSdkcXYxSpOTk+d2Ek4c6Ocxb95duWVmVPJdj3WxYyU7IKw2MCJrbONit 6xUSZymeWg4F1KaaP++lrCp0dKCqv6rrWjUJaiNqkdtWiqGJii/F2ChpbH1IRQ4HuLQ== X-Received: by 2002:a37:8483:: with SMTP id g125-v6mr552123qkd.392.1528547574900; Sat, 09 Jun 2018 05:32:54 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI2PoZJlUTzHrQ8wMPtRsWx1oz9AUtoNfs57aK8+AyP0u9wexJ8tXgf53f3nWCKg0YSOc07 X-Received: by 2002:a37:8483:: with SMTP id g125-v6mr552103qkd.392.1528547574414; Sat, 09 Jun 2018 05:32:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528547574; cv=none; d=google.com; s=arc-20160816; b=Eu10CKuC612QbUvEbDt37IE+uLlgdw8ADXB6qUt3qwOAR9/X/wF0i5V0UjeScOv+p3 xh4wM8bZiPTfMTzN/W1WzBKmSBCm4T4QyMkDEmBdIIzO+2WWJhHa71TkLTlG8EqmimMv X+83h4WjLtBMdn7DUJT7R5S7N31hMeKYonbOOFolviwxgdoVMoFO3DyV7wzcf0CRaBuF M1sIu2f8P3Blc3jhICXRO8G1t9s6mAQjtBIgsXWOH4kNHxDr4hxP54h+gYcEAU3Xc3j9 jhpNqnW5riN6uzPeuyLsURd4bhPC/6Y2bnSrdWlRK5GZXhfxXBgst6RXC+WrofUkEO50 1zsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=uUy2SJisx6we0CGtgtelrVjkM1gHLbJeT2XdukMcoBE=; b=xdv30twSIR5Y2C73t4vcauc9A4uRTl6O9pHO9J94w/xReSknLMLOboV8EwUzJwnfLU MJjQY9DmIi6i+CA1oiqBlYQ4/wtFORiBdMXefixQVHqIkOJtgA6WQArJ8K+zrZTaPmX+ 3TeFJkDN+jBmFC2z7IRbulvSaR7ETTHCnjbdflqjxYF0fD4BqtBlRwWOgAaJ3NjtsuDP F4RkzZ45xQ/0b/Ga3ZsMaFfLOthmYwyd501tT6r/oF7qh3aWqk/mZBVYwjDQzPIGC2In p/qG2yO1wmctczTaXCJ/mAzpvHOF4iRZ4DL0xEKsdnEiJI2eoaB2Qfo63Hocp+snzzmn 5szQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx3-rdu2.redhat.com. [66.187.233.73]) by mx.google.com with ESMTPS id h23-v6si534726qve.139.2018.06.09.05.32.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 09 Jun 2018 05:32:54 -0700 (PDT) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 as permitted sender) client-ip=66.187.233.73; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=ming.lei@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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:'' X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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)