Lines Matching refs:level
17 *root, struct btrfs_path *path, int level);
30 int level, int slot);
233 int level; in btrfs_copy_root() local
241 level = btrfs_header_level(buf); in btrfs_copy_root()
242 if (level == 0) in btrfs_copy_root()
248 &disk_key, level, buf->start, 0); in btrfs_copy_root()
294 u8 level; member
660 tm->old_root.level = btrfs_header_level(old_root); in tree_mod_log_insert_root()
977 int level = btrfs_header_level(buf); in update_ref_for_cow() local
982 new_flags, level, 0); in update_ref_for_cow()
1010 int level, in alloc_tree_block_no_bg_flush() argument
1040 root->root_key.objectid, disk_key, level, in alloc_tree_block_no_bg_flush()
1069 int level, ret; in __btrfs_cow_block() local
1084 level = btrfs_header_level(buf); in __btrfs_cow_block()
1086 if (level == 0) in __btrfs_cow_block()
1095 level, search_start, empty_size); in __btrfs_cow_block()
1388 int level; in get_old_root() local
1399 level = old_root->level; in get_old_root()
1402 level = btrfs_header_level(eb_root); in get_old_root()
1409 old = read_tree_block(fs_info, logical, 0, level, NULL); in get_old_root()
1460 btrfs_set_header_level(eb, old_root->level); in get_old_root()
1478 int level; in btrfs_old_root_level() local
1483 level = tm->old_root.level; in btrfs_old_root_level()
1485 level = btrfs_header_level(eb_root); in btrfs_old_root_level()
1489 return level; in btrfs_old_root_level()
1810 int level, int *slot) in btrfs_bin_search() argument
1812 if (level == 0) in btrfs_bin_search()
1849 int level = btrfs_header_level(parent); in read_node_slot() local
1856 BUG_ON(level == 0); in read_node_slot()
1861 level - 1, &first_key); in read_node_slot()
1877 struct btrfs_path *path, int level) in balance_level() argument
1887 int orig_slot = path->slots[level]; in balance_level()
1890 if (level == 0) in balance_level()
1893 mid = path->nodes[level]; in balance_level()
1895 WARN_ON(path->locks[level] != BTRFS_WRITE_LOCK && in balance_level()
1896 path->locks[level] != BTRFS_WRITE_LOCK_BLOCKING); in balance_level()
1901 if (level < BTRFS_MAX_LEVEL - 1) { in balance_level()
1902 parent = path->nodes[level + 1]; in balance_level()
1903 pslot = path->slots[level + 1]; in balance_level()
1940 path->locks[level] = 0; in balance_level()
1941 path->nodes[level] = NULL; in balance_level()
2005 del_ptr(root, path, level + 1, pslot + 1); in balance_level()
2050 del_ptr(root, path, level + 1, pslot); in balance_level()
2071 path->nodes[level] = left; in balance_level()
2072 path->slots[level + 1] -= 1; in balance_level()
2073 path->slots[level] = orig_slot; in balance_level()
2080 path->slots[level] = orig_slot; in balance_level()
2085 btrfs_node_blockptr(path->nodes[level], path->slots[level])) in balance_level()
2093 if (path->nodes[level] != left) in balance_level()
2106 struct btrfs_path *path, int level) in push_nodes_for_insert() argument
2116 int orig_slot = path->slots[level]; in push_nodes_for_insert()
2118 if (level == 0) in push_nodes_for_insert()
2121 mid = path->nodes[level]; in push_nodes_for_insert()
2124 if (level < BTRFS_MAX_LEVEL - 1) { in push_nodes_for_insert()
2125 parent = path->nodes[level + 1]; in push_nodes_for_insert()
2126 pslot = path->slots[level + 1]; in push_nodes_for_insert()
2168 path->nodes[level] = left; in push_nodes_for_insert()
2169 path->slots[level + 1] -= 1; in push_nodes_for_insert()
2170 path->slots[level] = orig_slot; in push_nodes_for_insert()
2176 path->slots[level] = orig_slot; in push_nodes_for_insert()
2225 path->nodes[level] = right; in push_nodes_for_insert()
2226 path->slots[level + 1] += 1; in push_nodes_for_insert()
2227 path->slots[level] = orig_slot - in push_nodes_for_insert()
2249 int level, int slot, u64 objectid) in reada_for_search() argument
2262 if (level != 1) in reada_for_search()
2265 if (!path->nodes[level]) in reada_for_search()
2268 node = path->nodes[level]; in reada_for_search()
2311 struct btrfs_path *path, int level) in reada_for_balance() argument
2321 parent = path->nodes[level + 1]; in reada_for_balance()
2326 slot = path->slots[level + 1]; in reada_for_balance()
2370 static noinline void unlock_up(struct btrfs_path *path, int level, in unlock_up() argument
2375 int skip_level = level; in unlock_up()
2379 for (i = level; i < BTRFS_MAX_LEVEL; i++) { in unlock_up()
2422 noinline void btrfs_unlock_up_safe(struct btrfs_path *path, int level) in btrfs_unlock_up_safe() argument
2429 for (i = level; i < BTRFS_MAX_LEVEL; i++) { in btrfs_unlock_up_safe()
2449 struct extent_buffer **eb_ret, int level, int slot, in read_block_for_search() argument
2510 btrfs_unlock_up_safe(p, level + 1); in read_block_for_search()
2514 reada_for_search(fs_info, p, level, slot, key->objectid); in read_block_for_search()
2549 struct extent_buffer *b, int level, int ins_len, in setup_nodes_for_search() argument
2559 if (*write_lock_level < level + 1) { in setup_nodes_for_search()
2560 *write_lock_level = level + 1; in setup_nodes_for_search()
2566 reada_for_balance(fs_info, p, level); in setup_nodes_for_search()
2567 sret = split_node(trans, root, p, level); in setup_nodes_for_search()
2575 b = p->nodes[level]; in setup_nodes_for_search()
2580 if (*write_lock_level < level + 1) { in setup_nodes_for_search()
2581 *write_lock_level = level + 1; in setup_nodes_for_search()
2587 reada_for_balance(fs_info, p, level); in setup_nodes_for_search()
2588 sret = balance_level(trans, root, p, level); in setup_nodes_for_search()
2595 b = p->nodes[level]; in setup_nodes_for_search()
2612 int level) in key_search_validate() argument
2619 if (level == 0) in key_search_validate()
2631 int level, int *prev_cmp, int *slot) in key_search() argument
2634 *prev_cmp = btrfs_bin_search(b, key, level, slot); in key_search()
2638 key_search_validate(b, key, level); in key_search()
2686 int level = 0; in btrfs_search_slot_get_root() local
2712 level = btrfs_header_level(b); in btrfs_search_slot_get_root()
2724 level = btrfs_header_level(b); in btrfs_search_slot_get_root()
2738 level = btrfs_header_level(b); in btrfs_search_slot_get_root()
2739 if (level > write_lock_level) in btrfs_search_slot_get_root()
2751 level = btrfs_header_level(b); in btrfs_search_slot_get_root()
2754 p->nodes[level] = b; in btrfs_search_slot_get_root()
2756 p->locks[level] = root_lock; in btrfs_search_slot_get_root()
2798 int level; in btrfs_search_slot() local
2844 level = btrfs_header_level(b); in btrfs_search_slot()
2851 bool last_level = (level == (BTRFS_MAX_LEVEL - 1)); in btrfs_search_slot()
2867 if (level > write_lock_level || in btrfs_search_slot()
2868 (level + 1 > write_lock_level && in btrfs_search_slot()
2869 level + 1 < BTRFS_MAX_LEVEL && in btrfs_search_slot()
2870 p->nodes[level + 1])) { in btrfs_search_slot()
2871 write_lock_level = level + 1; in btrfs_search_slot()
2882 p->nodes[level + 1], in btrfs_search_slot()
2883 p->slots[level + 1], &b); in btrfs_search_slot()
2890 p->nodes[level] = b; in btrfs_search_slot()
2905 int u = level + 1; in btrfs_search_slot()
2913 ret = key_search(b, key, level, &prev_cmp, &slot); in btrfs_search_slot()
2917 if (level != 0) { in btrfs_search_slot()
2923 p->slots[level] = slot; in btrfs_search_slot()
2924 err = setup_nodes_for_search(trans, root, p, b, level, in btrfs_search_slot()
2932 b = p->nodes[level]; in btrfs_search_slot()
2933 slot = p->slots[level]; in btrfs_search_slot()
2942 write_lock_level < level + 1) { in btrfs_search_slot()
2943 write_lock_level = level + 1; in btrfs_search_slot()
2948 unlock_up(p, level, lowest_unlock, in btrfs_search_slot()
2951 if (level == lowest_level) { in btrfs_search_slot()
2953 p->slots[level]++; in btrfs_search_slot()
2957 err = read_block_for_search(root, p, &b, level, in btrfs_search_slot()
2967 level = btrfs_header_level(b); in btrfs_search_slot()
2968 if (level <= write_lock_level) { in btrfs_search_slot()
2976 p->locks[level] = BTRFS_WRITE_LOCK; in btrfs_search_slot()
2985 p->locks[level] = BTRFS_READ_LOCK; in btrfs_search_slot()
2987 p->nodes[level] = b; in btrfs_search_slot()
2990 p->slots[level] = slot; in btrfs_search_slot()
3011 unlock_up(p, level, lowest_unlock, in btrfs_search_slot()
3048 int level; in btrfs_search_old_slot() local
3067 level = btrfs_header_level(b); in btrfs_search_old_slot()
3068 p->locks[level] = BTRFS_READ_LOCK; in btrfs_search_old_slot()
3071 level = btrfs_header_level(b); in btrfs_search_old_slot()
3072 p->nodes[level] = b; in btrfs_search_old_slot()
3081 btrfs_unlock_up_safe(p, level + 1); in btrfs_search_old_slot()
3088 ret = key_search(b, key, level, &prev_cmp, &slot); in btrfs_search_old_slot()
3090 if (level != 0) { in btrfs_search_old_slot()
3096 p->slots[level] = slot; in btrfs_search_old_slot()
3097 unlock_up(p, level, lowest_unlock, 0, NULL); in btrfs_search_old_slot()
3099 if (level == lowest_level) { in btrfs_search_old_slot()
3101 p->slots[level]++; in btrfs_search_old_slot()
3105 err = read_block_for_search(root, p, &b, level, in btrfs_search_old_slot()
3114 level = btrfs_header_level(b); in btrfs_search_old_slot()
3127 p->locks[level] = BTRFS_READ_LOCK; in btrfs_search_old_slot()
3128 p->nodes[level] = b; in btrfs_search_old_slot()
3130 p->slots[level] = slot; in btrfs_search_old_slot()
3131 unlock_up(p, level, lowest_unlock, 0, NULL); in btrfs_search_old_slot()
3231 struct btrfs_disk_key *key, int level) in fixup_low_keys() argument
3237 for (i = level; i < BTRFS_MAX_LEVEL; i++) { in fixup_low_keys()
3434 struct btrfs_path *path, int level) in insert_new_root() argument
3444 BUG_ON(path->nodes[level]); in insert_new_root()
3445 BUG_ON(path->nodes[level-1] != root->node); in insert_new_root()
3447 lower = path->nodes[level-1]; in insert_new_root()
3448 if (level == 1) in insert_new_root()
3453 c = alloc_tree_block_no_bg_flush(trans, root, 0, &lower_key, level, in insert_new_root()
3480 path->nodes[level] = c; in insert_new_root()
3481 path->locks[level] = BTRFS_WRITE_LOCK_BLOCKING; in insert_new_root()
3482 path->slots[level] = 0; in insert_new_root()
3496 int slot, int level) in insert_ptr() argument
3502 BUG_ON(!path->nodes[level]); in insert_ptr()
3503 btrfs_assert_tree_locked(path->nodes[level]); in insert_ptr()
3504 lower = path->nodes[level]; in insert_ptr()
3509 if (level) { in insert_ptr()
3519 if (level) { in insert_ptr()
3543 struct btrfs_path *path, int level) in split_node() argument
3553 c = path->nodes[level]; in split_node()
3566 ret = insert_new_root(trans, root, path, level + 1); in split_node()
3570 ret = push_nodes_for_insert(trans, root, path, level); in split_node()
3571 c = path->nodes[level]; in split_node()
3583 split = alloc_tree_block_no_bg_flush(trans, root, 0, &disk_key, level, in split_node()
3589 ASSERT(btrfs_header_level(c) == level); in split_node()
3610 path->slots[level + 1] + 1, level + 1); in split_node()
3612 if (path->slots[level] >= mid) { in split_node()
3613 path->slots[level] -= mid; in split_node()
3616 path->nodes[level] = split; in split_node()
3617 path->slots[level + 1] += 1; in split_node()
4960 int level, int slot) in del_ptr() argument
4962 struct extent_buffer *parent = path->nodes[level]; in del_ptr()
4968 if (level) { in del_ptr()
4978 } else if (level) { in del_ptr()
4994 fixup_low_keys(path, &disk_key, level + 1); in del_ptr()
5254 int level; in btrfs_search_forward() local
5261 level = btrfs_header_level(cur); in btrfs_search_forward()
5262 WARN_ON(path->nodes[level]); in btrfs_search_forward()
5263 path->nodes[level] = cur; in btrfs_search_forward()
5264 path->locks[level] = BTRFS_READ_LOCK; in btrfs_search_forward()
5272 level = btrfs_header_level(cur); in btrfs_search_forward()
5273 sret = btrfs_bin_search(cur, min_key, level, &slot); in btrfs_search_forward()
5276 if (level == path->lowest_level) { in btrfs_search_forward()
5280 path->slots[level] = slot; in btrfs_search_forward()
5306 path->slots[level] = slot; in btrfs_search_forward()
5308 sret = btrfs_find_next_key(root, path, min_key, level, in btrfs_search_forward()
5319 path->slots[level] = slot; in btrfs_search_forward()
5320 if (level == path->lowest_level) { in btrfs_search_forward()
5333 path->locks[level - 1] = BTRFS_READ_LOCK; in btrfs_search_forward()
5334 path->nodes[level - 1] = cur; in btrfs_search_forward()
5335 unlock_up(path, level, 1, 0, NULL); in btrfs_search_forward()
5350 int *level) in tree_move_down() argument
5354 BUG_ON(*level == 0); in tree_move_down()
5355 eb = read_node_slot(fs_info, path->nodes[*level], path->slots[*level]); in tree_move_down()
5359 path->nodes[*level - 1] = eb; in tree_move_down()
5360 path->slots[*level - 1] = 0; in tree_move_down()
5361 (*level)--; in tree_move_down()
5366 int *level, int root_level) in tree_move_next_or_upnext() argument
5370 nritems = btrfs_header_nritems(path->nodes[*level]); in tree_move_next_or_upnext()
5372 path->slots[*level]++; in tree_move_next_or_upnext()
5374 while (path->slots[*level] >= nritems) { in tree_move_next_or_upnext()
5375 if (*level == root_level) in tree_move_next_or_upnext()
5379 path->slots[*level] = 0; in tree_move_next_or_upnext()
5380 free_extent_buffer(path->nodes[*level]); in tree_move_next_or_upnext()
5381 path->nodes[*level] = NULL; in tree_move_next_or_upnext()
5382 (*level)++; in tree_move_next_or_upnext()
5383 path->slots[*level]++; in tree_move_next_or_upnext()
5385 nritems = btrfs_header_nritems(path->nodes[*level]); in tree_move_next_or_upnext()
5397 int *level, int root_level, in tree_advance() argument
5403 if (*level == 0 || !allow_down) { in tree_advance()
5404 ret = tree_move_next_or_upnext(path, level, root_level); in tree_advance()
5406 ret = tree_move_down(fs_info, path, level); in tree_advance()
5409 if (*level == 0) in tree_advance()
5410 btrfs_item_key_to_cpu(path->nodes[*level], key, in tree_advance()
5411 path->slots[*level]); in tree_advance()
5413 btrfs_node_key_to_cpu(path->nodes[*level], key, in tree_advance()
5414 path->slots[*level]); in tree_advance()
5728 struct btrfs_key *key, int level, u64 min_trans) in btrfs_find_next_key() argument
5734 while (level < BTRFS_MAX_LEVEL) { in btrfs_find_next_key()
5735 if (!path->nodes[level]) in btrfs_find_next_key()
5738 slot = path->slots[level] + 1; in btrfs_find_next_key()
5739 c = path->nodes[level]; in btrfs_find_next_key()
5745 if (level + 1 >= BTRFS_MAX_LEVEL || in btrfs_find_next_key()
5746 !path->nodes[level + 1]) in btrfs_find_next_key()
5749 if (path->locks[level + 1]) { in btrfs_find_next_key()
5750 level++; in btrfs_find_next_key()
5755 if (level == 0) in btrfs_find_next_key()
5762 path->lowest_level = level; in btrfs_find_next_key()
5769 c = path->nodes[level]; in btrfs_find_next_key()
5770 slot = path->slots[level]; in btrfs_find_next_key()
5776 if (level == 0) in btrfs_find_next_key()
5806 int level; in btrfs_next_old_leaf() local
5821 level = 1; in btrfs_next_old_leaf()
5870 while (level < BTRFS_MAX_LEVEL) { in btrfs_next_old_leaf()
5871 if (!path->nodes[level]) { in btrfs_next_old_leaf()
5876 slot = path->slots[level] + 1; in btrfs_next_old_leaf()
5877 c = path->nodes[level]; in btrfs_next_old_leaf()
5879 level++; in btrfs_next_old_leaf()
5880 if (level == BTRFS_MAX_LEVEL) { in btrfs_next_old_leaf()
5893 next_rw_lock = path->locks[level]; in btrfs_next_old_leaf()
5894 ret = read_block_for_search(root, path, &next, level, in btrfs_next_old_leaf()
5929 path->slots[level] = slot; in btrfs_next_old_leaf()
5931 level--; in btrfs_next_old_leaf()
5932 c = path->nodes[level]; in btrfs_next_old_leaf()
5933 if (path->locks[level]) in btrfs_next_old_leaf()
5934 btrfs_tree_unlock_rw(c, path->locks[level]); in btrfs_next_old_leaf()
5937 path->nodes[level] = next; in btrfs_next_old_leaf()
5938 path->slots[level] = 0; in btrfs_next_old_leaf()
5940 path->locks[level] = next_rw_lock; in btrfs_next_old_leaf()
5941 if (!level) in btrfs_next_old_leaf()
5944 ret = read_block_for_search(root, path, &next, level, in btrfs_next_old_leaf()