提交 7174109c 编写于 作者: Q Qu Wenruo 提交者: Chris Mason

btrfs: qgroup: Use new metadata reservation.

As we have the new metadata reservation functions, use them to replace
the old btrfs_qgroup_reserve() call for metadata.
Signed-off-by: NQu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: NChris Mason <clm@fb.com>
上级 55eeaf05
...@@ -5337,7 +5337,7 @@ int btrfs_subvolume_reserve_metadata(struct btrfs_root *root, ...@@ -5337,7 +5337,7 @@ int btrfs_subvolume_reserve_metadata(struct btrfs_root *root,
if (root->fs_info->quota_enabled) { if (root->fs_info->quota_enabled) {
/* One for parent inode, two for dir entries */ /* One for parent inode, two for dir entries */
num_bytes = 3 * root->nodesize; num_bytes = 3 * root->nodesize;
ret = btrfs_qgroup_reserve(root, num_bytes); ret = btrfs_qgroup_reserve_meta(root, num_bytes);
if (ret) if (ret)
return ret; return ret;
} else { } else {
...@@ -5355,10 +5355,8 @@ int btrfs_subvolume_reserve_metadata(struct btrfs_root *root, ...@@ -5355,10 +5355,8 @@ int btrfs_subvolume_reserve_metadata(struct btrfs_root *root,
if (ret == -ENOSPC && use_global_rsv) if (ret == -ENOSPC && use_global_rsv)
ret = btrfs_block_rsv_migrate(global_rsv, rsv, num_bytes); ret = btrfs_block_rsv_migrate(global_rsv, rsv, num_bytes);
if (ret) { if (ret && *qgroup_reserved)
if (*qgroup_reserved) btrfs_qgroup_free_meta(root, *qgroup_reserved);
btrfs_qgroup_free(root, *qgroup_reserved);
}
return ret; return ret;
} }
...@@ -5519,15 +5517,15 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes) ...@@ -5519,15 +5517,15 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)
spin_unlock(&BTRFS_I(inode)->lock); spin_unlock(&BTRFS_I(inode)->lock);
if (root->fs_info->quota_enabled) { if (root->fs_info->quota_enabled) {
ret = btrfs_qgroup_reserve(root, nr_extents * root->nodesize); ret = btrfs_qgroup_reserve_meta(root,
nr_extents * root->nodesize);
if (ret) if (ret)
goto out_fail; goto out_fail;
} }
ret = reserve_metadata_bytes(root, block_rsv, to_reserve, flush); ret = reserve_metadata_bytes(root, block_rsv, to_reserve, flush);
if (unlikely(ret)) { if (unlikely(ret)) {
if (root->fs_info->quota_enabled) btrfs_qgroup_free_meta(root, nr_extents * root->nodesize);
btrfs_qgroup_free(root, nr_extents * root->nodesize);
goto out_fail; goto out_fail;
} }
......
...@@ -480,13 +480,10 @@ start_transaction(struct btrfs_root *root, unsigned int num_items, ...@@ -480,13 +480,10 @@ start_transaction(struct btrfs_root *root, unsigned int num_items,
* the appropriate flushing if need be. * the appropriate flushing if need be.
*/ */
if (num_items > 0 && root != root->fs_info->chunk_root) { if (num_items > 0 && root != root->fs_info->chunk_root) {
if (root->fs_info->quota_enabled && qgroup_reserved = num_items * root->nodesize;
is_fstree(root->root_key.objectid)) { ret = btrfs_qgroup_reserve_meta(root, qgroup_reserved);
qgroup_reserved = num_items * root->nodesize; if (ret)
ret = btrfs_qgroup_reserve(root, qgroup_reserved); return ERR_PTR(ret);
if (ret)
return ERR_PTR(ret);
}
num_bytes = btrfs_calc_trans_metadata_size(root, num_items); num_bytes = btrfs_calc_trans_metadata_size(root, num_items);
/* /*
...@@ -547,6 +544,7 @@ start_transaction(struct btrfs_root *root, unsigned int num_items, ...@@ -547,6 +544,7 @@ start_transaction(struct btrfs_root *root, unsigned int num_items,
h->transaction = cur_trans; h->transaction = cur_trans;
h->root = root; h->root = root;
h->use_count = 1; h->use_count = 1;
h->type = type; h->type = type;
h->can_flush_pending_bgs = true; h->can_flush_pending_bgs = true;
INIT_LIST_HEAD(&h->qgroup_ref_list); INIT_LIST_HEAD(&h->qgroup_ref_list);
...@@ -568,7 +566,6 @@ start_transaction(struct btrfs_root *root, unsigned int num_items, ...@@ -568,7 +566,6 @@ start_transaction(struct btrfs_root *root, unsigned int num_items,
h->bytes_reserved = num_bytes; h->bytes_reserved = num_bytes;
h->reloc_reserved = reloc_reserved; h->reloc_reserved = reloc_reserved;
} }
h->qgroup_reserved = qgroup_reserved;
got_it: got_it:
btrfs_record_root_in_trans(h, root); btrfs_record_root_in_trans(h, root);
...@@ -586,8 +583,7 @@ start_transaction(struct btrfs_root *root, unsigned int num_items, ...@@ -586,8 +583,7 @@ start_transaction(struct btrfs_root *root, unsigned int num_items,
btrfs_block_rsv_release(root, &root->fs_info->trans_block_rsv, btrfs_block_rsv_release(root, &root->fs_info->trans_block_rsv,
num_bytes); num_bytes);
reserve_fail: reserve_fail:
if (qgroup_reserved) btrfs_qgroup_free_meta(root, qgroup_reserved);
btrfs_qgroup_free(root, qgroup_reserved);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
...@@ -805,15 +801,6 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans, ...@@ -805,15 +801,6 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
must_run_delayed_refs = 2; must_run_delayed_refs = 2;
} }
if (trans->qgroup_reserved) {
/*
* the same root has to be passed here between start_transaction
* and end_transaction. Subvolume quota depends on this.
*/
btrfs_qgroup_free(trans->root, trans->qgroup_reserved);
trans->qgroup_reserved = 0;
}
btrfs_trans_release_metadata(trans, root); btrfs_trans_release_metadata(trans, root);
trans->block_rsv = NULL; trans->block_rsv = NULL;
...@@ -1231,6 +1218,7 @@ static noinline int commit_fs_roots(struct btrfs_trans_handle *trans, ...@@ -1231,6 +1218,7 @@ static noinline int commit_fs_roots(struct btrfs_trans_handle *trans,
spin_lock(&fs_info->fs_roots_radix_lock); spin_lock(&fs_info->fs_roots_radix_lock);
if (err) if (err)
break; break;
btrfs_qgroup_free_meta_all(root);
} }
} }
spin_unlock(&fs_info->fs_roots_radix_lock); spin_unlock(&fs_info->fs_roots_radix_lock);
...@@ -1835,10 +1823,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, ...@@ -1835,10 +1823,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
btrfs_trans_release_metadata(trans, root); btrfs_trans_release_metadata(trans, root);
trans->block_rsv = NULL; trans->block_rsv = NULL;
if (trans->qgroup_reserved) {
btrfs_qgroup_free(root, trans->qgroup_reserved);
trans->qgroup_reserved = 0;
}
cur_trans = trans->transaction; cur_trans = trans->transaction;
...@@ -2191,10 +2175,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans, ...@@ -2191,10 +2175,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans,
btrfs_trans_release_metadata(trans, root); btrfs_trans_release_metadata(trans, root);
btrfs_trans_release_chunk_metadata(trans); btrfs_trans_release_chunk_metadata(trans);
trans->block_rsv = NULL; trans->block_rsv = NULL;
if (trans->qgroup_reserved) {
btrfs_qgroup_free(root, trans->qgroup_reserved);
trans->qgroup_reserved = 0;
}
btrfs_warn(root->fs_info, "Skipping commit of aborted transaction."); btrfs_warn(root->fs_info, "Skipping commit of aborted transaction.");
if (current->journal_info == trans) if (current->journal_info == trans)
current->journal_info = NULL; current->journal_info = NULL;
......
...@@ -107,7 +107,6 @@ struct btrfs_trans_handle { ...@@ -107,7 +107,6 @@ struct btrfs_trans_handle {
u64 transid; u64 transid;
u64 bytes_reserved; u64 bytes_reserved;
u64 chunk_bytes_reserved; u64 chunk_bytes_reserved;
u64 qgroup_reserved;
unsigned long use_count; unsigned long use_count;
unsigned long blocks_reserved; unsigned long blocks_reserved;
unsigned long blocks_used; unsigned long blocks_used;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册