projects
/
platform
/
upstream
/
btrfs-progs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
btrfs-progs: tests: add shell quotes to mkfs test scripts
[platform/upstream/btrfs-progs.git]
/
quick-test.c
diff --git
a/quick-test.c
b/quick-test.c
index
16a3bf4
..
5da47c3
100644
(file)
--- a/
quick-test.c
+++ b/
quick-test.c
@@
-18,6
+18,7
@@
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
+#include <fcntl.h>
#include "kerncompat.h"
#include "radix-tree.h"
#include "ctree.h"
#include "kerncompat.h"
#include "radix-tree.h"
#include "ctree.h"
@@
-26,7
+27,7
@@
#include "transaction.h"
/* for testing only */
#include "transaction.h"
/* for testing only */
-int next_key(int i, int max_key) {
+
static
int next_key(int i, int max_key) {
return rand() % max_key;
// return i;
}
return rand() % max_key;
// return i;
}
@@
-45,15
+46,19
@@
int main(int ac, char **av) {
struct btrfs_root *root;
struct btrfs_trans_handle *trans;
struct btrfs_root *root;
struct btrfs_trans_handle *trans;
- buf = malloc(512);
- memset(buf, 0, 512);
+ buf = calloc(1, 512);
radix_tree_init();
radix_tree_init();
- root = open_ctree(av[1], BTRFS_SUPER_INFO_OFFSET);
+ root = open_ctree(av[1], BTRFS_SUPER_INFO_OFFSET, OPEN_CTREE_WRITES);
+ if (!root) {
+ fprintf(stderr, "Open ctree failed\n");
+ exit(1);
+ }
trans = btrfs_start_transaction(root, 1);
trans = btrfs_start_transaction(root, 1);
+ BUG_ON(IS_ERR(trans));
srand(55);
srand(55);
-
btrfs_set_key_type(&ins, BTRFS_STRING_ITEM_KEY)
;
+
ins.type = BTRFS_STRING_ITEM_KEY
;
for (i = 0; i < run_size; i++) {
num = next_key(i, max_key);
// num = i;
for (i = 0; i < run_size; i++) {
num = next_key(i, max_key);
// num = i;
@@
-68,12
+73,17
@@
int main(int ac, char **av) {
if (i == run_size - 5) {
btrfs_commit_transaction(trans, root);
trans = btrfs_start_transaction(root, 1);
if (i == run_size - 5) {
btrfs_commit_transaction(trans, root);
trans = btrfs_start_transaction(root, 1);
+ BUG_ON(IS_ERR(trans));
}
}
btrfs_commit_transaction(trans, root);
close_ctree(root);
exit(1);
}
}
btrfs_commit_transaction(trans, root);
close_ctree(root);
exit(1);
- root = open_ctree(av[1], BTRFS_SUPER_INFO_OFFSET);
+ root = open_ctree(av[1], BTRFS_SUPER_INFO_OFFSET, OPEN_CTREE_WRITES);
+ if (!root) {
+ fprintf(stderr, "Open ctree failed\n");
+ exit(1);
+ }
printf("starting search\n");
srand(55);
for (i = 0; i < run_size; i++) {
printf("starting search\n");
srand(55);
for (i = 0; i < run_size; i++) {
@@
-84,24
+94,29
@@
int main(int ac, char **av) {
fprintf(stderr, "search %d:%d\n", num, i);
ret = btrfs_search_slot(NULL, root, &ins, &path, 0, 0);
if (ret) {
fprintf(stderr, "search %d:%d\n", num, i);
ret = btrfs_search_slot(NULL, root, &ins, &path, 0, 0);
if (ret) {
- btrfs_print_tree(root, root->node);
+ btrfs_print_tree(root, root->node
, 1
);
printf("unable to find %d\n", num);
exit(1);
}
printf("unable to find %d\n", num);
exit(1);
}
- btrfs_release_path(
root,
&path);
+ btrfs_release_path(&path);
}
close_ctree(root);
}
close_ctree(root);
- root = open_ctree(av[1], BTRFS_SUPER_INFO_OFFSET);
+ root = open_ctree(av[1], BTRFS_SUPER_INFO_OFFSET, OPEN_CTREE_WRITES);
+ if (!root) {
+ fprintf(stderr, "Open ctree failed\n");
+ exit(1);
+ }
printf("node %p level %d total ptrs %d free spc %lu\n", root->node,
btrfs_header_level(root->node),
btrfs_header_nritems(root->node),
printf("node %p level %d total ptrs %d free spc %lu\n", root->node,
btrfs_header_level(root->node),
btrfs_header_nritems(root->node),
-
BTRFS_NODEPTRS_PER_BLOCK(root
) -
+
(unsigned long)BTRFS_NODEPTRS_PER_BLOCK(root->fs_info
) -
btrfs_header_nritems(root->node));
printf("all searches good, deleting some items\n");
i = 0;
srand(55);
trans = btrfs_start_transaction(root, 1);
btrfs_header_nritems(root->node));
printf("all searches good, deleting some items\n");
i = 0;
srand(55);
trans = btrfs_start_transaction(root, 1);
+ BUG_ON(IS_ERR(trans));
for (i = 0 ; i < run_size/4; i++) {
num = next_key(i, max_key);
ins.objectid = num;
for (i = 0 ; i < run_size/4; i++) {
num = next_key(i, max_key);
ins.objectid = num;
@@
-115,13
+130,18
@@
int main(int ac, char **av) {
BUG();
tree_size--;
}
BUG();
tree_size--;
}
- btrfs_release_path(
root,
&path);
+ btrfs_release_path(&path);
}
btrfs_commit_transaction(trans, root);
close_ctree(root);
}
btrfs_commit_transaction(trans, root);
close_ctree(root);
- root = open_ctree(av[1], BTRFS_SUPER_INFO_OFFSET);
+ root = open_ctree(av[1], BTRFS_SUPER_INFO_OFFSET, OPEN_CTREE_WRITES);
+ if (!root) {
+ fprintf(stderr, "Open ctree failed\n");
+ exit(1);
+ }
trans = btrfs_start_transaction(root, 1);
trans = btrfs_start_transaction(root, 1);
+ BUG_ON(IS_ERR(trans));
srand(128);
for (i = 0; i < run_size; i++) {
num = next_key(i, max_key);
srand(128);
for (i = 0; i < run_size; i++) {
num = next_key(i, max_key);
@@
-136,7
+156,11
@@
int main(int ac, char **av) {
btrfs_commit_transaction(trans, root);
close_ctree(root);
btrfs_commit_transaction(trans, root);
close_ctree(root);
- root = open_ctree(av[1], BTRFS_SUPER_INFO_OFFSET);
+ root = open_ctree(av[1], BTRFS_SUPER_INFO_OFFSET, OPEN_CTREE_WRITES);
+ if (!root) {
+ fprintf(stderr, "Open ctree failed\n");
+ exit(1);
+ }
srand(128);
printf("starting search2\n");
for (i = 0; i < run_size; i++) {
srand(128);
printf("starting search2\n");
for (i = 0; i < run_size; i++) {
@@
-147,14
+171,15
@@
int main(int ac, char **av) {
fprintf(stderr, "search %d:%d\n", num, i);
ret = btrfs_search_slot(NULL, root, &ins, &path, 0, 0);
if (ret) {
fprintf(stderr, "search %d:%d\n", num, i);
ret = btrfs_search_slot(NULL, root, &ins, &path, 0, 0);
if (ret) {
- btrfs_print_tree(root, root->node);
+ btrfs_print_tree(root, root->node
, 1
);
printf("unable to find %d\n", num);
exit(1);
}
printf("unable to find %d\n", num);
exit(1);
}
- btrfs_release_path(
root,
&path);
+ btrfs_release_path(&path);
}
printf("starting big long delete run\n");
trans = btrfs_start_transaction(root, 1);
}
printf("starting big long delete run\n");
trans = btrfs_start_transaction(root, 1);
+ BUG_ON(IS_ERR(trans));
while(root->node && btrfs_header_nritems(root->node) > 0) {
struct extent_buffer *leaf;
int slot;
while(root->node && btrfs_header_nritems(root->node) > 0) {
struct extent_buffer *leaf;
int slot;
@@
-184,7
+209,7
@@
int main(int ac, char **av) {
}
tree_size--;
}
}
tree_size--;
}
- btrfs_release_path(
root,
&path);
+ btrfs_release_path(&path);
}
/*
printf("previous tree:\n");
}
/*
printf("previous tree:\n");
@@
-195,7
+220,7
@@
int main(int ac, char **av) {
btrfs_commit_transaction(trans, root);
printf("tree size is now %d\n", tree_size);
printf("root %p commit root %p\n", root->node, root->commit_root);
btrfs_commit_transaction(trans, root);
printf("tree size is now %d\n", tree_size);
printf("root %p commit root %p\n", root->node, root->commit_root);
- btrfs_print_tree(root, root->node);
+ btrfs_print_tree(root, root->node
, 1
);
close_ctree(root);
return 0;
}
close_ctree(root);
return 0;
}