Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7767744imu; Thu, 15 Nov 2018 00:56:52 -0800 (PST) X-Google-Smtp-Source: AJdET5ezLXZkx7J7hbFyHWCYZ/P9JJIj8BatVdyfzLiDLtPvFTyJZlXLuH+3W0HAEhD4e17iqag8 X-Received: by 2002:a62:4194:: with SMTP id g20-v6mr1487388pfd.44.1542272212207; Thu, 15 Nov 2018 00:56:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272212; cv=none; d=google.com; s=arc-20160816; b=vvk9vrA3KJwjqulEI0fBleSjycQviESBtfLDxDj3Yx3s7+/9XWQhVKkcU9s2rbDFUh nG9Wqtoi/Zk0BSJy9JFPSuSv8DfPDn5zkGCbQN+QKMJIFuKn7tPorG8xifPmy27NPJ8g eI2cjLOnlsMDiGv/p97Sb3xCB3uv5GyxrpEEUSMNJ1XfbphorMeIzwTQ7RNYvKKbSSjP SbZVrpgcoyJ2qf8Z+ixDUEfAuTPrcnKUtYJ6p9NdhvGFgnetdYThomv37Sg5dzqHkCIR 23TvGgshkDlxQ8OmgIujzkBVxPox7h0Gv4SRam9qPfIAOI6I5hxaxzenEtxc1TPCDFiy tjRQ== 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=tM2fCUTiqNJ83ZUHUFDg+ZAzp2ZS8MMRbJFFzEGHe40=; b=r55JQ5cjVSijA7csn5ZJTY1ps9iKaYn9d2KwsCDbvEvI/qw8Sbt62VuqCDAKm3UuIa sEhan7clAZr0GQebKenvh3Rhcyg25qYjrf3psIymU3vkut+k/j9nHaUuRYTWALQLI3PZ 9HaidLcoYYlTdMZyYXWxiHgLcKLf/OBs4T/NVktqdyFYTSWhYeTE7G73470Mx27szf+y Q2iBWD9YU5votc7wB00w168SKrG5nVCM7E6m/FGZ67q9ewTRdDn92LiGB3DK4wFlxnhS qDJIJFiidGYlZBNXiuQOLZiZO/JKxSka6aWei1GkducIptl1ZIBVY5Ghc4Bd1CHR0YVd mL1w== 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 g67-v6si19741998plb.163.2018.11.15.00.56.37; Thu, 15 Nov 2018 00:56:52 -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 S2387976AbeKOTC3 (ORCPT + 99 others); Thu, 15 Nov 2018 14:02:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51260 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728948AbeKOTC2 (ORCPT ); Thu, 15 Nov 2018 14:02:28 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7CE7FC072243; Thu, 15 Nov 2018 08:55:34 +0000 (UTC) Received: from localhost (ovpn-8-23.pek2.redhat.com [10.72.8.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F4451A928; Thu, 15 Nov 2018 08:55:19 +0000 (UTC) From: Ming Lei To: Jens Axboe Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ming Lei , Dave Chinner , Kent Overstreet , Mike Snitzer , dm-devel@redhat.com, Alexander Viro , linux-fsdevel@vger.kernel.org, Shaohua Li , linux-raid@vger.kernel.org, linux-erofs@lists.ozlabs.org, David Sterba , linux-btrfs@vger.kernel.org, "Darrick J . Wong" , linux-xfs@vger.kernel.org, Gao Xiang , Christoph Hellwig , Theodore Ts'o , linux-ext4@vger.kernel.org, Coly Li , linux-bcache@vger.kernel.org, Boaz Harrosh , Bob Peterson , cluster-devel@redhat.com Subject: [PATCH V10 08/19] btrfs: move bio_pages_all() to btrfs Date: Thu, 15 Nov 2018 16:52:55 +0800 Message-Id: <20181115085306.9910-9-ming.lei@redhat.com> In-Reply-To: <20181115085306.9910-1-ming.lei@redhat.com> References: <20181115085306.9910-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 15 Nov 2018 08:55:35 +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. Cc: Dave Chinner Cc: Kent Overstreet Cc: Mike Snitzer Cc: dm-devel@redhat.com Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Shaohua Li Cc: linux-raid@vger.kernel.org Cc: linux-erofs@lists.ozlabs.org Cc: David Sterba Cc: linux-btrfs@vger.kernel.org Cc: Darrick J. Wong Cc: linux-xfs@vger.kernel.org Cc: Gao Xiang Cc: Christoph Hellwig Cc: Theodore Ts'o Cc: linux-ext4@vger.kernel.org Cc: Coly Li Cc: linux-bcache@vger.kernel.org Cc: Boaz Harrosh Cc: Bob Peterson Cc: cluster-devel@redhat.com Signed-off-by: Ming Lei --- fs/btrfs/extent_io.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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); -- 2.9.5