aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-03-24 15:02:03 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:01 -0400
commit7d1660d411a24f9b5a2f38e41c9896d7151c934f (patch)
tree4deb14766922d4889721226a0de2d8b87eefe6b5
parent6324fbf334f4586325057197da7752f4ffa409d3 (diff)
Btrfs: Bring back find_free_extent CPU usage optimizations
Signed-off-by: Chris Mason <chris.mason@oracle.com>
-rw-r--r--fs/btrfs/extent-tree.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 15082b1087be..5e392804ab15 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -182,9 +182,9 @@ static int noinline find_search_start(struct btrfs_root *root,
182 int ret; 182 int ret;
183 struct btrfs_block_group_cache *cache = *cache_ret; 183 struct btrfs_block_group_cache *cache = *cache_ret;
184 struct extent_io_tree *free_space_cache; 184 struct extent_io_tree *free_space_cache;
185 struct extent_state *state;
185 u64 last; 186 u64 last;
186 u64 start = 0; 187 u64 start = 0;
187 u64 end = 0;
188 u64 cache_miss = 0; 188 u64 cache_miss = 0;
189 u64 total_fs_bytes; 189 u64 total_fs_bytes;
190 u64 search_start = *start_ret; 190 u64 search_start = *start_ret;
@@ -205,30 +205,34 @@ again:
205 goto new_group; 205 goto new_group;
206 } 206 }
207 207
208 spin_lock_irq(&free_space_cache->lock);
209 state = find_first_extent_bit_state(free_space_cache, last, EXTENT_DIRTY);
208 while(1) { 210 while(1) {
209 ret = find_first_extent_bit(&root->fs_info->free_space_cache, 211 if (!state) {
210 last, &start, &end, EXTENT_DIRTY);
211 if (ret) {
212 if (!cache_miss) 212 if (!cache_miss)
213 cache_miss = last; 213 cache_miss = last;
214 spin_unlock_irq(&free_space_cache->lock);
214 goto new_group; 215 goto new_group;
215 } 216 }
216 217
217 start = max(last, start); 218 start = max(last, state->start);
218 last = end + 1; 219 last = state->end + 1;
219 if (last - start < num) { 220 if (last - start < num) {
220 if (last == cache->key.objectid + cache->key.offset) 221 if (last == cache->key.objectid + cache->key.offset)
221 cache_miss = start; 222 cache_miss = start;
223 do {
224 state = extent_state_next(state);
225 } while(state && !(state->state & EXTENT_DIRTY));
222 continue; 226 continue;
223 } 227 }
228 spin_unlock_irq(&free_space_cache->lock);
224 if (start + num > cache->key.objectid + cache->key.offset) 229 if (start + num > cache->key.objectid + cache->key.offset)
225 goto new_group; 230 goto new_group;
226 if (start + num > total_fs_bytes) 231 if (start + num > total_fs_bytes)
227 goto new_group; 232 goto new_group;
228 *start_ret = start; 233 *start_ret = start;
229 return 0; 234 return 0;
230 } 235 } out:
231out:
232 cache = btrfs_lookup_block_group(root->fs_info, search_start); 236 cache = btrfs_lookup_block_group(root->fs_info, search_start);
233 if (!cache) { 237 if (!cache) {
234 printk("Unable to find block group for %Lu\n", search_start); 238 printk("Unable to find block group for %Lu\n", search_start);