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 0/5] btrfs: bs > ps support preparation
Date: Fri, 5 Sep 2025 19:47:16 +0200	[thread overview]
Message-ID: <20250905174716.GR5333@twin.jikos.cz> (raw)
In-Reply-To: <cover.1756803640.git.wqu@suse.com>

On Tue, Sep 02, 2025 at 06:32:11PM +0930, Qu Wenruo wrote:
> One of the blockage for bs > ps support is the conflicts between all the
> single-page bvec iterator/helpers (like memzero_bvec(),
> bio_for_each_segment() etc) and large folios (with highmem support).
> 
> For bs > ps support, all the folios will have a minimal order, so that
> each folio will cover at least one block. This saves the hassle of the
> fs to handle sub-block contents.
> 
> However for all those single-page bvec iterator/helpers, they can only
> handle a bvec that is no larger than a page.
> 
> To address the conflicting features, go a completely different way to
> handle a fs block:
> 
> - Use phys_addr_t to represent a block inside a bio
>   So we won't need to bother the sp bvec helpers, just pass a single
>   paddr around.
> 
> - Do proper highmem handling for checksum generation/verification
>   Now we will grab the folio from using the paddr, and make sure the
>   folio will cover at least one block starting at the paddr.
> 
>   If the folio is highmem, do proper per-page kmap_local_folio()/kunmap()
>   to handle highmem.
>   Otherwise do a full block csum calculation in one go.
> 
>   This should brings no extra overhead except the paddr->folio
>   conversion (which should be really tiny), as for systems without
>   HIGHMEM, folio_test_partial_kmap() will always return false, and the
>   HIGHMEM path will be optimized out by the compiler completely.
> 
>   Unfortunately I don't have a 32bit VM at hand to test.
> 
> - Introduce extra marcos to iterate blocks inside a bio
>   Two macros, btrfs_bio_for_each_block() which starts at the specified
>   bio_iter.
>   The other one, btrfs_bio_for_each_block_all() will go through all
>   blocks in the bio.
> 
>   Both returns a @paddr representing a block. Callers are either using
>   paddr based helper like
>   btrfs_calculate_block_csum()/btrfs_check_block_csum(), or RAID56 which
>   is already using paddr.
> 
>   For now it's only utilized by btrfs, bcachefs has a similar helper and
>   that's my inspiration.
> 
>   I hope one day it can be escalated to bio.h.
> 
> With all those preparation done, btrfs now can support basic file
> opeartions with bs > ps support, but still with quite some limits:
> 
> - No compression support
>   The compressed folios must be allocated using the minimal folio order.
>   As btrfs_calculate_block_csum() requires the minimal folio size.
> 
> - No RAID56 support
> - No scrub support
>   The same as compression, currently we're allocating the folios in page
>   size.
>   Although raid56 codes are now using the btrfs_bio_for_each_block*()
>   helpers, the underlying folio sizes still needs update.

Even with the limitations this is a good start. The changes look
reasonable, there are some minor things to consider but otherwise please
add it to for-next as you see fit. Regarding testing on 32bit it's
getting harder as the support in distros is fading out.

      parent reply	other threads:[~2025-09-05 17:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-02  9:02 [PATCH v2 0/5] btrfs: bs > ps support preparation Qu Wenruo
2025-09-02  9:02 ` [PATCH v2 1/5] btrfs: support all block sizes which is no larger than page size Qu Wenruo
2025-09-02  9:02 ` [PATCH v2 2/5] btrfs: concentrate highmem handling for data verification Qu Wenruo
2025-09-02  9:02 ` [PATCH v2 3/5] btrfs: introduce btrfs_bio_for_each_block() helper Qu Wenruo
2025-09-02  9:02 ` [PATCH v2 4/5] btrfs: introduce btrfs_bio_for_each_block_all() helper Qu Wenruo
2025-09-05 17:33   ` David Sterba
2025-09-05 22:08     ` Qu Wenruo
2025-09-08 17:44       ` David Sterba
2025-09-02  9:02 ` [PATCH v2 5/5] btrfs: cache max and min order inside btrfs_fs_info Qu Wenruo
2025-09-05 17:36   ` David Sterba
2025-09-06  8:47     ` Qu Wenruo
2025-09-05 17:47 ` David Sterba [this message]

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=20250905174716.GR5333@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