]> git.hungrycats.org Git - linux/commit
btrfs: add stripe_len < PAGE_SIZE support for alloc_rbio_*_pages()
authorQu Wenruo <wqu@suse.com>
Thu, 22 Oct 2026 09:39:29 +0000 (20:09 +1030)
committerDavid Sterba <dsterba@suse.com>
Fri, 30 Oct 2026 20:36:19 +0000 (21:36 +0100)
commitea5a5aed7d1a91bb7512d2d89f97f74151dfa698
treecaef0a8b818959add54d63445802ada3d98196f1
parent40092765f8b51f7c91ef3421f2302c35156f82e0
btrfs: add stripe_len < PAGE_SIZE support for alloc_rbio_*_pages()

The functions alloc_rbio_parity_pages() and alloc_rbio_data_pages()
didn't support stripe_len < PAGE_SIZE cases, and fallback to
alloc_rbio_pages() instead.

That's mostly to avoid the case where both data and P/Q blocks can exist
in the same page.

However even in that case, it's not a big deal, the existing
infrastructures like index_stripe_sectors() can handle it correctly.

Update those functions to support stripe_len < PAGE_SIZE cases, with two
points to note:

- Extra attention needed for the round direction
  For alloc_rbio_data_pages() we need to round up, so the last data page
  gets allocated.

  For alloc_rbio_parity_pages() we need to round down, so the first
  P/Q page get allocated.

- Mixed page allocation
  We can call alloc_rbio_parity_pages() first, then
  alloc_rbio_data_pages().

  In that case, it's alloc_pages_bulk() saving us, which always skips
  allocated slot. Thus we're still safe.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/raid56.c