diff options
author | Josef Bacik <jbacik@redhat.com> | 2008-11-17 21:11:49 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-11-17 21:11:49 -0500 |
commit | e3e469f86eebb1b3364c118add362d00c6cff956 (patch) | |
tree | b94e978d4249fea7aed066f2046daaf3f3202307 /fs | |
parent | 7cbd8a839118eede2393f0926b8e15027162bcd6 (diff) |
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')
-rw-r--r-- | fs/btrfs/extent-tree.c | 8 |
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: | |||
999 | path->slots[0] = extent_slot; | 999 | path->slots[0] = extent_slot; |
1000 | bytes_freed = op->num_bytes; | 1000 | bytes_freed = op->num_bytes; |
1001 | 1001 | ||
1002 | mutex_lock(&info->pinned_mutex); | ||
1003 | ret = pin_down_bytes(trans, extent_root, op->bytenr, | ||
1004 | op->num_bytes, op->level >= | ||
1005 | BTRFS_FIRST_FREE_OBJECTID); | ||
1006 | mutex_unlock(&info->pinned_mutex); | ||
1007 | BUG_ON(ret < 0); | ||
1008 | op->del = ret; | ||
1009 | |||
1002 | /* | 1010 | /* |
1003 | * we need to see if we can delete multiple things at once, so | 1011 | * we need to see if we can delete multiple things at once, so |
1004 | * start looping through the list of extents we are wanting to | 1012 | * start looping through the list of extents we are wanting to |