diff options
Diffstat (limited to 'fs/btrfs/tree-defrag.c')
| -rw-r--r-- | fs/btrfs/tree-defrag.c | 24 | 
1 files changed, 9 insertions, 15 deletions
diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c index 992ab425599..a63719cc957 100644 --- a/fs/btrfs/tree-defrag.c +++ b/fs/btrfs/tree-defrag.c @@ -23,27 +23,24 @@  #include "transaction.h"  #include "locking.h" -/* defrag all the leaves in a given btree.  If cache_only == 1, don't read - * things from disk, otherwise read all the leaves and try to get key order to +/* + * Defrag all the leaves in a given btree. + * Read all the leaves and try to get key order to   * better reflect disk order   */  int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, -			struct btrfs_root *root, int cache_only) +			struct btrfs_root *root)  {  	struct btrfs_path *path = NULL;  	struct btrfs_key key;  	int ret = 0;  	int wret;  	int level; -	int is_extent = 0;  	int next_key_ret = 0;  	u64 last_ret = 0;  	u64 min_trans = 0; -	if (cache_only) -		goto out; -  	if (root->fs_info->extent_root == root) {  		/*  		 * there's recursion here right now in the tree locking, @@ -52,7 +49,7 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,  		goto out;  	} -	if (root->ref_cows == 0 && !is_extent) +	if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state))  		goto out;  	if (btrfs_test_opt(root, SSD)) @@ -86,18 +83,15 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,  	}  	path->keep_locks = 1; -	if (cache_only) -		min_trans = root->defrag_trans_start; -	ret = btrfs_search_forward(root, &key, NULL, path, -				   cache_only, min_trans); +	ret = btrfs_search_forward(root, &key, path, min_trans);  	if (ret < 0)  		goto out;  	if (ret > 0) {  		ret = 0;  		goto out;  	} -	btrfs_release_path(root, path); +	btrfs_release_path(path);  	wret = btrfs_search_slot(trans, root, &key, path, 0, 1);  	if (wret < 0) { @@ -109,11 +103,11 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,  		goto out;  	}  	path->slots[1] = btrfs_header_nritems(path->nodes[1]); -	next_key_ret = btrfs_find_next_key(root, path, &key, 1, cache_only, +	next_key_ret = btrfs_find_next_key(root, path, &key, 1,  					   min_trans);  	ret = btrfs_realloc_node(trans, root,  				 path->nodes[1], 0, -				 cache_only, &last_ret, +				 &last_ret,  				 &root->defrag_progress);  	if (ret) {  		WARN_ON(ret == -EAGAIN);  | 
