Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 360420
b: refs/heads/master
c: 96f1bb5
h: refs/heads/master
v: v3
  • Loading branch information
Josef Bacik committed Feb 20, 2013
1 parent 1aaa80b commit fb88c29
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 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: 0f5d42b287f32417e54485d79f2318cf2970b37d
refs/heads/master: 96f1bb57771f71bf1d55d5031a1cf47908494330
21 changes: 19 additions & 2 deletions trunk/fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -3672,13 +3672,30 @@ static int can_overcommit(struct btrfs_root *root,
struct btrfs_space_info *space_info, u64 bytes,
enum btrfs_reserve_flush_enum flush)
{
struct btrfs_block_rsv *global_rsv = &root->fs_info->global_block_rsv;
u64 profile = btrfs_get_alloc_profile(root, 0);
u64 rsv_size = 0;
u64 avail;
u64 used;

used = space_info->bytes_used + space_info->bytes_reserved +
space_info->bytes_pinned + space_info->bytes_readonly +
space_info->bytes_may_use;
space_info->bytes_pinned + space_info->bytes_readonly;

spin_lock(&global_rsv->lock);
rsv_size = global_rsv->size;
spin_unlock(&global_rsv->lock);

/*
* We only want to allow over committing if we have lots of actual space
* free, but if we don't have enough space to handle the global reserve
* space then we could end up having a real enospc problem when trying
* to allocate a chunk or some other such important allocation.
*/
rsv_size <<= 1;
if (used + rsv_size >= space_info->total_bytes)
return 0;

used += space_info->bytes_may_use;

spin_lock(&root->fs_info->free_chunk_lock);
avail = root->fs_info->free_chunk_space;
Expand Down

0 comments on commit fb88c29

Please sign in to comment.