aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent_io.c
diff options
context:
space:
mode:
authorJosef Bacik <josef@redhat.com>2010-02-02 16:19:11 -0500
committerChris Mason <chris.mason@oracle.com>2010-03-15 11:00:13 -0400
commitc2a128d28a2e78e159e17e8c9274d0a9d9492555 (patch)
treede2a9aab9c2037aa027f598e66006de7b8cf70cd /fs/btrfs/extent_io.c
parent49958fd7dbb83cd4d65179d025940e01fe1fbacd (diff)
Btrfs: cache extent state in find_delalloc_range
This patch makes us cache the extent state we find in find_delalloc_range since we'll have to lock the extent later on in the function. This will keep us from re-searching for the rang when we try to lock the extent. Signed-off-by: Josef Bacik <josef@redhat.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent_io.c')
-rw-r--r--fs/btrfs/extent_io.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 355a973719a0..3c17c9eb0d98 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1171,7 +1171,8 @@ out:
1171 * 1 is returned if we find something, 0 if nothing was in the tree 1171 * 1 is returned if we find something, 0 if nothing was in the tree
1172 */ 1172 */
1173static noinline u64 find_delalloc_range(struct extent_io_tree *tree, 1173static noinline u64 find_delalloc_range(struct extent_io_tree *tree,
1174 u64 *start, u64 *end, u64 max_bytes) 1174 u64 *start, u64 *end, u64 max_bytes,
1175 struct extent_state **cached_state)
1175{ 1176{
1176 struct rb_node *node; 1177 struct rb_node *node;
1177 struct extent_state *state; 1178 struct extent_state *state;
@@ -1203,8 +1204,11 @@ static noinline u64 find_delalloc_range(struct extent_io_tree *tree,
1203 *end = state->end; 1204 *end = state->end;
1204 goto out; 1205 goto out;
1205 } 1206 }
1206 if (!found) 1207 if (!found) {
1207 *start = state->start; 1208 *start = state->start;
1209 *cached_state = state;
1210 atomic_inc(&state->refs);
1211 }
1208 found++; 1212 found++;
1209 *end = state->end; 1213 *end = state->end;
1210 cur_start = state->end + 1; 1214 cur_start = state->end + 1;
@@ -1336,10 +1340,11 @@ again:
1336 delalloc_start = *start; 1340 delalloc_start = *start;
1337 delalloc_end = 0; 1341 delalloc_end = 0;
1338 found = find_delalloc_range(tree, &delalloc_start, &delalloc_end, 1342 found = find_delalloc_range(tree, &delalloc_start, &delalloc_end,
1339 max_bytes); 1343 max_bytes, &cached_state);
1340 if (!found || delalloc_end <= *start) { 1344 if (!found || delalloc_end <= *start) {
1341 *start = delalloc_start; 1345 *start = delalloc_start;
1342 *end = delalloc_end; 1346 *end = delalloc_end;
1347 free_extent_state(cached_state);
1343 return found; 1348 return found;
1344 } 1349 }
1345 1350