diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-11-06 21:48:27 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-11-06 21:48:27 -0500 |
commit | 3b7885bf96e03271a9fff41124c38ed7176616e2 (patch) | |
tree | 6dcadb0d9548f990fd2b67367cbf8bfde40992d5 | |
parent | 771ed689d2cd53439e28e095bc38fbe40a71429e (diff) |
Btrfs: enforce metadata allocation clustering
The allocator uses the last allocation as a starting point for metadata
allocations, and tries to allocate in clusters of at least 256k.
If the search for a free block fails to find the expected block, this patch
forces a new cluster to be found in the free list.
Signed-off-by: Chris Mason <chris.mason@oracle.com>
-rw-r--r-- | fs/btrfs/extent-tree.c | 17 | ||||
-rw-r--r-- | fs/btrfs/extent_io.c | 7 |
2 files changed, 17 insertions, 7 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index ebd8275a1934..b8c6541c33fe 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -2195,6 +2195,23 @@ static int noinline find_free_extent(struct btrfs_trans_handle *trans, | |||
2195 | if (search_start + num_bytes > end) | 2195 | if (search_start + num_bytes > end) |
2196 | goto new_group; | 2196 | goto new_group; |
2197 | 2197 | ||
2198 | if (last_ptr && *last_ptr && search_start != *last_ptr) { | ||
2199 | total_needed += empty_cluster; | ||
2200 | *last_ptr = 0; | ||
2201 | /* | ||
2202 | * if search_start is still in this block group | ||
2203 | * then we just re-search this block group | ||
2204 | */ | ||
2205 | if (search_start >= start && | ||
2206 | search_start < end) { | ||
2207 | mutex_unlock(&block_group->alloc_mutex); | ||
2208 | continue; | ||
2209 | } | ||
2210 | |||
2211 | /* else we go to the next block group */ | ||
2212 | goto new_group; | ||
2213 | } | ||
2214 | |||
2198 | if (exclude_nr > 0 && | 2215 | if (exclude_nr > 0 && |
2199 | (search_start + num_bytes > exclude_start && | 2216 | (search_start + num_bytes > exclude_start && |
2200 | search_start < exclude_start + exclude_nr)) { | 2217 | search_start < exclude_start + exclude_nr)) { |
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index bbe3bcfcf4ae..ad75a9cc3604 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -2494,13 +2494,6 @@ retry: | |||
2494 | index = 0; | 2494 | index = 0; |
2495 | goto retry; | 2495 | goto retry; |
2496 | } | 2496 | } |
2497 | if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) | ||
2498 | mapping->writeback_index = index; | ||
2499 | if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) | ||
2500 | range_whole = 1; | ||
2501 | |||
2502 | if (wbc->range_cont) | ||
2503 | wbc->range_start = index << PAGE_CACHE_SHIFT; | ||
2504 | return ret; | 2497 | return ret; |
2505 | } | 2498 | } |
2506 | EXPORT_SYMBOL(extent_write_cache_pages); | 2499 | EXPORT_SYMBOL(extent_write_cache_pages); |