Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 360435
b: refs/heads/master
c: 70afa39
h: refs/heads/master
i:
  360433: 34efab5
  360431: 649fa5c
v: v3
  • Loading branch information
Josef Bacik committed Feb 20, 2013
1 parent 1369ac3 commit 134ea58
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 925396ecf251432d6d0f703a6cfd0cb9e651d936
refs/heads/master: 70afa3998c9baed4186df38988246de1abdab56d
15 changes: 12 additions & 3 deletions trunk/fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -3677,6 +3677,7 @@ static int can_overcommit(struct btrfs_root *root,
u64 rsv_size = 0;
u64 avail;
u64 used;
u64 to_add;

used = space_info->bytes_used + space_info->bytes_reserved +
space_info->bytes_pinned + space_info->bytes_readonly;
Expand Down Expand Up @@ -3710,17 +3711,25 @@ static int can_overcommit(struct btrfs_root *root,
BTRFS_BLOCK_GROUP_RAID10))
avail >>= 1;

to_add = space_info->total_bytes;

/*
* If we aren't flushing all things, let us overcommit up to
* 1/2th of the space. If we can flush, don't let us overcommit
* too much, let it overcommit up to 1/8 of the space.
*/
if (flush == BTRFS_RESERVE_FLUSH_ALL)
avail >>= 3;
to_add >>= 3;
else
avail >>= 1;
to_add >>= 1;

/*
* Limit the overcommit to the amount of free space we could possibly
* allocate for chunks.
*/
to_add = min(avail, to_add);

if (used + bytes < space_info->total_bytes + avail)
if (used + bytes < space_info->total_bytes + to_add)
return 1;
return 0;
}
Expand Down

0 comments on commit 134ea58

Please sign in to comment.