diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-06-19 15:50:51 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-06-19 15:50:51 -0400 |
commit | 85e55b13e4e318672f669747e5e010d1b707b198 (patch) | |
tree | f46a2f7f9bc96f183223db10ac46dd9e9a8f8894 /fs/btrfs/extent-tree.c | |
parent | 63c992fd0b733989d43e9762f48e300d61b5287e (diff) |
Btrfs: cache the extent tree preallocation
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index e0738c65bc5b..47e91184fff3 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -741,7 +741,6 @@ static int finish_current_insert(struct btrfs_trans_handle *trans, struct | |||
741 | BUG_ON(ret); | 741 | BUG_ON(ret); |
742 | } | 742 | } |
743 | extent_root->fs_info->extent_tree_insert_nr = 0; | 743 | extent_root->fs_info->extent_tree_insert_nr = 0; |
744 | extent_root->fs_info->extent_tree_prealloc_nr = 0; | ||
745 | return 0; | 744 | return 0; |
746 | } | 745 | } |
747 | 746 | ||
@@ -951,6 +950,18 @@ static int find_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root | |||
951 | num_blocks = 1; | 950 | num_blocks = 1; |
952 | total_needed = (min(level + 1, BTRFS_MAX_LEVEL) + 2) * 3; | 951 | total_needed = (min(level + 1, BTRFS_MAX_LEVEL) + 2) * 3; |
953 | } | 952 | } |
953 | if (fill_prealloc) { | ||
954 | u64 first; | ||
955 | int nr = info->extent_tree_prealloc_nr; | ||
956 | first = info->extent_tree_prealloc[nr - 1]; | ||
957 | if (info->extent_tree_prealloc_nr >= total_needed && | ||
958 | first >= search_start) { | ||
959 | ins->objectid = info->extent_tree_prealloc[0]; | ||
960 | ins->offset = 1; | ||
961 | return 0; | ||
962 | } | ||
963 | info->extent_tree_prealloc_nr = 0; | ||
964 | } | ||
954 | if (search_end == (u64)-1) | 965 | if (search_end == (u64)-1) |
955 | search_end = btrfs_super_total_blocks(info->disk_super); | 966 | search_end = btrfs_super_total_blocks(info->disk_super); |
956 | if (hint_block) { | 967 | if (hint_block) { |
@@ -1107,7 +1118,6 @@ check_pending: | |||
1107 | if (ins->objectid + num_blocks > first && | 1118 | if (ins->objectid + num_blocks > first && |
1108 | ins->objectid <= info->extent_tree_prealloc[0]) { | 1119 | ins->objectid <= info->extent_tree_prealloc[0]) { |
1109 | search_start = info->extent_tree_prealloc[0] + 1; | 1120 | search_start = info->extent_tree_prealloc[0] + 1; |
1110 | WARN_ON(!full_scan); | ||
1111 | goto new_group; | 1121 | goto new_group; |
1112 | } | 1122 | } |
1113 | } | 1123 | } |