• Qu Wenruo's avatar
    btrfs: scrub: refactor scrub_raid56_parity() · 9ae53bf9
    Qu Wenruo authored
    Currently scrub_raid56_parity() has a large double loop, handling the
    following things at the same time:
    
    - Iterate each data stripe
    - Iterate each extent item in one data stripe
    
    Refactor this by:
    
    - Introduce a new helper to handle data stripe iteration
      The new helper is scrub_raid56_data_stripe_for_parity(), which
      only has one while() loop handling the extent items inside the
      data stripe.
    
      The code is still mostly the same as the old code.
    
    - Call cond_resched() for each extent
      Previously we only call cond_resched() under a complex if () check.
      I see no special reason to do that, and for other scrub functions,
      like scrub_simple_mirror() we're already doing the same cond_resched()
      after scrubbing one extent.
    
    - Add more comments
    
    Please note that, this patch is only to address the double loop, there
    are incoming patches to do extra cleanup.
    Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    9ae53bf9
scrub.c 120 KB