Lines Matching defs:path
56 static int find_next_key(struct btrfs_path *path, int level,
90 struct btrfs_path *path;
92 path = btrfs_alloc_path();
93 if (!path)
99 ret = btrfs_search_slot(NULL, fs_info->extent_root, &key, path, 0, 0);
100 btrfs_free_path(path);
119 struct btrfs_path *path;
137 path = btrfs_alloc_path();
138 if (!path)
142 path->skip_locking = 1;
143 path->search_commit_root = 1;
154 ret = btrfs_search_slot(trans, fs_info->extent_root, &key, path, 0, 0);
159 if (path->slots[0]) {
160 path->slots[0]--;
161 btrfs_item_key_to_cpu(path->nodes[0], &key,
162 path->slots[0]);
171 leaf = path->nodes[0];
172 item_size = btrfs_item_size_nr(leaf, path->slots[0]);
174 ei = btrfs_item_ptr(leaf, path->slots[0],
207 btrfs_release_path(path);
236 btrfs_free_path(path);
439 struct btrfs_path *path,
464 ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
476 leaf = path->nodes[0];
479 if (path->slots[0] >= nritems) {
480 ret = btrfs_next_leaf(root, path);
486 leaf = path->nodes[0];
491 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
496 ref = btrfs_item_ptr(leaf, path->slots[0],
502 btrfs_release_path(path);
508 path->slots[0]++;
515 struct btrfs_path *path,
539 ret = btrfs_insert_empty_item(trans, root, path, &key, size);
543 leaf = path->nodes[0];
546 ref = btrfs_item_ptr(leaf, path->slots[0],
558 ref = btrfs_item_ptr(leaf, path->slots[0],
563 btrfs_release_path(path);
565 ret = btrfs_insert_empty_item(trans, root, path, &key,
570 leaf = path->nodes[0];
572 ref = btrfs_item_ptr(leaf, path->slots[0],
589 btrfs_release_path(path);
594 struct btrfs_path *path,
604 leaf = path->nodes[0];
605 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
608 ref1 = btrfs_item_ptr(leaf, path->slots[0],
612 ref2 = btrfs_item_ptr(leaf, path->slots[0],
627 ret = btrfs_del_item(trans, trans->fs_info->extent_root, path);
639 static noinline u32 extent_data_ref_count(struct btrfs_path *path,
649 leaf = path->nodes[0];
650 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
668 ref1 = btrfs_item_ptr(leaf, path->slots[0],
672 ref2 = btrfs_item_ptr(leaf, path->slots[0],
682 struct btrfs_path *path,
699 ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
706 struct btrfs_path *path,
723 path, &key, 0);
724 btrfs_release_path(path);
745 static int find_next_key(struct btrfs_path *path, int level,
750 if (!path->nodes[level])
752 if (path->slots[level] + 1 >=
753 btrfs_header_nritems(path->nodes[level]))
756 btrfs_item_key_to_cpu(path->nodes[level], key,
757 path->slots[level] + 1);
759 btrfs_node_key_to_cpu(path->nodes[level], key,
760 path->slots[level] + 1);
773 * if insert is true and there are too many inline back refs, the path
781 struct btrfs_path *path,
812 path->keep_locks = 1;
826 ret = btrfs_search_slot(trans, root, &key, path, extra_size, 1);
838 if (path->slots[0]) {
839 path->slots[0]--;
840 btrfs_item_key_to_cpu(path->nodes[0], &key,
841 path->slots[0]);
851 btrfs_release_path(path);
860 btrfs_print_leaf(path->nodes[0]);
869 leaf = path->nodes[0];
870 item_size = btrfs_item_size_nr(leaf, path->slots[0]);
878 ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
958 if (find_next_key(path, 0, &key) == 0 &&
968 path->keep_locks = 0;
969 btrfs_unlock_up_safe(path, 1);
979 struct btrfs_path *path,
994 leaf = path->nodes[0];
995 ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
1001 btrfs_extend_item(path, size);
1003 ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
1011 end = (unsigned long)ei + btrfs_item_size_nr(leaf, path->slots[0]);
1039 struct btrfs_path *path,
1046 ret = lookup_inline_extent_backref(trans, path, ref_ret, bytenr,
1052 btrfs_release_path(path);
1056 ret = lookup_tree_block_ref(trans, path, bytenr, parent,
1059 ret = lookup_extent_data_ref(trans, path, bytenr, parent,
1069 void update_inline_extent_backref(struct btrfs_path *path,
1075 struct extent_buffer *leaf = path->nodes[0];
1086 ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
1123 item_size = btrfs_item_size_nr(leaf, path->slots[0]);
1130 btrfs_truncate_item(path, item_size, 1);
1137 struct btrfs_path *path,
1146 ret = lookup_inline_extent_backref(trans, path, &iref, bytenr,
1161 "path->slots[0]=%d path->nodes[0]:", path->slots[0]);
1162 btrfs_print_leaf(path->nodes[0]);
1166 update_inline_extent_backref(path, iref, refs_to_add,
1169 setup_inline_extent_backref(trans->fs_info, path, iref, parent,
1178 struct btrfs_path *path,
1186 update_inline_extent_backref(path, iref, -refs_to_drop, NULL,
1189 ret = remove_extent_data_ref(trans, path, refs_to_drop,
1193 ret = btrfs_del_item(trans, trans->fs_info->extent_root, path);
1424 struct btrfs_path *path;
1433 path = btrfs_alloc_path();
1434 if (!path)
1437 path->leave_spinning = 1;
1438 /* this will setup the path even if it fails to insert the back ref */
1439 ret = insert_inline_extent_backref(trans, path, bytenr, num_bytes,
1450 leaf = path->nodes[0];
1451 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
1452 item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
1459 btrfs_release_path(path);
1461 path->leave_spinning = 1;
1465 ret = insert_tree_block_ref(trans, path, bytenr, parent,
1468 ret = insert_extent_data_ref(trans, path, bytenr, parent,
1475 btrfs_free_path(path);
1548 struct btrfs_path *path;
1562 path = btrfs_alloc_path();
1563 if (!path)
1577 path->leave_spinning = 1;
1578 ret = btrfs_search_slot(trans, fs_info->extent_root, &key, path, 0, 1);
1585 if (path->slots[0] > 0) {
1586 path->slots[0]--;
1587 btrfs_item_key_to_cpu(path->nodes[0], &key,
1588 path->slots[0]);
1595 btrfs_release_path(path);
1609 leaf = path->nodes[0];
1610 item_size = btrfs_item_size_nr(leaf, path->slots[0]);
1619 ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
1624 btrfs_free_path(path);
2211 struct btrfs_path *path,
2243 btrfs_release_path(path);
2291 struct btrfs_path *path,
2310 ret = btrfs_search_slot(NULL, extent_root, &key, path, 0, 0);
2316 if (path->slots[0] == 0)
2319 path->slots[0]--;
2320 leaf = path->nodes[0];
2321 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
2327 item_size = btrfs_item_size_nr(leaf, path->slots[0]);
2328 ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
2368 struct btrfs_path *path;
2371 path = btrfs_alloc_path();
2372 if (!path)
2376 ret = check_committed_ref(root, path, objectid,
2381 ret = check_delayed_ref(root, path, objectid, offset, bytenr);
2385 btrfs_free_path(path);
2961 struct btrfs_path *path;
2978 path = btrfs_alloc_path();
2979 if (!path)
2982 path->leave_spinning = 1;
2998 ret = lookup_extent_backref(trans, path, &iref, bytenr, num_bytes,
3006 * Here is a quick path to locate EXTENT/METADATA_ITEM.
3009 extent_slot = path->slots[0];
3011 btrfs_item_key_to_cpu(path->nodes[0], &key,
3026 /* Quick path didn't find the EXTEMT/METADATA_ITEM */
3027 if (path->slots[0] - extent_slot > 5)
3040 ret = remove_extent_backref(trans, path, NULL,
3047 btrfs_release_path(path);
3048 path->leave_spinning = 1;
3050 /* Slow path to locate EXTENT/METADATA_ITEM */
3061 &key, path, -1, 1);
3062 if (ret > 0 && skinny_metadata && path->slots[0]) {
3067 path->slots[0]--;
3068 btrfs_item_key_to_cpu(path->nodes[0], &key,
3069 path->slots[0]);
3081 btrfs_release_path(path);
3083 &key, path, -1, 1);
3091 btrfs_print_leaf(path->nodes[0]);
3097 extent_slot = path->slots[0];
3100 btrfs_print_leaf(path->nodes[0]);
3112 leaf = path->nodes[0];
3167 ret = remove_extent_backref(trans, path, iref,
3179 extent_data_ref_count(path, iref)) {
3182 extent_data_ref_count(path, iref),
3188 if (path->slots[0] != extent_slot) {
3203 if (path->slots[0] != extent_slot + 1) {
3209 path->slots[0] = extent_slot;
3215 ret = btrfs_del_items(trans, extent_root, path, path->slots[0],
3221 btrfs_release_path(path);
3244 btrfs_release_path(path);
3247 btrfs_free_path(path);
3255 btrfs_crit(info, "path->slots[0]=%d extent_slot=%d",
3256 path->slots[0], extent_slot);
3257 btrfs_print_leaf(path->nodes[0]);
3260 btrfs_free_path(path);
4361 struct btrfs_path *path;
4373 path = btrfs_alloc_path();
4374 if (!path)
4377 path->leave_spinning = 1;
4378 ret = btrfs_insert_empty_item(trans, fs_info->extent_root, path,
4381 btrfs_free_path(path);
4385 leaf = path->nodes[0];
4386 extent_item = btrfs_item_ptr(leaf, path->slots[0],
4409 btrfs_mark_buffer_dirty(path->nodes[0]);
4410 btrfs_free_path(path);
4436 struct btrfs_path *path;
4458 path = btrfs_alloc_path();
4459 if (!path)
4462 path->leave_spinning = 1;
4463 ret = btrfs_insert_empty_item(trans, fs_info->extent_root, path,
4466 btrfs_free_path(path);
4470 leaf = path->nodes[0];
4471 extent_item = btrfs_item_ptr(leaf, path->slots[0],
4499 btrfs_free_path(path);
4761 struct btrfs_path *path)
4775 if (path->slots[wc->level] < wc->reada_slot) {
4784 eb = path->nodes[wc->level];
4787 for (slot = path->slots[wc->level]; slot < nritems; slot++) {
4795 if (slot == path->slots[wc->level])
4848 struct btrfs_path *path,
4853 struct extent_buffer *eb = path->nodes[level];
4868 BUG_ON(!path->locks[level]);
4883 if (path->locks[level] && !wc->keep_locks) {
4884 btrfs_tree_unlock_rw(eb, path->locks[level]);
4885 path->locks[level] = 0;
4892 BUG_ON(!path->locks[level]);
4907 if (path->locks[level] && level > 0) {
4908 btrfs_tree_unlock_rw(eb, path->locks[level]);
4909 path->locks[level] = 0;
4922 struct btrfs_path *path;
4926 path = btrfs_alloc_path();
4927 if (!path)
4930 ret = lookup_extent_backref(trans, path, &iref, bytenr,
4933 btrfs_free_path(path);
4956 struct btrfs_path *path,
4972 generation = btrfs_node_ptr_generation(path->nodes[level],
4973 path->slots[level]);
4985 bytenr = btrfs_node_blockptr(path->nodes[level], path->slots[level]);
4986 btrfs_node_key_to_cpu(path->nodes[level], &first_key,
4987 path->slots[level]);
5026 btrfs_node_key_to_cpu(path->nodes[level], &key,
5027 path->slots[level]);
5050 reada_walk_down(trans, root, wc, path);
5070 path->nodes[level] = next;
5071 path->slots[level] = 0;
5072 path->locks[level] = BTRFS_WRITE_LOCK_BLOCKING;
5082 parent = path->nodes[level]->start;
5085 btrfs_header_owner(path->nodes[level]));
5087 btrfs_header_owner(path->nodes[level])) {
5136 find_next_key(path, level, &wc->drop_progress);
5170 struct btrfs_path *path,
5176 struct extent_buffer *eb = path->nodes[level];
5184 ret = find_next_key(path, level + 1, &wc->update_progress);
5190 path->slots[level] = 0;
5197 if (!path->locks[level]) {
5201 path->locks[level] = BTRFS_WRITE_LOCK_BLOCKING;
5208 btrfs_tree_unlock_rw(eb, path->locks[level]);
5209 path->locks[level] = 0;
5214 btrfs_tree_unlock_rw(eb, path->locks[level]);
5215 path->locks[level] = 0;
5222 BUG_ON(wc->refs[level] > 1 && !path->locks[level]);
5241 if (!path->locks[level] &&
5245 path->locks[level] = BTRFS_WRITE_LOCK_BLOCKING;
5257 parent = path->nodes[level + 1]->start;
5259 btrfs_header_owner(path->nodes[level + 1]))
5277 struct btrfs_path *path,
5285 ret = walk_down_proc(trans, root, path, wc, lookup_info);
5292 if (path->slots[level] >=
5293 btrfs_header_nritems(path->nodes[level]))
5296 ret = do_walk_down(trans, root, path, wc, &lookup_info);
5298 path->slots[level]++;
5309 struct btrfs_path *path,
5315 path->slots[level] = btrfs_header_nritems(path->nodes[level]);
5316 while (level < max_level && path->nodes[level]) {
5318 if (path->slots[level] + 1 <
5319 btrfs_header_nritems(path->nodes[level])) {
5320 path->slots[level]++;
5323 ret = walk_up_proc(trans, root, path, wc);
5329 if (path->locks[level]) {
5330 btrfs_tree_unlock_rw(path->nodes[level],
5331 path->locks[level]);
5332 path->locks[level] = 0;
5334 free_extent_buffer(path->nodes[level]);
5335 path->nodes[level] = NULL;
5358 struct btrfs_path *path;
5371 path = btrfs_alloc_path();
5372 if (!path) {
5379 btrfs_free_path(path);
5412 path->nodes[level] = btrfs_lock_root_node(root);
5413 btrfs_set_lock_blocking_write(path->nodes[level]);
5414 path->slots[level] = 0;
5415 path->locks[level] = BTRFS_WRITE_LOCK_BLOCKING;
5425 path->lowest_level = level;
5426 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
5427 path->lowest_level = 0;
5435 * unlock our path, this is safe because only this
5438 btrfs_unlock_up_safe(path, 0);
5442 btrfs_tree_lock(path->nodes[level]);
5443 btrfs_set_lock_blocking_write(path->nodes[level]);
5444 path->locks[level] = BTRFS_WRITE_LOCK_BLOCKING;
5447 path->nodes[level]->start,
5459 btrfs_tree_unlock(path->nodes[level]);
5460 path->locks[level] = 0;
5476 ret = walk_down_tree(trans, root, path, wc);
5482 ret = walk_up_tree(trans, root, path, wc, BTRFS_MAX_LEVEL);
5495 btrfs_node_key_to_cpu(path->nodes[wc->drop_level],
5497 path->slots[wc->drop_level]);
5538 btrfs_release_path(path);
5550 ret = btrfs_find_root(tree_root, &root->root_key, path,
5584 btrfs_free_path(path);
5610 struct btrfs_path *path;
5619 path = btrfs_alloc_path();
5620 if (!path)
5625 btrfs_free_path(path);
5632 path->nodes[parent_level] = parent;
5633 path->slots[parent_level] = btrfs_header_nritems(parent);
5637 path->nodes[level] = node;
5638 path->slots[level] = 0;
5639 path->locks[level] = BTRFS_WRITE_LOCK_BLOCKING;
5651 wret = walk_down_tree(trans, root, path, wc);
5657 wret = walk_up_tree(trans, root, path, wc, parent_level);
5665 btrfs_free_path(path);