summaryrefslogtreecommitdiff
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@redhat.com>2008-11-17 21:11:49 -0500
committerChris Mason <chris.mason@oracle.com>2008-11-17 21:11:49 -0500
commite3e469f86eebb1b3364c118add362d00c6cff956 (patch)
treeb94e978d4249fea7aed066f2046daaf3f3202307 /fs/btrfs/extent-tree.c
parent7cbd8a839118eede2393f0926b8e15027162bcd6 (diff)
downloadlwn-e3e469f86eebb1b3364c118add362d00c6cff956.tar.gz
lwn-e3e469f86eebb1b3364c118add362d00c6cff956.zip
Btrfs: fix free space leak
In my batch delete/update/insert patch I introduced a free space leak. The extent that we do the original search on in free_extents is never pinned, so we always update the block saying that it has free space, but the free space never actually gets added to the free space tree, since op->del will always be 0 and it's never actually added to the pinned extents tree. This patch fixes this problem by making sure we call pin_down_bytes on the pending extent op and set op->del to the return value of pin_down_bytes so update_block_group is called with the right value. This seems to fix the case where we were getting ENOSPC when there was plenty of space available. Signed-off-by: Josef Bacik <jbacik@redhat.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 197422c1dc4b..6c29669d81a2 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -999,6 +999,14 @@ search:
path->slots[0] = extent_slot;
bytes_freed = op->num_bytes;
+ mutex_lock(&info->pinned_mutex);
+ ret = pin_down_bytes(trans, extent_root, op->bytenr,
+ op->num_bytes, op->level >=
+ BTRFS_FIRST_FREE_OBJECTID);
+ mutex_unlock(&info->pinned_mutex);
+ BUG_ON(ret < 0);
+ op->del = ret;
+
/*
* we need to see if we can delete multiple things at once, so
* start looping through the list of extents we are wanting to