aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/relocation.c
diff options
context:
space:
mode:
authorYan, Zheng <zheng.yan@oracle.com>2010-05-16 10:48:46 -0400
committerChris Mason <chris.mason@oracle.com>2010-05-25 10:34:50 -0400
commita22285a6a32390195235171b89d157ed1a1fe932 (patch)
tree3fabc88a029e1af4f2fdcc708e7b62ef3cf3703a /fs/btrfs/relocation.c
parentf0486c68e4bd9a06a5904d3eeb3a0d73a83befb8 (diff)
Btrfs: Integrate metadata reservation with start_transaction
Besides simplify the code, this change makes sure all metadata reservation for normal metadata operations are released after committing transaction. Changes since V1: Add code that check if unlink and rmdir will free space. Add ENOSPC handling for clone ioctl. Signed-off-by: Yan Zheng <zheng.yan@oracle.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/relocation.c')
-rw-r--r--fs/btrfs/relocation.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index d565b45a6352..145a468c300d 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -1649,7 +1649,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
1649 } 1649 }
1650 1650
1651 if (level == 0 && rc->stage == UPDATE_DATA_PTRS) { 1651 if (level == 0 && rc->stage == UPDATE_DATA_PTRS) {
1652 trans = btrfs_start_transaction(root, 1); 1652 trans = btrfs_start_transaction(root, 0);
1653 1653
1654 leaf = path->nodes[0]; 1654 leaf = path->nodes[0];
1655 btrfs_item_key_to_cpu(leaf, &key, 0); 1655 btrfs_item_key_to_cpu(leaf, &key, 0);
@@ -1675,7 +1675,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
1675 while (1) { 1675 while (1) {
1676 leaf = NULL; 1676 leaf = NULL;
1677 replaced = 0; 1677 replaced = 0;
1678 trans = btrfs_start_transaction(root, 1); 1678 trans = btrfs_start_transaction(root, 0);
1679 max_level = level; 1679 max_level = level;
1680 1680
1681 ret = walk_down_reloc_tree(reloc_root, path, &level); 1681 ret = walk_down_reloc_tree(reloc_root, path, &level);
@@ -1803,7 +1803,7 @@ static void merge_func(struct btrfs_work *work)
1803 1803
1804 merge_reloc_root(async->rc, root); 1804 merge_reloc_root(async->rc, root);
1805 1805
1806 trans = btrfs_start_transaction(root, 1); 1806 trans = btrfs_start_transaction(root, 0);
1807 btrfs_update_reloc_root(trans, root); 1807 btrfs_update_reloc_root(trans, root);
1808 btrfs_end_transaction(trans, root); 1808 btrfs_end_transaction(trans, root);
1809 } 1809 }
@@ -3297,11 +3297,11 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
3297 rc->create_reloc_root = 1; 3297 rc->create_reloc_root = 1;
3298 set_reloc_control(rc); 3298 set_reloc_control(rc);
3299 3299
3300 trans = btrfs_start_transaction(rc->extent_root, 1); 3300 trans = btrfs_join_transaction(rc->extent_root, 1);
3301 btrfs_commit_transaction(trans, rc->extent_root); 3301 btrfs_commit_transaction(trans, rc->extent_root);
3302 3302
3303 while (1) { 3303 while (1) {
3304 trans = btrfs_start_transaction(rc->extent_root, 1); 3304 trans = btrfs_start_transaction(rc->extent_root, 0);
3305 3305
3306 ret = find_next_extent(trans, rc, path); 3306 ret = find_next_extent(trans, rc, path);
3307 if (ret < 0) 3307 if (ret < 0)
@@ -3411,7 +3411,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
3411 smp_mb(); 3411 smp_mb();
3412 3412
3413 if (rc->extents_found > 0) { 3413 if (rc->extents_found > 0) {
3414 trans = btrfs_start_transaction(rc->extent_root, 1); 3414 trans = btrfs_join_transaction(rc->extent_root, 1);
3415 btrfs_commit_transaction(trans, rc->extent_root); 3415 btrfs_commit_transaction(trans, rc->extent_root);
3416 } 3416 }
3417 3417
@@ -3420,7 +3420,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
3420 unset_reloc_control(rc); 3420 unset_reloc_control(rc);
3421 3421
3422 /* get rid of pinned extents */ 3422 /* get rid of pinned extents */
3423 trans = btrfs_start_transaction(rc->extent_root, 1); 3423 trans = btrfs_join_transaction(rc->extent_root, 1);
3424 btrfs_commit_transaction(trans, rc->extent_root); 3424 btrfs_commit_transaction(trans, rc->extent_root);
3425 3425
3426 return err; 3426 return err;
@@ -3475,7 +3475,7 @@ static struct inode *create_reloc_inode(struct btrfs_fs_info *fs_info,
3475 if (IS_ERR(root)) 3475 if (IS_ERR(root))
3476 return ERR_CAST(root); 3476 return ERR_CAST(root);
3477 3477
3478 trans = btrfs_start_transaction(root, 1); 3478 trans = btrfs_start_transaction(root, 6);
3479 BUG_ON(!trans); 3479 BUG_ON(!trans);
3480 3480
3481 err = btrfs_find_free_objectid(trans, root, objectid, &objectid); 3481 err = btrfs_find_free_objectid(trans, root, objectid, &objectid);
@@ -3619,7 +3619,7 @@ static noinline_for_stack int mark_garbage_root(struct btrfs_root *root)
3619 struct btrfs_trans_handle *trans; 3619 struct btrfs_trans_handle *trans;
3620 int ret; 3620 int ret;
3621 3621
3622 trans = btrfs_start_transaction(root->fs_info->tree_root, 1); 3622 trans = btrfs_start_transaction(root->fs_info->tree_root, 0);
3623 3623
3624 memset(&root->root_item.drop_progress, 0, 3624 memset(&root->root_item.drop_progress, 0,
3625 sizeof(root->root_item.drop_progress)); 3625 sizeof(root->root_item.drop_progress));