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>
This commit is contained in:
@@ -1649,7 +1649,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
|
||||
}
|
||||
|
||||
if (level == 0 && rc->stage == UPDATE_DATA_PTRS) {
|
||||
trans = btrfs_start_transaction(root, 1);
|
||||
trans = btrfs_start_transaction(root, 0);
|
||||
|
||||
leaf = path->nodes[0];
|
||||
btrfs_item_key_to_cpu(leaf, &key, 0);
|
||||
@@ -1675,7 +1675,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
|
||||
while (1) {
|
||||
leaf = NULL;
|
||||
replaced = 0;
|
||||
trans = btrfs_start_transaction(root, 1);
|
||||
trans = btrfs_start_transaction(root, 0);
|
||||
max_level = level;
|
||||
|
||||
ret = walk_down_reloc_tree(reloc_root, path, &level);
|
||||
@@ -1803,7 +1803,7 @@ static void merge_func(struct btrfs_work *work)
|
||||
|
||||
merge_reloc_root(async->rc, root);
|
||||
|
||||
trans = btrfs_start_transaction(root, 1);
|
||||
trans = btrfs_start_transaction(root, 0);
|
||||
btrfs_update_reloc_root(trans, root);
|
||||
btrfs_end_transaction(trans, root);
|
||||
}
|
||||
@@ -3297,11 +3297,11 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
|
||||
rc->create_reloc_root = 1;
|
||||
set_reloc_control(rc);
|
||||
|
||||
trans = btrfs_start_transaction(rc->extent_root, 1);
|
||||
trans = btrfs_join_transaction(rc->extent_root, 1);
|
||||
btrfs_commit_transaction(trans, rc->extent_root);
|
||||
|
||||
while (1) {
|
||||
trans = btrfs_start_transaction(rc->extent_root, 1);
|
||||
trans = btrfs_start_transaction(rc->extent_root, 0);
|
||||
|
||||
ret = find_next_extent(trans, rc, path);
|
||||
if (ret < 0)
|
||||
@@ -3411,7 +3411,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
|
||||
smp_mb();
|
||||
|
||||
if (rc->extents_found > 0) {
|
||||
trans = btrfs_start_transaction(rc->extent_root, 1);
|
||||
trans = btrfs_join_transaction(rc->extent_root, 1);
|
||||
btrfs_commit_transaction(trans, rc->extent_root);
|
||||
}
|
||||
|
||||
@@ -3420,7 +3420,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
|
||||
unset_reloc_control(rc);
|
||||
|
||||
/* get rid of pinned extents */
|
||||
trans = btrfs_start_transaction(rc->extent_root, 1);
|
||||
trans = btrfs_join_transaction(rc->extent_root, 1);
|
||||
btrfs_commit_transaction(trans, rc->extent_root);
|
||||
|
||||
return err;
|
||||
@@ -3475,7 +3475,7 @@ static struct inode *create_reloc_inode(struct btrfs_fs_info *fs_info,
|
||||
if (IS_ERR(root))
|
||||
return ERR_CAST(root);
|
||||
|
||||
trans = btrfs_start_transaction(root, 1);
|
||||
trans = btrfs_start_transaction(root, 6);
|
||||
BUG_ON(!trans);
|
||||
|
||||
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)
|
||||
struct btrfs_trans_handle *trans;
|
||||
int ret;
|
||||
|
||||
trans = btrfs_start_transaction(root->fs_info->tree_root, 1);
|
||||
trans = btrfs_start_transaction(root->fs_info->tree_root, 0);
|
||||
|
||||
memset(&root->root_item.drop_progress, 0,
|
||||
sizeof(root->root_item.drop_progress));
|
||||
|
Reference in New Issue
Block a user