Skip to content

Commit

Permalink
Btrfs: Defrag: only walk into nodes with the defrag bit set
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
Chris Mason committed Sep 25, 2008
1 parent 304fced commit cf786e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion fs/btrfs/ctree.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ int btrfs_realloc_node(struct btrfs_trans_handle *trans,
*last_ret = search_start;
if (parent_level == 1)
btrfs_clear_buffer_defrag(tmp);
btrfs_set_buffer_defrag_done(tmp);
free_extent_buffer(tmp);
}
return err;
Expand Down
8 changes: 4 additions & 4 deletions fs/btrfs/tree-defrag.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ static int defrag_walk_down(struct btrfs_trans_handle *trans,
if (cache_only) {
next = btrfs_find_tree_block(root, bytenr,
btrfs_level_size(root, *level - 1));
/* FIXME, test for defrag */
if (!next || !btrfs_buffer_uptodate(next)) {
if (!next || !btrfs_buffer_uptodate(next) ||
!btrfs_buffer_defrag(next)) {
free_extent_buffer(next);
path->slots[*level]++;
continue;
Expand Down Expand Up @@ -147,7 +147,8 @@ static int defrag_walk_up(struct btrfs_trans_handle *trans,
root->defrag_level = i;
return 0;
} else {
if (*level > 1 && path->nodes[*level] != root->node) {
if (*level > 1 && path->nodes[*level] != root->node &&
btrfs_buffer_defrag(path->nodes[*level])) {
struct extent_buffer *next;
u64 last;
int ret;
Expand All @@ -168,7 +169,6 @@ static int defrag_walk_up(struct btrfs_trans_handle *trans,
}

btrfs_clear_buffer_defrag(path->nodes[*level]);
btrfs_clear_buffer_defrag_done(path->nodes[*level]);
free_extent_buffer(path->nodes[*level]);
path->nodes[*level] = NULL;
*level = i + 1;
Expand Down

0 comments on commit cf786e7

Please sign in to comment.