• Q
    btrfs: scrub: use pointer array to replace sblocks_for_recheck · 1dfa5005
    Qu Wenruo 提交于
    In function scrub_handle_errored_block(), we use @sblocks_for_recheck
    pointer to hold one scrub_block for each mirror, and uses kcalloc() to
    allocate an array.
    
    But this one pointer for an array is not readable due to the member
    offsets done by addition and not [].
    
    Change this pointer to struct scrub_block *[BTRFS_MAX_MIRRORS], this
    will slightly increase the stack memory usage.
    
    Since function scrub_handle_errored_block() won't get iterative calls,
    this extra cost would completely be acceptable.
    
    And since we're here, also set sblock->refs and use scrub_block_put() to
    clean them up, as later we will add extra members in scrub_block, which
    needs scrub_block_put() to clean them up.
    Signed-off-by: NQu Wenruo <wqu@suse.com>
    Reviewed-by: NDavid Sterba <dsterba@suse.com>
    Signed-off-by: NDavid Sterba <dsterba@suse.com>
    1dfa5005
scrub.c 120.3 KB