summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorChris Mason2008-04-14 15:46:10 +0200
committerChris Mason2008-09-25 17:04:01 +0200
commit98d20f67cf99ccda638dbcdf7b3a9ee0a428d932 (patch)
tree2cd417558d34777ee8aabc950ccc0993d542d1b0 /fs/btrfs/extent-tree.c
parentBtrfs: bio_endio support for linux 2.6.23 and older. (diff)
downloadkernel-qcow2-linux-98d20f67cf99ccda638dbcdf7b3a9ee0a428d932.tar.gz
kernel-qcow2-linux-98d20f67cf99ccda638dbcdf7b3a9ee0a428d932.tar.xz
kernel-qcow2-linux-98d20f67cf99ccda638dbcdf7b3a9ee0a428d932.zip
Add a min size parameter to btrfs_alloc_extent
On huge machines, delayed allocation may try to allocate massive extents. This change allows btrfs_alloc_extent to return something smaller than the caller asked for, and the data allocation routines will loop over the allocations until it fills the whole delayed alloc. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index a056a2df689a..e49147e767df 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -1694,7 +1694,8 @@ error:
*/
int btrfs_alloc_extent(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
- u64 num_bytes, u64 root_objectid, u64 ref_generation,
+ u64 num_bytes, u64 min_alloc_size,
+ u64 root_objectid, u64 ref_generation,
u64 owner, u64 owner_offset,
u64 empty_size, u64 hint_byte,
u64 search_end, struct btrfs_key *ins, int data)
@@ -1727,7 +1728,7 @@ int btrfs_alloc_extent(struct btrfs_trans_handle *trans,
info->metadata_alloc_profile;
data = BTRFS_BLOCK_GROUP_METADATA | alloc_profile;
}
-
+again:
if (root->ref_cows) {
if (!(data & BTRFS_BLOCK_GROUP_METADATA)) {
ret = do_chunk_alloc(trans, root->fs_info->extent_root,
@@ -1751,6 +1752,11 @@ int btrfs_alloc_extent(struct btrfs_trans_handle *trans,
search_start, search_end, hint_byte, ins,
trans->alloc_exclude_start,
trans->alloc_exclude_nr, data);
+ if (ret == -ENOSPC && num_bytes > min_alloc_size) {
+ num_bytes = num_bytes >> 1;
+ num_bytes = max(num_bytes, min_alloc_size);
+ goto again;
+ }
BUG_ON(ret);
if (ret)
return ret;
@@ -1869,7 +1875,7 @@ struct extent_buffer *__btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
int ret;
struct extent_buffer *buf;
- ret = btrfs_alloc_extent(trans, root, blocksize,
+ ret = btrfs_alloc_extent(trans, root, blocksize, blocksize,
root_objectid, ref_generation,
level, first_objectid, empty_size, hint,
(u64)-1, &ins, 0);