• Dennis Zhou's avatar
    btrfs: add correction to handle -1 edge case in async discard · 81b29a3b
    Dennis Zhou authored
    From Dave's testing described below, it's possible to drive a file
    system to have bogus values of discardable_extents and _bytes.  As
    btrfs_discard_calc_delay() is the only user of discardable_extents, we
    can correct here for any negative discardable_extents/discardable_bytes.
    
    The problem is not reliably reproducible. The workload that created it
    was based on linux git tree, switching between release tags, then
    everytihng deleted followed by a full rebalance. At this state the
    values of discardable_bytes was 16K and discardable_extents was -1,
    expected values 0 and 0.
    
    Repeating the workload again did not correct the bogus values so the
    offset seems to be stable once it happens.
    Reported-by: default avatarDavid Sterba <dsterba@suse.com>
    Signed-off-by: default avatarDennis Zhou <dennis@kernel.org>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    81b29a3b
discard.c 22.4 KB