linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/5] btrfs: scrub: make scrub uses less memory for metadata scrub
@ 2022-07-19  7:24 Qu Wenruo
  2022-07-19  7:24 ` [PATCH v2 1/5] btrfs: scrub: use pointer array to replace @sblocks_for_recheck Qu Wenruo
                   ` (5 more replies)
  0 siblings, 6 replies; 9+ messages in thread
From: Qu Wenruo @ 2022-07-19  7:24 UTC (permalink / raw)
  To: linux-btrfs

[Changelog]
v2:
- Rebased to latest misc-next
  The conflicts are mostly from the member renaming.
  Has re-ran the tests on both aarch64 64K page size, and x86_64.
  For both scrub and replace groups.


Although btrfs scrub works for subpage from day one, it has a small
pitfall:

  Scrub will always allocate a full page for each sector.

This causes increased memory usage, although not a big deal, it's still
not ideal.

The patchset will change the behavior by integrating all pages into
scrub_block::pages[], instead of using scrub_sector::page.

Now scrub_sector will no longer hold a page pointer, but uses its
logical bytenr to caculate which page and page range it should use.

This behavior unfortunately still only affects memory usage on metadata
scrub, which uses nodesize for scrub.

For the best case, 64K node size with 64K page size, we waste no memory
to scrub one tree block.

For the worst case, 4K node size with 64K page size, we are no worse
than the existing behavior (still one 64K page for the tree block)

For the default case (16K nodesize), we use one 64K page, compared to
4x64K pages previously.

For data scrubing, we uses sector size, thus it causes no difference.
In the future, we may want to enlarge the data scrub size so that
subpage can waste less memory.

[PATCHSET STRUCTURE]
The first 3 patches are just cleanups, mostly to make scrub_sector
allocation much easier.

The 4th patch is to introduce the new page array for sblock, and
the last one to completely remove the usage of scrub_sector::page.

Qu Wenruo (5):
  btrfs: scrub: use pointer array to replace @sblocks_for_recheck
  btrfs: extract the initialization of scrub_block into a helper
    function
  btrfs: extract the allocation and initialization of scrub_sector into
    a helper
  btrfs: scrub: introduce scrub_block::pages for more efficient memory
    usage for subpage
  btrfs: scrub: remove scrub_sector::page and use scrub_block::pages
    instead

 fs/btrfs/scrub.c | 398 +++++++++++++++++++++++++++++++----------------
 1 file changed, 266 insertions(+), 132 deletions(-)

-- 
2.37.0


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

end of thread, other threads:[~2022-09-06 17:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-19  7:24 [PATCH v2 0/5] btrfs: scrub: make scrub uses less memory for metadata scrub Qu Wenruo
2022-07-19  7:24 ` [PATCH v2 1/5] btrfs: scrub: use pointer array to replace @sblocks_for_recheck Qu Wenruo
2022-07-19  7:24 ` [PATCH v2 2/5] btrfs: extract the initialization of scrub_block into a helper function Qu Wenruo
2022-07-19  7:24 ` [PATCH v2 3/5] btrfs: extract the allocation and initialization of scrub_sector into a helper Qu Wenruo
2022-07-19  7:24 ` [PATCH v2 4/5] btrfs: scrub: introduce scrub_block::pages for more efficient memory usage for subpage Qu Wenruo
2022-07-26 18:08   ` David Sterba
2022-07-19  7:24 ` [PATCH v2 5/5] btrfs: scrub: remove scrub_sector::page and use scrub_block::pages instead Qu Wenruo
2022-08-05  6:32 ` [PATCH v2 0/5] btrfs: scrub: make scrub uses less memory for metadata scrub Qu Wenruo
2022-09-06 16:52   ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).