diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-03-13 11:09:37 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-03-13 11:09:37 -0400 |
commit | 9aca1d51323c0291a7358e0728b64ec4f17d1a77 (patch) | |
tree | 6e341dfc026c26af2f654bdb5253e3cb2f3ac49a /fs | |
parent | 234b63a091e1df6bd4261dd7b3a7490074830628 (diff) |
Btrfs: make some funcs static
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/ctree.c | 16 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 47 |
2 files changed, 44 insertions, 19 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index c8529b394d5f..bbb632291709 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -34,7 +34,7 @@ void btrfs_release_path(struct btrfs_root *root, struct btrfs_path *p) | |||
34 | memset(p, 0, sizeof(*p)); | 34 | memset(p, 0, sizeof(*p)); |
35 | } | 35 | } |
36 | 36 | ||
37 | int btrfs_cow_block(struct btrfs_root *root, | 37 | static int btrfs_cow_block(struct btrfs_root *root, |
38 | struct btrfs_buffer *buf, | 38 | struct btrfs_buffer *buf, |
39 | struct btrfs_buffer *parent, | 39 | struct btrfs_buffer *parent, |
40 | int parent_slot, | 40 | int parent_slot, |
@@ -96,7 +96,7 @@ int btrfs_leaf_free_space(struct btrfs_leaf *leaf) | |||
96 | /* | 96 | /* |
97 | * compare two keys in a memcmp fashion | 97 | * compare two keys in a memcmp fashion |
98 | */ | 98 | */ |
99 | int comp_keys(struct btrfs_disk_key *disk, struct btrfs_key *k2) | 99 | static int comp_keys(struct btrfs_disk_key *disk, struct btrfs_key *k2) |
100 | { | 100 | { |
101 | struct btrfs_key k1; | 101 | struct btrfs_key k1; |
102 | 102 | ||
@@ -117,7 +117,7 @@ int comp_keys(struct btrfs_disk_key *disk, struct btrfs_key *k2) | |||
117 | return 0; | 117 | return 0; |
118 | } | 118 | } |
119 | 119 | ||
120 | int check_node(struct btrfs_path *path, int level) | 120 | static int check_node(struct btrfs_path *path, int level) |
121 | { | 121 | { |
122 | int i; | 122 | int i; |
123 | struct btrfs_node *parent = NULL; | 123 | struct btrfs_node *parent = NULL; |
@@ -146,7 +146,7 @@ int check_node(struct btrfs_path *path, int level) | |||
146 | return 0; | 146 | return 0; |
147 | } | 147 | } |
148 | 148 | ||
149 | int check_leaf(struct btrfs_path *path, int level) | 149 | static int check_leaf(struct btrfs_path *path, int level) |
150 | { | 150 | { |
151 | int i; | 151 | int i; |
152 | struct btrfs_leaf *leaf = &path->nodes[level]->leaf; | 152 | struct btrfs_leaf *leaf = &path->nodes[level]->leaf; |
@@ -186,7 +186,7 @@ int check_leaf(struct btrfs_path *path, int level) | |||
186 | return 0; | 186 | return 0; |
187 | } | 187 | } |
188 | 188 | ||
189 | int check_block(struct btrfs_path *path, int level) | 189 | static int check_block(struct btrfs_path *path, int level) |
190 | { | 190 | { |
191 | if (level == 0) | 191 | if (level == 0) |
192 | return check_leaf(path, level); | 192 | return check_leaf(path, level); |
@@ -202,7 +202,7 @@ int check_block(struct btrfs_path *path, int level) | |||
202 | * | 202 | * |
203 | * slot may point to max if the key is bigger than all of the keys | 203 | * slot may point to max if the key is bigger than all of the keys |
204 | */ | 204 | */ |
205 | int generic_bin_search(char *p, int item_size, struct btrfs_key *key, | 205 | static int generic_bin_search(char *p, int item_size, struct btrfs_key *key, |
206 | int max, int *slot) | 206 | int max, int *slot) |
207 | { | 207 | { |
208 | int low = 0; | 208 | int low = 0; |
@@ -233,7 +233,7 @@ int generic_bin_search(char *p, int item_size, struct btrfs_key *key, | |||
233 | * simple bin_search frontend that does the right thing for | 233 | * simple bin_search frontend that does the right thing for |
234 | * leaves vs nodes | 234 | * leaves vs nodes |
235 | */ | 235 | */ |
236 | int bin_search(struct btrfs_node *c, struct btrfs_key *key, int *slot) | 236 | static int bin_search(struct btrfs_node *c, struct btrfs_key *key, int *slot) |
237 | { | 237 | { |
238 | if (btrfs_is_leaf(c)) { | 238 | if (btrfs_is_leaf(c)) { |
239 | struct btrfs_leaf *l = (struct btrfs_leaf *)c; | 239 | struct btrfs_leaf *l = (struct btrfs_leaf *)c; |
@@ -250,7 +250,7 @@ int bin_search(struct btrfs_node *c, struct btrfs_key *key, int *slot) | |||
250 | return -1; | 250 | return -1; |
251 | } | 251 | } |
252 | 252 | ||
253 | struct btrfs_buffer *read_node_slot(struct btrfs_root *root, | 253 | static struct btrfs_buffer *read_node_slot(struct btrfs_root *root, |
254 | struct btrfs_buffer *parent_buf, | 254 | struct btrfs_buffer *parent_buf, |
255 | int slot) | 255 | int slot) |
256 | { | 256 | { |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 4a4f2d810d9f..a6969538bca2 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -365,8 +365,9 @@ error: | |||
365 | * | 365 | * |
366 | * returns 0 if everything worked, non-zero otherwise. | 366 | * returns 0 if everything worked, non-zero otherwise. |
367 | */ | 367 | */ |
368 | int alloc_extent(struct btrfs_root *root, u64 num_blocks, u64 search_start, | 368 | static int alloc_extent(struct btrfs_root *root, u64 num_blocks, |
369 | u64 search_end, u64 owner, struct btrfs_key *ins) | 369 | u64 search_start, u64 search_end, u64 owner, |
370 | struct btrfs_key *ins) | ||
370 | { | 371 | { |
371 | int ret; | 372 | int ret; |
372 | int pending_ret; | 373 | int pending_ret; |
@@ -425,7 +426,12 @@ struct btrfs_buffer *btrfs_alloc_free_block(struct btrfs_root *root) | |||
425 | return buf; | 426 | return buf; |
426 | } | 427 | } |
427 | 428 | ||
428 | int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path, int *level) | 429 | /* |
430 | * helper function for drop_snapshot, this walks down the tree dropping ref | ||
431 | * counts as it goes. | ||
432 | */ | ||
433 | static int walk_down_tree(struct btrfs_root *root, | ||
434 | struct btrfs_path *path, int *level) | ||
429 | { | 435 | { |
430 | struct btrfs_buffer *next; | 436 | struct btrfs_buffer *next; |
431 | struct btrfs_buffer *cur; | 437 | struct btrfs_buffer *cur; |
@@ -437,6 +443,9 @@ int walk_down_tree(struct btrfs_root *root, struct btrfs_path *path, int *level) | |||
437 | BUG_ON(ret); | 443 | BUG_ON(ret); |
438 | if (refs > 1) | 444 | if (refs > 1) |
439 | goto out; | 445 | goto out; |
446 | /* | ||
447 | * walk down to the last node level and free all the leaves | ||
448 | */ | ||
440 | while(*level > 0) { | 449 | while(*level > 0) { |
441 | cur = path->nodes[*level]; | 450 | cur = path->nodes[*level]; |
442 | if (path->slots[*level] >= | 451 | if (path->slots[*level] >= |
@@ -467,7 +476,13 @@ out: | |||
467 | return 0; | 476 | return 0; |
468 | } | 477 | } |
469 | 478 | ||
470 | int walk_up_tree(struct btrfs_root *root, struct btrfs_path *path, int *level) | 479 | /* |
480 | * helper for dropping snapshots. This walks back up the tree in the path | ||
481 | * to find the first node higher up where we haven't yet gone through | ||
482 | * all the slots | ||
483 | */ | ||
484 | static int walk_up_tree(struct btrfs_root *root, struct btrfs_path *path, | ||
485 | int *level) | ||
471 | { | 486 | { |
472 | int i; | 487 | int i; |
473 | int slot; | 488 | int slot; |
@@ -491,9 +506,15 @@ int walk_up_tree(struct btrfs_root *root, struct btrfs_path *path, int *level) | |||
491 | return 1; | 506 | return 1; |
492 | } | 507 | } |
493 | 508 | ||
509 | /* | ||
510 | * drop the reference count on the tree rooted at 'snap'. This traverses | ||
511 | * the tree freeing any blocks that have a ref count of zero after being | ||
512 | * decremented. | ||
513 | */ | ||
494 | int btrfs_drop_snapshot(struct btrfs_root *root, struct btrfs_buffer *snap) | 514 | int btrfs_drop_snapshot(struct btrfs_root *root, struct btrfs_buffer *snap) |
495 | { | 515 | { |
496 | int ret; | 516 | int ret = 0;; |
517 | int wret; | ||
497 | int level; | 518 | int level; |
498 | struct btrfs_path path; | 519 | struct btrfs_path path; |
499 | int i; | 520 | int i; |
@@ -506,18 +527,22 @@ int btrfs_drop_snapshot(struct btrfs_root *root, struct btrfs_buffer *snap) | |||
506 | path.nodes[level] = snap; | 527 | path.nodes[level] = snap; |
507 | path.slots[level] = 0; | 528 | path.slots[level] = 0; |
508 | while(1) { | 529 | while(1) { |
509 | ret = walk_down_tree(root, &path, &level); | 530 | wret = walk_down_tree(root, &path, &level); |
510 | if (ret > 0) | 531 | if (wret > 0) |
511 | break; | 532 | break; |
512 | ret = walk_up_tree(root, &path, &level); | 533 | if (wret < 0) |
513 | if (ret > 0) | 534 | ret = wret; |
535 | |||
536 | wret = walk_up_tree(root, &path, &level); | ||
537 | if (wret > 0) | ||
514 | break; | 538 | break; |
539 | if (wret < 0) | ||
540 | ret = wret; | ||
515 | } | 541 | } |
516 | for (i = 0; i <= orig_level; i++) { | 542 | for (i = 0; i <= orig_level; i++) { |
517 | if (path.nodes[i]) { | 543 | if (path.nodes[i]) { |
518 | btrfs_block_release(root, path.nodes[i]); | 544 | btrfs_block_release(root, path.nodes[i]); |
519 | } | 545 | } |
520 | } | 546 | } |
521 | 547 | return ret; | |
522 | return 0; | ||
523 | } | 548 | } |