aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorYan Zheng <zheng.yan@oracle.com>2009-09-11 16:11:19 -0400
committerChris Mason <chris.mason@oracle.com>2009-09-17 15:47:36 -0400
commit11833d66be94b514652466802100378046c16b72 (patch)
tree2b00b36d0aa42e9e10cecf3bf723eb70a607afec /fs/btrfs/disk-io.c
parent6e74057c4686dc12ea767b4bdc50a63876056e1c (diff)
Btrfs: improve async block group caching
This patch gets rid of two limitations of async block group caching. The old code delays handling pinned extents when block group is in caching. To allocate logged file extents, the old code need wait until block group is fully cached. To get rid of the limitations, This patch introduces a data structure to track the progress of caching. Base on the caching progress, we know which extents should be added to the free space cache when handling the pinned extents. The logged file extents are also handled in a similar way. This patch also changes how pinned extents are tracked. The old code uses one tree to track pinned extents, and copy the pinned extents tree at transaction commit time. This patch makes it use two trees to track pinned extents. One tree for extents that are pinned in the running transaction, one tree for extents that can be unpinned. At transaction commit time, we swap the two trees. Signed-off-by: Yan Zheng <zheng.yan@oracle.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 253da7e01ab3..16dae122dda4 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1563,6 +1563,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1563 INIT_LIST_HEAD(&fs_info->hashers); 1563 INIT_LIST_HEAD(&fs_info->hashers);
1564 INIT_LIST_HEAD(&fs_info->delalloc_inodes); 1564 INIT_LIST_HEAD(&fs_info->delalloc_inodes);
1565 INIT_LIST_HEAD(&fs_info->ordered_operations); 1565 INIT_LIST_HEAD(&fs_info->ordered_operations);
1566 INIT_LIST_HEAD(&fs_info->caching_block_groups);
1566 spin_lock_init(&fs_info->delalloc_lock); 1567 spin_lock_init(&fs_info->delalloc_lock);
1567 spin_lock_init(&fs_info->new_trans_lock); 1568 spin_lock_init(&fs_info->new_trans_lock);
1568 spin_lock_init(&fs_info->ref_cache_lock); 1569 spin_lock_init(&fs_info->ref_cache_lock);
@@ -1621,8 +1622,11 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1621 spin_lock_init(&fs_info->block_group_cache_lock); 1622 spin_lock_init(&fs_info->block_group_cache_lock);
1622 fs_info->block_group_cache_tree.rb_node = NULL; 1623 fs_info->block_group_cache_tree.rb_node = NULL;
1623 1624
1624 extent_io_tree_init(&fs_info->pinned_extents, 1625 extent_io_tree_init(&fs_info->freed_extents[0],
1625 fs_info->btree_inode->i_mapping, GFP_NOFS); 1626 fs_info->btree_inode->i_mapping, GFP_NOFS);
1627 extent_io_tree_init(&fs_info->freed_extents[1],
1628 fs_info->btree_inode->i_mapping, GFP_NOFS);
1629 fs_info->pinned_extents = &fs_info->freed_extents[0];
1626 fs_info->do_barriers = 1; 1630 fs_info->do_barriers = 1;
1627 1631
1628 BTRFS_I(fs_info->btree_inode)->root = tree_root; 1632 BTRFS_I(fs_info->btree_inode)->root = tree_root;
@@ -2359,7 +2363,6 @@ int close_ctree(struct btrfs_root *root)
2359 free_extent_buffer(root->fs_info->csum_root->commit_root); 2363 free_extent_buffer(root->fs_info->csum_root->commit_root);
2360 2364
2361 btrfs_free_block_groups(root->fs_info); 2365 btrfs_free_block_groups(root->fs_info);
2362 btrfs_free_pinned_extents(root->fs_info);
2363 2366
2364 del_fs_roots(fs_info); 2367 del_fs_roots(fs_info);
2365 2368