aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/delayed-ref.h
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2009-03-13 10:17:05 -0400
committerChris Mason <chris.mason@oracle.com>2009-03-24 16:14:26 -0400
commitc3e69d58e86c3917ae4e9e31b4acf490a7cafe60 (patch)
treebd4f1e62446a208bdae26f0c36d67e3afbc1cd1d /fs/btrfs/delayed-ref.h
parent1887be66dcc3140a81d1299958a41fc0eedfa64f (diff)
Btrfs: process the delayed reference queue in clusters
The delayed reference queue maintains pending operations that need to be done to the extent allocation tree. These are processed by finding records in the tree that are not currently being processed one at a time. This is slow because it uses lots of time searching through the rbtree and because it creates lock contention on the extent allocation tree when lots of different procs are running delayed refs at the same time. This commit changes things to grab a cluster of refs for processing, using a cursor into the rbtree as the starting point of the next search. This way we walk smoothly through the rbtree. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/delayed-ref.h')
-rw-r--r--fs/btrfs/delayed-ref.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h
index c345fee9f96b..57153fcc347b 100644
--- a/fs/btrfs/delayed-ref.h
+++ b/fs/btrfs/delayed-ref.h
@@ -68,6 +68,8 @@ struct btrfs_delayed_ref_head {
68 */ 68 */
69 struct mutex mutex; 69 struct mutex mutex;
70 70
71 struct list_head cluster;
72
71 /* 73 /*
72 * when a new extent is allocated, it is just reserved in memory 74 * when a new extent is allocated, it is just reserved in memory
73 * The actual extent isn't inserted into the extent allocation tree 75 * The actual extent isn't inserted into the extent allocation tree
@@ -115,12 +117,20 @@ struct btrfs_delayed_ref_root {
115 */ 117 */
116 unsigned long num_entries; 118 unsigned long num_entries;
117 119
120 /* total number of head nodes in tree */
121 unsigned long num_heads;
122
123 /* total number of head nodes ready for processing */
124 unsigned long num_heads_ready;
125
118 /* 126 /*
119 * set when the tree is flushing before a transaction commit, 127 * set when the tree is flushing before a transaction commit,
120 * used by the throttling code to decide if new updates need 128 * used by the throttling code to decide if new updates need
121 * to be run right away 129 * to be run right away
122 */ 130 */
123 int flushing; 131 int flushing;
132
133 u64 run_delayed_start;
124}; 134};
125 135
126static inline void btrfs_put_delayed_ref(struct btrfs_delayed_ref_node *ref) 136static inline void btrfs_put_delayed_ref(struct btrfs_delayed_ref_node *ref)
@@ -140,9 +150,6 @@ int btrfs_add_delayed_ref(struct btrfs_trans_handle *trans,
140struct btrfs_delayed_ref_head * 150struct btrfs_delayed_ref_head *
141btrfs_find_delayed_ref_head(struct btrfs_trans_handle *trans, u64 bytenr); 151btrfs_find_delayed_ref_head(struct btrfs_trans_handle *trans, u64 bytenr);
142int btrfs_delayed_ref_pending(struct btrfs_trans_handle *trans, u64 bytenr); 152int btrfs_delayed_ref_pending(struct btrfs_trans_handle *trans, u64 bytenr);
143int btrfs_lock_delayed_ref(struct btrfs_trans_handle *trans,
144 struct btrfs_delayed_ref_node *ref,
145 struct btrfs_delayed_ref_head **next_ret);
146int btrfs_lookup_extent_ref(struct btrfs_trans_handle *trans, 153int btrfs_lookup_extent_ref(struct btrfs_trans_handle *trans,
147 struct btrfs_root *root, u64 bytenr, 154 struct btrfs_root *root, u64 bytenr,
148 u64 num_bytes, u32 *refs); 155 u64 num_bytes, u32 *refs);
@@ -151,6 +158,10 @@ int btrfs_update_delayed_ref(struct btrfs_trans_handle *trans,
151 u64 parent, u64 orig_ref_root, u64 ref_root, 158 u64 parent, u64 orig_ref_root, u64 ref_root,
152 u64 orig_ref_generation, u64 ref_generation, 159 u64 orig_ref_generation, u64 ref_generation,
153 u64 owner_objectid, int pin); 160 u64 owner_objectid, int pin);
161int btrfs_delayed_ref_lock(struct btrfs_trans_handle *trans,
162 struct btrfs_delayed_ref_head *head);
163int btrfs_find_ref_cluster(struct btrfs_trans_handle *trans,
164 struct list_head *cluster, u64 search_start);
154/* 165/*
155 * a node might live in a head or a regular ref, this lets you 166 * a node might live in a head or a regular ref, this lets you
156 * test for the proper type to use. 167 * test for the proper type to use.