All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/16] btrfs: add subpage support for RAID56
@ 2022-04-01 11:23 Qu Wenruo
  2022-04-01 11:23 ` [PATCH 01/16] btrfs: open-code rbio_nr_pages() Qu Wenruo
                   ` (16 more replies)
  0 siblings, 17 replies; 33+ messages in thread
From: Qu Wenruo @ 2022-04-01 11:23 UTC (permalink / raw)
  To: linux-btrfs

The branch can be fetched from github, based on a slightly older
misc-next branch:
https://github.com/adam900710/linux/tree/subpage_raid56

[DESIGN]
To make RAID56 code to support subpage, we need to make every sector of
a RAID56 full stripe (including P/Q) to be addressable.

Previously we use page pointer directly for things like stripe_pages:

Full stripe is 64K * 3, 2 data stripes, one P stripe (RAID5)

stripe_pages:   | 0 | 1 | 2 |  .. | 46 | 47 |

Those 48 pages all points to a page we allocated.


The new subpage support will introduce a sector layer, based on the old
stripe_pages[] array:

The same 64K * 3, RAID5 layout, but 64K page size and 4K sector size:

stripe_sectors: | 0 | 1 | .. |15 |16 |  ...  |31 |32 | ..    |47 |
stripe_pages:   |      Page 0    |     Page 1    |    Page 2     |

Each stripe_ptr of stripe_sectors[] will include:

- One page pointer
  Points back the page inside stripe_pages[].

- One pgoff member
  To indicate the offset inside the page

- One uptodate member
  To indicate if the sector is uptodate, replacing the old PageUptodate
  flag.
  As introducing btrfs_subpage structure to stripe_pages[] looks a
  little overkilled, as we only care Uptodate flag.

The same applies to bio_sectors[] array, which is going to completely
replace the old bio_pages[] array.

[SIDE EFFECT]
Despite the obvious new ability for subpage to utilize btrfs RAID56
profiles, it will cause more memory usage for real btrfs_raid_bio
structure.

We allocate extra memory based on the stripe size and number of stripes,
and update the pointer arrays to utilize the extra memory.

To compare, we use a pretty standard setup, 3 disks raid5, 4K page size
on x86_64:

 Before: 1176
 After:  2032 (+72.8%)

The reason for such a big bump is:

- Extra size for sector_ptr.
  Instead of just a page pointer, now it's twice the size of a pointer
  (a page pointer + 2 * unsigned int)

  This means although we replace bio_pages[] with bio_sectors[], we are
  still enlarging the size.

- A completely new array for stripe_sectors[]
  And the array itself is also twice the size of the old stripe_pages[].

There is some attempt to reduce the size of btrfs_raid_bio itself, but
the big impact still comes from the new sector_ptr arrays.

I have tried my best to reduce the size, by compacting the sector_ptr
structure.
Without exotic macros, I don't have any better ideas on reducing the
real size of btrfs_raid_bio.

[TESTS]
Full fstests are run on both x86_64 and aarch64.
No new regressions found.
(In fact several regressions found during development, all fixed).

[PATCHSET LAYOUT]
The patchset layout puts several things into consideration:

- Every patch can be tested independently on x86_64
  No more tons of unused helpers then a big switch.
  Every change can be verified on x86_64.

- More temporary sanity checks than previous code
  For example, when rbio_add_io_page() is converted to be subpage
  compatible, extra ASSERT() is added to ensure no subpage range
  can even be added.

  Such temporary checks are removed in the last enablement patch.
  This is to make testing on x86_64 more comprehensive.

- Mostly small change in each patch
  The only exception is the conversion for rbio_add_io_page().
  But the most change in that patch comes from variable renaming.
  The overall line changed in each patch should still be small enough
  for review.

