From patchwork Wed Nov 21 03:23:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10691693 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1808B13BB for ; Wed, 21 Nov 2018 03:27:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFBB92B412 for ; Wed, 21 Nov 2018 03:27:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E030C2B409; Wed, 21 Nov 2018 03:27:02 +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 76EE92B409 for ; Wed, 21 Nov 2018 03:27:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D8736B23A3; Tue, 20 Nov 2018 22:27:01 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 987FF6B23A5; Tue, 20 Nov 2018 22:27:01 -0500 (EST) 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 8768D6B23A6; Tue, 20 Nov 2018 22:27:01 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by kanga.kvack.org (Postfix) with ESMTP id 51F216B23A3 for ; Tue, 20 Nov 2018 22:27:01 -0500 (EST) Received: by mail-qt1-f199.google.com with SMTP id n50so2206895qtb.9 for ; Tue, 20 Nov 2018 19:27:01 -0800 (PST) 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=tEMVf7aaXzhIFZ7juhc3JwrvQlu0r1fvaDx0TitR7hU=; b=tbgSnfJjCFmycBOYd1hVF8H0SHFi4oNuwCovTH+YlKhxX57MMSAcSLWsPmd9XDgJoc WImTdyQTZQVQmOWsu4d0gBR9CYZ+jyK1q57MBHGCfQ1iBAefV7lBps1MKAczwuBoIC8E m5eqaaMIW4ADHfX9V4tj8Fr1jVxnVJt4MfQE5yggDDtbUV9jCgrxLiNmZYQ4YpVR+684 gJ6AN67JwHEC6tZhE/fM6urwGnH2MMc8hdnnOzO3fqWDGNtHqJ/vyBFjxO4Yl4+DNIda ZN8rWsCvs8sYyN0j6a5pORMYEwfyi5hU7jSEpVcJYWu/dzUwVOg+0NDSdjObHQVNp0b2 xLDQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 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: AGRZ1gK58GiLtyl1WOH3ugrGtgjlTvNqxzDrkFDDI++uZi6zoNbqvfWp iJwM+a32DzjV6P3HqUAC0PfogbBAkxJPB8XHD86PXvDtOBoWOiq7XW7QDfGxvkkDAzZrkUGGT0v aO05WwV207ynNxYfUzwsWehX2JOiUOwdnFYThha8W+h0xATK8Yhw+vdEkGxkdoBfPVw== X-Received: by 2002:ac8:3790:: with SMTP id d16mr4424016qtc.20.1542770821066; Tue, 20 Nov 2018 19:27:01 -0800 (PST) X-Google-Smtp-Source: AFSGD/Ur9aNdchmVasR/mQ29pLW7eLDQ4xHxAhEg+CT+l05pKIqGurJdB2fgsVn+zd+WPLWoZbGA X-Received: by 2002:ac8:3790:: with SMTP id d16mr4423996qtc.20.1542770820503; Tue, 20 Nov 2018 19:27:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542770820; cv=none; d=google.com; s=arc-20160816; b=WpwdNVbHDnQfsHvwdGDFyfAnXxDes1X1Nx2t0wGZr4GasJ6TPD2+Xxlcm9Fpkc7rD+ o1cqGlPZA0L3REsZkkg93VdeLGh9Ak7ceKXxhxJ6N3sLOr/pe+LmMi8TCTmmRvvYMn9K mrgqt6SNzqK0ah4QRlf8uRE2LifmH5+tMBVLcmjAYbFSlC+j9PY1osT+sDngO0jM1ejN uTh0rHonr9bHoySW0lrnCsnqeWOuYL7UIQrOksPQxbtj3cE5n3cfKZILpvLY/WAGOSC5 Z0jWKGRyHZ9EQEAURY6a6clGYhZExQGrX9na8T33LLA0TxtcsJ/q4ECDZflYc7f6TZpq AW3g== 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; bh=tEMVf7aaXzhIFZ7juhc3JwrvQlu0r1fvaDx0TitR7hU=; b=B8V2XjTUVh5aFOHLi2i1AJOP6QsWuFXW60nT3jd8r0LbbkqqoUL7avpryucln09dIg N/ZOCnGo/ueYPqipdiaxGM90GS/pcM2ZSytJp3BL1PTF0jPA/FaFgzmo+hJkTijiQzod tn4mLoh1JvQYiCaXELo1aSZVgLNAv/sT2qqA0phkkyZg1+o/98LQ1XRjr8wEGeL4EIxI wUGEGls3GWwfYTdkGbPdRn2NfupeXTVdNU8xFcPSoN9Rkf550jp49SVzslLlC8JDSC9b 4DDWksWalgIaEHu9Kv1oXFZzPFOeHWLnKWh8vG7HyZS4HrfweXsbcNPaqF/lU+AL7huD fDug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 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 (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id f3si16236373qkf.49.2018.11.20.19.27.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Nov 2018 19:27:00 -0800 (PST) Received-SPF: pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ming.lei@redhat.com designates 209.132.183.28 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-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) 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 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));