]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: use the global rsv size in the preemptive thresh calculation
authorJosef Bacik <josef@toxicpanda.com>
Wed, 28 Apr 2021 17:38:45 +0000 (13:38 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jun 2021 13:19:04 +0000 (15:19 +0200)
commit9fa4cfb175513e4d5e3d2dc992f1ed70d61f0bb6
tree6966e7d0c76f4aedfc9d4fe43dd1c6c9725e7543
parentbadd8e37904ff893fae50598284cfeea9c9f4962
btrfs: use the global rsv size in the preemptive thresh calculation

We calculate the amount of "free" space available for normal
reservations by taking the total space and subtracting out the hard used
space, which is readonly, used, and reserved space.

However we weren't taking into account the global block rsv, which is
essentially hard used space.  Handle this by subtracting it from the
available free space, so that our threshold more closely mirrors
reality.

We need to do the check because it's possible that the global_rsv_size +
used is > total_bytes, sometimes the global reserve can end up being
calculated as larger than the available size (think small filesystems
where we only have the original 8MiB chunk of metadata).  It doesn't
usually happen, but that can get us into trouble so this is safer.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/space-info.c