Qu Wenruo (16):
  btrfs: open-code rbio_nr_pages()
  btrfs: make btrfs_raid_bio more compact
  btrfs: introduce new cached members for btrfs_raid_bio
  btrfs: introduce btrfs_raid_bio::stripe_sectors
  btrfs: introduce btrfs_raid_bio::bio_sectors
  btrfs: make rbio_add_io_page() subpage compatible
  btrfs: make finish_parity_scrub() subpage compatible
  btrfs: make __raid_recover_endio_io() subpage compatibable
  btrfs: make finish_rmw() subpage compatible
  btrfs: open-code rbio_stripe_page_index()
  btrfs: make raid56_add_scrub_pages() subpage compatible
  btrfs: remove btrfs_raid_bio::bio_pages array
  btrfs: make set_bio_pages_uptodate() subpage compatible
  btrfs: make steal_rbio() subpage compatible
  btrfs: make alloc_rbio_essential_pages() subpage compatible
  btrfs: enable subpage support for RAID56

 fs/btrfs/disk-io.c |   8 -
 fs/btrfs/raid56.c  | 748 ++++++++++++++++++++++++++++-----------------
 fs/btrfs/raid56.h  |   2 +-
 fs/btrfs/scrub.c   |   6 +-
 fs/btrfs/volumes.c |   7 -
 5 files changed, 467 insertions(+), 304 deletions(-)

-- 
2.35.1


^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2022-04-12 10:01 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-01 11:23 [PATCH 00/16] btrfs: add subpage support for RAID56 Qu Wenruo
2022-04-01 11:23 ` [PATCH 01/16] btrfs: open-code rbio_nr_pages() Qu Wenruo
2022-04-01 11:23 ` [PATCH 02/16] btrfs: make btrfs_raid_bio more compact Qu Wenruo
2022-04-01 11:23 ` [PATCH 03/16] btrfs: introduce new cached members for btrfs_raid_bio Qu Wenruo
2022-04-11 10:29   ` Geert Uytterhoeven
2022-04-11 11:09     ` Qu Wenruo
2022-04-01 11:23 ` [PATCH 04/16] btrfs: introduce btrfs_raid_bio::stripe_sectors Qu Wenruo
2022-04-08 16:40   ` David Sterba
2022-04-08 22:55     ` Qu Wenruo
2022-04-01 11:23 ` [PATCH 05/16] btrfs: introduce btrfs_raid_bio::bio_sectors Qu Wenruo
2022-04-08 16:46   ` David Sterba
2022-04-08 22:58     ` Qu Wenruo
2022-04-11 14:35       ` David Sterba
2022-04-01 11:23 ` [PATCH 06/16] btrfs: make rbio_add_io_page() subpage compatible Qu Wenruo
2022-04-01 11:23 ` [PATCH 07/16] btrfs: make finish_parity_scrub() " Qu Wenruo
2022-04-08 17:04   ` David Sterba
2022-04-08 22:59     ` Qu Wenruo
2022-04-11 14:36       ` David Sterba
2022-04-11 14:46         ` David Sterba
2022-04-01 11:23 ` [PATCH 08/16] btrfs: make __raid_recover_endio_io() subpage compatibable Qu Wenruo
2022-04-01 11:23 ` [PATCH 09/16] btrfs: make finish_rmw() subpage compatible Qu Wenruo
2022-04-11 17:00   ` Christoph Hellwig
2022-04-11 22:24     ` Qu Wenruo
2022-04-01 11:23 ` [PATCH 10/16] btrfs: open-code rbio_stripe_page_index() Qu Wenruo
2022-04-08 17:28   ` David Sterba
2022-04-01 11:23 ` [PATCH 11/16] btrfs: make raid56_add_scrub_pages() subpage compatible Qu Wenruo
2022-04-01 11:23 ` [PATCH 12/16] btrfs: remove btrfs_raid_bio::bio_pages array Qu Wenruo
2022-04-01 11:23 ` [PATCH 13/16] btrfs: make set_bio_pages_uptodate() subpage compatible Qu Wenruo
2022-04-01 11:23 ` [PATCH 14/16] btrfs: make steal_rbio() " Qu Wenruo
2022-04-01 11:23 ` [PATCH 15/16] btrfs: make alloc_rbio_essential_pages() " Qu Wenruo
2022-04-01 11:23 ` [PATCH 16/16] btrfs: enable subpage support for RAID56 Qu Wenruo
2022-04-08 18:16 ` [PATCH 00/16] btrfs: add " David Sterba
2022-04-12  7:15   ` Qu Wenruo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.