aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2012-01-06 15:41:34 -0500
committerChris Mason <chris.mason@oracle.com>2012-01-06 15:41:34 -0500
commitcf1d72c9ceec391d34c48724da57282e97f01122 (patch)
treeaddcb347d4c00d724f86d309ad26b75438b7a814 /fs/btrfs/extent-tree.c
parent203bf287cb01a5dc26c20bd3737cecf3aeba1d48 (diff)
Btrfs: lower the bar for chunk allocation
The chunk allocation code has tried to keep a pretty tight lid on creating new metadata chunks. This is partially because in the past the reservation code didn't give us an accurate idea of how much space was being used. The new code is much more accurate, so we're able to get rid of some of these checks. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 71549d11a09..247d2c94f8e 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3263,27 +3263,12 @@ static int should_alloc_chunk(struct btrfs_root *root,
3263 if (num_bytes - num_allocated < thresh) 3263 if (num_bytes - num_allocated < thresh)
3264 return 1; 3264 return 1;
3265 } 3265 }
3266
3267 /*
3268 * we have two similar checks here, one based on percentage
3269 * and once based on a hard number of 256MB. The idea
3270 * is that if we have a good amount of free
3271 * room, don't allocate a chunk. A good mount is
3272 * less than 80% utilized of the chunks we have allocated,
3273 * or more than 256MB free
3274 */
3275 if (num_allocated + alloc_bytes + 256 * 1024 * 1024 < num_bytes)
3276 return 0;
3277
3278 if (num_allocated + alloc_bytes < div_factor(num_bytes, 8))
3279 return 0;
3280
3281 thresh = btrfs_super_total_bytes(root->fs_info->super_copy); 3266 thresh = btrfs_super_total_bytes(root->fs_info->super_copy);
3282 3267
3283 /* 256MB or 5% of the FS */ 3268 /* 256MB or 2% of the FS */
3284 thresh = max_t(u64, 256 * 1024 * 1024, div_factor_fine(thresh, 5)); 3269 thresh = max_t(u64, 256 * 1024 * 1024, div_factor_fine(thresh, 2));
3285 3270
3286 if (num_bytes > thresh && sinfo->bytes_used < div_factor(num_bytes, 3)) 3271 if (num_bytes > thresh && sinfo->bytes_used < div_factor(num_bytes, 8))
3287 return 0; 3272 return 0;
3288 return 1; 3273 return 1;
3289} 3274}