]> git.hungrycats.org Git - linux/commit
btrfs: add stripe_len < PAGE_SIZE support for steal_rbio()
authorQu Wenruo <wqu@suse.com>
Thu, 22 Oct 2026 09:39:28 +0000 (20:09 +1030)
committerQu Wenruo <wqu@suse.com>
Mon, 26 Oct 2026 21:49:32 +0000 (08:19 +1030)
commit92e3cae8de942bedf5e19338d393cf4b71b8ffac
tree500c5e4f84463d83f5c906eb3fec4fb77035e3b4
parent1d282fa41c878b98eab6b9acf32ef5f8842526a2
btrfs: add stripe_len < PAGE_SIZE support for steal_rbio()

The function steal_rbio() is utilized to use the pages that belongs to
uptodate data blocks, without doing a page copy.

That is done by just updating the dest->stripe_pages[] pointer to use
the point inside @src directly.

That function previously will reject stripe_len < PAGE_SIZE cases, as a
page can contain both data and P/Q blocks.

But that shouldn't be a big deal, as long as the corresponding P/Q
blocks are not marked uptodate, we can still steal the page that also
contains P/Q blocks.

So rework steal_rbio() to support stripe_len < PAGE_SIZE by:

- Calculate the last page index correctly
  Instead of iterating all pages but skip P/Q pages, calculate the last
  page index properly.

  The last page may contain both data and P/Q blocks, but we can still
  steal the page.

- Update the bitmap in one go
  Instead of updating the stripe_uptodate_bitmap for every page, we can
  do the update in just one go, out of the main loop.

  And that update should not touch the P/Q blocks.

- Remove unused helpers
  * page_nr_to_sector_nr()
  * page_nr_to_num_sectors()
  * steal_rbio_page()
  * is_data_stripe_page()

  * full_page_sectors_uptodate()
    This one is very annoying, because of its __maybe_unused
    attribution.

  They are based on the old BTRFS_STRIPE_LEN >= PAGE_SIZE assumption,
  and no longer utilized.

- Make index_stripe_sectors() update the stripe_paddrs[] without a page
  This doesn't cause any functional change for now, as there is no one
  accessing the source stripe_paddrs[] after a steal.

  But this should still make the function a little more robust.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
fs/btrfs/raid56.c