Lines Matching refs:path

30 		      *root, struct btrfs_path *path, int level);
32 const struct btrfs_key *ins_key, struct btrfs_path *path,
921 struct btrfs_path *path, int level) in balance_level() argument
931 int orig_slot = path->slots[level]; in balance_level()
936 mid = path->nodes[level]; in balance_level()
938 WARN_ON(path->locks[level] != BTRFS_WRITE_LOCK); in balance_level()
944 parent = path->nodes[level + 1]; in balance_level()
945 pslot = path->slots[level + 1]; in balance_level()
986 path->locks[level] = 0; in balance_level()
987 path->nodes[level] = NULL; in balance_level()
1061 ret = btrfs_del_ptr(trans, root, path, level + 1, pslot + 1); in balance_level()
1123 ret = btrfs_del_ptr(trans, root, path, level + 1, pslot); in balance_level()
1156 path->nodes[level] = left; in balance_level()
1157 path->slots[level + 1] -= 1; in balance_level()
1158 path->slots[level] = orig_slot; in balance_level()
1165 path->slots[level] = orig_slot; in balance_level()
1170 btrfs_node_blockptr(path->nodes[level], path->slots[level])) in balance_level()
1178 if (path->nodes[level] != left) in balance_level()
1191 struct btrfs_path *path, int level) in push_nodes_for_insert() argument
1201 int orig_slot = path->slots[level]; in push_nodes_for_insert()
1206 mid = path->nodes[level]; in push_nodes_for_insert()
1210 parent = path->nodes[level + 1]; in push_nodes_for_insert()
1211 pslot = path->slots[level + 1]; in push_nodes_for_insert()
1257 path->nodes[level] = left; in push_nodes_for_insert()
1258 path->slots[level + 1] -= 1; in push_nodes_for_insert()
1259 path->slots[level] = orig_slot; in push_nodes_for_insert()
1265 path->slots[level] = orig_slot; in push_nodes_for_insert()
1318 path->nodes[level] = right; in push_nodes_for_insert()
1319 path->slots[level + 1] += 1; in push_nodes_for_insert()
1320 path->slots[level] = orig_slot - in push_nodes_for_insert()
1341 struct btrfs_path *path, in reada_for_search() argument
1355 if (level != 1 && path->reada != READA_FORWARD_ALWAYS) in reada_for_search()
1358 if (!path->nodes[level]) in reada_for_search()
1361 node = path->nodes[level]; in reada_for_search()
1368 if (path->reada == READA_FORWARD_ALWAYS) { in reada_for_search()
1379 if (path->reada != READA_FORWARD_ALWAYS) { in reada_for_search()
1395 if (path->reada == READA_BACK) { in reada_for_search()
1399 } else if (path->reada == READA_FORWARD || in reada_for_search()
1400 path->reada == READA_FORWARD_ALWAYS) { in reada_for_search()
1405 if (path->reada == READA_BACK && objectid) { in reada_for_search()
1411 if (path->reada == READA_FORWARD_ALWAYS || in reada_for_search()
1423 static noinline void reada_for_balance(struct btrfs_path *path, int level) in reada_for_balance() argument
1429 parent = path->nodes[level + 1]; in reada_for_balance()
1434 slot = path->slots[level + 1]; in reada_for_balance()
1456 static noinline void unlock_up(struct btrfs_path *path, int level, in unlock_up() argument
1465 if (!path->nodes[i]) in unlock_up()
1467 if (!path->locks[i]) in unlock_up()
1471 if (path->slots[i] == 0) { in unlock_up()
1476 if (path->keep_locks) { in unlock_up()
1479 nritems = btrfs_header_nritems(path->nodes[i]); in unlock_up()
1480 if (nritems < 1 || path->slots[i] >= nritems - 1) { in unlock_up()
1489 btrfs_tree_unlock_rw(path->nodes[i], path->locks[i]); in unlock_up()
1490 path->locks[i] = 0; in unlock_up()
1675 int btrfs_find_item(struct btrfs_root *fs_root, struct btrfs_path *path, in btrfs_find_item() argument
1683 ASSERT(path); in btrfs_find_item()
1690 ret = btrfs_search_slot(NULL, fs_root, &key, path, 0, 0); in btrfs_find_item()
1694 eb = path->nodes[0]; in btrfs_find_item()
1695 if (ret && path->slots[0] >= btrfs_header_nritems(eb)) { in btrfs_find_item()
1696 ret = btrfs_next_leaf(fs_root, path); in btrfs_find_item()
1699 eb = path->nodes[0]; in btrfs_find_item()
1702 btrfs_item_key_to_cpu(eb, found_key, path->slots[0]); in btrfs_find_item()
1804 static int finish_need_commit_sem_search(struct btrfs_path *path) in finish_need_commit_sem_search() argument
1806 const int i = path->lowest_level; in finish_need_commit_sem_search()
1807 const int slot = path->slots[i]; in finish_need_commit_sem_search()
1808 struct extent_buffer *lowest = path->nodes[i]; in finish_need_commit_sem_search()
1811 ASSERT(path->need_commit_sem); in finish_need_commit_sem_search()
1822 btrfs_release_path(path); in finish_need_commit_sem_search()
1823 path->nodes[i] = clone; in finish_need_commit_sem_search()
1824 path->slots[i] = slot; in finish_need_commit_sem_search()
1853 struct btrfs_path *path, in search_leaf() argument
1857 struct extent_buffer *leaf = path->nodes[0]; in search_leaf()
1881 if (path->locks[1] && leaf_free_space >= ins_len) { in search_leaf()
1908 btrfs_unlock_up_safe(path, 1); in search_leaf()
1926 btrfs_unlock_up_safe(path, 1); in search_leaf()
1933 path->slots[0] = 0; in search_leaf()
1940 prev_cmp, &path->slots[0]); in search_leaf()
1955 if (ret == 0 && !path->search_for_extension) { in search_leaf()
1965 err = split_leaf(trans, root, key, path, ins_len, in search_leaf()
2362 static int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path) in btrfs_prev_leaf() argument
2369 btrfs_item_key_to_cpu(path->nodes[0], &key, 0); in btrfs_prev_leaf()
2385 btrfs_release_path(path); in btrfs_prev_leaf()
2386 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in btrfs_prev_leaf()
2401 if (path->slots[0] < btrfs_header_nritems(path->nodes[0])) { in btrfs_prev_leaf()
2402 btrfs_item_key(path->nodes[0], &found_key, path->slots[0]); in btrfs_prev_leaf()
2405 if (path->slots[0] > 0) { in btrfs_prev_leaf()
2406 path->slots[0]--; in btrfs_prev_leaf()
2417 btrfs_item_key(path->nodes[0], &found_key, 0); in btrfs_prev_leaf()
2518 struct btrfs_path *path) in btrfs_search_backwards() argument
2522 ret = btrfs_search_slot(NULL, root, key, path, 0, 0); in btrfs_search_backwards()
2524 ret = btrfs_previous_item(root, path, key->objectid, key->type); in btrfs_search_backwards()
2527 btrfs_item_key_to_cpu(path->nodes[0], key, path->slots[0]); in btrfs_search_backwards()
2544 struct btrfs_path *path) in btrfs_get_next_valid_item() argument
2546 if (path->slots[0] >= btrfs_header_nritems(path->nodes[0])) { in btrfs_get_next_valid_item()
2549 ret = btrfs_next_leaf(root, path); in btrfs_get_next_valid_item()
2554 btrfs_item_key_to_cpu(path->nodes[0], key, path->slots[0]); in btrfs_get_next_valid_item()
2567 const struct btrfs_path *path, in fixup_low_keys() argument
2575 int tslot = path->slots[i]; in fixup_low_keys()
2577 if (!path->nodes[i]) in fixup_low_keys()
2579 t = path->nodes[i]; in fixup_low_keys()
2584 btrfs_mark_buffer_dirty(trans, path->nodes[i]); in fixup_low_keys()
2597 const struct btrfs_path *path, in btrfs_set_item_key_safe() argument
2605 eb = path->nodes[0]; in btrfs_set_item_key_safe()
2606 slot = path->slots[0]; in btrfs_set_item_key_safe()
2640 fixup_low_keys(trans, path, &disk_key, 1); in btrfs_set_item_key_safe()
2862 struct btrfs_path *path, int level) in insert_new_root() argument
2871 BUG_ON(path->nodes[level]); in insert_new_root()
2872 BUG_ON(path->nodes[level-1] != root->node); in insert_new_root()
2874 lower = path->nodes[level-1]; in insert_new_root()
2917 path->nodes[level] = c; in insert_new_root()
2918 path->locks[level] = BTRFS_WRITE_LOCK; in insert_new_root()
2919 path->slots[level] = 0; in insert_new_root()
2931 const struct btrfs_path *path, in insert_ptr() argument
2939 BUG_ON(!path->nodes[level]); in insert_ptr()
2940 btrfs_assert_tree_write_locked(path->nodes[level]); in insert_ptr()
2941 lower = path->nodes[level]; in insert_ptr()
2988 struct btrfs_path *path, int level) in split_node() argument
2998 c = path->nodes[level]; in split_node()
3011 ret = insert_new_root(trans, root, path, level + 1); in split_node()
3015 ret = push_nodes_for_insert(trans, root, path, level); in split_node()
3016 c = path->nodes[level]; in split_node()
3054 ret = insert_ptr(trans, path, &disk_key, split->start, in split_node()
3055 path->slots[level + 1] + 1, level + 1); in split_node()
3062 if (path->slots[level] >= mid) { in split_node()
3063 path->slots[level] -= mid; in split_node()
3066 path->nodes[level] = split; in split_node()
3067 path->slots[level + 1] += 1; in split_node()
3122 struct btrfs_path *path, in __push_leaf_right() argument
3129 struct extent_buffer *left = path->nodes[0]; in __push_leaf_right()
3130 struct extent_buffer *upper = path->nodes[1]; in __push_leaf_right()
3147 if (path->slots[0] >= left_nritems) in __push_leaf_right()
3150 slot = path->slots[1]; in __push_leaf_right()
3154 if (path->slots[0] > i) in __push_leaf_right()
3156 if (path->slots[0] == i) { in __push_leaf_right()
3164 if (path->slots[0] == i) in __push_leaf_right()
3229 if (path->slots[0] >= left_nritems) { in __push_leaf_right()
3230 path->slots[0] -= left_nritems; in __push_leaf_right()
3231 if (btrfs_header_nritems(path->nodes[0]) == 0) in __push_leaf_right()
3232 btrfs_clear_buffer_dirty(trans, path->nodes[0]); in __push_leaf_right()
3233 btrfs_tree_unlock(path->nodes[0]); in __push_leaf_right()
3234 free_extent_buffer(path->nodes[0]); in __push_leaf_right()
3235 path->nodes[0] = right; in __push_leaf_right()
3236 path->slots[1] += 1; in __push_leaf_right()
3260 *root, struct btrfs_path *path, in push_leaf_right() argument
3264 struct extent_buffer *left = path->nodes[0]; in push_leaf_right()
3272 if (!path->nodes[1]) in push_leaf_right()
3275 slot = path->slots[1]; in push_leaf_right()
3276 upper = path->nodes[1]; in push_leaf_right()
3280 btrfs_assert_tree_write_locked(path->nodes[1]); in push_leaf_right()
3308 if (path->slots[0] == left_nritems && !empty) { in push_leaf_right()
3315 path->nodes[0] = right; in push_leaf_right()
3316 path->slots[0] = 0; in push_leaf_right()
3317 path->slots[1]++; in push_leaf_right()
3321 return __push_leaf_right(trans, path, min_data_size, empty, right, in push_leaf_right()
3338 struct btrfs_path *path, int data_size, in __push_leaf_left() argument
3345 struct extent_buffer *right = path->nodes[0]; in __push_leaf_left()
3363 if (path->slots[0] < i) in __push_leaf_left()
3365 if (path->slots[0] == i) { in __push_leaf_left()
3373 if (path->slots[0] == i) in __push_leaf_left()
3445 fixup_low_keys(trans, path, &disk_key, 1); in __push_leaf_left()
3448 if (path->slots[0] < push_items) { in __push_leaf_left()
3449 path->slots[0] += old_left_nritems; in __push_leaf_left()
3450 btrfs_tree_unlock(path->nodes[0]); in __push_leaf_left()
3451 free_extent_buffer(path->nodes[0]); in __push_leaf_left()
3452 path->nodes[0] = left; in __push_leaf_left()
3453 path->slots[1] -= 1; in __push_leaf_left()
3457 path->slots[0] -= push_items; in __push_leaf_left()
3459 BUG_ON(path->slots[0] < 0); in __push_leaf_left()
3476 *root, struct btrfs_path *path, int min_data_size, in push_leaf_left() argument
3479 struct extent_buffer *right = path->nodes[0]; in push_leaf_left()
3486 slot = path->slots[1]; in push_leaf_left()
3489 if (!path->nodes[1]) in push_leaf_left()
3496 btrfs_assert_tree_write_locked(path->nodes[1]); in push_leaf_left()
3498 left = btrfs_read_node_slot(path->nodes[1], slot - 1); in push_leaf_left()
3511 path->nodes[1], slot - 1, &left, in push_leaf_left()
3525 return __push_leaf_left(trans, path, min_data_size, empty, left, in push_leaf_left()
3538 struct btrfs_path *path, in copy_for_split() argument
3572 ret = insert_ptr(trans, path, &disk_key, right->start, path->slots[1] + 1, 1); in copy_for_split()
3578 BUG_ON(path->slots[0] != slot); in copy_for_split()
3581 btrfs_tree_unlock(path->nodes[0]); in copy_for_split()
3582 free_extent_buffer(path->nodes[0]); in copy_for_split()
3583 path->nodes[0] = right; in copy_for_split()
3584 path->slots[0] -= mid; in copy_for_split()
3585 path->slots[1] += 1; in copy_for_split()
3591 BUG_ON(path->slots[0] < 0); in copy_for_split()
3608 struct btrfs_path *path, in push_for_double_split() argument
3617 slot = path->slots[0]; in push_for_double_split()
3618 if (slot < btrfs_header_nritems(path->nodes[0])) in push_for_double_split()
3619 space_needed -= btrfs_leaf_free_space(path->nodes[0]); in push_for_double_split()
3625 ret = push_leaf_right(trans, root, path, 1, space_needed, 0, slot); in push_for_double_split()
3632 nritems = btrfs_header_nritems(path->nodes[0]); in push_for_double_split()
3637 if (path->slots[0] == 0 || path->slots[0] == nritems) in push_for_double_split()
3640 if (btrfs_leaf_free_space(path->nodes[0]) >= data_size) in push_for_double_split()
3644 slot = path->slots[0]; in push_for_double_split()
3647 space_needed -= btrfs_leaf_free_space(path->nodes[0]); in push_for_double_split()
3648 ret = push_leaf_left(trans, root, path, 1, space_needed, 0, slot); in push_for_double_split()
3669 struct btrfs_path *path, int data_size, in split_leaf() argument
3685 l = path->nodes[0]; in split_leaf()
3686 slot = path->slots[0]; in split_leaf()
3692 if (data_size && path->nodes[1]) { in split_leaf()
3698 wret = push_leaf_right(trans, root, path, space_needed, in split_leaf()
3706 wret = push_leaf_left(trans, root, path, space_needed, in split_leaf()
3711 l = path->nodes[0]; in split_leaf()
3718 if (!path->nodes[1]) { in split_leaf()
3719 ret = insert_new_root(trans, root, path, 1); in split_leaf()
3725 l = path->nodes[0]; in split_leaf()
3726 slot = path->slots[0]; in split_leaf()
3792 ret = insert_ptr(trans, path, &disk_key, in split_leaf()
3793 right->start, path->slots[1] + 1, 1); in split_leaf()
3799 btrfs_tree_unlock(path->nodes[0]); in split_leaf()
3800 free_extent_buffer(path->nodes[0]); in split_leaf()
3801 path->nodes[0] = right; in split_leaf()
3802 path->slots[0] = 0; in split_leaf()
3803 path->slots[1] += 1; in split_leaf()
3806 ret = insert_ptr(trans, path, &disk_key, in split_leaf()
3807 right->start, path->slots[1], 1); in split_leaf()
3813 btrfs_tree_unlock(path->nodes[0]); in split_leaf()
3814 free_extent_buffer(path->nodes[0]); in split_leaf()
3815 path->nodes[0] = right; in split_leaf()
3816 path->slots[0] = 0; in split_leaf()
3817 if (path->slots[1] == 0) in split_leaf()
3818 fixup_low_keys(trans, path, &disk_key, 1); in split_leaf()
3828 ret = copy_for_split(trans, path, l, right, slot, mid, nritems); in split_leaf()
3844 push_for_double_split(trans, root, path, data_size); in split_leaf()
3846 if (btrfs_leaf_free_space(path->nodes[0]) >= data_size) in split_leaf()
3853 struct btrfs_path *path, int ins_len) in setup_leaf_for_split() argument
3862 leaf = path->nodes[0]; in setup_leaf_for_split()
3863 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); in setup_leaf_for_split()
3871 item_size = btrfs_item_size(leaf, path->slots[0]); in setup_leaf_for_split()
3873 fi = btrfs_item_ptr(leaf, path->slots[0], in setup_leaf_for_split()
3877 btrfs_release_path(path); in setup_leaf_for_split()
3879 path->keep_locks = 1; in setup_leaf_for_split()
3880 path->search_for_split = 1; in setup_leaf_for_split()
3881 ret = btrfs_search_slot(trans, root, &key, path, 0, 1); in setup_leaf_for_split()
3882 path->search_for_split = 0; in setup_leaf_for_split()
3889 leaf = path->nodes[0]; in setup_leaf_for_split()
3891 if (item_size != btrfs_item_size(leaf, path->slots[0])) in setup_leaf_for_split()
3895 if (btrfs_leaf_free_space(path->nodes[0]) >= ins_len) in setup_leaf_for_split()
3899 fi = btrfs_item_ptr(leaf, path->slots[0], in setup_leaf_for_split()
3905 ret = split_leaf(trans, root, &key, path, ins_len, 1); in setup_leaf_for_split()
3909 path->keep_locks = 0; in setup_leaf_for_split()
3910 btrfs_unlock_up_safe(path, 1); in setup_leaf_for_split()
3913 path->keep_locks = 0; in setup_leaf_for_split()
3918 struct btrfs_path *path, in split_item() argument
3930 leaf = path->nodes[0]; in split_item()
3938 orig_slot = path->slots[0]; in split_item()
3939 orig_offset = btrfs_item_offset(leaf, path->slots[0]); in split_item()
3940 item_size = btrfs_item_size(leaf, path->slots[0]); in split_item()
3947 path->slots[0]), item_size); in split_item()
3949 slot = path->slots[0] + 1; in split_item()
3970 btrfs_item_ptr_offset(leaf, path->slots[0]), in split_item()
4001 struct btrfs_path *path, in btrfs_split_item() argument
4006 ret = setup_leaf_for_split(trans, root, path, in btrfs_split_item()
4011 ret = split_item(trans, path, new_key, split_offset); in btrfs_split_item()
4022 const struct btrfs_path *path, u32 new_size, int from_end) in btrfs_truncate_item() argument
4034 leaf = path->nodes[0]; in btrfs_truncate_item()
4035 slot = path->slots[0]; in btrfs_truncate_item()
4098 fixup_low_keys(trans, path, &disk_key, 1); in btrfs_truncate_item()
4114 const struct btrfs_path *path, u32 data_size) in btrfs_extend_item() argument
4125 leaf = path->nodes[0]; in btrfs_extend_item()
4134 slot = path->slots[0]; in btrfs_extend_item()
4184 struct btrfs_root *root, struct btrfs_path *path, in setup_items_for_insert() argument
4202 if (path->slots[0] == 0) { in setup_items_for_insert()
4204 fixup_low_keys(trans, path, &disk_key, 1); in setup_items_for_insert()
4206 btrfs_unlock_up_safe(path, 1); in setup_items_for_insert()
4208 leaf = path->nodes[0]; in setup_items_for_insert()
4209 slot = path->slots[0]; in setup_items_for_insert()
4282 struct btrfs_path *path, in btrfs_setup_item_for_insert() argument
4293 setup_items_for_insert(trans, root, path, &batch); in btrfs_setup_item_for_insert()
4306 struct btrfs_path *path, in btrfs_insert_empty_items() argument
4314 ret = btrfs_search_slot(trans, root, &batch->keys[0], path, total_size, 1); in btrfs_insert_empty_items()
4320 slot = path->slots[0]; in btrfs_insert_empty_items()
4323 setup_items_for_insert(trans, root, path, batch); in btrfs_insert_empty_items()
4336 struct btrfs_path *path; in btrfs_insert_item() local
4340 path = btrfs_alloc_path(); in btrfs_insert_item()
4341 if (!path) in btrfs_insert_item()
4343 ret = btrfs_insert_empty_item(trans, root, path, cpu_key, data_size); in btrfs_insert_item()
4345 leaf = path->nodes[0]; in btrfs_insert_item()
4346 ptr = btrfs_item_ptr_offset(leaf, path->slots[0]); in btrfs_insert_item()
4350 btrfs_free_path(path); in btrfs_insert_item()
4364 struct btrfs_path *path, in btrfs_duplicate_item() argument
4371 leaf = path->nodes[0]; in btrfs_duplicate_item()
4372 item_size = btrfs_item_size(leaf, path->slots[0]); in btrfs_duplicate_item()
4373 ret = setup_leaf_for_split(trans, root, path, in btrfs_duplicate_item()
4378 path->slots[0]++; in btrfs_duplicate_item()
4379 btrfs_setup_item_for_insert(trans, root, path, new_key, item_size); in btrfs_duplicate_item()
4380 leaf = path->nodes[0]; in btrfs_duplicate_item()
4382 btrfs_item_ptr_offset(leaf, path->slots[0]), in btrfs_duplicate_item()
4383 btrfs_item_ptr_offset(leaf, path->slots[0] - 1), in btrfs_duplicate_item()
4397 struct btrfs_path *path, int level, int slot) in btrfs_del_ptr() argument
4399 struct extent_buffer *parent = path->nodes[level]; in btrfs_del_ptr()
4437 fixup_low_keys(trans, path, &disk_key, level + 1); in btrfs_del_ptr()
4455 struct btrfs_path *path, in btrfs_del_leaf() argument
4461 ret = btrfs_del_ptr(trans, root, path, 1, path->slots[1]); in btrfs_del_leaf()
4469 btrfs_unlock_up_safe(path, 0); in btrfs_del_leaf()
4486 struct btrfs_path *path, int slot, int nr) in btrfs_del_items() argument
4494 leaf = path->nodes[0]; in btrfs_del_items()
4529 ret = btrfs_del_leaf(trans, root, path, leaf); in btrfs_del_items()
4539 fixup_low_keys(trans, path, &disk_key, 1); in btrfs_del_items()
4557 slot = path->slots[1]; in btrfs_del_items()
4565 wret = push_leaf_left(trans, root, path, 0, in btrfs_del_items()
4570 if (path->nodes[0] == leaf && in btrfs_del_items()
4584 wret = push_leaf_right(trans, root, path, 0, in btrfs_del_items()
4591 path->slots[1] = slot; in btrfs_del_items()
4592 ret = btrfs_del_leaf(trans, root, path, leaf); in btrfs_del_items()
4603 if (path->nodes[0] == leaf) in btrfs_del_items()
4634 struct btrfs_path *path, in btrfs_search_forward() argument
4644 int keep_locks = path->keep_locks; in btrfs_search_forward()
4646 ASSERT(!path->nowait); in btrfs_search_forward()
4647 path->keep_locks = 1; in btrfs_search_forward()
4651 WARN_ON(path->nodes[level]); in btrfs_search_forward()
4652 path->nodes[level] = cur; in btrfs_search_forward()
4653 path->locks[level] = BTRFS_READ_LOCK; in btrfs_search_forward()
4669 if (level == path->lowest_level) { in btrfs_search_forward()
4673 path->slots[level] = slot; in btrfs_search_forward()
4699 path->slots[level] = slot; in btrfs_search_forward()
4700 sret = btrfs_find_next_key(root, path, min_key, level, in btrfs_search_forward()
4703 btrfs_release_path(path); in btrfs_search_forward()
4711 path->slots[level] = slot; in btrfs_search_forward()
4712 if (level == path->lowest_level) { in btrfs_search_forward()
4724 path->locks[level - 1] = BTRFS_READ_LOCK; in btrfs_search_forward()
4725 path->nodes[level - 1] = cur; in btrfs_search_forward()
4726 unlock_up(path, level, 1, 0, NULL); in btrfs_search_forward()
4729 path->keep_locks = keep_locks; in btrfs_search_forward()
4731 btrfs_unlock_up_safe(path, path->lowest_level + 1); in btrfs_search_forward()
4748 int btrfs_find_next_key(struct btrfs_root *root, struct btrfs_path *path, in btrfs_find_next_key() argument
4754 WARN_ON(!path->keep_locks && !path->skip_locking); in btrfs_find_next_key()
4756 if (!path->nodes[level]) in btrfs_find_next_key()
4759 slot = path->slots[level] + 1; in btrfs_find_next_key()
4760 c = path->nodes[level]; in btrfs_find_next_key()
4767 !path->nodes[level + 1]) in btrfs_find_next_key()
4770 if (path->locks[level + 1] || path->skip_locking) { in btrfs_find_next_key()
4781 orig_lowest = path->lowest_level; in btrfs_find_next_key()
4782 btrfs_release_path(path); in btrfs_find_next_key()
4783 path->lowest_level = level; in btrfs_find_next_key()
4784 ret = btrfs_search_slot(NULL, root, &cur_key, path, in btrfs_find_next_key()
4786 path->lowest_level = orig_lowest; in btrfs_find_next_key()
4790 c = path->nodes[level]; in btrfs_find_next_key()
4791 slot = path->slots[level]; in btrfs_find_next_key()
4813 int btrfs_next_old_leaf(struct btrfs_root *root, struct btrfs_path *path, in btrfs_next_old_leaf() argument
4832 ASSERT(!path->nowait); in btrfs_next_old_leaf()
4834 nritems = btrfs_header_nritems(path->nodes[0]); in btrfs_next_old_leaf()
4838 btrfs_item_key_to_cpu(path->nodes[0], &key, nritems - 1); in btrfs_next_old_leaf()
4842 btrfs_release_path(path); in btrfs_next_old_leaf()
4844 path->keep_locks = 1; in btrfs_next_old_leaf()
4847 ret = btrfs_search_old_slot(root, &key, path, time_seq); in btrfs_next_old_leaf()
4849 if (path->need_commit_sem) { in btrfs_next_old_leaf()
4850 path->need_commit_sem = 0; in btrfs_next_old_leaf()
4852 if (path->nowait) { in btrfs_next_old_leaf()
4861 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in btrfs_next_old_leaf()
4863 path->keep_locks = 0; in btrfs_next_old_leaf()
4868 nritems = btrfs_header_nritems(path->nodes[0]); in btrfs_next_old_leaf()
4875 if (nritems > 0 && path->slots[0] < nritems - 1) { in btrfs_next_old_leaf()
4877 path->slots[0]++; in btrfs_next_old_leaf()
4895 if (nritems > 0 && ret > 0 && path->slots[0] == nritems - 1) { in btrfs_next_old_leaf()
4901 if (!path->nodes[level]) { in btrfs_next_old_leaf()
4906 slot = path->slots[level] + 1; in btrfs_next_old_leaf()
4907 c = path->nodes[level]; in btrfs_next_old_leaf()
4924 if (path->locks[level]) { in btrfs_next_old_leaf()
4925 btrfs_tree_read_unlock(path->nodes[i]); in btrfs_next_old_leaf()
4926 path->locks[i] = 0; in btrfs_next_old_leaf()
4928 free_extent_buffer(path->nodes[i]); in btrfs_next_old_leaf()
4929 path->nodes[i] = NULL; in btrfs_next_old_leaf()
4933 ret = read_block_for_search(root, path, &next, level, in btrfs_next_old_leaf()
4935 if (ret == -EAGAIN && !path->nowait) in btrfs_next_old_leaf()
4939 btrfs_release_path(path); in btrfs_next_old_leaf()
4943 if (!path->skip_locking) { in btrfs_next_old_leaf()
4945 if (!ret && path->nowait) { in btrfs_next_old_leaf()
4958 btrfs_release_path(path); in btrfs_next_old_leaf()
4967 path->slots[level] = slot; in btrfs_next_old_leaf()
4970 path->nodes[level] = next; in btrfs_next_old_leaf()
4971 path->slots[level] = 0; in btrfs_next_old_leaf()
4972 if (!path->skip_locking) in btrfs_next_old_leaf()
4973 path->locks[level] = BTRFS_READ_LOCK; in btrfs_next_old_leaf()
4977 ret = read_block_for_search(root, path, &next, level, in btrfs_next_old_leaf()
4979 if (ret == -EAGAIN && !path->nowait) in btrfs_next_old_leaf()
4983 btrfs_release_path(path); in btrfs_next_old_leaf()
4987 if (!path->skip_locking) { in btrfs_next_old_leaf()
4988 if (path->nowait) { in btrfs_next_old_leaf()
5000 unlock_up(path, 0, 1, 0, NULL); in btrfs_next_old_leaf()
5004 path->need_commit_sem = 1; in btrfs_next_old_leaf()
5005 ret2 = finish_need_commit_sem_search(path); in btrfs_next_old_leaf()
5014 int btrfs_next_old_item(struct btrfs_root *root, struct btrfs_path *path, u64 time_seq) in btrfs_next_old_item() argument
5016 path->slots[0]++; in btrfs_next_old_item()
5017 if (path->slots[0] >= btrfs_header_nritems(path->nodes[0])) in btrfs_next_old_item()
5018 return btrfs_next_old_leaf(root, path, time_seq); in btrfs_next_old_item()
5029 struct btrfs_path *path, u64 min_objectid, in btrfs_previous_item() argument
5038 if (path->slots[0] == 0) { in btrfs_previous_item()
5039 ret = btrfs_prev_leaf(root, path); in btrfs_previous_item()
5043 path->slots[0]--; in btrfs_previous_item()
5045 leaf = path->nodes[0]; in btrfs_previous_item()
5049 if (path->slots[0] == nritems) in btrfs_previous_item()
5050 path->slots[0]--; in btrfs_previous_item()
5052 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); in btrfs_previous_item()
5071 struct btrfs_path *path, u64 min_objectid) in btrfs_previous_extent_item() argument
5079 if (path->slots[0] == 0) { in btrfs_previous_extent_item()
5080 ret = btrfs_prev_leaf(root, path); in btrfs_previous_extent_item()
5084 path->slots[0]--; in btrfs_previous_extent_item()
5086 leaf = path->nodes[0]; in btrfs_previous_extent_item()
5090 if (path->slots[0] == nritems) in btrfs_previous_extent_item()
5091 path->slots[0]--; in btrfs_previous_extent_item()
5093 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); in btrfs_previous_extent_item()