aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/random-test.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/random-test.c')
-rw-r--r--fs/btrfs/random-test.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/fs/btrfs/random-test.c b/fs/btrfs/random-test.c
index dcc852ad6737..7b37b6bae105 100644
--- a/fs/btrfs/random-test.c
+++ b/fs/btrfs/random-test.c
@@ -8,6 +8,7 @@
8#include "print-tree.h" 8#include "print-tree.h"
9 9
10int keep_running = 1; 10int keep_running = 1;
11struct ctree_super_block super;
11 12
12static int setup_key(struct radix_tree_root *root, struct key *key, int exists) 13static int setup_key(struct radix_tree_root *root, struct key *key, int exists)
13{ 14{
@@ -59,11 +60,6 @@ error:
59 return -1; 60 return -1;
60} 61}
61 62
62static int run_commit(struct ctree_root *root, struct radix_tree_root *radix)
63{
64 return commit_transaction(root);
65}
66
67static int insert_dup(struct ctree_root *root, struct radix_tree_root *radix) 63static int insert_dup(struct ctree_root *root, struct radix_tree_root *radix)
68{ 64{
69 struct ctree_path path; 65 struct ctree_path path;
@@ -210,7 +206,7 @@ static int fill_tree(struct ctree_root *root, struct radix_tree_root *radix,
210 goto out; 206 goto out;
211 } 207 }
212 if (i % 1000 == 0) { 208 if (i % 1000 == 0) {
213 ret = commit_transaction(root); 209 ret = commit_transaction(root, &super);
214 if (ret) { 210 if (ret) {
215 fprintf(stderr, "fill commit failed\n"); 211 fprintf(stderr, "fill commit failed\n");
216 return ret; 212 return ret;
@@ -229,7 +225,7 @@ out:
229static int bulk_op(struct ctree_root *root, struct radix_tree_root *radix) 225static int bulk_op(struct ctree_root *root, struct radix_tree_root *radix)
230{ 226{
231 int ret; 227 int ret;
232 int nr = rand() % 20000; 228 int nr = rand() % 5000;
233 static int run_nr = 0; 229 static int run_nr = 0;
234 230
235 /* do the bulk op much less frequently */ 231 /* do the bulk op much less frequently */
@@ -247,7 +243,7 @@ static int bulk_op(struct ctree_root *root, struct radix_tree_root *radix)
247 243
248int (*ops[])(struct ctree_root *root, struct radix_tree_root *radix) = 244int (*ops[])(struct ctree_root *root, struct radix_tree_root *radix) =
249 { ins_one, insert_dup, del_one, lookup_item, 245 { ins_one, insert_dup, del_one, lookup_item,
250 lookup_enoent, bulk_op, run_commit }; 246 lookup_enoent, bulk_op };
251 247
252static int fill_radix(struct ctree_root *root, struct radix_tree_root *radix) 248static int fill_radix(struct ctree_root *root, struct radix_tree_root *radix)
253{ 249{
@@ -314,7 +310,6 @@ int print_usage(void)
314int main(int ac, char **av) 310int main(int ac, char **av)
315{ 311{
316 RADIX_TREE(radix, GFP_KERNEL); 312 RADIX_TREE(radix, GFP_KERNEL);
317 struct ctree_super_block super;
318 struct ctree_root *root; 313 struct ctree_root *root;
319 int i; 314 int i;
320 int ret; 315 int ret;
@@ -365,8 +360,7 @@ int main(int ac, char **av)
365 printf("open & close, root level %d nritems %d\n", 360 printf("open & close, root level %d nritems %d\n",
366 node_level(root->node->node.header.flags), 361 node_level(root->node->node.header.flags),
367 root->node->node.header.nritems); 362 root->node->node.header.nritems);
368 write_ctree_super(root, &super); 363 close_ctree(root, &super);
369 close_ctree(root);
370 root = open_ctree("dbfile", &super); 364 root = open_ctree("dbfile", &super);
371 } 365 }
372 while(count--) { 366 while(count--) {
@@ -380,7 +374,7 @@ int main(int ac, char **av)
380 err = ret; 374 err = ret;
381 goto out; 375 goto out;
382 } 376 }
383 if (ops[op] == bulk_op || ops[op] == run_commit) 377 if (ops[op] == bulk_op)
384 break; 378 break;
385 if (keep_running == 0) { 379 if (keep_running == 0) {
386 err = 0; 380 err = 0;
@@ -389,8 +383,7 @@ int main(int ac, char **av)
389 } 383 }
390 } 384 }
391out: 385out:
392 write_ctree_super(root, &super); 386 close_ctree(root, &super);
393 close_ctree(root);
394 return err; 387 return err;
395} 388}
396 389