]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: take overcommit into account in inc_block_group_ro
authorJosef Bacik <josef@toxicpanda.com>
Fri, 17 Jan 2020 14:07:39 +0000 (09:07 -0500)
committerDavid Sterba <dsterba@suse.com>
Fri, 31 Jan 2020 13:02:01 +0000 (14:02 +0100)
commit75d6ac8185e70a533c395f07d5e6c58e3528228b
tree79aae74bcef4811226ad97d5247909f89a9c63bb
parent6fd4237f80eb123efeba62892850a94bd068cfaa
btrfs: take overcommit into account in inc_block_group_ro

inc_block_group_ro does a calculation to see if we have enough room left
over if we mark this block group as read only in order to see if it's ok
to mark the block group as read only.

The problem is this calculation _only_ works for data, where our used is
always less than our total.  For metadata we will overcommit, so this
will almost always fail for metadata.

Fix this by exporting btrfs_can_overcommit, and then see if we have
enough space to remove the remaining free space in the block group we
are trying to mark read only.  If we do then we can mark this block
group as read only.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/block-group.c
fs/btrfs/space-info.c
fs/btrfs/space-info.h