mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 12:42:02 +00:00
btrfs: calculate the right space for a single delayed ref when refilling
When refilling the delayed block reserve we are incorrectly computing the amount of bytes for a single delayed reference if the free space tree is being used. In that case we should double the calculated amount. Everywhere else we compute the correct amount, like when updating the delayed block reserve, at btrfs_update_delayed_refs_rsv(), or when releasing space from the delayed block reserve, at btrfs_delayed_refs_rsv_release(). So fix btrfs_delayed_refs_rsv_refill() to multiply the amount of bytes for a single delayed reference by two in case the free space tree is used. Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
afa4b0afee
commit
1d0df22a29
@ -186,6 +186,17 @@ int btrfs_delayed_refs_rsv_refill(struct btrfs_fs_info *fs_info,
|
||||
u64 num_bytes = 0;
|
||||
int ret = -ENOSPC;
|
||||
|
||||
/*
|
||||
* We have to check the mount option here because we could be enabling
|
||||
* the free space tree for the first time and don't have the compat_ro
|
||||
* option set yet.
|
||||
*
|
||||
* We need extra reservations if we have the free space tree because
|
||||
* we'll have to modify that tree as well.
|
||||
*/
|
||||
if (btrfs_test_opt(fs_info, FREE_SPACE_TREE))
|
||||
limit *= 2;
|
||||
|
||||
spin_lock(&block_rsv->lock);
|
||||
if (block_rsv->reserved < block_rsv->size) {
|
||||
num_bytes = block_rsv->size - block_rsv->reserved;
|
||||
|
Loading…
Reference in New Issue
Block a user