Commit 409eb95d authored by Chris Mason's avatar Chris Mason Committed by David Woodhouse

Btrfs: Further reduce the concurrency penalty of defrag and drop_snapshot

Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent 26b8003f
...@@ -1312,7 +1312,10 @@ static void reada_walk_down(struct btrfs_root *root, ...@@ -1312,7 +1312,10 @@ static void reada_walk_down(struct btrfs_root *root,
BUG_ON(ret); BUG_ON(ret);
if (refs != 1) if (refs != 1)
continue; continue;
mutex_unlock(&root->fs_info->fs_mutex);
ret = readahead_tree_block(root, blocknr); ret = readahead_tree_block(root, blocknr);
cond_resched();
mutex_lock(&root->fs_info->fs_mutex);
if (ret) if (ret)
break; break;
} }
...@@ -1445,7 +1448,6 @@ int btrfs_drop_snapshot(struct btrfs_trans_handle *trans, struct btrfs_root ...@@ -1445,7 +1448,6 @@ int btrfs_drop_snapshot(struct btrfs_trans_handle *trans, struct btrfs_root
struct btrfs_path *path; struct btrfs_path *path;
int i; int i;
int orig_level; int orig_level;
int num_walks = 0;
struct btrfs_root_item *root_item = &root->root_item; struct btrfs_root_item *root_item = &root->root_item;
path = btrfs_alloc_path(); path = btrfs_alloc_path();
...@@ -1486,12 +1488,9 @@ int btrfs_drop_snapshot(struct btrfs_trans_handle *trans, struct btrfs_root ...@@ -1486,12 +1488,9 @@ int btrfs_drop_snapshot(struct btrfs_trans_handle *trans, struct btrfs_root
break; break;
if (wret < 0) if (wret < 0)
ret = wret; ret = wret;
num_walks++; ret = -EAGAIN;
if (num_walks > 2) { get_bh(root->node);
ret = -EAGAIN; break;
get_bh(root->node);
break;
}
} }
for (i = 0; i <= orig_level; i++) { for (i = 0; i <= orig_level; i++) {
if (path->nodes[i]) { if (path->nodes[i]) {
......
...@@ -364,6 +364,9 @@ int btrfs_defrag_dirty_roots(struct btrfs_fs_info *info) ...@@ -364,6 +364,9 @@ int btrfs_defrag_dirty_roots(struct btrfs_fs_info *info)
break; break;
} }
root->defrag_running = 0; root->defrag_running = 0;
radix_tree_tag_clear(&info->fs_roots_radix,
(unsigned long)root->root_key.objectid,
BTRFS_ROOT_DEFRAG_TAG);
} }
} }
btrfs_end_transaction(trans, tree_root); btrfs_end_transaction(trans, tree_root);
......
...@@ -148,7 +148,6 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, ...@@ -148,7 +148,6 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
int level; int level;
int orig_level; int orig_level;
int i; int i;
int num_runs = 0;
if (root->ref_cows == 0) { if (root->ref_cows == 0) {
goto out; goto out;
...@@ -200,10 +199,8 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, ...@@ -200,10 +199,8 @@ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans,
break; break;
if (wret < 0) if (wret < 0)
ret = wret; ret = wret;
if (num_runs++ > 8) { ret = -EAGAIN;
ret = -EAGAIN; break;
break;
}
} }
for (i = 0; i <= orig_level; i++) { for (i = 0; i <= orig_level; i++) {
if (path->nodes[i]) { if (path->nodes[i]) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment