Lines Matching refs:path

22 		      *root, struct btrfs_path *path, int level);
24 const struct btrfs_key *ins_key, struct btrfs_path *path,
32 static void del_ptr(struct btrfs_root *root, struct btrfs_path *path,
867 struct btrfs_path *path, int level) in balance_level() argument
877 int orig_slot = path->slots[level]; in balance_level()
882 mid = path->nodes[level]; in balance_level()
884 WARN_ON(path->locks[level] != BTRFS_WRITE_LOCK); in balance_level()
890 parent = path->nodes[level + 1]; in balance_level()
891 pslot = path->slots[level + 1]; in balance_level()
928 path->locks[level] = 0; in balance_level()
929 path->nodes[level] = NULL; in balance_level()
993 del_ptr(root, path, level + 1, pslot + 1); in balance_level()
1039 del_ptr(root, path, level + 1, pslot); in balance_level()
1060 path->nodes[level] = left; in balance_level()
1061 path->slots[level + 1] -= 1; in balance_level()
1062 path->slots[level] = orig_slot; in balance_level()
1069 path->slots[level] = orig_slot; in balance_level()
1074 btrfs_node_blockptr(path->nodes[level], path->slots[level])) in balance_level()
1082 if (path->nodes[level] != left) in balance_level()
1095 struct btrfs_path *path, int level) in push_nodes_for_insert() argument
1105 int orig_slot = path->slots[level]; in push_nodes_for_insert()
1110 mid = path->nodes[level]; in push_nodes_for_insert()
1114 parent = path->nodes[level + 1]; in push_nodes_for_insert()
1115 pslot = path->slots[level + 1]; in push_nodes_for_insert()
1156 path->nodes[level] = left; in push_nodes_for_insert()
1157 path->slots[level + 1] -= 1; in push_nodes_for_insert()
1158 path->slots[level] = orig_slot; in push_nodes_for_insert()
1164 path->slots[level] = orig_slot; in push_nodes_for_insert()
1211 path->nodes[level] = right; in push_nodes_for_insert()
1212 path->slots[level + 1] += 1; in push_nodes_for_insert()
1213 path->slots[level] = orig_slot - in push_nodes_for_insert()
1234 struct btrfs_path *path, in reada_for_search() argument
1248 if (level != 1 && path->reada != READA_FORWARD_ALWAYS) in reada_for_search()
1251 if (!path->nodes[level]) in reada_for_search()
1254 node = path->nodes[level]; in reada_for_search()
1261 if (path->reada == READA_FORWARD_ALWAYS) { in reada_for_search()
1272 if (path->reada != READA_FORWARD_ALWAYS) { in reada_for_search()
1288 if (path->reada == READA_BACK) { in reada_for_search()
1292 } else if (path->reada == READA_FORWARD || in reada_for_search()
1293 path->reada == READA_FORWARD_ALWAYS) { in reada_for_search()
1298 if (path->reada == READA_BACK && objectid) { in reada_for_search()
1304 if (path->reada == READA_FORWARD_ALWAYS || in reada_for_search()
1316 static noinline void reada_for_balance(struct btrfs_path *path, int level) in reada_for_balance() argument
1322 parent = path->nodes[level + 1]; in reada_for_balance()
1327 slot = path->slots[level + 1]; in reada_for_balance()
1349 static noinline void unlock_up(struct btrfs_path *path, int level, in unlock_up() argument
1358 if (!path->nodes[i]) in unlock_up()
1360 if (!path->locks[i]) in unlock_up()
1364 if (path->slots[i] == 0) { in unlock_up()
1369 if (path->keep_locks) { in unlock_up()
1372 nritems = btrfs_header_nritems(path->nodes[i]); in unlock_up()
1373 if (nritems < 1 || path->slots[i] >= nritems - 1) { in unlock_up()
1382 btrfs_tree_unlock_rw(path->nodes[i], path->locks[i]); in unlock_up()
1383 path->locks[i] = 0; in unlock_up()
1563 int btrfs_find_item(struct btrfs_root *fs_root, struct btrfs_path *path, in btrfs_find_item() argument
1571 ASSERT(path); in btrfs_find_item()
1578 ret = btrfs_search_slot(NULL, fs_root, &key, path, 0, 0); in btrfs_find_item()
1582 eb = path->nodes[0]; in btrfs_find_item()
1583 if (ret && path->slots[0] >= btrfs_header_nritems(eb)) { in btrfs_find_item()
1584 ret = btrfs_next_leaf(fs_root, path); in btrfs_find_item()
1587 eb = path->nodes[0]; in btrfs_find_item()
1590 btrfs_item_key_to_cpu(eb, found_key, path->slots[0]); in btrfs_find_item()
1686 static int finish_need_commit_sem_search(struct btrfs_path *path) in finish_need_commit_sem_search() argument
1688 const int i = path->lowest_level; in finish_need_commit_sem_search()
1689 const int slot = path->slots[i]; in finish_need_commit_sem_search()
1690 struct extent_buffer *lowest = path->nodes[i]; in finish_need_commit_sem_search()
1693 ASSERT(path->need_commit_sem); in finish_need_commit_sem_search()
1704 btrfs_release_path(path); in finish_need_commit_sem_search()
1705 path->nodes[i] = clone; in finish_need_commit_sem_search()
1706 path->slots[i] = slot; in finish_need_commit_sem_search()
1735 struct btrfs_path *path, in search_leaf() argument
1739 struct extent_buffer *leaf = path->nodes[0]; in search_leaf()
1763 if (path->locks[1] && leaf_free_space >= ins_len) { in search_leaf()
1790 btrfs_unlock_up_safe(path, 1); in search_leaf()
1808 btrfs_unlock_up_safe(path, 1); in search_leaf()
1815 path->slots[0] = 0; in search_leaf()
1822 prev_cmp, &path->slots[0]); in search_leaf()
1837 if (ret == 0 && !path->search_for_extension) { in search_leaf()
1847 err = split_leaf(trans, root, key, path, ins_len, in search_leaf()
2296 struct btrfs_path *path) in btrfs_search_backwards() argument
2300 ret = btrfs_search_slot(NULL, root, key, path, 0, 0); in btrfs_search_backwards()
2302 ret = btrfs_previous_item(root, path, key->objectid, key->type); in btrfs_search_backwards()
2305 btrfs_item_key_to_cpu(path->nodes[0], key, path->slots[0]); in btrfs_search_backwards()
2322 struct btrfs_path *path) in btrfs_get_next_valid_item() argument
2326 const int slot = path->slots[0]; in btrfs_get_next_valid_item()
2327 const struct extent_buffer *leaf = path->nodes[0]; in btrfs_get_next_valid_item()
2335 ret = btrfs_next_leaf(root, path); in btrfs_get_next_valid_item()
2355 static void fixup_low_keys(struct btrfs_path *path, in fixup_low_keys() argument
2363 int tslot = path->slots[i]; in fixup_low_keys()
2365 if (!path->nodes[i]) in fixup_low_keys()
2367 t = path->nodes[i]; in fixup_low_keys()
2372 btrfs_mark_buffer_dirty(path->nodes[i]); in fixup_low_keys()
2385 struct btrfs_path *path, in btrfs_set_item_key_safe() argument
2392 eb = path->nodes[0]; in btrfs_set_item_key_safe()
2393 slot = path->slots[0]; in btrfs_set_item_key_safe()
2427 fixup_low_keys(path, &disk_key, 1); in btrfs_set_item_key_safe()
2642 struct btrfs_path *path, int level) in insert_new_root() argument
2652 BUG_ON(path->nodes[level]); in insert_new_root()
2653 BUG_ON(path->nodes[level-1] != root->node); in insert_new_root()
2655 lower = path->nodes[level-1]; in insert_new_root()
2689 path->nodes[level] = c; in insert_new_root()
2690 path->locks[level] = BTRFS_WRITE_LOCK; in insert_new_root()
2691 path->slots[level] = 0; in insert_new_root()
2703 struct btrfs_path *path, in insert_ptr() argument
2711 BUG_ON(!path->nodes[level]); in insert_ptr()
2712 btrfs_assert_tree_write_locked(path->nodes[level]); in insert_ptr()
2713 lower = path->nodes[level]; in insert_ptr()
2752 struct btrfs_path *path, int level) in split_node() argument
2762 c = path->nodes[level]; in split_node()
2775 ret = insert_new_root(trans, root, path, level + 1); in split_node()
2779 ret = push_nodes_for_insert(trans, root, path, level); in split_node()
2780 c = path->nodes[level]; in split_node()
2816 insert_ptr(trans, path, &disk_key, split->start, in split_node()
2817 path->slots[level + 1] + 1, level + 1); in split_node()
2819 if (path->slots[level] >= mid) { in split_node()
2820 path->slots[level] -= mid; in split_node()
2823 path->nodes[level] = split; in split_node()
2824 path->slots[level + 1] += 1; in split_node()
2878 static noinline int __push_leaf_right(struct btrfs_path *path, in __push_leaf_right() argument
2885 struct extent_buffer *left = path->nodes[0]; in __push_leaf_right()
2886 struct extent_buffer *upper = path->nodes[1]; in __push_leaf_right()
2903 if (path->slots[0] >= left_nritems) in __push_leaf_right()
2906 slot = path->slots[1]; in __push_leaf_right()
2910 if (path->slots[0] > i) in __push_leaf_right()
2912 if (path->slots[0] == i) { in __push_leaf_right()
2920 if (path->slots[0] == i) in __push_leaf_right()
2993 if (path->slots[0] >= left_nritems) { in __push_leaf_right()
2994 path->slots[0] -= left_nritems; in __push_leaf_right()
2995 if (btrfs_header_nritems(path->nodes[0]) == 0) in __push_leaf_right()
2996 btrfs_clean_tree_block(path->nodes[0]); in __push_leaf_right()
2997 btrfs_tree_unlock(path->nodes[0]); in __push_leaf_right()
2998 free_extent_buffer(path->nodes[0]); in __push_leaf_right()
2999 path->nodes[0] = right; in __push_leaf_right()
3000 path->slots[1] += 1; in __push_leaf_right()
3024 *root, struct btrfs_path *path, in push_leaf_right() argument
3028 struct extent_buffer *left = path->nodes[0]; in push_leaf_right()
3036 if (!path->nodes[1]) in push_leaf_right()
3039 slot = path->slots[1]; in push_leaf_right()
3040 upper = path->nodes[1]; in push_leaf_right()
3044 btrfs_assert_tree_write_locked(path->nodes[1]); in push_leaf_right()
3075 if (path->slots[0] == left_nritems && !empty) { in push_leaf_right()
3082 path->nodes[0] = right; in push_leaf_right()
3083 path->slots[0] = 0; in push_leaf_right()
3084 path->slots[1]++; in push_leaf_right()
3088 return __push_leaf_right(path, min_data_size, empty, in push_leaf_right()
3104 static noinline int __push_leaf_left(struct btrfs_path *path, int data_size, in __push_leaf_left() argument
3111 struct extent_buffer *right = path->nodes[0]; in __push_leaf_left()
3129 if (path->slots[0] < i) in __push_leaf_left()
3131 if (path->slots[0] == i) { in __push_leaf_left()
3139 if (path->slots[0] == i) in __push_leaf_left()
3220 fixup_low_keys(path, &disk_key, 1); in __push_leaf_left()
3223 if (path->slots[0] < push_items) { in __push_leaf_left()
3224 path->slots[0] += old_left_nritems; in __push_leaf_left()
3225 btrfs_tree_unlock(path->nodes[0]); in __push_leaf_left()
3226 free_extent_buffer(path->nodes[0]); in __push_leaf_left()
3227 path->nodes[0] = left; in __push_leaf_left()
3228 path->slots[1] -= 1; in __push_leaf_left()
3232 path->slots[0] -= push_items; in __push_leaf_left()
3234 BUG_ON(path->slots[0] < 0); in __push_leaf_left()
3251 *root, struct btrfs_path *path, int min_data_size, in push_leaf_left() argument
3254 struct extent_buffer *right = path->nodes[0]; in push_leaf_left()
3261 slot = path->slots[1]; in push_leaf_left()
3264 if (!path->nodes[1]) in push_leaf_left()
3271 btrfs_assert_tree_write_locked(path->nodes[1]); in push_leaf_left()
3273 left = btrfs_read_node_slot(path->nodes[1], slot - 1); in push_leaf_left()
3290 path->nodes[1], slot - 1, &left, in push_leaf_left()
3303 return __push_leaf_left(path, min_data_size, in push_leaf_left()
3317 struct btrfs_path *path, in copy_for_split() argument
3354 insert_ptr(trans, path, &disk_key, right->start, path->slots[1] + 1, 1); in copy_for_split()
3358 BUG_ON(path->slots[0] != slot); in copy_for_split()
3361 btrfs_tree_unlock(path->nodes[0]); in copy_for_split()
3362 free_extent_buffer(path->nodes[0]); in copy_for_split()
3363 path->nodes[0] = right; in copy_for_split()
3364 path->slots[0] -= mid; in copy_for_split()
3365 path->slots[1] += 1; in copy_for_split()
3371 BUG_ON(path->slots[0] < 0); in copy_for_split()
3386 struct btrfs_path *path, in push_for_double_split() argument
3395 slot = path->slots[0]; in push_for_double_split()
3396 if (slot < btrfs_header_nritems(path->nodes[0])) in push_for_double_split()
3397 space_needed -= btrfs_leaf_free_space(path->nodes[0]); in push_for_double_split()
3403 ret = push_leaf_right(trans, root, path, 1, space_needed, 0, slot); in push_for_double_split()
3410 nritems = btrfs_header_nritems(path->nodes[0]); in push_for_double_split()
3415 if (path->slots[0] == 0 || path->slots[0] == nritems) in push_for_double_split()
3418 if (btrfs_leaf_free_space(path->nodes[0]) >= data_size) in push_for_double_split()
3422 slot = path->slots[0]; in push_for_double_split()
3425 space_needed -= btrfs_leaf_free_space(path->nodes[0]); in push_for_double_split()
3426 ret = push_leaf_left(trans, root, path, 1, space_needed, 0, slot); in push_for_double_split()
3447 struct btrfs_path *path, int data_size, in split_leaf() argument
3463 l = path->nodes[0]; in split_leaf()
3464 slot = path->slots[0]; in split_leaf()
3470 if (data_size && path->nodes[1]) { in split_leaf()
3476 wret = push_leaf_right(trans, root, path, space_needed, in split_leaf()
3484 wret = push_leaf_left(trans, root, path, space_needed, in split_leaf()
3489 l = path->nodes[0]; in split_leaf()
3496 if (!path->nodes[1]) { in split_leaf()
3497 ret = insert_new_root(trans, root, path, 1); in split_leaf()
3503 l = path->nodes[0]; in split_leaf()
3504 slot = path->slots[0]; in split_leaf()
3570 insert_ptr(trans, path, &disk_key, in split_leaf()
3571 right->start, path->slots[1] + 1, 1); in split_leaf()
3572 btrfs_tree_unlock(path->nodes[0]); in split_leaf()
3573 free_extent_buffer(path->nodes[0]); in split_leaf()
3574 path->nodes[0] = right; in split_leaf()
3575 path->slots[0] = 0; in split_leaf()
3576 path->slots[1] += 1; in split_leaf()
3579 insert_ptr(trans, path, &disk_key, in split_leaf()
3580 right->start, path->slots[1], 1); in split_leaf()
3581 btrfs_tree_unlock(path->nodes[0]); in split_leaf()
3582 free_extent_buffer(path->nodes[0]); in split_leaf()
3583 path->nodes[0] = right; in split_leaf()
3584 path->slots[0] = 0; in split_leaf()
3585 if (path->slots[1] == 0) in split_leaf()
3586 fixup_low_keys(path, &disk_key, 1); in split_leaf()
3596 copy_for_split(trans, path, l, right, slot, mid, nritems); in split_leaf()
3607 push_for_double_split(trans, root, path, data_size); in split_leaf()
3609 if (btrfs_leaf_free_space(path->nodes[0]) >= data_size) in split_leaf()
3616 struct btrfs_path *path, int ins_len) in setup_leaf_for_split() argument
3625 leaf = path->nodes[0]; in setup_leaf_for_split()
3626 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); in setup_leaf_for_split()
3634 item_size = btrfs_item_size(leaf, path->slots[0]); in setup_leaf_for_split()
3636 fi = btrfs_item_ptr(leaf, path->slots[0], in setup_leaf_for_split()
3640 btrfs_release_path(path); in setup_leaf_for_split()
3642 path->keep_locks = 1; in setup_leaf_for_split()
3643 path->search_for_split = 1; in setup_leaf_for_split()
3644 ret = btrfs_search_slot(trans, root, &key, path, 0, 1); in setup_leaf_for_split()
3645 path->search_for_split = 0; in setup_leaf_for_split()
3652 leaf = path->nodes[0]; in setup_leaf_for_split()
3654 if (item_size != btrfs_item_size(leaf, path->slots[0])) in setup_leaf_for_split()
3658 if (btrfs_leaf_free_space(path->nodes[0]) >= ins_len) in setup_leaf_for_split()
3662 fi = btrfs_item_ptr(leaf, path->slots[0], in setup_leaf_for_split()
3668 ret = split_leaf(trans, root, &key, path, ins_len, 1); in setup_leaf_for_split()
3672 path->keep_locks = 0; in setup_leaf_for_split()
3673 btrfs_unlock_up_safe(path, 1); in setup_leaf_for_split()
3676 path->keep_locks = 0; in setup_leaf_for_split()
3680 static noinline int split_item(struct btrfs_path *path, in split_item() argument
3692 leaf = path->nodes[0]; in split_item()
3695 orig_slot = path->slots[0]; in split_item()
3696 orig_offset = btrfs_item_offset(leaf, path->slots[0]); in split_item()
3697 item_size = btrfs_item_size(leaf, path->slots[0]); in split_item()
3704 path->slots[0]), item_size); in split_item()
3706 slot = path->slots[0] + 1; in split_item()
3729 btrfs_item_ptr_offset(leaf, path->slots[0]), in split_item()
3760 struct btrfs_path *path, in btrfs_split_item() argument
3765 ret = setup_leaf_for_split(trans, root, path, in btrfs_split_item()
3770 ret = split_item(path, new_key, split_offset); in btrfs_split_item()
3780 void btrfs_truncate_item(struct btrfs_path *path, u32 new_size, int from_end) in btrfs_truncate_item() argument
3792 leaf = path->nodes[0]; in btrfs_truncate_item()
3793 slot = path->slots[0]; in btrfs_truncate_item()
3858 fixup_low_keys(path, &disk_key, 1); in btrfs_truncate_item()
3873 void btrfs_extend_item(struct btrfs_path *path, u32 data_size) in btrfs_extend_item() argument
3884 leaf = path->nodes[0]; in btrfs_extend_item()
3893 slot = path->slots[0]; in btrfs_extend_item()
3941 static void setup_items_for_insert(struct btrfs_root *root, struct btrfs_path *path, in setup_items_for_insert() argument
3959 if (path->slots[0] == 0) { in setup_items_for_insert()
3961 fixup_low_keys(path, &disk_key, 1); in setup_items_for_insert()
3963 btrfs_unlock_up_safe(path, 1); in setup_items_for_insert()
3965 leaf = path->nodes[0]; in setup_items_for_insert()
3966 slot = path->slots[0]; in setup_items_for_insert()
4041 struct btrfs_path *path, in btrfs_setup_item_for_insert() argument
4052 setup_items_for_insert(root, path, &batch); in btrfs_setup_item_for_insert()
4061 struct btrfs_path *path, in btrfs_insert_empty_items() argument
4069 ret = btrfs_search_slot(trans, root, &batch->keys[0], path, total_size, 1); in btrfs_insert_empty_items()
4075 slot = path->slots[0]; in btrfs_insert_empty_items()
4078 setup_items_for_insert(root, path, batch); in btrfs_insert_empty_items()
4091 struct btrfs_path *path; in btrfs_insert_item() local
4095 path = btrfs_alloc_path(); in btrfs_insert_item()
4096 if (!path) in btrfs_insert_item()
4098 ret = btrfs_insert_empty_item(trans, root, path, cpu_key, data_size); in btrfs_insert_item()
4100 leaf = path->nodes[0]; in btrfs_insert_item()
4101 ptr = btrfs_item_ptr_offset(leaf, path->slots[0]); in btrfs_insert_item()
4105 btrfs_free_path(path); in btrfs_insert_item()
4119 struct btrfs_path *path, in btrfs_duplicate_item() argument
4126 leaf = path->nodes[0]; in btrfs_duplicate_item()
4127 item_size = btrfs_item_size(leaf, path->slots[0]); in btrfs_duplicate_item()
4128 ret = setup_leaf_for_split(trans, root, path, in btrfs_duplicate_item()
4133 path->slots[0]++; in btrfs_duplicate_item()
4134 btrfs_setup_item_for_insert(root, path, new_key, item_size); in btrfs_duplicate_item()
4135 leaf = path->nodes[0]; in btrfs_duplicate_item()
4137 btrfs_item_ptr_offset(leaf, path->slots[0]), in btrfs_duplicate_item()
4138 btrfs_item_ptr_offset(leaf, path->slots[0] - 1), in btrfs_duplicate_item()
4149 static void del_ptr(struct btrfs_root *root, struct btrfs_path *path, in del_ptr() argument
4152 struct extent_buffer *parent = path->nodes[level]; in del_ptr()
4184 fixup_low_keys(path, &disk_key, level + 1); in del_ptr()
4201 struct btrfs_path *path, in btrfs_del_leaf() argument
4205 del_ptr(root, path, 1, path->slots[1]); in btrfs_del_leaf()
4211 btrfs_unlock_up_safe(path, 0); in btrfs_del_leaf()
4224 struct btrfs_path *path, int slot, int nr) in btrfs_del_items() argument
4232 leaf = path->nodes[0]; in btrfs_del_items()
4272 btrfs_del_leaf(trans, root, path, leaf); in btrfs_del_items()
4280 fixup_low_keys(path, &disk_key, 1); in btrfs_del_items()
4298 slot = path->slots[1]; in btrfs_del_items()
4306 wret = push_leaf_left(trans, root, path, 0, in btrfs_del_items()
4311 if (path->nodes[0] == leaf && in btrfs_del_items()
4325 wret = push_leaf_right(trans, root, path, 0, in btrfs_del_items()
4332 path->slots[1] = slot; in btrfs_del_items()
4333 btrfs_del_leaf(trans, root, path, leaf); in btrfs_del_items()
4342 if (path->nodes[0] == leaf) in btrfs_del_items()
4361 int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path) in btrfs_prev_leaf() argument
4367 btrfs_item_key_to_cpu(path->nodes[0], &key, 0); in btrfs_prev_leaf()
4382 btrfs_release_path(path); in btrfs_prev_leaf()
4383 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in btrfs_prev_leaf()
4386 btrfs_item_key(path->nodes[0], &found_key, 0); in btrfs_prev_leaf()
4423 struct btrfs_path *path, in btrfs_search_forward() argument
4433 int keep_locks = path->keep_locks; in btrfs_search_forward()
4435 path->keep_locks = 1; in btrfs_search_forward()
4439 WARN_ON(path->nodes[level]); in btrfs_search_forward()
4440 path->nodes[level] = cur; in btrfs_search_forward()
4441 path->locks[level] = BTRFS_READ_LOCK; in btrfs_search_forward()
4457 if (level == path->lowest_level) { in btrfs_search_forward()
4461 path->slots[level] = slot; in btrfs_search_forward()
4487 path->slots[level] = slot; in btrfs_search_forward()
4488 sret = btrfs_find_next_key(root, path, min_key, level, in btrfs_search_forward()
4491 btrfs_release_path(path); in btrfs_search_forward()
4499 path->slots[level] = slot; in btrfs_search_forward()
4500 if (level == path->lowest_level) { in btrfs_search_forward()
4512 path->locks[level - 1] = BTRFS_READ_LOCK; in btrfs_search_forward()
4513 path->nodes[level - 1] = cur; in btrfs_search_forward()
4514 unlock_up(path, level, 1, 0, NULL); in btrfs_search_forward()
4517 path->keep_locks = keep_locks; in btrfs_search_forward()
4519 btrfs_unlock_up_safe(path, path->lowest_level + 1); in btrfs_search_forward()
4536 int btrfs_find_next_key(struct btrfs_root *root, struct btrfs_path *path, in btrfs_find_next_key() argument
4542 WARN_ON(!path->keep_locks && !path->skip_locking); in btrfs_find_next_key()
4544 if (!path->nodes[level]) in btrfs_find_next_key()
4547 slot = path->slots[level] + 1; in btrfs_find_next_key()
4548 c = path->nodes[level]; in btrfs_find_next_key()
4555 !path->nodes[level + 1]) in btrfs_find_next_key()
4558 if (path->locks[level + 1] || path->skip_locking) { in btrfs_find_next_key()
4569 orig_lowest = path->lowest_level; in btrfs_find_next_key()
4570 btrfs_release_path(path); in btrfs_find_next_key()
4571 path->lowest_level = level; in btrfs_find_next_key()
4572 ret = btrfs_search_slot(NULL, root, &cur_key, path, in btrfs_find_next_key()
4574 path->lowest_level = orig_lowest; in btrfs_find_next_key()
4578 c = path->nodes[level]; in btrfs_find_next_key()
4579 slot = path->slots[level]; in btrfs_find_next_key()
4601 int btrfs_next_old_leaf(struct btrfs_root *root, struct btrfs_path *path, in btrfs_next_old_leaf() argument
4615 nritems = btrfs_header_nritems(path->nodes[0]); in btrfs_next_old_leaf()
4619 btrfs_item_key_to_cpu(path->nodes[0], &key, nritems - 1); in btrfs_next_old_leaf()
4623 btrfs_release_path(path); in btrfs_next_old_leaf()
4625 path->keep_locks = 1; in btrfs_next_old_leaf()
4628 ret = btrfs_search_old_slot(root, &key, path, time_seq); in btrfs_next_old_leaf()
4630 if (path->need_commit_sem) { in btrfs_next_old_leaf()
4631 path->need_commit_sem = 0; in btrfs_next_old_leaf()
4635 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in btrfs_next_old_leaf()
4637 path->keep_locks = 0; in btrfs_next_old_leaf()
4642 nritems = btrfs_header_nritems(path->nodes[0]); in btrfs_next_old_leaf()
4649 if (nritems > 0 && path->slots[0] < nritems - 1) { in btrfs_next_old_leaf()
4651 path->slots[0]++; in btrfs_next_old_leaf()
4669 if (nritems > 0 && ret > 0 && path->slots[0] == nritems - 1) { in btrfs_next_old_leaf()
4675 if (!path->nodes[level]) { in btrfs_next_old_leaf()
4680 slot = path->slots[level] + 1; in btrfs_next_old_leaf()
4681 c = path->nodes[level]; in btrfs_next_old_leaf()
4698 if (path->locks[level]) { in btrfs_next_old_leaf()
4699 btrfs_tree_read_unlock(path->nodes[i]); in btrfs_next_old_leaf()
4700 path->locks[i] = 0; in btrfs_next_old_leaf()
4702 free_extent_buffer(path->nodes[i]); in btrfs_next_old_leaf()
4703 path->nodes[i] = NULL; in btrfs_next_old_leaf()
4707 ret = read_block_for_search(root, path, &next, level, in btrfs_next_old_leaf()
4713 btrfs_release_path(path); in btrfs_next_old_leaf()
4717 if (!path->skip_locking) { in btrfs_next_old_leaf()
4728 btrfs_release_path(path); in btrfs_next_old_leaf()
4737 path->slots[level] = slot; in btrfs_next_old_leaf()
4740 path->nodes[level] = next; in btrfs_next_old_leaf()
4741 path->slots[level] = 0; in btrfs_next_old_leaf()
4742 if (!path->skip_locking) in btrfs_next_old_leaf()
4743 path->locks[level] = BTRFS_READ_LOCK; in btrfs_next_old_leaf()
4747 ret = read_block_for_search(root, path, &next, level, in btrfs_next_old_leaf()
4753 btrfs_release_path(path); in btrfs_next_old_leaf()
4757 if (!path->skip_locking) in btrfs_next_old_leaf()
4762 unlock_up(path, 0, 1, 0, NULL); in btrfs_next_old_leaf()
4766 path->need_commit_sem = 1; in btrfs_next_old_leaf()
4767 ret2 = finish_need_commit_sem_search(path); in btrfs_next_old_leaf()
4783 struct btrfs_path *path, u64 min_objectid, in btrfs_previous_item() argument
4792 if (path->slots[0] == 0) { in btrfs_previous_item()
4793 ret = btrfs_prev_leaf(root, path); in btrfs_previous_item()
4797 path->slots[0]--; in btrfs_previous_item()
4799 leaf = path->nodes[0]; in btrfs_previous_item()
4803 if (path->slots[0] == nritems) in btrfs_previous_item()
4804 path->slots[0]--; in btrfs_previous_item()
4806 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); in btrfs_previous_item()
4825 struct btrfs_path *path, u64 min_objectid) in btrfs_previous_extent_item() argument
4833 if (path->slots[0] == 0) { in btrfs_previous_extent_item()
4834 ret = btrfs_prev_leaf(root, path); in btrfs_previous_extent_item()
4838 path->slots[0]--; in btrfs_previous_extent_item()
4840 leaf = path->nodes[0]; in btrfs_previous_extent_item()
4844 if (path->slots[0] == nritems) in btrfs_previous_extent_item()
4845 path->slots[0]--; in btrfs_previous_extent_item()
4847 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); in btrfs_previous_extent_item()