/* *Sincethetesttransdoesn'thavethecomplicateddelayedrefs, *wecanonlycallbtrfs_qgroup_account_extent()directlytotest *quota.
*/
ret = btrfs_find_all_roots(&ctx, false); if (ret) {
test_err("couldn't find old roots: %d", ret); return ret;
}
old_roots = ctx.roots;
ctx.roots = NULL;
ret = insert_normal_tree_ref(root, nodesize, nodesize, 0,
BTRFS_FS_TREE_OBJECTID); if (ret) {
ulist_free(old_roots); return ret;
}
ret = btrfs_find_all_roots(&ctx, false); if (ret) {
ulist_free(old_roots);
test_err("couldn't find old roots: %d", ret); return ret;
}
new_roots = ctx.roots;
ctx.roots = NULL;
ret = btrfs_qgroup_account_extent(&trans, nodesize, nodesize, old_roots,
new_roots); if (ret) {
test_err("couldn't account space for a qgroup %d", ret); return ret;
}
/* btrfs_qgroup_account_extent() always frees the ulists passed to it. */
old_roots = NULL;
new_roots = NULL;
if (btrfs_verify_qgroup_counts(fs_info, BTRFS_FS_TREE_OBJECTID,
nodesize, nodesize)) {
test_err("qgroup counts didn't match expected values"); return -EINVAL;
}
ret = btrfs_find_all_roots(&ctx, false); if (ret) {
test_err("couldn't find old roots: %d", ret); return ret;
}
old_roots = ctx.roots;
ctx.roots = NULL;
ret = remove_extent_item(root, nodesize, nodesize); if (ret) {
ulist_free(old_roots); return -EINVAL;
}
ret = btrfs_find_all_roots(&ctx, false); if (ret) {
ulist_free(old_roots);
test_err("couldn't find old roots: %d", ret); return ret;
}
new_roots = ctx.roots;
ctx.roots = NULL;
ret = btrfs_qgroup_account_extent(&trans, nodesize, nodesize, old_roots,
new_roots); if (ret) {
test_err("couldn't account space for a qgroup %d", ret); return -EINVAL;
}
if (btrfs_verify_qgroup_counts(fs_info, BTRFS_FS_TREE_OBJECTID, 0, 0)) {
test_err("qgroup counts didn't match expected values"); return -EINVAL;
}
ret = btrfs_find_all_roots(&ctx, false); if (ret) {
test_err("couldn't find old roots: %d", ret); return ret;
}
old_roots = ctx.roots;
ctx.roots = NULL;
ret = insert_normal_tree_ref(root, nodesize, nodesize, 0,
BTRFS_FS_TREE_OBJECTID); if (ret) {
ulist_free(old_roots); return ret;
}
ret = btrfs_find_all_roots(&ctx, false); if (ret) {
ulist_free(old_roots);
test_err("couldn't find old roots: %d", ret); return ret;
}
new_roots = ctx.roots;
ctx.roots = NULL;
ret = btrfs_qgroup_account_extent(&trans, nodesize, nodesize, old_roots,
new_roots); if (ret) {
test_err("couldn't account space for a qgroup %d", ret); return ret;
}
if (btrfs_verify_qgroup_counts(fs_info, BTRFS_FS_TREE_OBJECTID,
nodesize, nodesize)) {
test_err("qgroup counts didn't match expected values"); return -EINVAL;
}
ret = btrfs_find_all_roots(&ctx, false); if (ret) {
test_err("couldn't find old roots: %d", ret); return ret;
}
old_roots = ctx.roots;
ctx.roots = NULL;
ret = add_tree_ref(root, nodesize, nodesize, 0,
BTRFS_FIRST_FREE_OBJECTID); if (ret) {
ulist_free(old_roots); return ret;
}
ret = btrfs_find_all_roots(&ctx, false); if (ret) {
ulist_free(old_roots);
test_err("couldn't find old roots: %d", ret); return ret;
}
new_roots = ctx.roots;
ctx.roots = NULL;
ret = btrfs_qgroup_account_extent(&trans, nodesize, nodesize, old_roots,
new_roots); if (ret) {
test_err("couldn't account space for a qgroup %d", ret); return ret;
}
if (btrfs_verify_qgroup_counts(fs_info, BTRFS_FS_TREE_OBJECTID,
nodesize, 0)) {
test_err("qgroup counts didn't match expected values"); return -EINVAL;
}
if (btrfs_verify_qgroup_counts(fs_info, BTRFS_FIRST_FREE_OBJECTID,
nodesize, 0)) {
test_err("qgroup counts didn't match expected values"); return -EINVAL;
}
ret = btrfs_find_all_roots(&ctx, false); if (ret) {
test_err("couldn't find old roots: %d", ret); return ret;
}
old_roots = ctx.roots;
ctx.roots = NULL;
ret = remove_extent_ref(root, nodesize, nodesize, 0,
BTRFS_FIRST_FREE_OBJECTID); if (ret) {
ulist_free(old_roots); return ret;
}
ret = btrfs_find_all_roots(&ctx, false); if (ret) {
ulist_free(old_roots);
test_err("couldn't find old roots: %d", ret); return ret;
}
new_roots = ctx.roots;
ctx.roots = NULL;
ret = btrfs_qgroup_account_extent(&trans, nodesize, nodesize, old_roots,
new_roots); if (ret) {
test_err("couldn't account space for a qgroup %d", ret); return ret;
}
if (btrfs_verify_qgroup_counts(fs_info, BTRFS_FIRST_FREE_OBJECTID, 0, 0)) {
test_err("qgroup counts didn't match expected values"); return -EINVAL;
}
if (btrfs_verify_qgroup_counts(fs_info, BTRFS_FS_TREE_OBJECTID,
nodesize, nodesize)) {
test_err("qgroup counts didn't match expected values"); return -EINVAL;
}
return0;
}
int btrfs_test_qgroups(u32 sectorsize, u32 nodesize)
{ struct btrfs_fs_info *fs_info = NULL; struct btrfs_root *root; struct btrfs_root *tmp_root; int ret = 0;
root = btrfs_alloc_dummy_root(fs_info); if (IS_ERR(root)) {
test_std_err(TEST_ALLOC_ROOT);
ret = PTR_ERR(root); goto out;
}
/* We are using this root as our extent root */
root->root_key.objectid = BTRFS_EXTENT_TREE_OBJECTID;
root->root_key.type = BTRFS_ROOT_ITEM_KEY;
root->root_key.offset = 0;
btrfs_global_root_insert(root);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.