diff options
Diffstat (limited to 'fs/btrfs/tree-defrag.c')
| -rw-r--r-- | fs/btrfs/tree-defrag.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c index 3b580ee8ab1d..94e05c1f118a 100644 --- a/fs/btrfs/tree-defrag.c +++ b/fs/btrfs/tree-defrag.c | |||
| @@ -23,13 +23,14 @@ | |||
| 23 | #include "transaction.h" | 23 | #include "transaction.h" |
| 24 | #include "locking.h" | 24 | #include "locking.h" |
| 25 | 25 | ||
| 26 | /* defrag all the leaves in a given btree. If cache_only == 1, don't read | 26 | /* |
| 27 | * things from disk, otherwise read all the leaves and try to get key order to | 27 | * Defrag all the leaves in a given btree. |
| 28 | * Read all the leaves and try to get key order to | ||
| 28 | * better reflect disk order | 29 | * better reflect disk order |
| 29 | */ | 30 | */ |
| 30 | 31 | ||
| 31 | int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, | 32 | int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, |
| 32 | struct btrfs_root *root, int cache_only) | 33 | struct btrfs_root *root) |
| 33 | { | 34 | { |
| 34 | struct btrfs_path *path = NULL; | 35 | struct btrfs_path *path = NULL; |
| 35 | struct btrfs_key key; | 36 | struct btrfs_key key; |
| @@ -41,9 +42,6 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, | |||
| 41 | u64 last_ret = 0; | 42 | u64 last_ret = 0; |
| 42 | u64 min_trans = 0; | 43 | u64 min_trans = 0; |
| 43 | 44 | ||
| 44 | if (cache_only) | ||
| 45 | goto out; | ||
| 46 | |||
| 47 | if (root->fs_info->extent_root == root) { | 45 | if (root->fs_info->extent_root == root) { |
| 48 | /* | 46 | /* |
| 49 | * there's recursion here right now in the tree locking, | 47 | * there's recursion here right now in the tree locking, |
| @@ -86,11 +84,8 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, | |||
| 86 | } | 84 | } |
| 87 | 85 | ||
| 88 | path->keep_locks = 1; | 86 | path->keep_locks = 1; |
| 89 | if (cache_only) | ||
| 90 | min_trans = root->defrag_trans_start; | ||
| 91 | 87 | ||
| 92 | ret = btrfs_search_forward(root, &key, NULL, path, | 88 | ret = btrfs_search_forward(root, &key, NULL, path, min_trans); |
| 93 | cache_only, min_trans); | ||
| 94 | if (ret < 0) | 89 | if (ret < 0) |
| 95 | goto out; | 90 | goto out; |
| 96 | if (ret > 0) { | 91 | if (ret > 0) { |
| @@ -109,11 +104,11 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, | |||
| 109 | goto out; | 104 | goto out; |
| 110 | } | 105 | } |
| 111 | path->slots[1] = btrfs_header_nritems(path->nodes[1]); | 106 | path->slots[1] = btrfs_header_nritems(path->nodes[1]); |
| 112 | next_key_ret = btrfs_find_next_key(root, path, &key, 1, cache_only, | 107 | next_key_ret = btrfs_find_next_key(root, path, &key, 1, |
| 113 | min_trans); | 108 | min_trans); |
| 114 | ret = btrfs_realloc_node(trans, root, | 109 | ret = btrfs_realloc_node(trans, root, |
| 115 | path->nodes[1], 0, | 110 | path->nodes[1], 0, |
| 116 | cache_only, &last_ret, | 111 | &last_ret, |
| 117 | &root->defrag_progress); | 112 | &root->defrag_progress); |
| 118 | if (ret) { | 113 | if (ret) { |
| 119 | WARN_ON(ret == -EAGAIN); | 114 | WARN_ON(ret == -EAGAIN); |
