diff options
Diffstat (limited to 'fs/btrfs/quick-test.c')
-rw-r--r-- | fs/btrfs/quick-test.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/fs/btrfs/quick-test.c b/fs/btrfs/quick-test.c index 3a2571617121..d676577185d5 100644 --- a/fs/btrfs/quick-test.c +++ b/fs/btrfs/quick-test.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include "ctree.h" | 5 | #include "ctree.h" |
6 | #include "disk-io.h" | 6 | #include "disk-io.h" |
7 | #include "print-tree.h" | 7 | #include "print-tree.h" |
8 | #include "transaction.h" | ||
8 | 9 | ||
9 | /* for testing only */ | 10 | /* for testing only */ |
10 | int next_key(int i, int max_key) { | 11 | int next_key(int i, int max_key) { |
@@ -25,10 +26,12 @@ int main(int ac, char **av) { | |||
25 | struct btrfs_path path; | 26 | struct btrfs_path path; |
26 | struct btrfs_super_block super; | 27 | struct btrfs_super_block super; |
27 | struct btrfs_root *root; | 28 | struct btrfs_root *root; |
29 | struct btrfs_trans_handle *trans; | ||
28 | 30 | ||
29 | radix_tree_init(); | 31 | radix_tree_init(); |
30 | 32 | ||
31 | root = open_ctree("dbfile", &super); | 33 | root = open_ctree("dbfile", &super); |
34 | trans = btrfs_start_transaction(root, 1); | ||
32 | srand(55); | 35 | srand(55); |
33 | ins.flags = 0; | 36 | ins.flags = 0; |
34 | btrfs_set_key_type(&ins, BTRFS_STRING_ITEM_KEY); | 37 | btrfs_set_key_type(&ins, BTRFS_STRING_ITEM_KEY); |
@@ -41,12 +44,12 @@ int main(int ac, char **av) { | |||
41 | fprintf(stderr, "insert %d:%d\n", num, i); | 44 | fprintf(stderr, "insert %d:%d\n", num, i); |
42 | ins.objectid = num; | 45 | ins.objectid = num; |
43 | ins.offset = 0; | 46 | ins.offset = 0; |
44 | ret = btrfs_insert_item(root, &ins, buf, strlen(buf)); | 47 | ret = btrfs_insert_item(trans, root, &ins, buf, strlen(buf)); |
45 | if (!ret) | 48 | if (!ret) |
46 | tree_size++; | 49 | tree_size++; |
47 | free(buf); | 50 | free(buf); |
48 | if (i == run_size - 5) { | 51 | if (i == run_size - 5) { |
49 | btrfs_commit_transaction(root, &super); | 52 | btrfs_commit_transaction(trans, root, &super); |
50 | } | 53 | } |
51 | 54 | ||
52 | } | 55 | } |
@@ -61,7 +64,7 @@ int main(int ac, char **av) { | |||
61 | btrfs_init_path(&path); | 64 | btrfs_init_path(&path); |
62 | if (i % 10000 == 0) | 65 | if (i % 10000 == 0) |
63 | fprintf(stderr, "search %d:%d\n", num, i); | 66 | fprintf(stderr, "search %d:%d\n", num, i); |
64 | ret = btrfs_search_slot(root, &ins, &path, 0, 0); | 67 | ret = btrfs_search_slot(trans, root, &ins, &path, 0, 0); |
65 | if (ret) { | 68 | if (ret) { |
66 | btrfs_print_tree(root, root->node); | 69 | btrfs_print_tree(root, root->node); |
67 | printf("unable to find %d\n", num); | 70 | printf("unable to find %d\n", num); |
@@ -83,11 +86,11 @@ int main(int ac, char **av) { | |||
83 | num = next_key(i, max_key); | 86 | num = next_key(i, max_key); |
84 | ins.objectid = num; | 87 | ins.objectid = num; |
85 | btrfs_init_path(&path); | 88 | btrfs_init_path(&path); |
86 | ret = btrfs_search_slot(root, &ins, &path, -1, 1); | 89 | ret = btrfs_search_slot(trans, root, &ins, &path, -1, 1); |
87 | if (!ret) { | 90 | if (!ret) { |
88 | if (i % 10000 == 0) | 91 | if (i % 10000 == 0) |
89 | fprintf(stderr, "del %d:%d\n", num, i); | 92 | fprintf(stderr, "del %d:%d\n", num, i); |
90 | ret = btrfs_del_item(root, &path); | 93 | ret = btrfs_del_item(trans, root, &path); |
91 | if (ret != 0) | 94 | if (ret != 0) |
92 | BUG(); | 95 | BUG(); |
93 | tree_size--; | 96 | tree_size--; |
@@ -104,7 +107,7 @@ int main(int ac, char **av) { | |||
104 | ins.objectid = num; | 107 | ins.objectid = num; |
105 | if (i % 10000 == 0) | 108 | if (i % 10000 == 0) |
106 | fprintf(stderr, "insert %d:%d\n", num, i); | 109 | fprintf(stderr, "insert %d:%d\n", num, i); |
107 | ret = btrfs_insert_item(root, &ins, buf, strlen(buf)); | 110 | ret = btrfs_insert_item(trans, root, &ins, buf, strlen(buf)); |
108 | if (!ret) | 111 | if (!ret) |
109 | tree_size++; | 112 | tree_size++; |
110 | free(buf); | 113 | free(buf); |
@@ -119,7 +122,7 @@ int main(int ac, char **av) { | |||
119 | btrfs_init_path(&path); | 122 | btrfs_init_path(&path); |
120 | if (i % 10000 == 0) | 123 | if (i % 10000 == 0) |
121 | fprintf(stderr, "search %d:%d\n", num, i); | 124 | fprintf(stderr, "search %d:%d\n", num, i); |
122 | ret = btrfs_search_slot(root, &ins, &path, 0, 0); | 125 | ret = btrfs_search_slot(trans, root, &ins, &path, 0, 0); |
123 | if (ret) { | 126 | if (ret) { |
124 | btrfs_print_tree(root, root->node); | 127 | btrfs_print_tree(root, root->node); |
125 | printf("unable to find %d\n", num); | 128 | printf("unable to find %d\n", num); |
@@ -134,7 +137,7 @@ int main(int ac, char **av) { | |||
134 | int slot; | 137 | int slot; |
135 | ins.objectid = (u64)-1; | 138 | ins.objectid = (u64)-1; |
136 | btrfs_init_path(&path); | 139 | btrfs_init_path(&path); |
137 | ret = btrfs_search_slot(root, &ins, &path, -1, 1); | 140 | ret = btrfs_search_slot(trans, root, &ins, &path, -1, 1); |
138 | if (ret == 0) | 141 | if (ret == 0) |
139 | BUG(); | 142 | BUG(); |
140 | 143 | ||
@@ -150,7 +153,7 @@ int main(int ac, char **av) { | |||
150 | btrfs_disk_key_to_cpu(&last, &leaf->items[slot].key); | 153 | btrfs_disk_key_to_cpu(&last, &leaf->items[slot].key); |
151 | if (tree_size % 10000 == 0) | 154 | if (tree_size % 10000 == 0) |
152 | printf("big del %d:%d\n", tree_size, i); | 155 | printf("big del %d:%d\n", tree_size, i); |
153 | ret = btrfs_del_item(root, &path); | 156 | ret = btrfs_del_item(trans, root, &path); |
154 | if (ret != 0) { | 157 | if (ret != 0) { |
155 | printf("del_item returned %d\n", ret); | 158 | printf("del_item returned %d\n", ret); |
156 | BUG(); | 159 | BUG(); |
@@ -165,7 +168,7 @@ int main(int ac, char **av) { | |||
165 | printf("map before commit\n"); | 168 | printf("map before commit\n"); |
166 | btrfs_print_tree(root->extent_root, root->extent_root->node); | 169 | btrfs_print_tree(root->extent_root, root->extent_root->node); |
167 | */ | 170 | */ |
168 | btrfs_commit_transaction(root, &super); | 171 | btrfs_commit_transaction(trans, root, &super); |
169 | printf("tree size is now %d\n", tree_size); | 172 | printf("tree size is now %d\n", tree_size); |
170 | printf("root %p commit root %p\n", root->node, root->commit_root); | 173 | printf("root %p commit root %p\n", root->node, root->commit_root); |
171 | printf("map tree\n"); | 174 | printf("map tree\n"); |