Lines Matching refs:path
20 *root, struct btrfs_path *path, int level);
22 const struct btrfs_key *ins_key, struct btrfs_path *path,
30 static void del_ptr(struct btrfs_root *root, struct btrfs_path *path,
891 struct btrfs_path *path, int level) in balance_level() argument
901 int orig_slot = path->slots[level]; in balance_level()
906 mid = path->nodes[level]; in balance_level()
908 WARN_ON(path->locks[level] != BTRFS_WRITE_LOCK); in balance_level()
914 parent = path->nodes[level + 1]; in balance_level()
915 pslot = path->slots[level + 1]; in balance_level()
957 path->locks[level] = 0; in balance_level()
958 path->nodes[level] = NULL; in balance_level()
1022 del_ptr(root, path, level + 1, pslot + 1); in balance_level()
1071 del_ptr(root, path, level + 1, pslot); in balance_level()
1095 path->nodes[level] = left; in balance_level()
1096 path->slots[level + 1] -= 1; in balance_level()
1097 path->slots[level] = orig_slot; in balance_level()
1104 path->slots[level] = orig_slot; in balance_level()
1109 btrfs_node_blockptr(path->nodes[level], path->slots[level])) in balance_level()
1117 if (path->nodes[level] != left) in balance_level()
1130 struct btrfs_path *path, int level) in push_nodes_for_insert() argument
1140 int orig_slot = path->slots[level]; in push_nodes_for_insert()
1145 mid = path->nodes[level]; in push_nodes_for_insert()
1149 parent = path->nodes[level + 1]; in push_nodes_for_insert()
1150 pslot = path->slots[level + 1]; in push_nodes_for_insert()
1191 path->nodes[level] = left; in push_nodes_for_insert()
1192 path->slots[level + 1] -= 1; in push_nodes_for_insert()
1193 path->slots[level] = orig_slot; in push_nodes_for_insert()
1199 path->slots[level] = orig_slot; in push_nodes_for_insert()
1246 path->nodes[level] = right; in push_nodes_for_insert()
1247 path->slots[level + 1] += 1; in push_nodes_for_insert()
1248 path->slots[level] = orig_slot - in push_nodes_for_insert()
1269 struct btrfs_path *path, in reada_for_search() argument
1283 if (level != 1 && path->reada != READA_FORWARD_ALWAYS) in reada_for_search()
1286 if (!path->nodes[level]) in reada_for_search()
1289 node = path->nodes[level]; in reada_for_search()
1296 if (path->reada == READA_FORWARD_ALWAYS) { in reada_for_search()
1307 if (path->reada != READA_FORWARD_ALWAYS) { in reada_for_search()
1323 if (path->reada == READA_BACK) { in reada_for_search()
1327 } else if (path->reada == READA_FORWARD || in reada_for_search()
1328 path->reada == READA_FORWARD_ALWAYS) { in reada_for_search()
1333 if (path->reada == READA_BACK && objectid) { in reada_for_search()
1339 if (path->reada == READA_FORWARD_ALWAYS || in reada_for_search()
1351 static noinline void reada_for_balance(struct btrfs_path *path, int level) in reada_for_balance() argument
1357 parent = path->nodes[level + 1]; in reada_for_balance()
1362 slot = path->slots[level + 1]; in reada_for_balance()
1384 static noinline void unlock_up(struct btrfs_path *path, int level, in unlock_up() argument
1394 if (!path->nodes[i]) in unlock_up()
1396 if (!path->locks[i]) in unlock_up()
1398 if (!no_skips && path->slots[i] == 0) { in unlock_up()
1402 if (!no_skips && path->keep_locks) { in unlock_up()
1404 t = path->nodes[i]; in unlock_up()
1406 if (nritems < 1 || path->slots[i] >= nritems - 1) { in unlock_up()
1414 t = path->nodes[i]; in unlock_up()
1416 btrfs_tree_unlock_rw(t, path->locks[i]); in unlock_up()
1417 path->locks[i] = 0; in unlock_up()
1573 int btrfs_find_item(struct btrfs_root *fs_root, struct btrfs_path *path, in btrfs_find_item() argument
1581 ASSERT(path); in btrfs_find_item()
1588 ret = btrfs_search_slot(NULL, fs_root, &key, path, 0, 0); in btrfs_find_item()
1592 eb = path->nodes[0]; in btrfs_find_item()
1593 if (ret && path->slots[0] >= btrfs_header_nritems(eb)) { in btrfs_find_item()
1594 ret = btrfs_next_leaf(fs_root, path); in btrfs_find_item()
1597 eb = path->nodes[0]; in btrfs_find_item()
1600 btrfs_item_key_to_cpu(eb, found_key, path->slots[0]); in btrfs_find_item()
1696 static int finish_need_commit_sem_search(struct btrfs_path *path) in finish_need_commit_sem_search() argument
1698 const int i = path->lowest_level; in finish_need_commit_sem_search()
1699 const int slot = path->slots[i]; in finish_need_commit_sem_search()
1700 struct extent_buffer *lowest = path->nodes[i]; in finish_need_commit_sem_search()
1703 ASSERT(path->need_commit_sem); in finish_need_commit_sem_search()
1714 btrfs_release_path(path); in finish_need_commit_sem_search()
1715 path->nodes[i] = clone; in finish_need_commit_sem_search()
1716 path->slots[i] = slot; in finish_need_commit_sem_search()
2201 struct btrfs_path *path) in btrfs_search_backwards() argument
2205 ret = btrfs_search_slot(NULL, root, key, path, 0, 0); in btrfs_search_backwards()
2207 ret = btrfs_previous_item(root, path, key->objectid, key->type); in btrfs_search_backwards()
2210 btrfs_item_key_to_cpu(path->nodes[0], key, path->slots[0]); in btrfs_search_backwards()
2223 static void fixup_low_keys(struct btrfs_path *path, in fixup_low_keys() argument
2231 int tslot = path->slots[i]; in fixup_low_keys()
2233 if (!path->nodes[i]) in fixup_low_keys()
2235 t = path->nodes[i]; in fixup_low_keys()
2240 btrfs_mark_buffer_dirty(path->nodes[i]); in fixup_low_keys()
2253 struct btrfs_path *path, in btrfs_set_item_key_safe() argument
2260 eb = path->nodes[0]; in btrfs_set_item_key_safe()
2261 slot = path->slots[0]; in btrfs_set_item_key_safe()
2295 fixup_low_keys(path, &disk_key, 1); in btrfs_set_item_key_safe()
2510 struct btrfs_path *path, int level) in insert_new_root() argument
2520 BUG_ON(path->nodes[level]); in insert_new_root()
2521 BUG_ON(path->nodes[level-1] != root->node); in insert_new_root()
2523 lower = path->nodes[level-1]; in insert_new_root()
2557 path->nodes[level] = c; in insert_new_root()
2558 path->locks[level] = BTRFS_WRITE_LOCK; in insert_new_root()
2559 path->slots[level] = 0; in insert_new_root()
2571 struct btrfs_path *path, in insert_ptr() argument
2579 BUG_ON(!path->nodes[level]); in insert_ptr()
2580 btrfs_assert_tree_locked(path->nodes[level]); in insert_ptr()
2581 lower = path->nodes[level]; in insert_ptr()
2620 struct btrfs_path *path, int level) in split_node() argument
2630 c = path->nodes[level]; in split_node()
2643 ret = insert_new_root(trans, root, path, level + 1); in split_node()
2647 ret = push_nodes_for_insert(trans, root, path, level); in split_node()
2648 c = path->nodes[level]; in split_node()
2686 insert_ptr(trans, path, &disk_key, split->start, in split_node()
2687 path->slots[level + 1] + 1, level + 1); in split_node()
2689 if (path->slots[level] >= mid) { in split_node()
2690 path->slots[level] -= mid; in split_node()
2693 path->nodes[level] = split; in split_node()
2694 path->slots[level + 1] += 1; in split_node()
2753 static noinline int __push_leaf_right(struct btrfs_path *path, in __push_leaf_right() argument
2760 struct extent_buffer *left = path->nodes[0]; in __push_leaf_right()
2761 struct extent_buffer *upper = path->nodes[1]; in __push_leaf_right()
2779 if (path->slots[0] >= left_nritems) in __push_leaf_right()
2782 slot = path->slots[1]; in __push_leaf_right()
2788 if (path->slots[0] > i) in __push_leaf_right()
2790 if (path->slots[0] == i) { in __push_leaf_right()
2798 if (path->slots[0] == i) in __push_leaf_right()
2871 if (path->slots[0] >= left_nritems) { in __push_leaf_right()
2872 path->slots[0] -= left_nritems; in __push_leaf_right()
2873 if (btrfs_header_nritems(path->nodes[0]) == 0) in __push_leaf_right()
2874 btrfs_clean_tree_block(path->nodes[0]); in __push_leaf_right()
2875 btrfs_tree_unlock(path->nodes[0]); in __push_leaf_right()
2876 free_extent_buffer(path->nodes[0]); in __push_leaf_right()
2877 path->nodes[0] = right; in __push_leaf_right()
2878 path->slots[1] += 1; in __push_leaf_right()
2902 *root, struct btrfs_path *path, in push_leaf_right() argument
2906 struct extent_buffer *left = path->nodes[0]; in push_leaf_right()
2914 if (!path->nodes[1]) in push_leaf_right()
2917 slot = path->slots[1]; in push_leaf_right()
2918 upper = path->nodes[1]; in push_leaf_right()
2922 btrfs_assert_tree_locked(path->nodes[1]); in push_leaf_right()
2959 if (path->slots[0] == left_nritems && !empty) { in push_leaf_right()
2966 path->nodes[0] = right; in push_leaf_right()
2967 path->slots[0] = 0; in push_leaf_right()
2968 path->slots[1]++; in push_leaf_right()
2972 return __push_leaf_right(path, min_data_size, empty, in push_leaf_right()
2988 static noinline int __push_leaf_left(struct btrfs_path *path, int data_size, in __push_leaf_left() argument
2995 struct extent_buffer *right = path->nodes[0]; in __push_leaf_left()
3016 if (path->slots[0] < i) in __push_leaf_left()
3018 if (path->slots[0] == i) { in __push_leaf_left()
3026 if (path->slots[0] == i) in __push_leaf_left()
3110 fixup_low_keys(path, &disk_key, 1); in __push_leaf_left()
3113 if (path->slots[0] < push_items) { in __push_leaf_left()
3114 path->slots[0] += old_left_nritems; in __push_leaf_left()
3115 btrfs_tree_unlock(path->nodes[0]); in __push_leaf_left()
3116 free_extent_buffer(path->nodes[0]); in __push_leaf_left()
3117 path->nodes[0] = left; in __push_leaf_left()
3118 path->slots[1] -= 1; in __push_leaf_left()
3122 path->slots[0] -= push_items; in __push_leaf_left()
3124 BUG_ON(path->slots[0] < 0); in __push_leaf_left()
3141 *root, struct btrfs_path *path, int min_data_size, in push_leaf_left() argument
3144 struct extent_buffer *right = path->nodes[0]; in push_leaf_left()
3151 slot = path->slots[1]; in push_leaf_left()
3154 if (!path->nodes[1]) in push_leaf_left()
3161 btrfs_assert_tree_locked(path->nodes[1]); in push_leaf_left()
3163 left = btrfs_read_node_slot(path->nodes[1], slot - 1); in push_leaf_left()
3181 path->nodes[1], slot - 1, &left, in push_leaf_left()
3201 return __push_leaf_left(path, min_data_size, in push_leaf_left()
3215 struct btrfs_path *path, in copy_for_split() argument
3253 insert_ptr(trans, path, &disk_key, right->start, path->slots[1] + 1, 1); in copy_for_split()
3257 BUG_ON(path->slots[0] != slot); in copy_for_split()
3260 btrfs_tree_unlock(path->nodes[0]); in copy_for_split()
3261 free_extent_buffer(path->nodes[0]); in copy_for_split()
3262 path->nodes[0] = right; in copy_for_split()
3263 path->slots[0] -= mid; in copy_for_split()
3264 path->slots[1] += 1; in copy_for_split()
3270 BUG_ON(path->slots[0] < 0); in copy_for_split()
3285 struct btrfs_path *path, in push_for_double_split() argument
3294 slot = path->slots[0]; in push_for_double_split()
3295 if (slot < btrfs_header_nritems(path->nodes[0])) in push_for_double_split()
3296 space_needed -= btrfs_leaf_free_space(path->nodes[0]); in push_for_double_split()
3302 ret = push_leaf_right(trans, root, path, 1, space_needed, 0, slot); in push_for_double_split()
3309 nritems = btrfs_header_nritems(path->nodes[0]); in push_for_double_split()
3314 if (path->slots[0] == 0 || path->slots[0] == nritems) in push_for_double_split()
3317 if (btrfs_leaf_free_space(path->nodes[0]) >= data_size) in push_for_double_split()
3321 slot = path->slots[0]; in push_for_double_split()
3324 space_needed -= btrfs_leaf_free_space(path->nodes[0]); in push_for_double_split()
3325 ret = push_leaf_left(trans, root, path, 1, space_needed, 0, slot); in push_for_double_split()
3346 struct btrfs_path *path, int data_size, in split_leaf() argument
3362 l = path->nodes[0]; in split_leaf()
3363 slot = path->slots[0]; in split_leaf()
3369 if (data_size && path->nodes[1]) { in split_leaf()
3375 wret = push_leaf_right(trans, root, path, space_needed, in split_leaf()
3383 wret = push_leaf_left(trans, root, path, space_needed, in split_leaf()
3388 l = path->nodes[0]; in split_leaf()
3395 if (!path->nodes[1]) { in split_leaf()
3396 ret = insert_new_root(trans, root, path, 1); in split_leaf()
3402 l = path->nodes[0]; in split_leaf()
3403 slot = path->slots[0]; in split_leaf()
3469 insert_ptr(trans, path, &disk_key, in split_leaf()
3470 right->start, path->slots[1] + 1, 1); in split_leaf()
3471 btrfs_tree_unlock(path->nodes[0]); in split_leaf()
3472 free_extent_buffer(path->nodes[0]); in split_leaf()
3473 path->nodes[0] = right; in split_leaf()
3474 path->slots[0] = 0; in split_leaf()
3475 path->slots[1] += 1; in split_leaf()
3478 insert_ptr(trans, path, &disk_key, in split_leaf()
3479 right->start, path->slots[1], 1); in split_leaf()
3480 btrfs_tree_unlock(path->nodes[0]); in split_leaf()
3481 free_extent_buffer(path->nodes[0]); in split_leaf()
3482 path->nodes[0] = right; in split_leaf()
3483 path->slots[0] = 0; in split_leaf()
3484 if (path->slots[1] == 0) in split_leaf()
3485 fixup_low_keys(path, &disk_key, 1); in split_leaf()
3495 copy_for_split(trans, path, l, right, slot, mid, nritems); in split_leaf()
3506 push_for_double_split(trans, root, path, data_size); in split_leaf()
3508 if (btrfs_leaf_free_space(path->nodes[0]) >= data_size) in split_leaf()
3515 struct btrfs_path *path, int ins_len) in setup_leaf_for_split() argument
3524 leaf = path->nodes[0]; in setup_leaf_for_split()
3525 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); in setup_leaf_for_split()
3533 item_size = btrfs_item_size_nr(leaf, path->slots[0]); in setup_leaf_for_split()
3535 fi = btrfs_item_ptr(leaf, path->slots[0], in setup_leaf_for_split()
3539 btrfs_release_path(path); in setup_leaf_for_split()
3541 path->keep_locks = 1; in setup_leaf_for_split()
3542 path->search_for_split = 1; in setup_leaf_for_split()
3543 ret = btrfs_search_slot(trans, root, &key, path, 0, 1); in setup_leaf_for_split()
3544 path->search_for_split = 0; in setup_leaf_for_split()
3551 leaf = path->nodes[0]; in setup_leaf_for_split()
3553 if (item_size != btrfs_item_size_nr(leaf, path->slots[0])) in setup_leaf_for_split()
3557 if (btrfs_leaf_free_space(path->nodes[0]) >= ins_len) in setup_leaf_for_split()
3561 fi = btrfs_item_ptr(leaf, path->slots[0], in setup_leaf_for_split()
3567 ret = split_leaf(trans, root, &key, path, ins_len, 1); in setup_leaf_for_split()
3571 path->keep_locks = 0; in setup_leaf_for_split()
3572 btrfs_unlock_up_safe(path, 1); in setup_leaf_for_split()
3575 path->keep_locks = 0; in setup_leaf_for_split()
3579 static noinline int split_item(struct btrfs_path *path, in split_item() argument
3593 leaf = path->nodes[0]; in split_item()
3596 item = btrfs_item_nr(path->slots[0]); in split_item()
3605 path->slots[0]), item_size); in split_item()
3607 slot = path->slots[0] + 1; in split_item()
3632 btrfs_item_ptr_offset(leaf, path->slots[0]), in split_item()
3663 struct btrfs_path *path, in btrfs_split_item() argument
3668 ret = setup_leaf_for_split(trans, root, path, in btrfs_split_item()
3673 ret = split_item(path, new_key, split_offset); in btrfs_split_item()
3687 struct btrfs_path *path, in btrfs_duplicate_item() argument
3694 leaf = path->nodes[0]; in btrfs_duplicate_item()
3695 item_size = btrfs_item_size_nr(leaf, path->slots[0]); in btrfs_duplicate_item()
3696 ret = setup_leaf_for_split(trans, root, path, in btrfs_duplicate_item()
3701 path->slots[0]++; in btrfs_duplicate_item()
3702 setup_items_for_insert(root, path, new_key, &item_size, 1); in btrfs_duplicate_item()
3703 leaf = path->nodes[0]; in btrfs_duplicate_item()
3705 btrfs_item_ptr_offset(leaf, path->slots[0]), in btrfs_duplicate_item()
3706 btrfs_item_ptr_offset(leaf, path->slots[0] - 1), in btrfs_duplicate_item()
3717 void btrfs_truncate_item(struct btrfs_path *path, u32 new_size, int from_end) in btrfs_truncate_item() argument
3730 leaf = path->nodes[0]; in btrfs_truncate_item()
3731 slot = path->slots[0]; in btrfs_truncate_item()
3797 fixup_low_keys(path, &disk_key, 1); in btrfs_truncate_item()
3813 void btrfs_extend_item(struct btrfs_path *path, u32 data_size) in btrfs_extend_item() argument
3825 leaf = path->nodes[0]; in btrfs_extend_item()
3834 slot = path->slots[0]; in btrfs_extend_item()
3886 void setup_items_for_insert(struct btrfs_root *root, struct btrfs_path *path, in setup_items_for_insert() argument
3906 if (path->slots[0] == 0) { in setup_items_for_insert()
3908 fixup_low_keys(path, &disk_key, 1); in setup_items_for_insert()
3910 btrfs_unlock_up_safe(path, 1); in setup_items_for_insert()
3912 leaf = path->nodes[0]; in setup_items_for_insert()
3913 slot = path->slots[0]; in setup_items_for_insert()
3985 struct btrfs_path *path, in btrfs_insert_empty_items() argument
3999 ret = btrfs_search_slot(trans, root, cpu_key, path, total_size, 1); in btrfs_insert_empty_items()
4005 slot = path->slots[0]; in btrfs_insert_empty_items()
4008 setup_items_for_insert(root, path, cpu_key, data_size, nr); in btrfs_insert_empty_items()
4021 struct btrfs_path *path; in btrfs_insert_item() local
4025 path = btrfs_alloc_path(); in btrfs_insert_item()
4026 if (!path) in btrfs_insert_item()
4028 ret = btrfs_insert_empty_item(trans, root, path, cpu_key, data_size); in btrfs_insert_item()
4030 leaf = path->nodes[0]; in btrfs_insert_item()
4031 ptr = btrfs_item_ptr_offset(leaf, path->slots[0]); in btrfs_insert_item()
4035 btrfs_free_path(path); in btrfs_insert_item()
4045 static void del_ptr(struct btrfs_root *root, struct btrfs_path *path, in del_ptr() argument
4048 struct extent_buffer *parent = path->nodes[level]; in del_ptr()
4080 fixup_low_keys(path, &disk_key, level + 1); in del_ptr()
4097 struct btrfs_path *path, in btrfs_del_leaf() argument
4101 del_ptr(root, path, 1, path->slots[1]); in btrfs_del_leaf()
4107 btrfs_unlock_up_safe(path, 0); in btrfs_del_leaf()
4120 struct btrfs_path *path, int slot, int nr) in btrfs_del_items() argument
4132 leaf = path->nodes[0]; in btrfs_del_items()
4172 btrfs_del_leaf(trans, root, path, leaf); in btrfs_del_items()
4180 fixup_low_keys(path, &disk_key, 1); in btrfs_del_items()
4189 slot = path->slots[1]; in btrfs_del_items()
4192 wret = push_leaf_left(trans, root, path, 1, 1, in btrfs_del_items()
4197 if (path->nodes[0] == leaf && in btrfs_del_items()
4199 wret = push_leaf_right(trans, root, path, 1, in btrfs_del_items()
4206 path->slots[1] = slot; in btrfs_del_items()
4207 btrfs_del_leaf(trans, root, path, leaf); in btrfs_del_items()
4216 if (path->nodes[0] == leaf) in btrfs_del_items()
4235 int btrfs_prev_leaf(struct btrfs_root *root, struct btrfs_path *path) in btrfs_prev_leaf() argument
4242 btrfs_item_key_to_cpu(path->nodes[0], &key, 0); in btrfs_prev_leaf()
4258 btrfs_release_path(path); in btrfs_prev_leaf()
4259 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in btrfs_prev_leaf()
4274 if (path->slots[0] < btrfs_header_nritems(path->nodes[0])) { in btrfs_prev_leaf()
4275 btrfs_item_key(path->nodes[0], &found_key, path->slots[0]); in btrfs_prev_leaf()
4278 if (path->slots[0] > 0) { in btrfs_prev_leaf()
4279 path->slots[0]--; in btrfs_prev_leaf()
4290 btrfs_item_key(path->nodes[0], &found_key, 0); in btrfs_prev_leaf()
4327 struct btrfs_path *path, in btrfs_search_forward() argument
4337 int keep_locks = path->keep_locks; in btrfs_search_forward()
4339 path->keep_locks = 1; in btrfs_search_forward()
4343 WARN_ON(path->nodes[level]); in btrfs_search_forward()
4344 path->nodes[level] = cur; in btrfs_search_forward()
4345 path->locks[level] = BTRFS_READ_LOCK; in btrfs_search_forward()
4361 if (level == path->lowest_level) { in btrfs_search_forward()
4365 path->slots[level] = slot; in btrfs_search_forward()
4391 path->slots[level] = slot; in btrfs_search_forward()
4392 sret = btrfs_find_next_key(root, path, min_key, level, in btrfs_search_forward()
4395 btrfs_release_path(path); in btrfs_search_forward()
4403 path->slots[level] = slot; in btrfs_search_forward()
4404 if (level == path->lowest_level) { in btrfs_search_forward()
4416 path->locks[level - 1] = BTRFS_READ_LOCK; in btrfs_search_forward()
4417 path->nodes[level - 1] = cur; in btrfs_search_forward()
4418 unlock_up(path, level, 1, 0, NULL); in btrfs_search_forward()
4421 path->keep_locks = keep_locks; in btrfs_search_forward()
4423 btrfs_unlock_up_safe(path, path->lowest_level + 1); in btrfs_search_forward()
4440 int btrfs_find_next_key(struct btrfs_root *root, struct btrfs_path *path, in btrfs_find_next_key() argument
4446 WARN_ON(!path->keep_locks && !path->skip_locking); in btrfs_find_next_key()
4448 if (!path->nodes[level]) in btrfs_find_next_key()
4451 slot = path->slots[level] + 1; in btrfs_find_next_key()
4452 c = path->nodes[level]; in btrfs_find_next_key()
4459 !path->nodes[level + 1]) in btrfs_find_next_key()
4462 if (path->locks[level + 1] || path->skip_locking) { in btrfs_find_next_key()
4473 orig_lowest = path->lowest_level; in btrfs_find_next_key()
4474 btrfs_release_path(path); in btrfs_find_next_key()
4475 path->lowest_level = level; in btrfs_find_next_key()
4476 ret = btrfs_search_slot(NULL, root, &cur_key, path, in btrfs_find_next_key()
4478 path->lowest_level = orig_lowest; in btrfs_find_next_key()
4482 c = path->nodes[level]; in btrfs_find_next_key()
4483 slot = path->slots[level]; in btrfs_find_next_key()
4505 int btrfs_next_old_leaf(struct btrfs_root *root, struct btrfs_path *path, in btrfs_next_old_leaf() argument
4519 nritems = btrfs_header_nritems(path->nodes[0]); in btrfs_next_old_leaf()
4523 btrfs_item_key_to_cpu(path->nodes[0], &key, nritems - 1); in btrfs_next_old_leaf()
4527 btrfs_release_path(path); in btrfs_next_old_leaf()
4529 path->keep_locks = 1; in btrfs_next_old_leaf()
4532 ret = btrfs_search_old_slot(root, &key, path, time_seq); in btrfs_next_old_leaf()
4534 if (path->need_commit_sem) { in btrfs_next_old_leaf()
4535 path->need_commit_sem = 0; in btrfs_next_old_leaf()
4539 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in btrfs_next_old_leaf()
4541 path->keep_locks = 0; in btrfs_next_old_leaf()
4546 nritems = btrfs_header_nritems(path->nodes[0]); in btrfs_next_old_leaf()
4553 if (nritems > 0 && path->slots[0] < nritems - 1) { in btrfs_next_old_leaf()
4555 path->slots[0]++; in btrfs_next_old_leaf()
4573 if (nritems > 0 && ret > 0 && path->slots[0] == nritems - 1) { in btrfs_next_old_leaf()
4579 if (!path->nodes[level]) { in btrfs_next_old_leaf()
4584 slot = path->slots[level] + 1; in btrfs_next_old_leaf()
4585 c = path->nodes[level]; in btrfs_next_old_leaf()
4602 if (path->locks[level]) { in btrfs_next_old_leaf()
4603 btrfs_tree_read_unlock(path->nodes[i]); in btrfs_next_old_leaf()
4604 path->locks[i] = 0; in btrfs_next_old_leaf()
4606 free_extent_buffer(path->nodes[i]); in btrfs_next_old_leaf()
4607 path->nodes[i] = NULL; in btrfs_next_old_leaf()
4611 ret = read_block_for_search(root, path, &next, level, in btrfs_next_old_leaf()
4617 btrfs_release_path(path); in btrfs_next_old_leaf()
4621 if (!path->skip_locking) { in btrfs_next_old_leaf()
4632 btrfs_release_path(path); in btrfs_next_old_leaf()
4641 path->slots[level] = slot; in btrfs_next_old_leaf()
4644 path->nodes[level] = next; in btrfs_next_old_leaf()
4645 path->slots[level] = 0; in btrfs_next_old_leaf()
4646 if (!path->skip_locking) in btrfs_next_old_leaf()
4647 path->locks[level] = BTRFS_READ_LOCK; in btrfs_next_old_leaf()
4651 ret = read_block_for_search(root, path, &next, level, in btrfs_next_old_leaf()
4657 btrfs_release_path(path); in btrfs_next_old_leaf()
4661 if (!path->skip_locking) in btrfs_next_old_leaf()
4666 unlock_up(path, 0, 1, 0, NULL); in btrfs_next_old_leaf()
4670 path->need_commit_sem = 1; in btrfs_next_old_leaf()
4671 ret2 = finish_need_commit_sem_search(path); in btrfs_next_old_leaf()
4687 struct btrfs_path *path, u64 min_objectid, in btrfs_previous_item() argument
4696 if (path->slots[0] == 0) { in btrfs_previous_item()
4697 ret = btrfs_prev_leaf(root, path); in btrfs_previous_item()
4701 path->slots[0]--; in btrfs_previous_item()
4703 leaf = path->nodes[0]; in btrfs_previous_item()
4707 if (path->slots[0] == nritems) in btrfs_previous_item()
4708 path->slots[0]--; in btrfs_previous_item()
4710 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); in btrfs_previous_item()
4729 struct btrfs_path *path, u64 min_objectid) in btrfs_previous_extent_item() argument
4737 if (path->slots[0] == 0) { in btrfs_previous_extent_item()
4738 ret = btrfs_prev_leaf(root, path); in btrfs_previous_extent_item()
4742 path->slots[0]--; in btrfs_previous_extent_item()
4744 leaf = path->nodes[0]; in btrfs_previous_extent_item()
4748 if (path->slots[0] == nritems) in btrfs_previous_extent_item()
4749 path->slots[0]--; in btrfs_previous_extent_item()
4751 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); in btrfs_previous_extent_item()