]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: add correction to handle -1 edge case in async discard
authorDennis Zhou <dennis@kernel.org>
Thu, 2 Jan 2020 21:26:46 +0000 (16:26 -0500)
committerDavid Sterba <dsterba@suse.com>
Mon, 20 Jan 2020 15:41:01 +0000 (16:41 +0100)
commit3ffc28d9f5266172ef2b60da94a5a0c4e7fb83bf
tree2fe26501894495a31b10a55b90b11d1e8718d808
parent26b43c0a0c2e7881fb0c5e3b88db671a0ea01e8a
btrfs: add correction to handle -1 edge case in async discard

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: David Sterba <dsterba@suse.com>
Signed-off-by: Dennis Zhou <dennis@kernel.org>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/discard.c