aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2011-01-24 16:43:19 -0500
committerChris Mason <chris.mason@oracle.com>2011-01-28 16:40:37 -0500
commite9e22899de661af94cb9995885fd04e4c738838b (patch)
tree3932040f0c5416e6ecbf508fa5d99b50eefbbc18 /fs/btrfs
parentdedefd7215d3ec451291ca393e5c8e4c1882c8c6 (diff)
Btrfs: do not release more reserved bytes to the global_block_rsv than we need
When we do btrfs_block_rsv_release, if global_block_rsv is not full we will release all the extra bytes to global_block_rsv, even if it's only a little short of the amount of space that we need to reserve. This causes us to starve ourselves of reservable space during the transaction which will force us to shrink delalloc bytes and commit the transaction more often than we should. So instead just add the amount of bytes we need to add to the global reserve so reserved == size, and then add the rest back into the space_info for general use. Thanks, Signed-off-by: Josef Bacik <josef@redhat.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/extent-tree.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 98ee139885cc..7af618dcf2c0 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3589,8 +3589,20 @@ void block_rsv_release_bytes(struct btrfs_block_rsv *block_rsv,
3589 3589
3590 if (num_bytes > 0) { 3590 if (num_bytes > 0) {
3591 if (dest) { 3591 if (dest) {
3592 block_rsv_add_bytes(dest, num_bytes, 0); 3592 spin_lock(&dest->lock);
3593 } else { 3593 if (!dest->full) {
3594 u64 bytes_to_add;
3595
3596 bytes_to_add = dest->size - dest->reserved;
3597 bytes_to_add = min(num_bytes, bytes_to_add);
3598 dest->reserved += bytes_to_add;
3599 if (dest->reserved >= dest->size)
3600 dest->full = 1;
3601 num_bytes -= bytes_to_add;
3602 }
3603 spin_unlock(&dest->lock);
3604 }
3605 if (num_bytes) {
3594 spin_lock(&space_info->lock); 3606 spin_lock(&space_info->lock);
3595 space_info->bytes_reserved -= num_bytes; 3607 space_info->bytes_reserved -= num_bytes;
3596 spin_unlock(&space_info->lock); 3608 spin_unlock(&space_info->lock);