• Qu Wenruo's avatar
    btrfs: scrub: introduce scrub_block::pages for more efficient memory usage for subpage · f3e01e0e
    Qu Wenruo authored
    [BACKGROUND]
    Currently for scrub, we allocate one page for one sector, this is fine
    for PAGE_SIZE == sectorsize support, but can waste extra memory for
    subpage support.
    
    [CODE CHANGE]
    Make scrub_block contain all the pages, so if we're scrubbing an extent
    sized 64K, and our page size is also 64K, we only need to allocate one
    page.
    
    [LIFESPAN CHANGE]
    Since now scrub_sector no longer holds a page, but is using
    scrub_block::pages[] instead, we have to ensure scrub_block has a longer
    lifespan for write bio. The lifespan for read bio is already large
    enough.
    
    Now scrub_block will only be released after the write bio finished.
    
    [COMING NEXT]
    Currently we only added scrub_block::pages[] for this purpose, but
    scrub_sector is still utilizing the old scrub_sector::page.
    
    The switch will happen in the next patch.
    Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    f3e01e0e
scrub.c 122 KB