public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 2/3] btrfs: make btrfs_do_readpage() to do block-by-block read
Date: Tue, 25 Feb 2025 14:04:33 +0100	[thread overview]
Message-ID: <20250225130433.GP5777@twin.jikos.cz> (raw)
In-Reply-To: <14cfa9f204c6f2f840b87102f59e8343559f03d6.1739328504.git.wqu@suse.com>

On Wed, Feb 12, 2025 at 01:22:46PM +1030, Qu Wenruo wrote:
> Currently if a btrfs has block size (the older sector size) < page size,
> btrfs_do_readpage() will handle the range extent by extent, this is good
> for performance as it doesn't need to re-lookup the same extent map again
> and again.
> (Although __get_extent_map() already does extra cached em check, thus

Minor thing, __get_extent_map has been renamed to get_extent_map.

> the optimization is not that obvious)
> 
> This is totally fine and is a valid optimization, but it has an
> assumption that, there is no partial uptodate range in the page.
> 
> Meanwhile there is an incoming feature, requiring btrfs to skip the full
> page read if a buffered write range covers a full block but not a full
> page.
> 
> In that case, we can have a page that is partially uptodate, and the
> current per-extent lookup can not handle such case.
> 
> So here we change btrfs_do_readpage() to do block-by-block read, this
> simplifies the following things:
> 
> - Remove the need for @iosize variable
>   Because we just use sectorsize as our increment.
> 
> - Remove @pg_offset, and calculate it inside the loop when needed
>   It's just offset_in_folio().
> 
> - Use a for() loop instead of a while() loop
> 
> This will slightly reduce the read performance for
> block size < page size cases, but for the future where we can skip a
> full page read for a lot of cases, it should still be worthy.
> 
> For block size == page size, this brings no performance change.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>

  reply	other threads:[~2025-02-25 13:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-12  2:52 [PATCH v2 0/3] btrfs: enhancement to pass generic/563 Qu Wenruo
2025-02-12  2:52 ` [PATCH v2 1/3] btrfs: introduce a read path dedicated extent lock helper Qu Wenruo
2025-02-25 13:00   ` David Sterba
2025-02-26  0:04     ` Qu Wenruo
2025-02-12  2:52 ` [PATCH v2 2/3] btrfs: make btrfs_do_readpage() to do block-by-block read Qu Wenruo
2025-02-25 13:04   ` David Sterba [this message]
2025-02-12  2:52 ` [PATCH v2 3/3] btrfs: allow buffered write to avoid full page read if it's block aligned Qu Wenruo
2025-02-25 13:05   ` David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250225130433.GP5777@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox