aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-08-08 10:08:58 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-08-08 10:08:58 -0400
commitf4468e94c86c2031f447788c4bfe7dfd2fcdc93a (patch)
tree984a0751f69524cada1113d5504875a0fb5cec35
parent37fa704640059d515cb2c7c6eaa5eb82901b95ac (diff)
Btrfs: Let some locks go during defrag and snapshot dropping
Signed-off-by: Chris Mason <chris.mason@oracle.com>
-rw-r--r--fs/btrfs/ctree.h4
-rw-r--r--fs/btrfs/extent-tree.c6
-rw-r--r--fs/btrfs/transaction.c8
3 files changed, 14 insertions, 4 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 42aa20301bc..8b7d01597f4 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -300,9 +300,9 @@ struct btrfs_fs_info {
300 struct radix_tree_root block_group_data_radix; 300 struct radix_tree_root block_group_data_radix;
301 struct radix_tree_root extent_map_radix; 301 struct radix_tree_root extent_map_radix;
302 302
303 u64 extent_tree_insert[BTRFS_MAX_LEVEL * 3]; 303 u64 extent_tree_insert[BTRFS_MAX_LEVEL * 6];
304 int extent_tree_insert_nr; 304 int extent_tree_insert_nr;
305 u64 extent_tree_prealloc[BTRFS_MAX_LEVEL * 3]; 305 u64 extent_tree_prealloc[BTRFS_MAX_LEVEL * 6];
306 int extent_tree_prealloc_nr; 306 int extent_tree_prealloc_nr;
307 307
308 u64 generation; 308 u64 generation;
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 26b8d340649..f7d76d34fc3 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -1018,7 +1018,7 @@ static int find_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root
1018 if (num_blocks == 0) { 1018 if (num_blocks == 0) {
1019 fill_prealloc = 1; 1019 fill_prealloc = 1;
1020 num_blocks = 1; 1020 num_blocks = 1;
1021 total_needed = (min(level + 1, BTRFS_MAX_LEVEL) + 2) * 3; 1021 total_needed = (min(level + 1, BTRFS_MAX_LEVEL)) * 6;
1022 } 1022 }
1023 if (fill_prealloc) { 1023 if (fill_prealloc) {
1024 u64 first; 1024 u64 first;
@@ -1300,6 +1300,8 @@ int btrfs_alloc_extent(struct btrfs_trans_handle *trans,
1300 ins->objectid; 1300 ins->objectid;
1301 ret = update_block_group(trans, root, 1301 ret = update_block_group(trans, root,
1302 ins->objectid, ins->offset, 1, 0, 0); 1302 ins->objectid, ins->offset, 1, 0, 0);
1303 WARN_ON(info->extent_tree_insert_nr >
1304 ARRAY_SIZE(info->extent_tree_insert));
1303 BUG_ON(ret); 1305 BUG_ON(ret);
1304 return 0; 1306 return 0;
1305 } 1307 }
@@ -1628,7 +1630,7 @@ int btrfs_drop_snapshot(struct btrfs_trans_handle *trans, struct btrfs_root
1628 if (wret < 0) 1630 if (wret < 0)
1629 ret = wret; 1631 ret = wret;
1630 num_walks++; 1632 num_walks++;
1631 if (num_walks > 10) { 1633 if (num_walks > 2) {
1632 ret = -EAGAIN; 1634 ret = -EAGAIN;
1633 get_bh(root->node); 1635 get_bh(root->node);
1634 break; 1636 break;
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 338a7199363..88b0752550b 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -354,6 +354,7 @@ int btrfs_defrag_dirty_roots(struct btrfs_fs_info *info)
354 mutex_unlock(&info->fs_mutex); 354 mutex_unlock(&info->fs_mutex);
355 355
356 btrfs_btree_balance_dirty(root); 356 btrfs_btree_balance_dirty(root);
357 cond_resched();
357 358
358 mutex_lock(&info->fs_mutex); 359 mutex_lock(&info->fs_mutex);
359 trans = btrfs_start_transaction(tree_root, 1); 360 trans = btrfs_start_transaction(tree_root, 1);
@@ -394,6 +395,12 @@ static int drop_dirty_roots(struct btrfs_root *tree_root,
394 ret = err; 395 ret = err;
395 ret = btrfs_end_transaction(trans, tree_root); 396 ret = btrfs_end_transaction(trans, tree_root);
396 BUG_ON(ret); 397 BUG_ON(ret);
398 mutex_unlock(&tree_root->fs_info->fs_mutex);
399
400 btrfs_btree_balance_dirty(tree_root);
401 schedule();
402
403 mutex_lock(&tree_root->fs_info->fs_mutex);
397 } 404 }
398 BUG_ON(ret); 405 BUG_ON(ret);
399 ret = btrfs_del_root(trans, tree_root, &dirty->root->root_key); 406 ret = btrfs_del_root(trans, tree_root, &dirty->root->root_key);
@@ -406,6 +413,7 @@ static int drop_dirty_roots(struct btrfs_root *tree_root,
406 kfree(dirty); 413 kfree(dirty);
407 mutex_unlock(&tree_root->fs_info->fs_mutex); 414 mutex_unlock(&tree_root->fs_info->fs_mutex);
408 btrfs_btree_balance_dirty(tree_root); 415 btrfs_btree_balance_dirty(tree_root);
416 schedule();
409 } 417 }
410 return ret; 418 return ret;
411} 419}