• Naohiro Aota's avatar
    btrfs: scrub: run relocation repair when/only needed · 7192833c
    Naohiro Aota authored
    When btrfs scrub finds an error, it reads mirrors to find correct data. If
    all the errors are fixed, sctx->error_bitmap is cleared for the stripe
    range. However, in the zoned mode, it runs relocation to repair scrub
    errors when the bitmap is *not* empty, which is a flipped condition.
    
    Also, it runs the relocation even if the scrub is read-only. This was
    missed by a fix in commit 1f2030ff ("btrfs: scrub: respect the
    read-only flag during repair").
    
    The repair is only necessary when there is a repaired sector and should be
    done on read-write scrub. So, tweak the condition for both regular and
    zoned case.
    
    Fixes: 54765392 ("btrfs: scrub: introduce helper to queue a stripe for scrub")
    Fixes: 1f2030ff ("btrfs: scrub: respect the read-only flag during repair")
    CC: stable@vger.kernel.org # 6.6+
    Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
    Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
    Signed-off-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    7192833c
scrub.c 89.7 KB