From patchwork Wed Jun 27 12:45:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 10491429 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 BE9BA60325 for ; Wed, 27 Jun 2018 12:49:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AEC9B28C9A for ; Wed, 27 Jun 2018 12:49:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2EF928D8F; Wed, 27 Jun 2018 12:49:28 +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 850C128C9A for ; Wed, 27 Jun 2018 12:49:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8FBBB6B0288; Wed, 27 Jun 2018 08:49:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8AAEE6B028A; Wed, 27 Jun 2018 08:49:26 -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 7C23D6B028B; Wed, 27 Jun 2018 08:49:26 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt0-f198.google.com (mail-qt0-f198.google.com [209.85.216.198]) by kanga.kvack.org (Postfix) with ESMTP id 4EDAC6B0288 for ; Wed, 27 Jun 2018 08:49:26 -0400 (EDT) Received: by mail-qt0-f198.google.com with SMTP id f8-v6so1762929qtj.22 for ; Wed, 27 Jun 2018 05:49:26 -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=tuIc8U+AmrUw++LAC5CrBge73Vb8Oi4YpQc2ImVtxds=; b=J3YtzARgq2PuTAOcIH5bLZxdPciRe62dJ8AWa69fxut2Fv4JRvo1+rcmLdRk3vMga7 +uxR4TVHPiZ0989x6brxkzHZWDKDvuG2xDxPYCPeABBfAqzKUROHZgkrZ7vkbtIUUr79 lfvN9I3nNJWOULYdwVVlaPzwq4WHyzlYKX1r3cPggVk92k8lvN3HzTZvWYcnE8CoXqyG JkyHn/1/cd0wrEmkfqMFQf2gjcIpoPvYKpiz7bkWz4DQBnVaifXSBmZ+qpDogjDw5EGf hiRhWAwG4SL4ONRkqa0fGf9LK7/oTEUvtqtqZnx0xHwSNjLzyHt01dTd1I4hG/xHaY4X Tb/A== 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: APt69E2bFY5nK55dC07IFJNs9lceN/rF9Aj4NlRgF6Wngy16DCh1mUnC N4AY9I6NDIoPCUtM6V04LLBZSbiyThBWOI4lswHfPGPpGpGValWiU7UaCgbJOLnnYmdc+P2SG/A aXUMMzWW0qpQTRnQXxiYuVc2KI8r00o3Y4RccogqVTMF9ELW2lZcOU2bDCjuRLyqYNw== X-Received: by 2002:ac8:2e83:: with SMTP id h3-v6mr5163957qta.365.1530103766114; Wed, 27 Jun 2018 05:49:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcJbQFbzZ1NlEfFG7h2L4Kap4B+aXbaYEfejb2jBETT0HQDqp2A+hvStf9r1gq209A3GoU4 X-Received: by 2002:ac8:2e83:: with SMTP id h3-v6mr5163927qta.365.1530103765518; Wed, 27 Jun 2018 05:49:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530103765; cv=none; d=google.com; s=arc-20160816; b=xSpl9Fmd1lFoKjdDyZ23Ij664B4vugtiduswkWCCpP8BOX4lh86vU2IqB459k9vQn8 9PG8xMCbgHAnjCWjPG1g/1FX/kATVDpj2gVbk0WETKNnmtwJtzTNLl8ptKsFlQUZvarQ SGd+eFzaDKGqRI43+EqdR9x/jJ6KQljp1iBY6U/YqZKz5xUIQhdG1sXA9Lq8L6pFGb+t o0P5uTAV27LBzB51NAjB/LRENXbkMt6DRihPDjRzclKydz3bwOM9ZUwhfTb1g4T8XwpB veMZia3ZTKvJhFWC7wRNQokRZ/m6Sh1oZgGEJ9KUzIUDtJHlOna7UdPJppEn/BfqM/5+ Df0g== 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=tuIc8U+AmrUw++LAC5CrBge73Vb8Oi4YpQc2ImVtxds=; b=CSrlFooN0ZeRPd7XWAFW1BD6dm/djYsgN7IuIZ3rbY7SOzdktVoetlIThJodCR5LYc BIaB3MK93JXYR5MO85GKcFEVyGCM4Q9WGivsOkb/GMPsHkIETamJvJZnBgtmKgyDTZnc LTzx5W6jHxaCLhHZ6QlLIVOqgaKZiSibj33TLMa6xel0+QW3R1opeG7Qr/ltGfq2IYQG O0ZSayIle71zc2VmKVgA2HIS3TcNryTjH/AO+mnSFwvfQ5jAV/V1qjhu7pBHoD6vadYW lwHWW8WMewppUdf34wiAcFg77688epTR56LUwxBUKQ6r6p5Y7gvInzF7GDlKlzirFCml Fg5g== 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 32-v6si686720qvh.7.2018.06.27.05.49.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Jun 2018 05:49:25 -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-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2BE4B81A4EBC; Wed, 27 Jun 2018 12:49:25 +0000 (UTC) Received: from localhost (ovpn-12-44.pek2.redhat.com [10.72.12.44]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BD631117658; Wed, 27 Jun 2018 12:49:16 +0000 (UTC) From: Ming Lei To: Jens Axboe , Christoph Hellwig , Kent Overstreet Cc: David Sterba , Huang Ying , Mike Snitzer , 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 , Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org Subject: [PATCH V7 17/24] btrfs: move bio_pages_all() to btrfs Date: Wed, 27 Jun 2018 20:45:41 +0800 Message-Id: <20180627124548.3456-18-ming.lei@redhat.com> In-Reply-To: <20180627124548.3456-1-ming.lei@redhat.com> References: <20180627124548.3456-1-ming.lei@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 27 Jun 2018 12:49:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 27 Jun 2018 12:49:25 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.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 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: Chris Mason Cc: Josef Bacik Cc: David Sterba Cc: linux-btrfs@vger.kernel.org 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 0b5e07723f5f..9fce9f0793fe 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2356,6 +2356,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 @@ -2376,7 +2388,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);