diff options
Diffstat (limited to 'fs/btrfs/tree-defrag.c')
-rw-r--r-- | fs/btrfs/tree-defrag.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c index 6ef1ba5f9c2f..3994795edfeb 100644 --- a/fs/btrfs/tree-defrag.c +++ b/fs/btrfs/tree-defrag.c | |||
@@ -58,6 +58,10 @@ static int defrag_walk_down(struct btrfs_trans_handle *trans, | |||
58 | if (root->fs_info->extent_root == root) | 58 | if (root->fs_info->extent_root == root) |
59 | is_extent = 1; | 59 | is_extent = 1; |
60 | 60 | ||
61 | if (*level == 1 && cache_only && path->nodes[1] && | ||
62 | !btrfs_buffer_defrag(path->nodes[1])) { | ||
63 | goto out; | ||
64 | } | ||
61 | while(*level > 0) { | 65 | while(*level > 0) { |
62 | WARN_ON(*level < 0); | 66 | WARN_ON(*level < 0); |
63 | WARN_ON(*level >= BTRFS_MAX_LEVEL); | 67 | WARN_ON(*level >= BTRFS_MAX_LEVEL); |
@@ -116,7 +120,7 @@ static int defrag_walk_down(struct btrfs_trans_handle *trans, | |||
116 | WARN_ON(*level >= BTRFS_MAX_LEVEL); | 120 | WARN_ON(*level >= BTRFS_MAX_LEVEL); |
117 | 121 | ||
118 | btrfs_clear_buffer_defrag(path->nodes[*level]); | 122 | btrfs_clear_buffer_defrag(path->nodes[*level]); |
119 | 123 | out: | |
120 | free_extent_buffer(path->nodes[*level]); | 124 | free_extent_buffer(path->nodes[*level]); |
121 | path->nodes[*level] = NULL; | 125 | path->nodes[*level] = NULL; |
122 | *level += 1; | 126 | *level += 1; |