qgroup-tests.c (01b944fe1cd4e21a2a9ed51adbdbafe2d5e905ba) qgroup-tests.c (7c55ee0c4afba4434d973117234577ae6ff77a1c)
1/*
2 * Copyright (C) 2013 Facebook. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,

--- 9 unchanged lines hidden (view full) ---

18
19#include "btrfs-tests.h"
20#include "../ctree.h"
21#include "../transaction.h"
22#include "../disk-io.h"
23#include "../qgroup.h"
24#include "../backref.h"
25
1/*
2 * Copyright (C) 2013 Facebook. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,

--- 9 unchanged lines hidden (view full) ---

18
19#include "btrfs-tests.h"
20#include "../ctree.h"
21#include "../transaction.h"
22#include "../disk-io.h"
23#include "../qgroup.h"
24#include "../backref.h"
25
26static void init_dummy_trans(struct btrfs_trans_handle *trans)
27{
28 memset(trans, 0, sizeof(*trans));
29 trans->transid = 1;
30 INIT_LIST_HEAD(&trans->qgroup_ref_list);
31 trans->type = __TRANS_DUMMY;
32}
33
34static int insert_normal_tree_ref(struct btrfs_root *root, u64 bytenr,
35 u64 num_bytes, u64 parent, u64 root_objectid)
36{
37 struct btrfs_trans_handle trans;
38 struct btrfs_extent_item *item;
39 struct btrfs_extent_inline_ref *iref;
40 struct btrfs_tree_block_info *block_info;
41 struct btrfs_path *path;
42 struct extent_buffer *leaf;
43 struct btrfs_key ins;
44 u32 size = sizeof(*item) + sizeof(*iref) + sizeof(*block_info);
45 int ret;
46
26static int insert_normal_tree_ref(struct btrfs_root *root, u64 bytenr,
27 u64 num_bytes, u64 parent, u64 root_objectid)
28{
29 struct btrfs_trans_handle trans;
30 struct btrfs_extent_item *item;
31 struct btrfs_extent_inline_ref *iref;
32 struct btrfs_tree_block_info *block_info;
33 struct btrfs_path *path;
34 struct extent_buffer *leaf;
35 struct btrfs_key ins;
36 u32 size = sizeof(*item) + sizeof(*iref) + sizeof(*block_info);
37 int ret;
38
47 init_dummy_trans(&trans);
39 btrfs_init_dummy_trans(&trans);
48
49 ins.objectid = bytenr;
50 ins.type = BTRFS_EXTENT_ITEM_KEY;
51 ins.offset = num_bytes;
52
53 path = btrfs_alloc_path();
54 if (!path) {
55 test_msg("Couldn't allocate path\n");

--- 33 unchanged lines hidden (view full) ---

89{
90 struct btrfs_trans_handle trans;
91 struct btrfs_extent_item *item;
92 struct btrfs_path *path;
93 struct btrfs_key key;
94 u64 refs;
95 int ret;
96
40
41 ins.objectid = bytenr;
42 ins.type = BTRFS_EXTENT_ITEM_KEY;
43 ins.offset = num_bytes;
44
45 path = btrfs_alloc_path();
46 if (!path) {
47 test_msg("Couldn't allocate path\n");

--- 33 unchanged lines hidden (view full) ---

81{
82 struct btrfs_trans_handle trans;
83 struct btrfs_extent_item *item;
84 struct btrfs_path *path;
85 struct btrfs_key key;
86 u64 refs;
87 int ret;
88
97 init_dummy_trans(&trans);
89 btrfs_init_dummy_trans(&trans);
98
99 key.objectid = bytenr;
100 key.type = BTRFS_EXTENT_ITEM_KEY;
101 key.offset = num_bytes;
102
103 path = btrfs_alloc_path();
104 if (!path) {
105 test_msg("Couldn't allocate path\n");

--- 33 unchanged lines hidden (view full) ---

139static int remove_extent_item(struct btrfs_root *root, u64 bytenr,
140 u64 num_bytes)
141{
142 struct btrfs_trans_handle trans;
143 struct btrfs_key key;
144 struct btrfs_path *path;
145 int ret;
146
90
91 key.objectid = bytenr;
92 key.type = BTRFS_EXTENT_ITEM_KEY;
93 key.offset = num_bytes;
94
95 path = btrfs_alloc_path();
96 if (!path) {
97 test_msg("Couldn't allocate path\n");

--- 33 unchanged lines hidden (view full) ---

131static int remove_extent_item(struct btrfs_root *root, u64 bytenr,
132 u64 num_bytes)
133{
134 struct btrfs_trans_handle trans;
135 struct btrfs_key key;
136 struct btrfs_path *path;
137 int ret;
138
147 init_dummy_trans(&trans);
139 btrfs_init_dummy_trans(&trans);
148
149 key.objectid = bytenr;
150 key.type = BTRFS_EXTENT_ITEM_KEY;
151 key.offset = num_bytes;
152
153 path = btrfs_alloc_path();
154 if (!path) {
155 test_msg("Couldn't allocate path\n");

--- 17 unchanged lines hidden (view full) ---

173{
174 struct btrfs_trans_handle trans;
175 struct btrfs_extent_item *item;
176 struct btrfs_path *path;
177 struct btrfs_key key;
178 u64 refs;
179 int ret;
180
140
141 key.objectid = bytenr;
142 key.type = BTRFS_EXTENT_ITEM_KEY;
143 key.offset = num_bytes;
144
145 path = btrfs_alloc_path();
146 if (!path) {
147 test_msg("Couldn't allocate path\n");

--- 17 unchanged lines hidden (view full) ---

165{
166 struct btrfs_trans_handle trans;
167 struct btrfs_extent_item *item;
168 struct btrfs_path *path;
169 struct btrfs_key key;
170 u64 refs;
171 int ret;
172
181 init_dummy_trans(&trans);
173 btrfs_init_dummy_trans(&trans);
182
183 key.objectid = bytenr;
184 key.type = BTRFS_EXTENT_ITEM_KEY;
185 key.offset = num_bytes;
186
187 path = btrfs_alloc_path();
188 if (!path) {
189 test_msg("Couldn't allocate path\n");

--- 37 unchanged lines hidden (view full) ---

227static int test_no_shared_qgroup(struct btrfs_root *root)
228{
229 struct btrfs_trans_handle trans;
230 struct btrfs_fs_info *fs_info = root->fs_info;
231 struct ulist *old_roots = NULL;
232 struct ulist *new_roots = NULL;
233 int ret;
234
174
175 key.objectid = bytenr;
176 key.type = BTRFS_EXTENT_ITEM_KEY;
177 key.offset = num_bytes;
178
179 path = btrfs_alloc_path();
180 if (!path) {
181 test_msg("Couldn't allocate path\n");

--- 37 unchanged lines hidden (view full) ---

219static int test_no_shared_qgroup(struct btrfs_root *root)
220{
221 struct btrfs_trans_handle trans;
222 struct btrfs_fs_info *fs_info = root->fs_info;
223 struct ulist *old_roots = NULL;
224 struct ulist *new_roots = NULL;
225 int ret;
226
235 init_dummy_trans(&trans);
227 btrfs_init_dummy_trans(&trans);
236
237 test_msg("Qgroup basic add\n");
238 ret = btrfs_create_qgroup(NULL, fs_info, 5);
239 if (ret) {
240 test_msg("Couldn't create a qgroup %d\n", ret);
241 return ret;
242 }
243

--- 77 unchanged lines hidden (view full) ---

321static int test_multiple_refs(struct btrfs_root *root)
322{
323 struct btrfs_trans_handle trans;
324 struct btrfs_fs_info *fs_info = root->fs_info;
325 struct ulist *old_roots = NULL;
326 struct ulist *new_roots = NULL;
327 int ret;
328
228
229 test_msg("Qgroup basic add\n");
230 ret = btrfs_create_qgroup(NULL, fs_info, 5);
231 if (ret) {
232 test_msg("Couldn't create a qgroup %d\n", ret);
233 return ret;
234 }
235

--- 77 unchanged lines hidden (view full) ---

313static int test_multiple_refs(struct btrfs_root *root)
314{
315 struct btrfs_trans_handle trans;
316 struct btrfs_fs_info *fs_info = root->fs_info;
317 struct ulist *old_roots = NULL;
318 struct ulist *new_roots = NULL;
319 int ret;
320
329 init_dummy_trans(&trans);
321 btrfs_init_dummy_trans(&trans);
330
331 test_msg("Qgroup multiple refs test\n");
332
333 /* We have 5 created already from the previous test */
334 ret = btrfs_create_qgroup(NULL, fs_info, 256);
335 if (ret) {
336 test_msg("Couldn't create a qgroup %d\n", ret);
337 return ret;

--- 189 unchanged lines hidden ---
322
323 test_msg("Qgroup multiple refs test\n");
324
325 /* We have 5 created already from the previous test */
326 ret = btrfs_create_qgroup(NULL, fs_info, 256);
327 if (ret) {
328 test_msg("Couldn't create a qgroup %d\n", ret);
329 return ret;

--- 189 unchanged lines hidden ---