]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
Btrfs: enforce metadata allocation clustering
authorChris Mason <chris.mason@oracle.com>
Fri, 7 Nov 2008 02:48:27 +0000 (21:48 -0500)
committerChris Mason <chris.mason@oracle.com>
Fri, 7 Nov 2008 02:48:27 +0000 (21:48 -0500)
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>
fs/btrfs/extent-tree.c
fs/btrfs/extent_io.c

index ebd8275a19348eaa3059f5d98023bf56d0dd2976..b8c6541c33fe07efad3fac31caa4666b9f58264f 100644 (file)
@@ -2195,6 +2195,23 @@ static int noinline find_free_extent(struct btrfs_trans_handle *trans,
                        if (search_start + num_bytes > end)
                                goto new_group;
 
+                       if (last_ptr && *last_ptr && search_start != *last_ptr) {
+                               total_needed += empty_cluster;
+                               *last_ptr = 0;
+                               /*
+                                * if search_start is still in this block group
+                                * then we just re-search this block group
+                                */
+                               if (search_start >= start &&
+                                   search_start < end) {
+                                       mutex_unlock(&block_group->alloc_mutex);
+                                       continue;
+                               }
+
+                               /* else we go to the next block group */
+                               goto new_group;
+                       }
+
                        if (exclude_nr > 0 &&
                            (search_start + num_bytes > exclude_start &&
                             search_start < exclude_start + exclude_nr)) {
index bbe3bcfcf4ae5b141e893f30e2993c40ff9f8e24..ad75a9cc3604fda59a9eacdac591e7ac962e39af 100644 (file)
@@ -2494,13 +2494,6 @@ retry:
                index = 0;
                goto retry;
        }
-       if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
-               mapping->writeback_index = index;
-               if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
-                       range_whole = 1;
-
-       if (wbc->range_cont)
-               wbc->range_start = index << PAGE_CACHE_SHIFT;
        return ret;
 }
 EXPORT_SYMBOL(extent_write_cache_pages);