Lines Matching defs:path
37 * A fs_path is a helper to dynamically build path names with unknown size.
39 * It allows fast adding of path elements on the right side (normal path) and
40 * fast adding to the left side (reversed path). A reversed path can also be
55 * Average path length does not exceed 200 bytes, we'll have
415 * The real size of the buffer is bigger, this will let the fast path
538 struct btrfs_path *path;
540 path = btrfs_alloc_path();
541 if (!path)
543 path->search_commit_root = 1;
544 path->skip_locking = 1;
545 path->need_commit_sem = 1;
546 return path;
749 struct fs_path *path, struct fs_path *lnk)
754 btrfs_debug(fs_info, "send_link %s -> %s", path->start, lnk->start);
760 TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, path);
773 static int send_unlink(struct send_ctx *sctx, struct fs_path *path)
778 btrfs_debug(fs_info, "send_unlink %s", path->start);
784 TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, path);
796 static int send_rmdir(struct send_ctx *sctx, struct fs_path *path)
801 btrfs_debug(fs_info, "send_rmdir %s", path->start);
807 TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, path);
819 static int __get_inode_info(struct btrfs_root *root, struct btrfs_path *path,
830 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
837 ii = btrfs_item_ptr(path->nodes[0], path->slots[0],
840 *size = btrfs_inode_size(path->nodes[0], ii);
842 *gen = btrfs_inode_generation(path->nodes[0], ii);
844 *mode = btrfs_inode_mode(path->nodes[0], ii);
846 *uid = btrfs_inode_uid(path->nodes[0], ii);
848 *gid = btrfs_inode_gid(path->nodes[0], ii);
850 *rdev = btrfs_inode_rdev(path->nodes[0], ii);
860 struct btrfs_path *path;
863 path = alloc_path_for_send();
864 if (!path)
866 ret = __get_inode_info(root, path, ino, size, gen, mode, uid, gid,
868 btrfs_free_path(path);
882 * path must point to the INODE_REF or INODE_EXTREF when called.
884 static int iterate_inode_ref(struct btrfs_root *root, struct btrfs_path *path,
888 struct extent_buffer *eb = path->nodes[0];
896 int slot = path->slots[0];
1002 * path must point to the dir item when called.
1004 static int iterate_dir_item(struct btrfs_root *root, struct btrfs_path *path,
1036 eb = path->nodes[0];
1037 slot = path->slots[0];
1132 * Retrieve the first path of an inode. If an inode has more then one
1136 u64 ino, struct fs_path *path)
1146 fs_path_reset(path);
1168 __copy_first_ref, path);
1295 * path must point to the extent item when called.
1298 struct btrfs_path *path,
1312 struct extent_buffer *eb = path->nodes[0];
1325 /* We only use this path under the commit sem */
1344 fi = btrfs_item_ptr(eb, path->slots[0],
1486 struct btrfs_path *path;
1494 path = alloc_path_for_send();
1495 if (!path)
1501 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
1520 ei = btrfs_item_ptr(path->nodes[0], path->slots[0],
1522 type = btrfs_file_extent_type(path->nodes[0], ei);
1523 compression = btrfs_file_extent_compression(path->nodes[0], ei);
1528 len = btrfs_file_extent_ram_bytes(path->nodes[0], ei);
1530 ret = fs_path_add_from_extent_buffer(dest, path->nodes[0], off, len);
1533 btrfs_free_path(path);
1546 struct btrfs_path *path;
1552 path = alloc_path_for_send();
1553 if (!path)
1562 path, BTRFS_FIRST_FREE_OBJECTID,
1564 btrfs_release_path(path);
1582 path, BTRFS_FIRST_FREE_OBJECTID,
1584 btrfs_release_path(path);
1601 btrfs_free_path(path);
1712 struct btrfs_path *path;
1714 path = alloc_path_for_send();
1715 if (!path)
1718 di = btrfs_lookup_dir_item(NULL, root, path,
1724 btrfs_dir_item_key_to_cpu(path->nodes[0], di, &key);
1730 *found_type = btrfs_dir_type(path->nodes[0], di);
1733 btrfs_free_path(path);
1747 struct btrfs_path *path;
1751 path = alloc_path_for_send();
1752 if (!path)
1759 ret = btrfs_search_slot_for_read(root, &key, path, 1, 0);
1763 btrfs_item_key_to_cpu(path->nodes[0], &found_key,
1764 path->slots[0]);
1774 iref = btrfs_item_ptr(path->nodes[0], path->slots[0],
1776 len = btrfs_inode_ref_name_len(path->nodes[0], iref);
1777 ret = fs_path_add_from_extent_buffer(name, path->nodes[0],
1783 extref = btrfs_item_ptr(path->nodes[0], path->slots[0],
1785 len = btrfs_inode_extref_name_len(path->nodes[0], extref);
1786 ret = fs_path_add_from_extent_buffer(name, path->nodes[0],
1788 parent_dir = btrfs_inode_extref_parent(path->nodes[0], extref);
1792 btrfs_release_path(path);
1804 btrfs_free_path(path);
1989 * if it has to use the path as returned by get_cur_path or the orphan name.
2258 * We walk the path up to the root. For every inode in between, we check if it
2269 * tried to get the path to the dir items, it would get a path inside that
2352 struct btrfs_path *path;
2359 path = btrfs_alloc_path();
2360 if (!path)
2365 btrfs_free_path(path);
2374 &key, path, 1, 0);
2382 leaf = path->nodes[0];
2383 btrfs_item_key_to_cpu(leaf, &key, path->slots[0]);
2389 ref = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_root_ref);
2392 btrfs_release_path(path);
2430 btrfs_free_path(path);
2533 struct btrfs_path *path = NULL;
2544 path = alloc_path_for_send();
2545 if (!path) {
2553 ret = btrfs_search_slot(NULL, sctx->send_root, &key, path, 0, 0);
2559 eb = path->nodes[0];
2560 slot = path->slots[0];
2581 btrfs_free_path(path);
2587 * a valid path yet because we did not process the refs yet. So, the inode
2678 struct btrfs_path *path = NULL;
2686 path = alloc_path_for_send();
2687 if (!path) {
2695 ret = btrfs_search_slot(NULL, sctx->send_root, &key, path, 0, 0);
2700 eb = path->nodes[0];
2701 slot = path->slots[0];
2703 ret = btrfs_next_leaf(sctx->send_root, path);
2729 path->slots[0]++;
2733 btrfs_free_path(path);
2774 static void set_ref_path(struct recorded_ref *ref, struct fs_path *path)
2776 ref->full_path = path;
2787 u64 dir_gen, struct fs_path *path)
2797 set_ref_path(ref, path);
2842 struct fs_path *path)
2855 ret = send_rename(sctx, path, orphan);
2944 struct btrfs_path *path;
2957 path = alloc_path_for_send();
2958 if (!path)
2969 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
2976 if (path->slots[0] >= btrfs_header_nritems(path->nodes[0])) {
2977 ret = btrfs_next_leaf(root, path);
2984 btrfs_item_key_to_cpu(path->nodes[0], &found_key,
2985 path->slots[0]);
2990 di = btrfs_item_ptr(path->nodes[0], path->slots[0],
2992 btrfs_dir_item_key_to_cpu(path->nodes[0], di, &loc);
3021 path->slots[0]++;
3028 btrfs_free_path(path);
3473 struct btrfs_path *path;
3485 path = alloc_path_for_send();
3486 if (!path)
3493 ret = btrfs_search_slot(NULL, sctx->parent_root, &key, path, 0, 0);
3501 di = btrfs_match_dir_item_name(fs_info, path, parent_ref->name,
3515 btrfs_dir_item_key_to_cpu(path->nodes[0], di, &di_key);
3552 btrfs_free_path(path);
3590 * possible path (in case ino2 is not a directory and has multiple hard links).
3601 struct btrfs_path *path = NULL;
3611 path = alloc_path_for_send();
3612 if (!path) {
3621 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
3626 struct extent_buffer *leaf = path->nodes[0];
3627 int slot = path->slots[0];
3632 ret = btrfs_next_leaf(root, path);
3678 path->slots[0]++;
3682 btrfs_free_path(path);
3711 * that ancestor is processed to avoid path build infinite loops (done
3725 * the send stream or getting into infinite path build
3798 * we use here a new path.
3825 * inode, we might need to orphanize another inode, but the path we have in the
3849 * collecting all its new references we set a full path of "d1/d2" for its new
3855 * orphanization we use a source path corresponding to the path we stored in the
3857 * receiver fail since the path component "d1/" no longer exists, it was renamed
3859 * must recompute the path in the new reference and use it for the new
3927 * get the path of the first ref as it would like while receiving at
3961 * that the path used for link and rename commands don't use an
3988 * path in "valid_path" already contains the orphanized name for 259.
4037 * the source path when performing its rename
4066 * current path of cur_ino) again because it
4086 * processed, recompute the current path because
4087 * that directory may be part of the path.
4195 * so our reference's full path, which was
4268 * to recompute the full path for deleted names,
4269 * since any such path was computed before we
4467 struct btrfs_path *path,
4480 ret = iterate_inode_ref(root, path, key, 0, __find_iref, &ctx);
4563 struct btrfs_path *path;
4571 path = alloc_path_for_send();
4572 if (!path)
4591 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
4596 eb = path->nodes[0];
4597 slot = path->slots[0];
4599 ret = btrfs_next_leaf(root, path);
4614 ret = iterate_inode_ref(root, path, &found_key, 0, cb, sctx);
4618 path->slots[0]++;
4620 btrfs_release_path(path);
4629 btrfs_free_path(path);
4634 struct fs_path *path,
4644 TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, path);
4656 struct fs_path *path,
4665 TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, path);
4788 struct btrfs_path *path,
4802 ret = iterate_dir_item(root, path, __find_xattr, &ctx);
4886 struct btrfs_path *path;
4892 path = alloc_path_for_send();
4893 if (!path)
4901 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
4906 eb = path->nodes[0];
4907 slot = path->slots[0];
4909 ret = btrfs_next_leaf(root, path);
4926 ret = iterate_dir_item(root, path, __process_new_xattr, sctx);
4930 path->slots[0]++;
4934 btrfs_free_path(path);
5265 struct btrfs_path *path;
5273 path = alloc_path_for_send();
5274 if (!path)
5277 di = btrfs_lookup_xattr(NULL, sctx->send_root, path, sctx->cur_ino,
5287 leaf = path->nodes[0];
5309 btrfs_free_path(path);
5320 struct btrfs_path *path;
5344 path = alloc_path_for_send();
5345 if (!path)
5352 ret = __get_inode_info(clone_root->root, path, clone_root->ino,
5354 btrfs_release_path(path);
5383 ret = btrfs_search_slot(NULL, clone_root->root, &key, path, 0, 0);
5386 if (ret > 0 && path->slots[0] > 0) {
5387 btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0] - 1);
5390 path->slots[0]--;
5394 struct extent_buffer *leaf = path->nodes[0];
5395 int slot = path->slots[0];
5404 ret = btrfs_next_leaf(clone_root->root, path);
5569 path->slots[0]++;
5577 btrfs_free_path(path);
5582 struct btrfs_path *path,
5591 end = min_t(u64, btrfs_file_extent_end(path), sctx->cur_inode_size);
5600 ei = btrfs_item_ptr(path->nodes[0], path->slots[0],
5602 disk_byte = btrfs_file_extent_disk_bytenr(path->nodes[0], ei);
5603 data_offset = btrfs_file_extent_offset(path->nodes[0], ei);
5619 struct btrfs_path *path = NULL;
5636 path = alloc_path_for_send();
5637 if (!path)
5678 ret = btrfs_search_slot_for_read(sctx->parent_root, &key, path, 0, 0);
5689 eb = path->nodes[0];
5690 slot = path->slots[0];
5768 ret = btrfs_next_item(sctx->parent_root, path);
5772 eb = path->nodes[0];
5773 slot = path->slots[0];
5799 btrfs_free_path(path);
5805 struct btrfs_path *path;
5810 path = alloc_path_for_send();
5811 if (!path)
5819 ret = btrfs_search_slot_for_read(root, &key, path, 0, 1);
5823 btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]);
5827 sctx->cur_inode_last_extent = btrfs_file_extent_end(path);
5829 btrfs_free_path(path);
5837 struct btrfs_path *path;
5843 path = alloc_path_for_send();
5844 if (!path)
5850 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
5853 if (ret > 0 && path->slots[0] > 0)
5854 path->slots[0]--;
5857 struct extent_buffer *leaf = path->nodes[0];
5858 int slot = path->slots[0];
5863 ret = btrfs_next_leaf(root, path);
5881 extent_end = btrfs_file_extent_end(path);
5891 path->slots[0]++;
5895 btrfs_free_path(path);
5899 static int maybe_send_hole(struct send_ctx *sctx, struct btrfs_path *path,
5913 if (path->slots[0] == 0 &&
5938 sctx->cur_inode_last_extent = btrfs_file_extent_end(path);
5943 struct btrfs_path *path,
5953 ret = is_extent_unchanged(sctx, path, key);
5964 ei = btrfs_item_ptr(path->nodes[0], path->slots[0],
5966 type = btrfs_file_extent_type(path->nodes[0], ei);
5981 if (btrfs_file_extent_disk_bytenr(path->nodes[0], ei) == 0) {
5988 ret = find_extent_clone(sctx, path, key->objectid, key->offset,
5993 ret = send_write_or_clone(sctx, path, key, found_clone);
5997 ret = maybe_send_hole(sctx, path, key);
6006 struct btrfs_path *path;
6013 path = alloc_path_for_send();
6014 if (!path)
6020 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
6025 eb = path->nodes[0];
6026 slot = path->slots[0];
6029 ret = btrfs_next_leaf(root, path);
6047 ret = process_extent(sctx, path, &found_key);
6051 path->slots[0]++;
6055 btrfs_free_path(path);
6114 * the old path (pre move/rename) of our current inode, and the
6243 struct btrfs_path *path;
6248 path = alloc_path_for_send();
6249 if (!path)
6255 ret = btrfs_search_slot(NULL, sctx->parent_root, &key, path, 0, 0);
6263 struct extent_buffer *eb = path->nodes[0];
6264 int slot = path->slots[0];
6267 ret = btrfs_next_leaf(sctx->parent_root, path);
6282 ret = iterate_inode_ref(sctx->parent_root, path, &key, 1,
6287 path->slots[0]++;
6303 btrfs_free_path(path);
6599 static int compare_refs(struct send_ctx *sctx, struct btrfs_path *path,
6619 leaf = path->nodes[0];
6620 item_size = btrfs_item_size_nr(leaf, path->slots[0]);
6621 ptr = btrfs_item_ptr_offset(leaf, path->slots[0]);
6703 struct btrfs_path *path;
6707 path = alloc_path_for_send();
6708 if (!path)
6715 ret = btrfs_search_slot_for_read(send_root, &key, path, 1, 0);
6722 eb = path->nodes[0];
6723 slot = path->slots[0];
6726 ret = changed_cb(path, NULL, &key,
6731 ret = btrfs_next_item(send_root, path);
6744 btrfs_free_path(path);
6748 static int tree_move_down(struct btrfs_path *path, int *level)
6753 eb = btrfs_read_node_slot(path->nodes[*level], path->slots[*level]);
6757 path->nodes[*level - 1] = eb;
6758 path->slots[*level - 1] = 0;
6763 static int tree_move_next_or_upnext(struct btrfs_path *path,
6768 nritems = btrfs_header_nritems(path->nodes[*level]);
6770 path->slots[*level]++;
6772 while (path->slots[*level] >= nritems) {
6777 path->slots[*level] = 0;
6778 free_extent_buffer(path->nodes[*level]);
6779 path->nodes[*level] = NULL;
6781 path->slots[*level]++;
6783 nritems = btrfs_header_nritems(path->nodes[*level]);
6793 static int tree_advance(struct btrfs_path *path,
6801 ret = tree_move_next_or_upnext(path, level, root_level);
6803 ret = tree_move_down(path, level);
6807 btrfs_item_key_to_cpu(path->nodes[*level], key,
6808 path->slots[*level]);
6810 btrfs_node_key_to_cpu(path->nodes[*level], key,
6811 path->slots[*level]);