diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-10-15 16:19:46 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:03:56 -0400 |
commit | 0f1ebbd159baade0417f8f62f0cd6810cc950832 (patch) | |
tree | 7b973923c6ad62cd20045618819a6fad19046662 /fs/btrfs/tree-defrag.c | |
parent | 19c00ddcc31ad4bdfb86b57085e06d6135b9b1d7 (diff) |
Btrfs: Large block related defrag optimizations
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/tree-defrag.c')
-rw-r--r-- | fs/btrfs/tree-defrag.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c index 0d1a1be0995c..d31c21ac6f23 100644 --- a/fs/btrfs/tree-defrag.c +++ b/fs/btrfs/tree-defrag.c | |||
@@ -118,7 +118,6 @@ static int defrag_walk_down(struct btrfs_trans_handle *trans, | |||
118 | WARN_ON(*level >= BTRFS_MAX_LEVEL); | 118 | WARN_ON(*level >= BTRFS_MAX_LEVEL); |
119 | 119 | ||
120 | btrfs_clear_buffer_defrag(path->nodes[*level]); | 120 | btrfs_clear_buffer_defrag(path->nodes[*level]); |
121 | btrfs_clear_buffer_defrag_done(path->nodes[*level]); | ||
122 | 121 | ||
123 | free_extent_buffer(path->nodes[*level]); | 122 | free_extent_buffer(path->nodes[*level]); |
124 | path->nodes[*level] = NULL; | 123 | path->nodes[*level] = NULL; |
@@ -148,6 +147,26 @@ static int defrag_walk_up(struct btrfs_trans_handle *trans, | |||
148 | root->defrag_level = i; | 147 | root->defrag_level = i; |
149 | return 0; | 148 | return 0; |
150 | } else { | 149 | } else { |
150 | if (*level > 1 && path->nodes[*level] != root->node) { | ||
151 | struct extent_buffer *next; | ||
152 | u64 last; | ||
153 | int ret; | ||
154 | ret = btrfs_cow_block(trans, root, | ||
155 | path->nodes[*level], | ||
156 | path->nodes[*level + 1], | ||
157 | path->slots[*level + 1], | ||
158 | &next); | ||
159 | BUG_ON(ret); | ||
160 | path->nodes[*level] = next; | ||
161 | last = next->start; | ||
162 | ret = btrfs_realloc_node(trans, root, next, | ||
163 | cache_only, &last); | ||
164 | BUG_ON(ret); | ||
165 | |||
166 | if (root == root->fs_info->extent_root) | ||
167 | btrfs_extent_post_op(trans, root); | ||
168 | } | ||
169 | |||
151 | btrfs_clear_buffer_defrag(path->nodes[*level]); | 170 | btrfs_clear_buffer_defrag(path->nodes[*level]); |
152 | btrfs_clear_buffer_defrag_done(path->nodes[*level]); | 171 | btrfs_clear_buffer_defrag_done(path->nodes[*level]); |
153 | free_extent_buffer(path->nodes[*level]); | 172 | free_extent_buffer(path->nodes[*level]); |
@@ -183,9 +202,11 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, | |||
183 | 202 | ||
184 | level = btrfs_header_level(root->node); | 203 | level = btrfs_header_level(root->node); |
185 | orig_level = level; | 204 | orig_level = level; |
205 | |||
186 | if (level == 0) { | 206 | if (level == 0) { |
187 | goto out; | 207 | goto out; |
188 | } | 208 | } |
209 | |||
189 | if (root->defrag_progress.objectid == 0) { | 210 | if (root->defrag_progress.objectid == 0) { |
190 | extent_buffer_get(root->node); | 211 | extent_buffer_get(root->node); |
191 | ret = btrfs_cow_block(trans, root, root->node, NULL, 0, &tmp); | 212 | ret = btrfs_cow_block(trans, root, root->node, NULL, 0, &tmp); |