Btrfs: cache the extent tree preallocation
authorChris Mason <chris.mason@oracle.com>
Tue, 19 Jun 2007 19:50:51 +0000 (15:50 -0400)
committerDavid Woodhouse <dwmw2@hera.kernel.org>
Tue, 19 Jun 2007 19:50:51 +0000 (15:50 -0400)
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/extent-tree.c

index e0738c65bc5bd32bb18a2fbc2edf47630f3fa980..47e91184fff3e5dad892f44e9e5cb1451c46a606 100644 (file)
@@ -741,7 +741,6 @@ static int finish_current_insert(struct btrfs_trans_handle *trans, struct
                BUG_ON(ret);
        }
        extent_root->fs_info->extent_tree_insert_nr = 0;
-       extent_root->fs_info->extent_tree_prealloc_nr = 0;
        return 0;
 }
 
@@ -951,6 +950,18 @@ static int find_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
                num_blocks = 1;
                total_needed = (min(level + 1, BTRFS_MAX_LEVEL) + 2) * 3;
        }
+       if (fill_prealloc) {
+               u64 first;
+               int nr = info->extent_tree_prealloc_nr;
+               first = info->extent_tree_prealloc[nr - 1];
+               if (info->extent_tree_prealloc_nr >= total_needed &&
+                   first >= search_start) {
+                       ins->objectid = info->extent_tree_prealloc[0];
+                       ins->offset = 1;
+                       return 0;
+               }
+               info->extent_tree_prealloc_nr = 0;
+       }
        if (search_end == (u64)-1)
                search_end = btrfs_super_total_blocks(info->disk_super);
        if (hint_block) {
@@ -1107,7 +1118,6 @@ check_pending:
                if (ins->objectid + num_blocks > first &&
                    ins->objectid <= info->extent_tree_prealloc[0]) {
                        search_start = info->extent_tree_prealloc[0] + 1;
-                       WARN_ON(!full_scan);
                        goto new_group;
                }
        }