diff options
author | Josef Bacik <jbacik@fusionio.com> | 2012-08-14 16:20:52 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2012-10-01 15:19:02 -0400 |
commit | 54338b5cc4fa3cfe260e8e4ade8b62a9079ea3f9 (patch) | |
tree | a522e7606064efdfe51b444c5c8cec158c9ca2f6 /fs/btrfs/extent-tree.c | |
parent | 7c735313bd1277c2eb28421934d4c7a0fa7339f7 (diff) |
Btrfs: do not allocate chunks as agressively
Swinging this pendulum back the other way. We've been allocating chunks up
to 2% of the disk no matter how much we actually have allocated. So instead
fix this calculation to only allocate chunks if we have more than 80% of the
space available allocated. Please test this as it will likely cause all
sorts of ENOSPC problems to pop up suddenly. Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index ba58024d40d3..62fc92f2b9d7 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -3504,7 +3504,8 @@ static int should_alloc_chunk(struct btrfs_root *root, | |||
3504 | * and purposes it's used space. Don't worry about locking the | 3504 | * and purposes it's used space. Don't worry about locking the |
3505 | * global_rsv, it doesn't change except when the transaction commits. | 3505 | * global_rsv, it doesn't change except when the transaction commits. |
3506 | */ | 3506 | */ |
3507 | num_allocated += global_rsv->size; | 3507 | if (sinfo->flags & BTRFS_BLOCK_GROUP_METADATA) |
3508 | num_allocated += global_rsv->size; | ||
3508 | 3509 | ||
3509 | /* | 3510 | /* |
3510 | * in limited mode, we want to have some free space up to | 3511 | * in limited mode, we want to have some free space up to |
@@ -3518,15 +3519,8 @@ static int should_alloc_chunk(struct btrfs_root *root, | |||
3518 | if (num_bytes - num_allocated < thresh) | 3519 | if (num_bytes - num_allocated < thresh) |
3519 | return 1; | 3520 | return 1; |
3520 | } | 3521 | } |
3521 | thresh = btrfs_super_total_bytes(root->fs_info->super_copy); | ||
3522 | 3522 | ||
3523 | /* 256MB or 2% of the FS */ | 3523 | if (num_allocated + alloc_bytes < div_factor(num_bytes, 8)) |
3524 | thresh = max_t(u64, 256 * 1024 * 1024, div_factor_fine(thresh, 2)); | ||
3525 | /* system chunks need a much small threshold */ | ||
3526 | if (sinfo->flags & BTRFS_BLOCK_GROUP_SYSTEM) | ||
3527 | thresh = 32 * 1024 * 1024; | ||
3528 | |||
3529 | if (num_bytes > thresh && sinfo->bytes_used < div_factor(num_bytes, 8)) | ||
3530 | return 0; | 3524 | return 0; |
3531 | return 1; | 3525 | return 1; |
3532 | } | 3526 | } |