btrfs: scrub: make scrub uses less memory for metadata scrub
cover btrfs: scrub: make scrub uses less memory for metadata scrub
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. We need to do more work on data scrubing size to properly handle mutilpe sectors for non-RAID56 profiles.
The patchset requires the rename patchset.
(https://lore.kernel.org/linux-btrfs/[email protected]/)
If David is not happy with the big change again, at least first 3 patches can be considered as some cleanup.
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 | 399 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 270 insertions(+), 129 deletions(-)
Signature · 1 line
2.35.1
Quoted 36 lines · Qu Wenruo
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_sectorwill 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. We need to do more work on data scrubing size to properly handle mutilpe sectors for non-RAID56 profiles.
The patchset requires the rename patchset.
(https://lore.kernel.org/linux-btrfs/[email protected]/)If David is not happy with the big change again, at least first 3 patches can be considered as some cleanup.
Quoted 10 lines
Qu Wenruo (5):
btrfs: scrub: use pointer array to replace @sblocks_for_recheck
btrfs: extract the initialization ofscrub_blockinto a helper
function
btrfs: extract the allocation and initialization ofscrub_sectorinto
a helper
btrfs: scrub: introducescrub_block::pagesfor more efficient memory
usage for subpage
btrfs: scrub: removescrub_sector::pageand usescrub_block::pages
instead
Added to for-next as topic branch for now.
Quoted 48 lines · David Sterba
Quoted 36 lines · Qu Wenruo
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_sectorwill 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. We need to do more work on data scrubing size to properly handle mutilpe sectors for non-RAID56 profiles.
The patchset requires the rename patchset.
(https://lore.kernel.org/linux-btrfs/[email protected]/)If David is not happy with the big change again, at least first 3 patches can be considered as some cleanup.
Quoted 10 lines
Qu Wenruo (5):
btrfs: scrub: use pointer array to replace @sblocks_for_recheck
btrfs: extract the initialization ofscrub_blockinto a helper
function
btrfs: extract the allocation and initialization ofscrub_sectorinto
a helper
btrfs: scrub: introducescrub_block::pagesfor more efficient memory
usage for subpage
btrfs: scrub: removescrub_sector::pageand usescrub_block::pages
instead
Quoted 1 line
Added to for-next as topic branch for now.
I guess you replied to the wrong patch?
The for-next branch only contains the scrub entrance refactor v3.
No the renaming nor the subpage optimization.
Thanks,
Qu
Quoted 17 lines · Qu Wenruo
Quoted 17 lines
Quoted 16 lines
The patchset requires the rename patchset.
(https://lore.kernel.org/linux-btrfs/[email protected]/)If David is not happy with the big change again, at least first 3 patches can be considered as some cleanup.
Qu Wenruo (5):
btrfs: scrub: use pointer array to replace @sblocks_for_recheck
btrfs: extract the initialization ofscrub_blockinto a helper
function
btrfs: extract the allocation and initialization ofscrub_sectorinto
a helper
btrfs: scrub: introducescrub_block::pagesfor more efficient memory
usage for subpage
btrfs: scrub: removescrub_sector::pageand usescrub_block::pages
instead
Quoted 3 lines
Quoted 1 line
Added to for-next as topic branch for now.
I guess you replied to the wrong patch?
Yeah.
Quoted 3 lines
The for-next branch only contains the scrub entrance refactor v3.
No the renaming nor the subpage optimization.
The scrub renaming is in misc-next, please refresh this patchset, thanks.
Quoted 36 lines · Qu Wenruo
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_sectorwill 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. We need to do more work on data scrubing size to properly handle mutilpe sectors for non-RAID56 profiles.
The patchset requires the rename patchset.
(https://lore.kernel.org/linux-btrfs/[email protected]/)If David is not happy with the big change again, at least first 3 patches can be considered as some cleanup.
Quoted 10 lines
Qu Wenruo (5):
btrfs: scrub: use pointer array to replace @sblocks_for_recheck
btrfs: extract the initialization ofscrub_blockinto a helper
function
btrfs: extract the allocation and initialization ofscrub_sectorinto
a helper
btrfs: scrub: introducescrub_block::pagesfor more efficient memory
usage for subpage
btrfs: scrub: removescrub_sector::pageand usescrub_block::pages
instead
This patchset still seems relevant, but does not apply after recent changes. Please refresh and resend, thanks.