Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CEA2C64EC4 for ; Fri, 10 Mar 2023 07:35:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229597AbjCJHfx (ORCPT ); Fri, 10 Mar 2023 02:35:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229952AbjCJHfi (ORCPT ); Fri, 10 Mar 2023 02:35:38 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5E54E63C6 for ; Thu, 9 Mar 2023 23:35:36 -0800 (PST) Received: from [0.0.0.0] ([149.28.201.231]) by mail.gmx.net (mrgmx104 [212.227.17.174]) with ESMTPSA (Nemesis) id 1Mlf0U-1qHsjD2wz4-00ii2v; Fri, 10 Mar 2023 08:35:30 +0100 Message-ID: <659eecea-d5fd-a966-d073-9dd85e34db60@gmx.com> Date: Fri, 10 Mar 2023 15:35:26 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.0 Content-Language: en-US To: Christoph Hellwig , Chris Mason , Josef Bacik , David Sterba Cc: linux-btrfs@vger.kernel.org References: <20230309090526.332550-1-hch@lst.de> <20230309090526.332550-5-hch@lst.de> From: Qu Wenruo Subject: Re: [PATCH 04/20] btrfs: always read the entire extent_buffer In-Reply-To: <20230309090526.332550-5-hch@lst.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:YBCJqtyCgu+6o74nCFXHJc9NuktVGGsgHkKF3IMMLoojQHk3OKz uIIJIFXwP5MO3Osumxv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pqV4OpPyKur0QP/pcx23/ 9/J/pjysFxDaE11xpQtceWvwvaDDHn34RmyZYP/OlXAmSGKJohGbR1ZOkYN6Wuu8zp+aM/yq3 rixigEQTx0I4EzxgrckOQygWdn8= Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On 2023/3/9 17:05, Christoph Hellwig wrote: > Currently read_extent_buffer_pages skips pages that are already uptodate > when reading in an extent_buffer. While this reduces the amount of data > read, it increases the number of I/O operations as we now need to do > multiple I/Os when reading an extent buffer with one or more uptodate > pages in the middle of it. On any modern storage device, be that hard > drives or SSDs this actually decreases I/O performance. Fortunately > this case is pretty rare as the pages are always initially read together > and then aged the same way. > Besides simplifying the code a bit as-is > this will allow for major simplifications to the I/O completion handler > later on. > > Note that the case where all pages are uptodate is still handled by an > optimized fast path that does not read any data from disk. > > Signed-off-by: Christoph Hellwig Reviewed-by: Qu Wenruo Thanks, Qu > --- > fs/btrfs/extent_io.c | 17 +++++------------ > 1 file changed, 5 insertions(+), 12 deletions(-) > > diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c > index 302af9b01bda2a..26d8162bee000d 100644 > --- a/fs/btrfs/extent_io.c > +++ b/fs/btrfs/extent_io.c > @@ -4313,7 +4313,6 @@ int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num, > int locked_pages = 0; > int all_uptodate = 1; > int num_pages; > - unsigned long num_reads = 0; > struct btrfs_bio_ctrl bio_ctrl = { > .opf = REQ_OP_READ, > .mirror_num = mirror_num, > @@ -4359,10 +4358,8 @@ int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num, > */ > for (i = 0; i < num_pages; i++) { > page = eb->pages[i]; > - if (!PageUptodate(page)) { > - num_reads++; > + if (!PageUptodate(page)) > all_uptodate = 0; > - } > } > > if (all_uptodate) { > @@ -4372,7 +4369,7 @@ int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num, > > clear_bit(EXTENT_BUFFER_READ_ERR, &eb->bflags); > eb->read_mirror = 0; > - atomic_set(&eb->io_pages, num_reads); > + atomic_set(&eb->io_pages, num_pages); > /* > * It is possible for release_folio to clear the TREE_REF bit before we > * set io_pages. See check_buffer_tree_ref for a more detailed comment. > @@ -4382,13 +4379,9 @@ int read_extent_buffer_pages(struct extent_buffer *eb, int wait, int mirror_num, > for (i = 0; i < num_pages; i++) { > page = eb->pages[i]; > > - if (!PageUptodate(page)) { > - ClearPageError(page); > - submit_extent_page(&bio_ctrl, page_offset(page), page, > - PAGE_SIZE, 0); > - } else { > - unlock_page(page); > - } > + ClearPageError(page); > + submit_extent_page(&bio_ctrl, page_offset(page), page, > + PAGE_SIZE, 0); > } > > submit_one_bio(&bio_ctrl);