Skip to content

Commit d9b0218

Browse files
liubkdave
authored andcommitted
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: Liu Bo <liubo2009@cn.fujitsu.com>
1 parent 9d47c76 commit d9b0218

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

fs/btrfs/extent-tree.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3611,12 +3611,15 @@ static int may_commit_transaction(struct btrfs_root *root,
36113611
if (space_info != delayed_rsv->space_info)
36123612
return -ENOSPC;
36133613

3614+
spin_lock(&space_info->lock);
36143615
spin_lock(&delayed_rsv->lock);
3615-
if (delayed_rsv->size < bytes) {
3616+
if (space_info->bytes_pinned + delayed_rsv->size < bytes) {
36163617
spin_unlock(&delayed_rsv->lock);
3618+
spin_unlock(&space_info->lock);
36173619
return -ENOSPC;
36183620
}
36193621
spin_unlock(&delayed_rsv->lock);
3622+
spin_unlock(&space_info->lock);
36203623

36213624
commit:
36223625
trans = btrfs_join_transaction(root);

0 commit comments

Comments
 (0)