Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1491684imu; Tue, 20 Nov 2018 19:28:28 -0800 (PST) X-Google-Smtp-Source: AFSGD/WKvI6N1Js68hXm5qMddEwsycDtzUjOu5/y9O7A0XorIoTiky8JBsP7U1b3YJBwMoXqdB/6 X-Received: by 2002:a17:902:a81:: with SMTP id 1-v6mr5074417plp.20.1542770908869; Tue, 20 Nov 2018 19:28:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542770908; cv=none; d=google.com; s=arc-20160816; b=aseKL9m0rLiyuLKORpREadWPQzYTYqnXX7f5DVbvhaOZVPrsB5B5ey7+B3AQtK9gOX T1cBXAlhse74WwvCaIAdxhqbRdd/fWWtqhAwLmd8WOTp97Be/vtLSyAlrM3iyfXNQ+ii GEvUyPLdCTEdch9vJmbG91KvDCN19SijHtwU8YpKMhZPZvltIw868qZEDkU62JXxZOiI N9GYkL/vieWyOkMdnfD9l5Hq2bnVRaE+7TRtLCpDKSINuX7htl/pqfJuuClO8P44T9Me gQgl6pqnPJ498u1N1h9zm7CBSjjJkMx7VRkdVy9lQnLQYGoT0motJKKPdKbOPnvXBoWL zJMA== 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; bh=tEMVf7aaXzhIFZ7juhc3JwrvQlu0r1fvaDx0TitR7hU=; b=OOAWyH3hXzO+aBGiz+cqrPIiLYWeBYuV2ts2o7ugYuERwwKFs52deWW+hZBOCWF15I AmEFnJ9pHZV/LJew57zUitZ1urbiO0khmZ/XWdaeEDT22XaydPHbRKCPDQyo6251/pGD efdoY7xmsFitlWviMnUKZoF8k1OE4teJPsuWuPRhYTNC5Wo5hIt/wz8SA+FatlSJQPc8 2sCrWwADusHERwPgi/dIoSDm7gqZZ9DP8Kqr4nc3zsgRZvFhGRQeb71pfyJwPiZx6R2j juol4A4PWCfwNPLw211rlWVFWkxVwoIc770SlJz1Nxrm9zhTED28Wcu7K7OHSB0EwpnD mqOQ== 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 g69si30789685pfg.225.2018.11.20.19.28.14; Tue, 20 Nov 2018 19:28:28 -0800 (PST) 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 S1727963AbeKUN7b (ORCPT + 99 others); Wed, 21 Nov 2018 08:59:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44318 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727069AbeKUN7a (ORCPT ); Wed, 21 Nov 2018 08:59:30 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6E2DAC057E26; Wed, 21 Nov 2018 03:26:59 +0000 (UTC) Received: from localhost (ovpn-8-21.pek2.redhat.com [10.72.8.21]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7C4D6012B; Wed, 21 Nov 2018 03:26:47 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Theodore Ts'o , Omar Sandoval , Sagi Grimberg , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com, Ming Lei Subject: [PATCH V11 09/19] btrfs: move bio_pages_all() to btrfs Date: Wed, 21 Nov 2018 11:23:17 +0800 Message-Id: <20181121032327.8434-10-ming.lei@redhat.com> In-Reply-To: <20181121032327.8434-1-ming.lei@redhat.com> References: <20181121032327.8434-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Wed, 21 Nov 2018 03:26:59 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org BTRFS is the only user of this helper, so move this helper into BTRFS, and implement it via bio_for_each_segment_all(), since bio->bi_vcnt may not equal to number of pages after multipage bvec is enabled. Signed-off-by: Ming Lei --- fs/btrfs/extent_io.c | 14 +++++++++++++- include/linux/bio.h | 6 ------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 5d5965297e7e..874bb9aeebdc 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2348,6 +2348,18 @@ struct bio *btrfs_create_repair_bio(struct inode *inode, struct bio *failed_bio, return bio; } +static unsigned btrfs_bio_pages_all(struct bio *bio) +{ + unsigned i; + struct bio_vec *bv; + + WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)); + + bio_for_each_segment_all(bv, bio, i) + ; + return i; +} + /* * this is a generic handler for readpage errors (default * readpage_io_failed_hook). if other copies exist, read those and write back @@ -2368,7 +2380,7 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset, int read_mode = 0; blk_status_t status; int ret; - unsigned failed_bio_pages = bio_pages_all(failed_bio); + unsigned failed_bio_pages = btrfs_bio_pages_all(failed_bio); BUG_ON(bio_op(failed_bio) == REQ_OP_WRITE); diff --git a/include/linux/bio.h b/include/linux/bio.h index 7560209d6a8a..9d6284f53c07 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -282,12 +282,6 @@ static inline void bio_get_last_bvec(struct bio *bio, struct bio_vec *bv) bv->bv_len = iter.bi_bvec_done; } -static inline unsigned bio_pages_all(struct bio *bio) -{ - WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)); - return bio->bi_vcnt; -} - static inline struct bio_vec *bio_first_bvec_all(struct bio *bio) { WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)); -- 2.9.5