From patchwork Thu Nov 15 08:52: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: 10683781 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 3F8A814D6 for ; Thu, 15 Nov 2018 08:55:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B3D7299C2 for ; Thu, 15 Nov 2018 08:55:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F41F2B334; Thu, 15 Nov 2018 08:55:38 +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=unavailable 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 B1325299C2 for ; Thu, 15 Nov 2018 08:55:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E350D6B027B; Thu, 15 Nov 2018 03:55:36 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DE3CD6B027C; Thu, 15 Nov 2018 03:55:36 -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 CFAA86B027D; Thu, 15 Nov 2018 03:55:36 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by kanga.kvack.org (Postfix) with ESMTP id A2AAE6B027B for ; Thu, 15 Nov 2018 03:55:36 -0500 (EST) Received: by mail-qk1-f197.google.com with SMTP id s19so43892036qke.20 for ; Thu, 15 Nov 2018 00:55:36 -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=tM2fCUTiqNJ83ZUHUFDg+ZAzp2ZS8MMRbJFFzEGHe40=; b=Iw7PbkiWGyU0aeHq9bnY92+MQP7Ru60MKxfzk/WPanfhTFOuSmAgIldh9fTMS3Nvt6 FG7YzfpfXFDpy645i4DqsGTt2BC5yKfGlDm+i2afp2m1Hb8yLcW1lN5FAIEkIF+zRLZo qjOdaiAA2FM9m6aWha1AOIq1+Xeo5cmumylV6qzmugoBotRNxp8mYlpOo+a7ZnYUzlyr lEb26+V1grUswYxODp1kKj8ofC30KDGYsVb8IkUGFkA6dKqIPA3+OxIUTwSwisADOwQG 5a8evDH7H7/TA5Z2YHILcclXySnjmEJ7Xq6GZRkandRZiHp3wMfmBp7DmX9etdfDWK75 4gsQ== 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: AGRZ1gKC9V2EQYZ/2XqQ2tsilELpOAuV9ikxH9Gzhl+qHOmVDXtZSHrK p97xtnG5lGuF+mwIPYdWzFHEPYgGlCUomLcIJyoF/k58wfpkS41pfgw43xA+nn1bVRthUbR+Ivc V1ld8L2n+G1lIUiFVGrEmEXdOjuXwH2S+2luNrkCko5qqaGlvCXmiGavEV93MYjID/w== X-Received: by 2002:a37:7d05:: with SMTP id y5mr4909065qkc.310.1542272136417; Thu, 15 Nov 2018 00:55:36 -0800 (PST) X-Google-Smtp-Source: AJdET5eoyWn5ax+N91csBu0mayQ9DNJrVeb0R2Xxqbdcux0uGdnjRm2N4bkHNz07X4T/MzELE8b7 X-Received: by 2002:a37:7d05:: with SMTP id y5mr4909041qkc.310.1542272135756; Thu, 15 Nov 2018 00:55:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542272135; cv=none; d=google.com; s=arc-20160816; b=s7y9R9yR1ZdMEp3MGvsQHSOAsB967IvFKIzgp1IGOUc5xNGiLxlwUMch0FxBqlA486 1fj53qL5N2D3mqD2PSbdoXZ33lebZfp37/sfOb54f9wOoYUomrOoloaPdC7mY2SmYhrH 1ybGCl5ILg3nT1dOxG+2lS/kw1dAhTG8IISEVaRqiprgja1SxZi9Sk68UXjz7BO3rX9n SzMnCexG+TTUEvdwhh2auuUhSyV2xZwcDI4rMHvhBQSiv/Y/FY1ef8NnKPXbJNisMo3d shuRLkDHhBbUbbh/kclpBib4Y+2htIeo/JejedSTY29boEh6uWU7AlKNl/9WmEczmFhK dp2w== 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=tM2fCUTiqNJ83ZUHUFDg+ZAzp2ZS8MMRbJFFzEGHe40=; b=iUN4NEDDgPEorx8o/zwDNPbeWP63dj8snjoQxRoOKljhjPQSsTnlGqHSdSjxXho2sJ sVdWdQz6IooDaXTYHUm2T4i75F/ulCmK9sSl0cPeYZXMvc2nw0lqKsWwv7J+YNKOcRpp JiqdRQe4x27NSCJgLvHewh8N0LAfkqZjwN+Qmkyd1cLu0Fv7dxez5wSNf9SNVtDA+MKv EWbhGyUHwXPAueu6Z1zVgIqP196utyE+zK4Sx4El/WhxgC3KodjWgl5uPqC/ksAOBj3c 0IPcp+p6gOWbEievo5MQAmele2kdpXRjFm3Sd00IiATLHB9Xe/mcwioWxGE95KvlMWgp ruNQ== 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 x2si3058711qvp.94.2018.11.15.00.55.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 00:55:35 -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-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) 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. 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);