summaryrefslogtreecommitdiff
path: root/extent-tree.c
diff options
context:
space:
mode:
authorYan Zheng <yanzheng@21cn.com>2008-04-24 14:57:50 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2008-04-24 14:57:50 -0400
commit4415143185b8c3ac799301a72a9cdbbd746fc723 (patch)
tree77c2037cbf7abe6745295f5de2d75f16fdd17482 /extent-tree.c
parent309ce6768b29f72815ab8301b3670c7d8f7af307 (diff)
Speed improvement and bug fixes for ext3 converter
This patch improves converter's allocator and fixes a bug in data relocation function. The new allocator caches free blocks as Btrfs's default allocator. In testing here, the user CPU time reduced to half of the original when checksum and small file packing was disabled. This patch also enlarges the size of block groups created by the converter.
Diffstat (limited to 'extent-tree.c')
-rw-r--r--extent-tree.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/extent-tree.c b/extent-tree.c
index 6687d2e2..1d1dbc8b 100644
--- a/extent-tree.c
+++ b/extent-tree.c
@@ -2349,7 +2349,9 @@ int btrfs_make_block_groups(struct btrfs_trans_handle *trans,
u64 cur_start;
u64 group_type;
u64 group_size;
- u64 group_nr = 0;
+ u64 group_align;
+ u64 total_data = 0;
+ u64 total_metadata = 0;
u64 chunk_objectid;
int ret;
int bit;
@@ -2361,26 +2363,33 @@ int btrfs_make_block_groups(struct btrfs_trans_handle *trans,
block_group_cache = &root->fs_info->block_group_cache;
chunk_objectid = BTRFS_FIRST_CHUNK_TREE_OBJECTID;
total_bytes = btrfs_super_total_bytes(&root->fs_info->super_copy);
+ group_align = 64 * root->sectorsize;
cur_start = 0;
while (cur_start < total_bytes) {
- if (group_nr == 0) {
+ group_size = total_bytes / 12;
+ group_size = min_t(u64, group_size, total_bytes - cur_start);
+ if (cur_start == 0) {
bit = BLOCK_GROUP_SYSTEM;
group_type = BTRFS_BLOCK_GROUP_SYSTEM;
- } else if (group_nr % 3 == 1) {
- bit = BLOCK_GROUP_DATA;
- group_type = BTRFS_BLOCK_GROUP_METADATA;
+ group_size /= 4;
+ group_size &= ~(group_align - 1);
+ group_size = max_t(u64, group_size, 32 * 1024 * 1024);
+ group_size = min_t(u64, group_size, 128 * 1024 * 1024);
} else {
- bit = BLOCK_GROUP_METADATA;
- group_type = BTRFS_BLOCK_GROUP_DATA;
- }
- group_nr++;
-
- if (group_type == BTRFS_BLOCK_GROUP_SYSTEM) {
- group_size = 32 * 1024 * 1024;
- } else {
- group_size = 256 * 1024 * 1024;
- if (total_bytes - cur_start < group_size * 5 / 4)
+ group_size &= ~(group_align - 1);
+ if (total_data >= total_metadata * 2) {
+ group_type = BTRFS_BLOCK_GROUP_METADATA;
+ group_size = min_t(u64, group_size,
+ 1ULL * 1024 * 1024 * 1024);
+ total_metadata += group_size;
+ } else {
+ group_type = BTRFS_BLOCK_GROUP_DATA;
+ group_size = min_t(u64, group_size,
+ 5ULL * 1024 * 1024 * 1024);
+ total_data += group_size;
+ }
+ if ((total_bytes - cur_start) * 4 < group_size * 5)
group_size = total_bytes - cur_start;
}