aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/transaction.c
diff options
context:
space:
mode:
authorZheng Yan <zheng.yan@oracle.com>2008-09-26 10:05:38 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-26 10:05:38 -0400
commit5b21f2ed3f2947b5195b65c9fdbdd9e52904cc03 (patch)
tree9af8f539ac487c163f3207bc065767c3c8b37ae7 /fs/btrfs/transaction.c
parente465768938f95388723b0fd3c50a0ae48173edb9 (diff)
Btrfs: extent_map and data=ordered fixes for space balancing
* Add an EXTENT_BOUNDARY state bit to keep the writepage code from merging data extents that are in the process of being relocated. This allows us to do accounting for them properly. * The balancing code relocates data extents indepdent of the underlying inode. The extent_map code was modified to properly account for things moving around (invalidating extent_map caches in the inode). * Don't take the drop_mutex in the create_subvol ioctl. It isn't required. * Fix walking of the ordered extent list to avoid races with sys_unlink * Change the lock ordering rules. Transaction start goes outside the drop_mutex. This allows btrfs_commit_transaction to directly drop the relocation trees. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/transaction.c')
-rw-r--r--fs/btrfs/transaction.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 656baefa5255..8c83cf464c83 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -109,6 +109,7 @@ noinline int btrfs_record_root_in_trans(struct btrfs_root *root)
109 spin_lock_init(&dirty->root->node_lock); 109 spin_lock_init(&dirty->root->node_lock);
110 spin_lock_init(&dirty->root->list_lock); 110 spin_lock_init(&dirty->root->list_lock);
111 mutex_init(&dirty->root->objectid_mutex); 111 mutex_init(&dirty->root->objectid_mutex);
112 mutex_init(&dirty->root->log_mutex);
112 INIT_LIST_HEAD(&dirty->root->dead_list); 113 INIT_LIST_HEAD(&dirty->root->dead_list);
113 dirty->root->node = root->commit_root; 114 dirty->root->node = root->commit_root;
114 dirty->root->commit_root = NULL; 115 dirty->root->commit_root = NULL;
@@ -590,13 +591,14 @@ static noinline int drop_dirty_roots(struct btrfs_root *tree_root,
590 root = dirty->latest_root; 591 root = dirty->latest_root;
591 atomic_inc(&root->fs_info->throttles); 592 atomic_inc(&root->fs_info->throttles);
592 593
593 mutex_lock(&root->fs_info->drop_mutex);
594 while(1) { 594 while(1) {
595 trans = btrfs_start_transaction(tree_root, 1); 595 trans = btrfs_start_transaction(tree_root, 1);
596 mutex_lock(&root->fs_info->drop_mutex);
596 ret = btrfs_drop_snapshot(trans, dirty->root); 597 ret = btrfs_drop_snapshot(trans, dirty->root);
597 if (ret != -EAGAIN) { 598 if (ret != -EAGAIN) {
598 break; 599 break;
599 } 600 }
601 mutex_unlock(&root->fs_info->drop_mutex);
600 602
601 err = btrfs_update_root(trans, 603 err = btrfs_update_root(trans,
602 tree_root, 604 tree_root,
@@ -608,10 +610,8 @@ static noinline int drop_dirty_roots(struct btrfs_root *tree_root,
608 ret = btrfs_end_transaction(trans, tree_root); 610 ret = btrfs_end_transaction(trans, tree_root);
609 BUG_ON(ret); 611 BUG_ON(ret);
610 612
611 mutex_unlock(&root->fs_info->drop_mutex);
612 btrfs_btree_balance_dirty(tree_root, nr); 613 btrfs_btree_balance_dirty(tree_root, nr);
613 cond_resched(); 614 cond_resched();
614 mutex_lock(&root->fs_info->drop_mutex);
615 } 615 }
616 BUG_ON(ret); 616 BUG_ON(ret);
617 atomic_dec(&root->fs_info->throttles); 617 atomic_dec(&root->fs_info->throttles);
@@ -689,7 +689,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
689 memcpy(new_root_item, &root->root_item, sizeof(*new_root_item)); 689 memcpy(new_root_item, &root->root_item, sizeof(*new_root_item));
690 690
691 key.objectid = objectid; 691 key.objectid = objectid;
692 key.offset = 1; 692 key.offset = trans->transid;
693 btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY); 693 btrfs_set_key_type(&key, BTRFS_ROOT_ITEM_KEY);
694 694
695 old = btrfs_lock_root_node(root); 695 old = btrfs_lock_root_node(root);