Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d9b0218f authored by Liu Bo's avatar Liu Bo Committed by David Sterba
Browse files

Btrfs: fix a bug on overcommit stuff



When overcommitting, we should check the sum of pinned space and
bytes for delayed item.

Signed-off-by: default avatarLiu Bo <liubo2009@cn.fujitsu.com>
parent 9d47c767
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -3611,12 +3611,15 @@ static int may_commit_transaction(struct btrfs_root *root,
	if (space_info != delayed_rsv->space_info)
		return -ENOSPC;

	spin_lock(&space_info->lock);
	spin_lock(&delayed_rsv->lock);
	if (delayed_rsv->size < bytes) {
	if (space_info->bytes_pinned + delayed_rsv->size < bytes) {
		spin_unlock(&delayed_rsv->lock);
		spin_unlock(&space_info->lock);
		return -ENOSPC;
	}
	spin_unlock(&delayed_rsv->lock);
	spin_unlock(&space_info->lock);

commit:
	trans = btrfs_join_transaction(root);