aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
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/ctree.h
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/ctree.h')
-rw-r--r--fs/btrfs/ctree.h29
1 files changed, 20 insertions, 9 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 732d5b884aa7..3b6df7140575 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -726,6 +726,15 @@ enum btrfs_caching_type {
726 BTRFS_CACHE_FINISHED = 2, 726 BTRFS_CACHE_FINISHED = 2,
727}; 727};
728 728
729struct btrfs_caching_control {
730 struct list_head list;
731 struct mutex mutex;
732 wait_queue_head_t wait;
733 struct btrfs_block_group_cache *block_group;
734 u64 progress;
735 atomic_t count;
736};
737
729struct btrfs_block_group_cache { 738struct btrfs_block_group_cache {
730 struct btrfs_key key; 739 struct btrfs_key key;
731 struct btrfs_block_group_item item; 740 struct btrfs_block_group_item item;
@@ -742,8 +751,9 @@ struct btrfs_block_group_cache {
742 int dirty; 751 int dirty;
743 752
744 /* cache tracking stuff */ 753 /* cache tracking stuff */
745 wait_queue_head_t caching_q;
746 int cached; 754 int cached;
755 struct btrfs_caching_control *caching_ctl;
756 u64 last_byte_to_unpin;
747 757
748 struct btrfs_space_info *space_info; 758 struct btrfs_space_info *space_info;
749 759
@@ -788,7 +798,8 @@ struct btrfs_fs_info {
788 spinlock_t block_group_cache_lock; 798 spinlock_t block_group_cache_lock;
789 struct rb_root block_group_cache_tree; 799 struct rb_root block_group_cache_tree;
790 800
791 struct extent_io_tree pinned_extents; 801 struct extent_io_tree freed_extents[2];
802 struct extent_io_tree *pinned_extents;
792 803
793 /* logical->physical extent mapping */ 804 /* logical->physical extent mapping */
794 struct btrfs_mapping_tree mapping_tree; 805 struct btrfs_mapping_tree mapping_tree;
@@ -825,8 +836,6 @@ struct btrfs_fs_info {
825 struct mutex drop_mutex; 836 struct mutex drop_mutex;
826 struct mutex volume_mutex; 837 struct mutex volume_mutex;
827 struct mutex tree_reloc_mutex; 838 struct mutex tree_reloc_mutex;
828 struct rw_semaphore extent_commit_sem;
829
830 /* 839 /*
831 * this protects the ordered operations list only while we are 840 * this protects the ordered operations list only while we are
832 * processing all of the entries on it. This way we make 841 * processing all of the entries on it. This way we make
@@ -835,10 +844,12 @@ struct btrfs_fs_info {
835 * before jumping into the main commit. 844 * before jumping into the main commit.
836 */ 845 */
837 struct mutex ordered_operations_mutex; 846 struct mutex ordered_operations_mutex;
847 struct rw_semaphore extent_commit_sem;
838 848
839 struct list_head trans_list; 849 struct list_head trans_list;
840 struct list_head hashers; 850 struct list_head hashers;
841 struct list_head dead_roots; 851 struct list_head dead_roots;
852 struct list_head caching_block_groups;
842 853
843 atomic_t nr_async_submits; 854 atomic_t nr_async_submits;
844 atomic_t async_submit_draining; 855 atomic_t async_submit_draining;
@@ -1920,8 +1931,8 @@ void btrfs_put_block_group(struct btrfs_block_group_cache *cache);
1920int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, 1931int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,
1921 struct btrfs_root *root, unsigned long count); 1932 struct btrfs_root *root, unsigned long count);
1922int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len); 1933int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len);
1923int btrfs_update_pinned_extents(struct btrfs_root *root, 1934int btrfs_pin_extent(struct btrfs_root *root,
1924 u64 bytenr, u64 num, int pin); 1935 u64 bytenr, u64 num, int reserved);
1925int btrfs_drop_leaf_ref(struct btrfs_trans_handle *trans, 1936int btrfs_drop_leaf_ref(struct btrfs_trans_handle *trans,
1926 struct btrfs_root *root, struct extent_buffer *leaf); 1937 struct btrfs_root *root, struct extent_buffer *leaf);
1927int btrfs_cross_ref_exist(struct btrfs_trans_handle *trans, 1938int btrfs_cross_ref_exist(struct btrfs_trans_handle *trans,
@@ -1971,9 +1982,10 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans,
1971 u64 root_objectid, u64 owner, u64 offset); 1982 u64 root_objectid, u64 owner, u64 offset);
1972 1983
1973int btrfs_free_reserved_extent(struct btrfs_root *root, u64 start, u64 len); 1984int btrfs_free_reserved_extent(struct btrfs_root *root, u64 start, u64 len);
1985int btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans,
1986 struct btrfs_root *root);
1974int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans, 1987int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
1975 struct btrfs_root *root, 1988 struct btrfs_root *root);
1976 struct extent_io_tree *unpin);
1977int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, 1989int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
1978 struct btrfs_root *root, 1990 struct btrfs_root *root,
1979 u64 bytenr, u64 num_bytes, u64 parent, 1991 u64 bytenr, u64 num_bytes, u64 parent,
@@ -2006,7 +2018,6 @@ void btrfs_delalloc_reserve_space(struct btrfs_root *root, struct inode *inode,
2006 u64 bytes); 2018 u64 bytes);
2007void btrfs_delalloc_free_space(struct btrfs_root *root, struct inode *inode, 2019void btrfs_delalloc_free_space(struct btrfs_root *root, struct inode *inode,
2008 u64 bytes); 2020 u64 bytes);
2009void btrfs_free_pinned_extents(struct btrfs_fs_info *info);
2010/* ctree.c */ 2021/* ctree.c */
2011int btrfs_bin_search(struct extent_buffer *eb, struct btrfs_key *key, 2022int btrfs_bin_search(struct extent_buffer *eb, struct btrfs_key *key,
2012 int level, int *slot); 2023 int level, int *slot);