diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-03-13 10:46:10 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-03-13 10:46:10 -0400 |
commit | 234b63a091e1df6bd4261dd7b3a7490074830628 (patch) | |
tree | 1947f6e49aa3c19017c948205378c5cb76a7b536 /fs/btrfs/ctree.c | |
parent | cf27e1eec063fa68a89c57ae0a83f93aa38851d6 (diff) |
rename funcs and structs to btrfs
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r-- | fs/btrfs/ctree.c | 317 |
1 files changed, 159 insertions, 158 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index 762810731001..c8529b394d5f 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -6,47 +6,47 @@ | |||
6 | #include "disk-io.h" | 6 | #include "disk-io.h" |
7 | #include "print-tree.h" | 7 | #include "print-tree.h" |
8 | 8 | ||
9 | static int split_node(struct ctree_root *root, struct ctree_path *path, | 9 | static int split_node(struct btrfs_root *root, struct btrfs_path *path, |
10 | int level); | 10 | int level); |
11 | static int split_leaf(struct ctree_root *root, struct ctree_path *path, | 11 | static int split_leaf(struct btrfs_root *root, struct btrfs_path *path, |
12 | int data_size); | 12 | int data_size); |
13 | static int push_node_left(struct ctree_root *root, struct tree_buffer *dst, | 13 | static int push_node_left(struct btrfs_root *root, struct btrfs_buffer *dst, |
14 | struct tree_buffer *src); | 14 | struct btrfs_buffer *src); |
15 | static int balance_node_right(struct ctree_root *root, | 15 | static int balance_node_right(struct btrfs_root *root, |
16 | struct tree_buffer *dst_buf, | 16 | struct btrfs_buffer *dst_buf, |
17 | struct tree_buffer *src_buf); | 17 | struct btrfs_buffer *src_buf); |
18 | static int del_ptr(struct ctree_root *root, struct ctree_path *path, int level, | 18 | static int del_ptr(struct btrfs_root *root, struct btrfs_path *path, int level, |
19 | int slot); | 19 | int slot); |
20 | 20 | ||
21 | inline void init_path(struct ctree_path *p) | 21 | inline void btrfs_init_path(struct btrfs_path *p) |
22 | { | 22 | { |
23 | memset(p, 0, sizeof(*p)); | 23 | memset(p, 0, sizeof(*p)); |
24 | } | 24 | } |
25 | 25 | ||
26 | void release_path(struct ctree_root *root, struct ctree_path *p) | 26 | void btrfs_release_path(struct btrfs_root *root, struct btrfs_path *p) |
27 | { | 27 | { |
28 | int i; | 28 | int i; |
29 | for (i = 0; i < MAX_LEVEL; i++) { | 29 | for (i = 0; i < BTRFS_MAX_LEVEL; i++) { |
30 | if (!p->nodes[i]) | 30 | if (!p->nodes[i]) |
31 | break; | 31 | break; |
32 | tree_block_release(root, p->nodes[i]); | 32 | btrfs_block_release(root, p->nodes[i]); |
33 | } | 33 | } |
34 | memset(p, 0, sizeof(*p)); | 34 | memset(p, 0, sizeof(*p)); |
35 | } | 35 | } |
36 | 36 | ||
37 | int btrfs_cow_block(struct ctree_root *root, | 37 | int btrfs_cow_block(struct btrfs_root *root, |
38 | struct tree_buffer *buf, | 38 | struct btrfs_buffer *buf, |
39 | struct tree_buffer *parent, | 39 | struct btrfs_buffer *parent, |
40 | int parent_slot, | 40 | int parent_slot, |
41 | struct tree_buffer **cow_ret) | 41 | struct btrfs_buffer **cow_ret) |
42 | { | 42 | { |
43 | struct tree_buffer *cow; | 43 | struct btrfs_buffer *cow; |
44 | 44 | ||
45 | if (!list_empty(&buf->dirty)) { | 45 | if (!list_empty(&buf->dirty)) { |
46 | *cow_ret = buf; | 46 | *cow_ret = buf; |
47 | return 0; | 47 | return 0; |
48 | } | 48 | } |
49 | cow = alloc_free_block(root); | 49 | cow = btrfs_alloc_free_block(root); |
50 | memcpy(&cow->node, &buf->node, sizeof(buf->node)); | 50 | memcpy(&cow->node, &buf->node, sizeof(buf->node)); |
51 | btrfs_set_header_blocknr(&cow->node.header, cow->blocknr); | 51 | btrfs_set_header_blocknr(&cow->node.header, cow->blocknr); |
52 | *cow_ret = cow; | 52 | *cow_ret = cow; |
@@ -55,15 +55,15 @@ int btrfs_cow_block(struct ctree_root *root, | |||
55 | root->node = cow; | 55 | root->node = cow; |
56 | cow->count++; | 56 | cow->count++; |
57 | if (buf != root->commit_root) | 57 | if (buf != root->commit_root) |
58 | free_extent(root, buf->blocknr, 1); | 58 | btrfs_free_extent(root, buf->blocknr, 1); |
59 | tree_block_release(root, buf); | 59 | btrfs_block_release(root, buf); |
60 | } else { | 60 | } else { |
61 | btrfs_set_node_blockptr(&parent->node, parent_slot, | 61 | btrfs_set_node_blockptr(&parent->node, parent_slot, |
62 | cow->blocknr); | 62 | cow->blocknr); |
63 | BUG_ON(list_empty(&parent->dirty)); | 63 | BUG_ON(list_empty(&parent->dirty)); |
64 | free_extent(root, buf->blocknr, 1); | 64 | btrfs_free_extent(root, buf->blocknr, 1); |
65 | } | 65 | } |
66 | tree_block_release(root, buf); | 66 | btrfs_block_release(root, buf); |
67 | return 0; | 67 | return 0; |
68 | } | 68 | } |
69 | 69 | ||
@@ -72,7 +72,7 @@ int btrfs_cow_block(struct ctree_root *root, | |||
72 | * this returns the address of the start of the last item, | 72 | * this returns the address of the start of the last item, |
73 | * which is the stop of the leaf data stack | 73 | * which is the stop of the leaf data stack |
74 | */ | 74 | */ |
75 | static inline unsigned int leaf_data_end(struct leaf *leaf) | 75 | static inline unsigned int leaf_data_end(struct btrfs_leaf *leaf) |
76 | { | 76 | { |
77 | u32 nr = btrfs_header_nritems(&leaf->header); | 77 | u32 nr = btrfs_header_nritems(&leaf->header); |
78 | if (nr == 0) | 78 | if (nr == 0) |
@@ -85,7 +85,7 @@ static inline unsigned int leaf_data_end(struct leaf *leaf) | |||
85 | * the start of the leaf data. IOW, how much room | 85 | * the start of the leaf data. IOW, how much room |
86 | * the leaf has left for both items and data | 86 | * the leaf has left for both items and data |
87 | */ | 87 | */ |
88 | int leaf_free_space(struct leaf *leaf) | 88 | int btrfs_leaf_free_space(struct btrfs_leaf *leaf) |
89 | { | 89 | { |
90 | int data_end = leaf_data_end(leaf); | 90 | int data_end = leaf_data_end(leaf); |
91 | int nritems = btrfs_header_nritems(&leaf->header); | 91 | int nritems = btrfs_header_nritems(&leaf->header); |
@@ -117,11 +117,11 @@ 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 ctree_path *path, int level) | 120 | int check_node(struct btrfs_path *path, int level) |
121 | { | 121 | { |
122 | int i; | 122 | int i; |
123 | struct node *parent = NULL; | 123 | struct btrfs_node *parent = NULL; |
124 | struct node *node = &path->nodes[level]->node; | 124 | struct btrfs_node *node = &path->nodes[level]->node; |
125 | int parent_slot; | 125 | int parent_slot; |
126 | u32 nritems = btrfs_header_nritems(&node->header); | 126 | u32 nritems = btrfs_header_nritems(&node->header); |
127 | 127 | ||
@@ -146,18 +146,18 @@ int check_node(struct ctree_path *path, int level) | |||
146 | return 0; | 146 | return 0; |
147 | } | 147 | } |
148 | 148 | ||
149 | int check_leaf(struct ctree_path *path, int level) | 149 | int check_leaf(struct btrfs_path *path, int level) |
150 | { | 150 | { |
151 | int i; | 151 | int i; |
152 | struct leaf *leaf = &path->nodes[level]->leaf; | 152 | struct btrfs_leaf *leaf = &path->nodes[level]->leaf; |
153 | struct node *parent = NULL; | 153 | struct btrfs_node *parent = NULL; |
154 | int parent_slot; | 154 | int parent_slot; |
155 | u32 nritems = btrfs_header_nritems(&leaf->header); | 155 | u32 nritems = btrfs_header_nritems(&leaf->header); |
156 | 156 | ||
157 | if (path->nodes[level + 1]) | 157 | if (path->nodes[level + 1]) |
158 | parent = &path->nodes[level + 1]->node; | 158 | parent = &path->nodes[level + 1]->node; |
159 | parent_slot = path->slots[level + 1]; | 159 | parent_slot = path->slots[level + 1]; |
160 | BUG_ON(leaf_free_space(leaf) < 0); | 160 | BUG_ON(btrfs_leaf_free_space(leaf) < 0); |
161 | 161 | ||
162 | if (nritems == 0) | 162 | if (nritems == 0) |
163 | return 0; | 163 | return 0; |
@@ -186,7 +186,7 @@ int check_leaf(struct ctree_path *path, int level) | |||
186 | return 0; | 186 | return 0; |
187 | } | 187 | } |
188 | 188 | ||
189 | int check_block(struct ctree_path *path, int level) | 189 | 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); |
@@ -233,10 +233,10 @@ 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 node *c, struct btrfs_key *key, int *slot) | 236 | 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 leaf *l = (struct leaf *)c; | 239 | struct btrfs_leaf *l = (struct btrfs_leaf *)c; |
240 | return generic_bin_search((void *)l->items, | 240 | return generic_bin_search((void *)l->items, |
241 | sizeof(struct btrfs_item), | 241 | sizeof(struct btrfs_item), |
242 | key, btrfs_header_nritems(&c->header), | 242 | key, btrfs_header_nritems(&c->header), |
@@ -250,11 +250,11 @@ int bin_search(struct node *c, struct btrfs_key *key, int *slot) | |||
250 | return -1; | 250 | return -1; |
251 | } | 251 | } |
252 | 252 | ||
253 | struct tree_buffer *read_node_slot(struct ctree_root *root, | 253 | struct btrfs_buffer *read_node_slot(struct btrfs_root *root, |
254 | struct tree_buffer *parent_buf, | 254 | struct btrfs_buffer *parent_buf, |
255 | int slot) | 255 | int slot) |
256 | { | 256 | { |
257 | struct node *node = &parent_buf->node; | 257 | struct btrfs_node *node = &parent_buf->node; |
258 | if (slot < 0) | 258 | if (slot < 0) |
259 | return NULL; | 259 | return NULL; |
260 | if (slot >= btrfs_header_nritems(&node->header)) | 260 | if (slot >= btrfs_header_nritems(&node->header)) |
@@ -262,17 +262,17 @@ struct tree_buffer *read_node_slot(struct ctree_root *root, | |||
262 | return read_tree_block(root, btrfs_node_blockptr(node, slot)); | 262 | return read_tree_block(root, btrfs_node_blockptr(node, slot)); |
263 | } | 263 | } |
264 | 264 | ||
265 | static int balance_level(struct ctree_root *root, struct ctree_path *path, | 265 | static int balance_level(struct btrfs_root *root, struct btrfs_path *path, |
266 | int level) | 266 | int level) |
267 | { | 267 | { |
268 | struct tree_buffer *right_buf; | 268 | struct btrfs_buffer *right_buf; |
269 | struct tree_buffer *mid_buf; | 269 | struct btrfs_buffer *mid_buf; |
270 | struct tree_buffer *left_buf; | 270 | struct btrfs_buffer *left_buf; |
271 | struct tree_buffer *parent_buf = NULL; | 271 | struct btrfs_buffer *parent_buf = NULL; |
272 | struct node *right = NULL; | 272 | struct btrfs_node *right = NULL; |
273 | struct node *mid; | 273 | struct btrfs_node *mid; |
274 | struct node *left = NULL; | 274 | struct btrfs_node *left = NULL; |
275 | struct node *parent = NULL; | 275 | struct btrfs_node *parent = NULL; |
276 | int ret = 0; | 276 | int ret = 0; |
277 | int wret; | 277 | int wret; |
278 | int pslot; | 278 | int pslot; |
@@ -286,12 +286,12 @@ static int balance_level(struct ctree_root *root, struct ctree_path *path, | |||
286 | mid = &mid_buf->node; | 286 | mid = &mid_buf->node; |
287 | orig_ptr = btrfs_node_blockptr(mid, orig_slot); | 287 | orig_ptr = btrfs_node_blockptr(mid, orig_slot); |
288 | 288 | ||
289 | if (level < MAX_LEVEL - 1) | 289 | if (level < BTRFS_MAX_LEVEL - 1) |
290 | parent_buf = path->nodes[level + 1]; | 290 | parent_buf = path->nodes[level + 1]; |
291 | pslot = path->slots[level + 1]; | 291 | pslot = path->slots[level + 1]; |
292 | 292 | ||
293 | if (!parent_buf) { | 293 | if (!parent_buf) { |
294 | struct tree_buffer *child; | 294 | struct btrfs_buffer *child; |
295 | u64 blocknr = mid_buf->blocknr; | 295 | u64 blocknr = mid_buf->blocknr; |
296 | 296 | ||
297 | if (btrfs_header_nritems(&mid->header) != 1) | 297 | if (btrfs_header_nritems(&mid->header) != 1) |
@@ -303,11 +303,11 @@ static int balance_level(struct ctree_root *root, struct ctree_path *path, | |||
303 | root->node = child; | 303 | root->node = child; |
304 | path->nodes[level] = NULL; | 304 | path->nodes[level] = NULL; |
305 | /* once for the path */ | 305 | /* once for the path */ |
306 | tree_block_release(root, mid_buf); | 306 | btrfs_block_release(root, mid_buf); |
307 | /* once for the root ptr */ | 307 | /* once for the root ptr */ |
308 | tree_block_release(root, mid_buf); | 308 | btrfs_block_release(root, mid_buf); |
309 | clean_tree_block(root, mid_buf); | 309 | clean_tree_block(root, mid_buf); |
310 | return free_extent(root, blocknr, 1); | 310 | return btrfs_free_extent(root, blocknr, 1); |
311 | } | 311 | } |
312 | parent = &parent_buf->node; | 312 | parent = &parent_buf->node; |
313 | 313 | ||
@@ -340,14 +340,14 @@ static int balance_level(struct ctree_root *root, struct ctree_path *path, | |||
340 | ret = wret; | 340 | ret = wret; |
341 | if (btrfs_header_nritems(&right->header) == 0) { | 341 | if (btrfs_header_nritems(&right->header) == 0) { |
342 | u64 blocknr = right_buf->blocknr; | 342 | u64 blocknr = right_buf->blocknr; |
343 | tree_block_release(root, right_buf); | 343 | btrfs_block_release(root, right_buf); |
344 | clean_tree_block(root, right_buf); | 344 | clean_tree_block(root, right_buf); |
345 | right_buf = NULL; | 345 | right_buf = NULL; |
346 | right = NULL; | 346 | right = NULL; |
347 | wret = del_ptr(root, path, level + 1, pslot + 1); | 347 | wret = del_ptr(root, path, level + 1, pslot + 1); |
348 | if (wret) | 348 | if (wret) |
349 | ret = wret; | 349 | ret = wret; |
350 | wret = free_extent(root, blocknr, 1); | 350 | wret = btrfs_free_extent(root, blocknr, 1); |
351 | if (wret) | 351 | if (wret) |
352 | ret = wret; | 352 | ret = wret; |
353 | } else { | 353 | } else { |
@@ -375,14 +375,14 @@ static int balance_level(struct ctree_root *root, struct ctree_path *path, | |||
375 | if (btrfs_header_nritems(&mid->header) == 0) { | 375 | if (btrfs_header_nritems(&mid->header) == 0) { |
376 | /* we've managed to empty the middle node, drop it */ | 376 | /* we've managed to empty the middle node, drop it */ |
377 | u64 blocknr = mid_buf->blocknr; | 377 | u64 blocknr = mid_buf->blocknr; |
378 | tree_block_release(root, mid_buf); | 378 | btrfs_block_release(root, mid_buf); |
379 | clean_tree_block(root, mid_buf); | 379 | clean_tree_block(root, mid_buf); |
380 | mid_buf = NULL; | 380 | mid_buf = NULL; |
381 | mid = NULL; | 381 | mid = NULL; |
382 | wret = del_ptr(root, path, level + 1, pslot); | 382 | wret = del_ptr(root, path, level + 1, pslot); |
383 | if (wret) | 383 | if (wret) |
384 | ret = wret; | 384 | ret = wret; |
385 | wret = free_extent(root, blocknr, 1); | 385 | wret = btrfs_free_extent(root, blocknr, 1); |
386 | if (wret) | 386 | if (wret) |
387 | ret = wret; | 387 | ret = wret; |
388 | } else { | 388 | } else { |
@@ -400,7 +400,7 @@ static int balance_level(struct ctree_root *root, struct ctree_path *path, | |||
400 | path->slots[level + 1] -= 1; | 400 | path->slots[level + 1] -= 1; |
401 | path->slots[level] = orig_slot; | 401 | path->slots[level] = orig_slot; |
402 | if (mid_buf) | 402 | if (mid_buf) |
403 | tree_block_release(root, mid_buf); | 403 | btrfs_block_release(root, mid_buf); |
404 | } else { | 404 | } else { |
405 | orig_slot -= btrfs_header_nritems(&left->header); | 405 | orig_slot -= btrfs_header_nritems(&left->header); |
406 | path->slots[level] = orig_slot; | 406 | path->slots[level] = orig_slot; |
@@ -413,9 +413,9 @@ static int balance_level(struct ctree_root *root, struct ctree_path *path, | |||
413 | BUG(); | 413 | BUG(); |
414 | 414 | ||
415 | if (right_buf) | 415 | if (right_buf) |
416 | tree_block_release(root, right_buf); | 416 | btrfs_block_release(root, right_buf); |
417 | if (left_buf) | 417 | if (left_buf) |
418 | tree_block_release(root, left_buf); | 418 | btrfs_block_release(root, left_buf); |
419 | return ret; | 419 | return ret; |
420 | } | 420 | } |
421 | 421 | ||
@@ -432,12 +432,12 @@ static int balance_level(struct ctree_root *root, struct ctree_path *path, | |||
432 | * tree. if ins_len < 0, nodes will be merged as we walk down the tree (if | 432 | * tree. if ins_len < 0, nodes will be merged as we walk down the tree (if |
433 | * possible) | 433 | * possible) |
434 | */ | 434 | */ |
435 | int search_slot(struct ctree_root *root, struct btrfs_key *key, | 435 | int btrfs_search_slot(struct btrfs_root *root, struct btrfs_key *key, |
436 | struct ctree_path *p, int ins_len, int cow) | 436 | struct btrfs_path *p, int ins_len, int cow) |
437 | { | 437 | { |
438 | struct tree_buffer *b; | 438 | struct btrfs_buffer *b; |
439 | struct tree_buffer *cow_buf; | 439 | struct btrfs_buffer *cow_buf; |
440 | struct node *c; | 440 | struct btrfs_node *c; |
441 | int slot; | 441 | int slot; |
442 | int ret; | 442 | int ret; |
443 | int level; | 443 | int level; |
@@ -486,9 +486,9 @@ again: | |||
486 | } | 486 | } |
487 | b = read_tree_block(root, btrfs_node_blockptr(c, slot)); | 487 | b = read_tree_block(root, btrfs_node_blockptr(c, slot)); |
488 | } else { | 488 | } else { |
489 | struct leaf *l = (struct leaf *)c; | 489 | struct btrfs_leaf *l = (struct btrfs_leaf *)c; |
490 | p->slots[level] = slot; | 490 | p->slots[level] = slot; |
491 | if (ins_len > 0 && leaf_free_space(l) < | 491 | if (ins_len > 0 && btrfs_leaf_free_space(l) < |
492 | sizeof(struct btrfs_item) + ins_len) { | 492 | sizeof(struct btrfs_item) + ins_len) { |
493 | int sret = split_leaf(root, p, ins_len); | 493 | int sret = split_leaf(root, p, ins_len); |
494 | BUG_ON(sret > 0); | 494 | BUG_ON(sret > 0); |
@@ -513,14 +513,14 @@ again: | |||
513 | * If this fails to write a tree block, it returns -1, but continues | 513 | * If this fails to write a tree block, it returns -1, but continues |
514 | * fixing up the blocks in ram so the tree is consistent. | 514 | * fixing up the blocks in ram so the tree is consistent. |
515 | */ | 515 | */ |
516 | static int fixup_low_keys(struct ctree_root *root, | 516 | static int fixup_low_keys(struct btrfs_root *root, |
517 | struct ctree_path *path, struct btrfs_disk_key *key, | 517 | struct btrfs_path *path, struct btrfs_disk_key *key, |
518 | int level) | 518 | int level) |
519 | { | 519 | { |
520 | int i; | 520 | int i; |
521 | int ret = 0; | 521 | int ret = 0; |
522 | for (i = level; i < MAX_LEVEL; i++) { | 522 | for (i = level; i < BTRFS_MAX_LEVEL; i++) { |
523 | struct node *t; | 523 | struct btrfs_node *t; |
524 | int tslot = path->slots[i]; | 524 | int tslot = path->slots[i]; |
525 | if (!path->nodes[i]) | 525 | if (!path->nodes[i]) |
526 | break; | 526 | break; |
@@ -540,11 +540,11 @@ static int fixup_low_keys(struct ctree_root *root, | |||
540 | * returns 0 if some ptrs were pushed left, < 0 if there was some horrible | 540 | * returns 0 if some ptrs were pushed left, < 0 if there was some horrible |
541 | * error, and > 0 if there was no room in the left hand block. | 541 | * error, and > 0 if there was no room in the left hand block. |
542 | */ | 542 | */ |
543 | static int push_node_left(struct ctree_root *root, struct tree_buffer *dst_buf, | 543 | static int push_node_left(struct btrfs_root *root, struct btrfs_buffer *dst_buf, |
544 | struct tree_buffer *src_buf) | 544 | struct btrfs_buffer *src_buf) |
545 | { | 545 | { |
546 | struct node *src = &src_buf->node; | 546 | struct btrfs_node *src = &src_buf->node; |
547 | struct node *dst = &dst_buf->node; | 547 | struct btrfs_node *dst = &dst_buf->node; |
548 | int push_items = 0; | 548 | int push_items = 0; |
549 | int src_nritems; | 549 | int src_nritems; |
550 | int dst_nritems; | 550 | int dst_nritems; |
@@ -587,12 +587,12 @@ static int push_node_left(struct ctree_root *root, struct tree_buffer *dst_buf, | |||
587 | * | 587 | * |
588 | * this will only push up to 1/2 the contents of the left node over | 588 | * this will only push up to 1/2 the contents of the left node over |
589 | */ | 589 | */ |
590 | static int balance_node_right(struct ctree_root *root, | 590 | static int balance_node_right(struct btrfs_root *root, |
591 | struct tree_buffer *dst_buf, | 591 | struct btrfs_buffer *dst_buf, |
592 | struct tree_buffer *src_buf) | 592 | struct btrfs_buffer *src_buf) |
593 | { | 593 | { |
594 | struct node *src = &src_buf->node; | 594 | struct btrfs_node *src = &src_buf->node; |
595 | struct node *dst = &dst_buf->node; | 595 | struct btrfs_node *dst = &dst_buf->node; |
596 | int push_items = 0; | 596 | int push_items = 0; |
597 | int max_push; | 597 | int max_push; |
598 | int src_nritems; | 598 | int src_nritems; |
@@ -637,18 +637,18 @@ static int balance_node_right(struct ctree_root *root, | |||
637 | * | 637 | * |
638 | * returns zero on success or < 0 on failure. | 638 | * returns zero on success or < 0 on failure. |
639 | */ | 639 | */ |
640 | static int insert_new_root(struct ctree_root *root, | 640 | static int insert_new_root(struct btrfs_root *root, |
641 | struct ctree_path *path, int level) | 641 | struct btrfs_path *path, int level) |
642 | { | 642 | { |
643 | struct tree_buffer *t; | 643 | struct btrfs_buffer *t; |
644 | struct node *lower; | 644 | struct btrfs_node *lower; |
645 | struct node *c; | 645 | struct btrfs_node *c; |
646 | struct btrfs_disk_key *lower_key; | 646 | struct btrfs_disk_key *lower_key; |
647 | 647 | ||
648 | BUG_ON(path->nodes[level]); | 648 | BUG_ON(path->nodes[level]); |
649 | BUG_ON(path->nodes[level-1] != root->node); | 649 | BUG_ON(path->nodes[level-1] != root->node); |
650 | 650 | ||
651 | t = alloc_free_block(root); | 651 | t = btrfs_alloc_free_block(root); |
652 | c = &t->node; | 652 | c = &t->node; |
653 | memset(c, 0, sizeof(c)); | 653 | memset(c, 0, sizeof(c)); |
654 | btrfs_set_header_nritems(&c->header, 1); | 654 | btrfs_set_header_nritems(&c->header, 1); |
@@ -658,13 +658,13 @@ static int insert_new_root(struct ctree_root *root, | |||
658 | btrfs_header_parentid(&root->node->node.header)); | 658 | btrfs_header_parentid(&root->node->node.header)); |
659 | lower = &path->nodes[level-1]->node; | 659 | lower = &path->nodes[level-1]->node; |
660 | if (btrfs_is_leaf(lower)) | 660 | if (btrfs_is_leaf(lower)) |
661 | lower_key = &((struct leaf *)lower)->items[0].key; | 661 | lower_key = &((struct btrfs_leaf *)lower)->items[0].key; |
662 | else | 662 | else |
663 | lower_key = lower->keys; | 663 | lower_key = lower->keys; |
664 | memcpy(c->keys, lower_key, sizeof(struct btrfs_disk_key)); | 664 | memcpy(c->keys, lower_key, sizeof(struct btrfs_disk_key)); |
665 | btrfs_set_node_blockptr(c, 0, path->nodes[level - 1]->blocknr); | 665 | btrfs_set_node_blockptr(c, 0, path->nodes[level - 1]->blocknr); |
666 | /* the super has an extra ref to root->node */ | 666 | /* the super has an extra ref to root->node */ |
667 | tree_block_release(root, root->node); | 667 | btrfs_block_release(root, root->node); |
668 | root->node = t; | 668 | root->node = t; |
669 | t->count++; | 669 | t->count++; |
670 | path->nodes[level] = t; | 670 | path->nodes[level] = t; |
@@ -681,11 +681,11 @@ static int insert_new_root(struct ctree_root *root, | |||
681 | * | 681 | * |
682 | * returns zero on success and < 0 on any error | 682 | * returns zero on success and < 0 on any error |
683 | */ | 683 | */ |
684 | static int insert_ptr(struct ctree_root *root, | 684 | static int insert_ptr(struct btrfs_root *root, |
685 | struct ctree_path *path, struct btrfs_disk_key *key, | 685 | struct btrfs_path *path, struct btrfs_disk_key *key, |
686 | u64 blocknr, int slot, int level) | 686 | u64 blocknr, int slot, int level) |
687 | { | 687 | { |
688 | struct node *lower; | 688 | struct btrfs_node *lower; |
689 | int nritems; | 689 | int nritems; |
690 | 690 | ||
691 | BUG_ON(!path->nodes[level]); | 691 | BUG_ON(!path->nodes[level]); |
@@ -719,13 +719,13 @@ static int insert_ptr(struct ctree_root *root, | |||
719 | * | 719 | * |
720 | * returns 0 on success and < 0 on failure | 720 | * returns 0 on success and < 0 on failure |
721 | */ | 721 | */ |
722 | static int split_node(struct ctree_root *root, struct ctree_path *path, | 722 | static int split_node(struct btrfs_root *root, struct btrfs_path *path, |
723 | int level) | 723 | int level) |
724 | { | 724 | { |
725 | struct tree_buffer *t; | 725 | struct btrfs_buffer *t; |
726 | struct node *c; | 726 | struct btrfs_node *c; |
727 | struct tree_buffer *split_buffer; | 727 | struct btrfs_buffer *split_buffer; |
728 | struct node *split; | 728 | struct btrfs_node *split; |
729 | int mid; | 729 | int mid; |
730 | int ret; | 730 | int ret; |
731 | int wret; | 731 | int wret; |
@@ -740,7 +740,7 @@ static int split_node(struct ctree_root *root, struct ctree_path *path, | |||
740 | return ret; | 740 | return ret; |
741 | } | 741 | } |
742 | c_nritems = btrfs_header_nritems(&c->header); | 742 | c_nritems = btrfs_header_nritems(&c->header); |
743 | split_buffer = alloc_free_block(root); | 743 | split_buffer = btrfs_alloc_free_block(root); |
744 | split = &split_buffer->node; | 744 | split = &split_buffer->node; |
745 | btrfs_set_header_flags(&split->header, btrfs_header_flags(&c->header)); | 745 | btrfs_set_header_flags(&split->header, btrfs_header_flags(&c->header)); |
746 | btrfs_set_header_blocknr(&split->header, split_buffer->blocknr); | 746 | btrfs_set_header_blocknr(&split->header, split_buffer->blocknr); |
@@ -763,11 +763,11 @@ static int split_node(struct ctree_root *root, struct ctree_path *path, | |||
763 | 763 | ||
764 | if (path->slots[level] >= mid) { | 764 | if (path->slots[level] >= mid) { |
765 | path->slots[level] -= mid; | 765 | path->slots[level] -= mid; |
766 | tree_block_release(root, t); | 766 | btrfs_block_release(root, t); |
767 | path->nodes[level] = split_buffer; | 767 | path->nodes[level] = split_buffer; |
768 | path->slots[level + 1] += 1; | 768 | path->slots[level + 1] += 1; |
769 | } else { | 769 | } else { |
770 | tree_block_release(root, split_buffer); | 770 | btrfs_block_release(root, split_buffer); |
771 | } | 771 | } |
772 | return ret; | 772 | return ret; |
773 | } | 773 | } |
@@ -777,7 +777,7 @@ static int split_node(struct ctree_root *root, struct ctree_path *path, | |||
777 | * and nr indicate which items in the leaf to check. This totals up the | 777 | * and nr indicate which items in the leaf to check. This totals up the |
778 | * space used both by the item structs and the item data | 778 | * space used both by the item structs and the item data |
779 | */ | 779 | */ |
780 | static int leaf_space_used(struct leaf *l, int start, int nr) | 780 | static int leaf_space_used(struct btrfs_leaf *l, int start, int nr) |
781 | { | 781 | { |
782 | int data_len; | 782 | int data_len; |
783 | int end = start + nr - 1; | 783 | int end = start + nr - 1; |
@@ -797,14 +797,14 @@ static int leaf_space_used(struct leaf *l, int start, int nr) | |||
797 | * returns 1 if the push failed because the other node didn't have enough | 797 | * returns 1 if the push failed because the other node didn't have enough |
798 | * room, 0 if everything worked out and < 0 if there were major errors. | 798 | * room, 0 if everything worked out and < 0 if there were major errors. |
799 | */ | 799 | */ |
800 | static int push_leaf_right(struct ctree_root *root, struct ctree_path *path, | 800 | static int push_leaf_right(struct btrfs_root *root, struct btrfs_path *path, |
801 | int data_size) | 801 | int data_size) |
802 | { | 802 | { |
803 | struct tree_buffer *left_buf = path->nodes[0]; | 803 | struct btrfs_buffer *left_buf = path->nodes[0]; |
804 | struct leaf *left = &left_buf->leaf; | 804 | struct btrfs_leaf *left = &left_buf->leaf; |
805 | struct leaf *right; | 805 | struct btrfs_leaf *right; |
806 | struct tree_buffer *right_buf; | 806 | struct btrfs_buffer *right_buf; |
807 | struct tree_buffer *upper; | 807 | struct btrfs_buffer *upper; |
808 | int slot; | 808 | int slot; |
809 | int i; | 809 | int i; |
810 | int free_space; | 810 | int free_space; |
@@ -825,17 +825,17 @@ static int push_leaf_right(struct ctree_root *root, struct ctree_path *path, | |||
825 | right_buf = read_tree_block(root, btrfs_node_blockptr(&upper->node, | 825 | right_buf = read_tree_block(root, btrfs_node_blockptr(&upper->node, |
826 | slot + 1)); | 826 | slot + 1)); |
827 | right = &right_buf->leaf; | 827 | right = &right_buf->leaf; |
828 | free_space = leaf_free_space(right); | 828 | free_space = btrfs_leaf_free_space(right); |
829 | if (free_space < data_size + sizeof(struct btrfs_item)) { | 829 | if (free_space < data_size + sizeof(struct btrfs_item)) { |
830 | tree_block_release(root, right_buf); | 830 | btrfs_block_release(root, right_buf); |
831 | return 1; | 831 | return 1; |
832 | } | 832 | } |
833 | /* cow and double check */ | 833 | /* cow and double check */ |
834 | btrfs_cow_block(root, right_buf, upper, slot + 1, &right_buf); | 834 | btrfs_cow_block(root, right_buf, upper, slot + 1, &right_buf); |
835 | right = &right_buf->leaf; | 835 | right = &right_buf->leaf; |
836 | free_space = leaf_free_space(right); | 836 | free_space = btrfs_leaf_free_space(right); |
837 | if (free_space < data_size + sizeof(struct btrfs_item)) { | 837 | if (free_space < data_size + sizeof(struct btrfs_item)) { |
838 | tree_block_release(root, right_buf); | 838 | btrfs_block_release(root, right_buf); |
839 | return 1; | 839 | return 1; |
840 | } | 840 | } |
841 | 841 | ||
@@ -851,7 +851,7 @@ static int push_leaf_right(struct ctree_root *root, struct ctree_path *path, | |||
851 | push_space += btrfs_item_size(item) + sizeof(*item); | 851 | push_space += btrfs_item_size(item) + sizeof(*item); |
852 | } | 852 | } |
853 | if (push_items == 0) { | 853 | if (push_items == 0) { |
854 | tree_block_release(root, right_buf); | 854 | btrfs_block_release(root, right_buf); |
855 | return 1; | 855 | return 1; |
856 | } | 856 | } |
857 | right_nritems = btrfs_header_nritems(&right->header); | 857 | right_nritems = btrfs_header_nritems(&right->header); |
@@ -893,11 +893,11 @@ static int push_leaf_right(struct ctree_root *root, struct ctree_path *path, | |||
893 | /* then fixup the leaf pointer in the path */ | 893 | /* then fixup the leaf pointer in the path */ |
894 | if (path->slots[0] >= left_nritems) { | 894 | if (path->slots[0] >= left_nritems) { |
895 | path->slots[0] -= left_nritems; | 895 | path->slots[0] -= left_nritems; |
896 | tree_block_release(root, path->nodes[0]); | 896 | btrfs_block_release(root, path->nodes[0]); |
897 | path->nodes[0] = right_buf; | 897 | path->nodes[0] = right_buf; |
898 | path->slots[1] += 1; | 898 | path->slots[1] += 1; |
899 | } else { | 899 | } else { |
900 | tree_block_release(root, right_buf); | 900 | btrfs_block_release(root, right_buf); |
901 | } | 901 | } |
902 | return 0; | 902 | return 0; |
903 | } | 903 | } |
@@ -905,13 +905,13 @@ static int push_leaf_right(struct ctree_root *root, struct ctree_path *path, | |||
905 | * push some data in the path leaf to the left, trying to free up at | 905 | * push some data in the path leaf to the left, trying to free up at |
906 | * least data_size bytes. returns zero if the push worked, nonzero otherwise | 906 | * least data_size bytes. returns zero if the push worked, nonzero otherwise |
907 | */ | 907 | */ |
908 | static int push_leaf_left(struct ctree_root *root, struct ctree_path *path, | 908 | static int push_leaf_left(struct btrfs_root *root, struct btrfs_path *path, |
909 | int data_size) | 909 | int data_size) |
910 | { | 910 | { |
911 | struct tree_buffer *right_buf = path->nodes[0]; | 911 | struct btrfs_buffer *right_buf = path->nodes[0]; |
912 | struct leaf *right = &right_buf->leaf; | 912 | struct btrfs_leaf *right = &right_buf->leaf; |
913 | struct tree_buffer *t; | 913 | struct btrfs_buffer *t; |
914 | struct leaf *left; | 914 | struct btrfs_leaf *left; |
915 | int slot; | 915 | int slot; |
916 | int i; | 916 | int i; |
917 | int free_space; | 917 | int free_space; |
@@ -932,18 +932,18 @@ static int push_leaf_left(struct ctree_root *root, struct ctree_path *path, | |||
932 | t = read_tree_block(root, btrfs_node_blockptr(&path->nodes[1]->node, | 932 | t = read_tree_block(root, btrfs_node_blockptr(&path->nodes[1]->node, |
933 | slot - 1)); | 933 | slot - 1)); |
934 | left = &t->leaf; | 934 | left = &t->leaf; |
935 | free_space = leaf_free_space(left); | 935 | free_space = btrfs_leaf_free_space(left); |
936 | if (free_space < data_size + sizeof(struct btrfs_item)) { | 936 | if (free_space < data_size + sizeof(struct btrfs_item)) { |
937 | tree_block_release(root, t); | 937 | btrfs_block_release(root, t); |
938 | return 1; | 938 | return 1; |
939 | } | 939 | } |
940 | 940 | ||
941 | /* cow and double check */ | 941 | /* cow and double check */ |
942 | btrfs_cow_block(root, t, path->nodes[1], slot - 1, &t); | 942 | btrfs_cow_block(root, t, path->nodes[1], slot - 1, &t); |
943 | left = &t->leaf; | 943 | left = &t->leaf; |
944 | free_space = leaf_free_space(left); | 944 | free_space = btrfs_leaf_free_space(left); |
945 | if (free_space < data_size + sizeof(struct btrfs_item)) { | 945 | if (free_space < data_size + sizeof(struct btrfs_item)) { |
946 | tree_block_release(root, t); | 946 | btrfs_block_release(root, t); |
947 | return 1; | 947 | return 1; |
948 | } | 948 | } |
949 | 949 | ||
@@ -958,7 +958,7 @@ static int push_leaf_left(struct ctree_root *root, struct ctree_path *path, | |||
958 | push_space += btrfs_item_size(item) + sizeof(*item); | 958 | push_space += btrfs_item_size(item) + sizeof(*item); |
959 | } | 959 | } |
960 | if (push_items == 0) { | 960 | if (push_items == 0) { |
961 | tree_block_release(root, t); | 961 | btrfs_block_release(root, t); |
962 | return 1; | 962 | return 1; |
963 | } | 963 | } |
964 | /* push data from right to left */ | 964 | /* push data from right to left */ |
@@ -1009,11 +1009,11 @@ static int push_leaf_left(struct ctree_root *root, struct ctree_path *path, | |||
1009 | /* then fixup the leaf pointer in the path */ | 1009 | /* then fixup the leaf pointer in the path */ |
1010 | if (path->slots[0] < push_items) { | 1010 | if (path->slots[0] < push_items) { |
1011 | path->slots[0] += old_left_nritems; | 1011 | path->slots[0] += old_left_nritems; |
1012 | tree_block_release(root, path->nodes[0]); | 1012 | btrfs_block_release(root, path->nodes[0]); |
1013 | path->nodes[0] = t; | 1013 | path->nodes[0] = t; |
1014 | path->slots[1] -= 1; | 1014 | path->slots[1] -= 1; |
1015 | } else { | 1015 | } else { |
1016 | tree_block_release(root, t); | 1016 | btrfs_block_release(root, t); |
1017 | path->slots[0] -= push_items; | 1017 | path->slots[0] -= push_items; |
1018 | } | 1018 | } |
1019 | BUG_ON(path->slots[0] < 0); | 1019 | BUG_ON(path->slots[0] < 0); |
@@ -1026,16 +1026,16 @@ static int push_leaf_left(struct ctree_root *root, struct ctree_path *path, | |||
1026 | * | 1026 | * |
1027 | * returns 0 if all went well and < 0 on failure. | 1027 | * returns 0 if all went well and < 0 on failure. |
1028 | */ | 1028 | */ |
1029 | static int split_leaf(struct ctree_root *root, struct ctree_path *path, | 1029 | static int split_leaf(struct btrfs_root *root, struct btrfs_path *path, |
1030 | int data_size) | 1030 | int data_size) |
1031 | { | 1031 | { |
1032 | struct tree_buffer *l_buf; | 1032 | struct btrfs_buffer *l_buf; |
1033 | struct leaf *l; | 1033 | struct btrfs_leaf *l; |
1034 | u32 nritems; | 1034 | u32 nritems; |
1035 | int mid; | 1035 | int mid; |
1036 | int slot; | 1036 | int slot; |
1037 | struct leaf *right; | 1037 | struct btrfs_leaf *right; |
1038 | struct tree_buffer *right_buffer; | 1038 | struct btrfs_buffer *right_buffer; |
1039 | int space_needed = data_size + sizeof(struct btrfs_item); | 1039 | int space_needed = data_size + sizeof(struct btrfs_item); |
1040 | int data_copy_size; | 1040 | int data_copy_size; |
1041 | int rt_data_off; | 1041 | int rt_data_off; |
@@ -1047,7 +1047,7 @@ static int split_leaf(struct ctree_root *root, struct ctree_path *path, | |||
1047 | l = &l_buf->leaf; | 1047 | l = &l_buf->leaf; |
1048 | 1048 | ||
1049 | /* did the pushes work? */ | 1049 | /* did the pushes work? */ |
1050 | if (leaf_free_space(l) >= sizeof(struct btrfs_item) + data_size) | 1050 | if (btrfs_leaf_free_space(l) >= sizeof(struct btrfs_item) + data_size) |
1051 | return 0; | 1051 | return 0; |
1052 | 1052 | ||
1053 | if (!path->nodes[1]) { | 1053 | if (!path->nodes[1]) { |
@@ -1058,7 +1058,7 @@ static int split_leaf(struct ctree_root *root, struct ctree_path *path, | |||
1058 | slot = path->slots[0]; | 1058 | slot = path->slots[0]; |
1059 | nritems = btrfs_header_nritems(&l->header); | 1059 | nritems = btrfs_header_nritems(&l->header); |
1060 | mid = (nritems + 1)/ 2; | 1060 | mid = (nritems + 1)/ 2; |
1061 | right_buffer = alloc_free_block(root); | 1061 | right_buffer = btrfs_alloc_free_block(root); |
1062 | BUG_ON(!right_buffer); | 1062 | BUG_ON(!right_buffer); |
1063 | BUG_ON(mid == nritems); | 1063 | BUG_ON(mid == nritems); |
1064 | right = &right_buffer->leaf; | 1064 | right = &right_buffer->leaf; |
@@ -1101,12 +1101,12 @@ static int split_leaf(struct ctree_root *root, struct ctree_path *path, | |||
1101 | BUG_ON(list_empty(&l_buf->dirty)); | 1101 | BUG_ON(list_empty(&l_buf->dirty)); |
1102 | BUG_ON(path->slots[0] != slot); | 1102 | BUG_ON(path->slots[0] != slot); |
1103 | if (mid <= slot) { | 1103 | if (mid <= slot) { |
1104 | tree_block_release(root, path->nodes[0]); | 1104 | btrfs_block_release(root, path->nodes[0]); |
1105 | path->nodes[0] = right_buffer; | 1105 | path->nodes[0] = right_buffer; |
1106 | path->slots[0] -= mid; | 1106 | path->slots[0] -= mid; |
1107 | path->slots[1] += 1; | 1107 | path->slots[1] += 1; |
1108 | } else | 1108 | } else |
1109 | tree_block_release(root, right_buffer); | 1109 | btrfs_block_release(root, right_buffer); |
1110 | BUG_ON(path->slots[0] < 0); | 1110 | BUG_ON(path->slots[0] < 0); |
1111 | return ret; | 1111 | return ret; |
1112 | } | 1112 | } |
@@ -1115,17 +1115,17 @@ static int split_leaf(struct ctree_root *root, struct ctree_path *path, | |||
1115 | * Given a key and some data, insert an item into the tree. | 1115 | * Given a key and some data, insert an item into the tree. |
1116 | * This does all the path init required, making room in the tree if needed. | 1116 | * This does all the path init required, making room in the tree if needed. |
1117 | */ | 1117 | */ |
1118 | int insert_item(struct ctree_root *root, struct btrfs_key *cpu_key, | 1118 | int btrfs_insert_item(struct btrfs_root *root, struct btrfs_key *cpu_key, |
1119 | void *data, int data_size) | 1119 | void *data, int data_size) |
1120 | { | 1120 | { |
1121 | int ret = 0; | 1121 | int ret = 0; |
1122 | int slot; | 1122 | int slot; |
1123 | int slot_orig; | 1123 | int slot_orig; |
1124 | struct leaf *leaf; | 1124 | struct btrfs_leaf *leaf; |
1125 | struct tree_buffer *leaf_buf; | 1125 | struct btrfs_buffer *leaf_buf; |
1126 | u32 nritems; | 1126 | u32 nritems; |
1127 | unsigned int data_end; | 1127 | unsigned int data_end; |
1128 | struct ctree_path path; | 1128 | struct btrfs_path path; |
1129 | struct btrfs_disk_key disk_key; | 1129 | struct btrfs_disk_key disk_key; |
1130 | 1130 | ||
1131 | btrfs_cpu_key_to_disk(&disk_key, cpu_key); | 1131 | btrfs_cpu_key_to_disk(&disk_key, cpu_key); |
@@ -1133,10 +1133,10 @@ int insert_item(struct ctree_root *root, struct btrfs_key *cpu_key, | |||
1133 | /* create a root if there isn't one */ | 1133 | /* create a root if there isn't one */ |
1134 | if (!root->node) | 1134 | if (!root->node) |
1135 | BUG(); | 1135 | BUG(); |
1136 | init_path(&path); | 1136 | btrfs_init_path(&path); |
1137 | ret = search_slot(root, cpu_key, &path, data_size, 1); | 1137 | ret = btrfs_search_slot(root, cpu_key, &path, data_size, 1); |
1138 | if (ret == 0) { | 1138 | if (ret == 0) { |
1139 | release_path(root, &path); | 1139 | btrfs_release_path(root, &path); |
1140 | return -EEXIST; | 1140 | return -EEXIST; |
1141 | } | 1141 | } |
1142 | if (ret < 0) | 1142 | if (ret < 0) |
@@ -1149,7 +1149,8 @@ int insert_item(struct ctree_root *root, struct btrfs_key *cpu_key, | |||
1149 | nritems = btrfs_header_nritems(&leaf->header); | 1149 | nritems = btrfs_header_nritems(&leaf->header); |
1150 | data_end = leaf_data_end(leaf); | 1150 | data_end = leaf_data_end(leaf); |
1151 | 1151 | ||
1152 | if (leaf_free_space(leaf) < sizeof(struct btrfs_item) + data_size) | 1152 | if (btrfs_leaf_free_space(leaf) < |
1153 | sizeof(struct btrfs_item) + data_size) | ||
1153 | BUG(); | 1154 | BUG(); |
1154 | 1155 | ||
1155 | slot = path.slots[0]; | 1156 | slot = path.slots[0]; |
@@ -1190,11 +1191,11 @@ int insert_item(struct ctree_root *root, struct btrfs_key *cpu_key, | |||
1190 | ret = fixup_low_keys(root, &path, &disk_key, 1); | 1191 | ret = fixup_low_keys(root, &path, &disk_key, 1); |
1191 | 1192 | ||
1192 | BUG_ON(list_empty(&leaf_buf->dirty)); | 1193 | BUG_ON(list_empty(&leaf_buf->dirty)); |
1193 | if (leaf_free_space(leaf) < 0) | 1194 | if (btrfs_leaf_free_space(leaf) < 0) |
1194 | BUG(); | 1195 | BUG(); |
1195 | check_leaf(&path, 0); | 1196 | check_leaf(&path, 0); |
1196 | out: | 1197 | out: |
1197 | release_path(root, &path); | 1198 | btrfs_release_path(root, &path); |
1198 | return ret; | 1199 | return ret; |
1199 | } | 1200 | } |
1200 | 1201 | ||
@@ -1205,11 +1206,11 @@ out: | |||
1205 | * continuing all the way the root if required. The root is converted into | 1206 | * continuing all the way the root if required. The root is converted into |
1206 | * a leaf if all the nodes are emptied. | 1207 | * a leaf if all the nodes are emptied. |
1207 | */ | 1208 | */ |
1208 | static int del_ptr(struct ctree_root *root, struct ctree_path *path, int level, | 1209 | static int del_ptr(struct btrfs_root *root, struct btrfs_path *path, int level, |
1209 | int slot) | 1210 | int slot) |
1210 | { | 1211 | { |
1211 | struct node *node; | 1212 | struct btrfs_node *node; |
1212 | struct tree_buffer *parent = path->nodes[level]; | 1213 | struct btrfs_buffer *parent = path->nodes[level]; |
1213 | u32 nritems; | 1214 | u32 nritems; |
1214 | int ret = 0; | 1215 | int ret = 0; |
1215 | int wret; | 1216 | int wret; |
@@ -1242,11 +1243,11 @@ static int del_ptr(struct ctree_root *root, struct ctree_path *path, int level, | |||
1242 | * delete the item at the leaf level in path. If that empties | 1243 | * delete the item at the leaf level in path. If that empties |
1243 | * the leaf, remove it from the tree | 1244 | * the leaf, remove it from the tree |
1244 | */ | 1245 | */ |
1245 | int del_item(struct ctree_root *root, struct ctree_path *path) | 1246 | int btrfs_del_item(struct btrfs_root *root, struct btrfs_path *path) |
1246 | { | 1247 | { |
1247 | int slot; | 1248 | int slot; |
1248 | struct leaf *leaf; | 1249 | struct btrfs_leaf *leaf; |
1249 | struct tree_buffer *leaf_buf; | 1250 | struct btrfs_buffer *leaf_buf; |
1250 | int doff; | 1251 | int doff; |
1251 | int dsize; | 1252 | int dsize; |
1252 | int ret = 0; | 1253 | int ret = 0; |
@@ -1286,7 +1287,7 @@ int del_item(struct ctree_root *root, struct ctree_path *path) | |||
1286 | wret = del_ptr(root, path, 1, path->slots[1]); | 1287 | wret = del_ptr(root, path, 1, path->slots[1]); |
1287 | if (wret) | 1288 | if (wret) |
1288 | ret = wret; | 1289 | ret = wret; |
1289 | wret = free_extent(root, leaf_buf->blocknr, 1); | 1290 | wret = btrfs_free_extent(root, leaf_buf->blocknr, 1); |
1290 | if (wret) | 1291 | if (wret) |
1291 | ret = wret; | 1292 | ret = wret; |
1292 | } | 1293 | } |
@@ -1323,12 +1324,12 @@ int del_item(struct ctree_root *root, struct ctree_path *path) | |||
1323 | wret = del_ptr(root, path, 1, slot); | 1324 | wret = del_ptr(root, path, 1, slot); |
1324 | if (wret) | 1325 | if (wret) |
1325 | ret = wret; | 1326 | ret = wret; |
1326 | tree_block_release(root, leaf_buf); | 1327 | btrfs_block_release(root, leaf_buf); |
1327 | wret = free_extent(root, blocknr, 1); | 1328 | wret = btrfs_free_extent(root, blocknr, 1); |
1328 | if (wret) | 1329 | if (wret) |
1329 | ret = wret; | 1330 | ret = wret; |
1330 | } else { | 1331 | } else { |
1331 | tree_block_release(root, leaf_buf); | 1332 | btrfs_block_release(root, leaf_buf); |
1332 | } | 1333 | } |
1333 | } | 1334 | } |
1334 | } | 1335 | } |
@@ -1340,15 +1341,15 @@ int del_item(struct ctree_root *root, struct ctree_path *path) | |||
1340 | * returns 0 if it found something or 1 if there are no greater leaves. | 1341 | * returns 0 if it found something or 1 if there are no greater leaves. |
1341 | * returns < 0 on io errors. | 1342 | * returns < 0 on io errors. |
1342 | */ | 1343 | */ |
1343 | int next_leaf(struct ctree_root *root, struct ctree_path *path) | 1344 | int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path) |
1344 | { | 1345 | { |
1345 | int slot; | 1346 | int slot; |
1346 | int level = 1; | 1347 | int level = 1; |
1347 | u64 blocknr; | 1348 | u64 blocknr; |
1348 | struct tree_buffer *c; | 1349 | struct btrfs_buffer *c; |
1349 | struct tree_buffer *next = NULL; | 1350 | struct btrfs_buffer *next = NULL; |
1350 | 1351 | ||
1351 | while(level < MAX_LEVEL) { | 1352 | while(level < BTRFS_MAX_LEVEL) { |
1352 | if (!path->nodes[level]) | 1353 | if (!path->nodes[level]) |
1353 | return 1; | 1354 | return 1; |
1354 | slot = path->slots[level] + 1; | 1355 | slot = path->slots[level] + 1; |
@@ -1359,7 +1360,7 @@ int next_leaf(struct ctree_root *root, struct ctree_path *path) | |||
1359 | } | 1360 | } |
1360 | blocknr = btrfs_node_blockptr(&c->node, slot); | 1361 | blocknr = btrfs_node_blockptr(&c->node, slot); |
1361 | if (next) | 1362 | if (next) |
1362 | tree_block_release(root, next); | 1363 | btrfs_block_release(root, next); |
1363 | next = read_tree_block(root, blocknr); | 1364 | next = read_tree_block(root, blocknr); |
1364 | break; | 1365 | break; |
1365 | } | 1366 | } |
@@ -1367,7 +1368,7 @@ int next_leaf(struct ctree_root *root, struct ctree_path *path) | |||
1367 | while(1) { | 1368 | while(1) { |
1368 | level--; | 1369 | level--; |
1369 | c = path->nodes[level]; | 1370 | c = path->nodes[level]; |
1370 | tree_block_release(root, c); | 1371 | btrfs_block_release(root, c); |
1371 | path->nodes[level] = next; | 1372 | path->nodes[level] = next; |
1372 | path->slots[level] = 0; | 1373 | path->slots[level] = 0; |
1373 | if (!level) | 1374 | if (!level) |