• Qu Wenruo's avatar
    btrfs: scrub: try harder to mark RAID56 block groups read-only · 7561551e
    Qu Wenruo authored
    Currently we allow a block group not to be marked read-only for scrub.
    
    But for RAID56 block groups if we require the block group to be
    read-only, then we're allowed to use cached content from scrub stripe to
    reduce unnecessary RAID56 reads.
    
    So this patch would:
    
    - Make btrfs_inc_block_group_ro() try harder
      During my tests, for cases like btrfs/061 and btrfs/064, we can hit
      ENOSPC from btrfs_inc_block_group_ro() calls during scrub.
    
      The reason is if we only have one single data chunk, and trying to
      scrub it, we won't have any space left for any newer data writes.
    
      But this check should be done by the caller, especially for scrub
      cases we only temporarily mark the chunk read-only.
      And newer data writes would always try to allocate a new data chunk
      when needed.
    
    - Return error for scrub if we failed to mark a RAID56 chunk read-only
    Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    7561551e
scrub.c 85.5 KB