• Home
  • Raw
  • Download

Lines Matching refs:ret

275 	int ret;  member
445 int ret; in fs_path_prepare_for_add() local
451 ret = fs_path_ensure_buf(p, new_len); in fs_path_prepare_for_add()
452 if (ret < 0) in fs_path_prepare_for_add()
469 return ret; in fs_path_prepare_for_add()
474 int ret; in fs_path_add() local
477 ret = fs_path_prepare_for_add(p, name_len, &prepared); in fs_path_add()
478 if (ret < 0) in fs_path_add()
483 return ret; in fs_path_add()
488 int ret; in fs_path_add_path() local
491 ret = fs_path_prepare_for_add(p, p2->end - p2->start, &prepared); in fs_path_add_path()
492 if (ret < 0) in fs_path_add_path()
497 return ret; in fs_path_add_path()
504 int ret; in fs_path_add_from_extent_buffer() local
507 ret = fs_path_prepare_for_add(p, len, &prepared); in fs_path_add_from_extent_buffer()
508 if (ret < 0) in fs_path_add_from_extent_buffer()
514 return ret; in fs_path_add_from_extent_buffer()
519 int ret; in fs_path_copy() local
524 ret = fs_path_add_path(p, from); in fs_path_copy()
526 return ret; in fs_path_copy()
561 int ret; in write_buf() local
565 ret = kernel_write(filp, buf + pos, len - pos, off); in write_buf()
570 if (ret < 0) in write_buf()
571 return ret; in write_buf()
572 if (ret == 0) { in write_buf()
575 pos += ret; in write_buf()
635 ret = tlv_put(sctx, attrtype, data, attrlen); \
636 if (ret < 0) \
642 ret = tlv_put_u##bits(sctx, attrtype, value); \
643 if (ret < 0) \
653 ret = tlv_put_string(sctx, attrtype, str, len); \
654 if (ret < 0) \
659 ret = tlv_put_string(sctx, attrtype, p->start, \
661 if (ret < 0) \
666 ret = tlv_put_uuid(sctx, attrtype, uuid); \
667 if (ret < 0) \
672 ret = tlv_put_btrfs_timespec(sctx, attrtype, eb, ts); \
673 if (ret < 0) \
709 int ret; in send_cmd() local
720 ret = write_buf(sctx->send_filp, sctx->send_buf, sctx->send_size, in send_cmd()
727 return ret; in send_cmd()
737 int ret; in send_rename() local
741 ret = begin_cmd(sctx, BTRFS_SEND_C_RENAME); in send_rename()
742 if (ret < 0) in send_rename()
748 ret = send_cmd(sctx); in send_rename()
752 return ret; in send_rename()
762 int ret; in send_link() local
766 ret = begin_cmd(sctx, BTRFS_SEND_C_LINK); in send_link()
767 if (ret < 0) in send_link()
773 ret = send_cmd(sctx); in send_link()
777 return ret; in send_link()
786 int ret; in send_unlink() local
790 ret = begin_cmd(sctx, BTRFS_SEND_C_UNLINK); in send_unlink()
791 if (ret < 0) in send_unlink()
796 ret = send_cmd(sctx); in send_unlink()
800 return ret; in send_unlink()
809 int ret; in send_rmdir() local
813 ret = begin_cmd(sctx, BTRFS_SEND_C_RMDIR); in send_rmdir()
814 if (ret < 0) in send_rmdir()
819 ret = send_cmd(sctx); in send_rmdir()
823 return ret; in send_rmdir()
833 int ret; in __get_inode_info() local
840 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in __get_inode_info()
841 if (ret) { in __get_inode_info()
842 if (ret > 0) in __get_inode_info()
843 ret = -ENOENT; in __get_inode_info()
844 return ret; in __get_inode_info()
862 return ret; in __get_inode_info()
871 int ret; in get_inode_info() local
876 ret = __get_inode_info(root, path, ino, size, gen, mode, uid, gid, in get_inode_info()
879 return ret; in get_inode_info()
909 int ret = 0; in iterate_inode_ref() local
962 ret = PTR_ERR(start); in iterate_inode_ref()
967 ret = fs_path_ensure_buf(p, in iterate_inode_ref()
969 if (ret < 0) in iterate_inode_ref()
976 ret = PTR_ERR(start); in iterate_inode_ref()
983 ret = fs_path_add_from_extent_buffer(p, eb, name_off, in iterate_inode_ref()
985 if (ret < 0) in iterate_inode_ref()
990 ret = iterate(num, dir, index, p, ctx); in iterate_inode_ref()
991 if (ret) in iterate_inode_ref()
999 return ret; in iterate_inode_ref()
1017 int ret = 0; in iterate_dir_item() local
1042 ret = -ENOMEM; in iterate_dir_item()
1063 ret = -ENAMETOOLONG; in iterate_dir_item()
1068 ret = -E2BIG; in iterate_dir_item()
1076 ret = -ENAMETOOLONG; in iterate_dir_item()
1097 ret = -ENOMEM; in iterate_dir_item()
1110 ret = iterate(num, &di_key, buf, name_len, buf + name_len, in iterate_dir_item()
1112 if (ret < 0) in iterate_dir_item()
1114 if (ret) { in iterate_dir_item()
1115 ret = 0; in iterate_dir_item()
1124 return ret; in iterate_dir_item()
1130 int ret; in __copy_first_ref() local
1133 ret = fs_path_copy(pt, p); in __copy_first_ref()
1134 if (ret < 0) in __copy_first_ref()
1135 return ret; in __copy_first_ref()
1148 int ret; in get_inode_path() local
1162 ret = btrfs_search_slot_for_read(root, &key, p, 1, 0); in get_inode_path()
1163 if (ret < 0) in get_inode_path()
1165 if (ret) { in get_inode_path()
1166 ret = 1; in get_inode_path()
1173 ret = -ENOENT; in get_inode_path()
1177 ret = iterate_inode_ref(root, p, &found_key, 1, in get_inode_path()
1179 if (ret < 0) in get_inode_path()
1181 ret = 0; in get_inode_path()
1185 return ret; in get_inode_path()
1311 int ret; in find_extent_clone() local
1341 ret = 0; in find_extent_clone()
1349 ret = -ENOENT; in find_extent_clone()
1357 ret = -ENOENT; in find_extent_clone()
1363 ret = extent_from_logical(fs_info, disk_byte, tmp_path, in find_extent_clone()
1367 if (ret < 0) in find_extent_clone()
1370 ret = -EIO; in find_extent_clone()
1384 ret = -ENOENT; in find_extent_clone()
1421 ret = iterate_extent_inodes(fs_info, found_key.objectid, in find_extent_clone()
1425 if (ret < 0) in find_extent_clone()
1443 ret = -ENOENT; in find_extent_clone()
1450 ret = -EIO; in find_extent_clone()
1478 ret = 0; in find_extent_clone()
1480 ret = -ENOENT; in find_extent_clone()
1485 return ret; in find_extent_clone()
1492 int ret; in read_symlink() local
1508 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in read_symlink()
1509 if (ret < 0) in read_symlink()
1511 if (ret) { in read_symlink()
1523 ret = -EIO; in read_symlink()
1537 ret = fs_path_add_from_extent_buffer(dest, path->nodes[0], off, len); in read_symlink()
1541 return ret; in read_symlink()
1552 int ret = 0; in gen_unique_name() local
1573 ret = PTR_ERR(di); in gen_unique_name()
1584 ret = 0; in gen_unique_name()
1593 ret = PTR_ERR(di); in gen_unique_name()
1605 ret = fs_path_add(dest, tmp, strlen(tmp)); in gen_unique_name()
1609 return ret; in gen_unique_name()
1622 int ret; in get_cur_inode_state() local
1628 ret = get_inode_info(sctx->send_root, ino, NULL, &left_gen, NULL, NULL, in get_cur_inode_state()
1630 if (ret < 0 && ret != -ENOENT) in get_cur_inode_state()
1632 left_ret = ret; in get_cur_inode_state()
1637 ret = get_inode_info(sctx->parent_root, ino, NULL, &right_gen, in get_cur_inode_state()
1639 if (ret < 0 && ret != -ENOENT) in get_cur_inode_state()
1641 right_ret = ret; in get_cur_inode_state()
1646 ret = inode_state_no_change; in get_cur_inode_state()
1649 ret = inode_state_did_create; in get_cur_inode_state()
1651 ret = inode_state_will_create; in get_cur_inode_state()
1654 ret = inode_state_did_delete; in get_cur_inode_state()
1656 ret = inode_state_will_delete; in get_cur_inode_state()
1658 ret = -ENOENT; in get_cur_inode_state()
1663 ret = inode_state_did_create; in get_cur_inode_state()
1665 ret = inode_state_will_create; in get_cur_inode_state()
1667 ret = -ENOENT; in get_cur_inode_state()
1672 ret = inode_state_did_delete; in get_cur_inode_state()
1674 ret = inode_state_will_delete; in get_cur_inode_state()
1676 ret = -ENOENT; in get_cur_inode_state()
1679 ret = -ENOENT; in get_cur_inode_state()
1683 return ret; in get_cur_inode_state()
1688 int ret; in is_inode_existent() local
1693 ret = get_cur_inode_state(sctx, ino, gen); in is_inode_existent()
1694 if (ret < 0) in is_inode_existent()
1697 if (ret == inode_state_no_change || in is_inode_existent()
1698 ret == inode_state_did_create || in is_inode_existent()
1699 ret == inode_state_will_delete) in is_inode_existent()
1700 ret = 1; in is_inode_existent()
1702 ret = 0; in is_inode_existent()
1705 return ret; in is_inode_existent()
1716 int ret = 0; in lookup_dir_item_inode() local
1728 ret = di ? PTR_ERR(di) : -ENOENT; in lookup_dir_item_inode()
1733 ret = -ENOENT; in lookup_dir_item_inode()
1741 return ret; in lookup_dir_item_inode()
1751 int ret; in get_first_ref() local
1766 ret = btrfs_search_slot_for_read(root, &key, path, 1, 0); in get_first_ref()
1767 if (ret < 0) in get_first_ref()
1769 if (!ret) in get_first_ref()
1772 if (ret || found_key.objectid != ino || in get_first_ref()
1775 ret = -ENOENT; in get_first_ref()
1784 ret = fs_path_add_from_extent_buffer(name, path->nodes[0], in get_first_ref()
1793 ret = fs_path_add_from_extent_buffer(name, path->nodes[0], in get_first_ref()
1797 if (ret < 0) in get_first_ref()
1802 ret = get_inode_info(root, parent_dir, NULL, dir_gen, NULL, in get_first_ref()
1804 if (ret < 0) in get_first_ref()
1812 return ret; in get_first_ref()
1819 int ret; in is_first_ref() local
1827 ret = get_first_ref(root, ino, &tmp_dir, NULL, tmp_name); in is_first_ref()
1828 if (ret < 0) in is_first_ref()
1832 ret = 0; in is_first_ref()
1836 ret = !memcmp(tmp_name->start, name, name_len); in is_first_ref()
1840 return ret; in is_first_ref()
1857 int ret = 0; in will_overwrite_ref() local
1865 ret = is_inode_existent(sctx, dir, dir_gen); in will_overwrite_ref()
1866 if (ret <= 0) in will_overwrite_ref()
1875 ret = get_inode_info(sctx->parent_root, dir, NULL, &gen, NULL, in will_overwrite_ref()
1877 if (ret < 0 && ret != -ENOENT) in will_overwrite_ref()
1879 if (ret) { in will_overwrite_ref()
1880 ret = 0; in will_overwrite_ref()
1887 ret = lookup_dir_item_inode(sctx->parent_root, dir, name, name_len, in will_overwrite_ref()
1889 if (ret < 0 && ret != -ENOENT) in will_overwrite_ref()
1891 if (ret) { in will_overwrite_ref()
1892 ret = 0; in will_overwrite_ref()
1903 ret = get_inode_info(sctx->parent_root, other_inode, NULL, in will_overwrite_ref()
1905 if (ret < 0) in will_overwrite_ref()
1908 ret = 1; in will_overwrite_ref()
1911 ret = 0; in will_overwrite_ref()
1915 return ret; in will_overwrite_ref()
1930 int ret = 0; in did_overwrite_ref() local
1938 ret = is_inode_existent(sctx, dir, dir_gen); in did_overwrite_ref()
1939 if (ret <= 0) in did_overwrite_ref()
1943 ret = get_inode_info(sctx->send_root, dir, NULL, &gen, NULL, in did_overwrite_ref()
1945 if (ret < 0 && ret != -ENOENT) in did_overwrite_ref()
1947 if (ret) { in did_overwrite_ref()
1948 ret = 0; in did_overwrite_ref()
1956 ret = lookup_dir_item_inode(sctx->send_root, dir, name, name_len, in did_overwrite_ref()
1958 if (ret < 0 && ret != -ENOENT) in did_overwrite_ref()
1960 if (ret) { in did_overwrite_ref()
1962 ret = 0; in did_overwrite_ref()
1966 ret = get_inode_info(sctx->send_root, ow_inode, NULL, &gen, NULL, NULL, in did_overwrite_ref()
1968 if (ret < 0) in did_overwrite_ref()
1972 ret = 0; in did_overwrite_ref()
1985 ret = 1; in did_overwrite_ref()
1987 ret = 0; in did_overwrite_ref()
1990 return ret; in did_overwrite_ref()
2000 int ret = 0; in did_overwrite_first_ref() local
2012 ret = get_first_ref(sctx->parent_root, ino, &dir, &dir_gen, name); in did_overwrite_first_ref()
2013 if (ret < 0) in did_overwrite_first_ref()
2016 ret = did_overwrite_ref(sctx, dir, dir_gen, ino, gen, in did_overwrite_first_ref()
2021 return ret; in did_overwrite_first_ref()
2033 int ret = 0; in name_cache_insert() local
2046 ret = radix_tree_insert(&sctx->name_cache, nce->ino, nce_head); in name_cache_insert()
2047 if (ret < 0) { in name_cache_insert()
2050 return ret; in name_cache_insert()
2057 return ret; in name_cache_insert()
2147 int ret; in __get_cur_name_and_parent() local
2172 ret = fs_path_add(dest, nce->name, nce->name_len); in __get_cur_name_and_parent()
2173 if (ret < 0) in __get_cur_name_and_parent()
2175 ret = nce->ret; in __get_cur_name_and_parent()
2185 ret = is_inode_existent(sctx, ino, gen); in __get_cur_name_and_parent()
2186 if (ret < 0) in __get_cur_name_and_parent()
2189 if (!ret) { in __get_cur_name_and_parent()
2190 ret = gen_unique_name(sctx, ino, gen, dest); in __get_cur_name_and_parent()
2191 if (ret < 0) in __get_cur_name_and_parent()
2193 ret = 1; in __get_cur_name_and_parent()
2202 ret = get_first_ref(sctx->send_root, ino, in __get_cur_name_and_parent()
2205 ret = get_first_ref(sctx->parent_root, ino, in __get_cur_name_and_parent()
2207 if (ret < 0) in __get_cur_name_and_parent()
2214 ret = did_overwrite_ref(sctx, *parent_ino, *parent_gen, ino, gen, in __get_cur_name_and_parent()
2216 if (ret < 0) in __get_cur_name_and_parent()
2218 if (ret) { in __get_cur_name_and_parent()
2220 ret = gen_unique_name(sctx, ino, gen, dest); in __get_cur_name_and_parent()
2221 if (ret < 0) in __get_cur_name_and_parent()
2223 ret = 1; in __get_cur_name_and_parent()
2232 ret = -ENOMEM; in __get_cur_name_and_parent()
2241 nce->ret = ret; in __get_cur_name_and_parent()
2251 ret = nce_ret; in __get_cur_name_and_parent()
2255 return ret; in __get_cur_name_and_parent()
2286 int ret = 0; in get_cur_path() local
2294 ret = -ENOMEM; in get_cur_path()
2307 ret = gen_unique_name(sctx, ino, gen, name); in get_cur_path()
2308 if (ret < 0) in get_cur_path()
2310 ret = fs_path_add_path(dest, name); in get_cur_path()
2316 ret = gen_unique_name(sctx, ino, gen, name); in get_cur_path()
2319 ret = get_first_ref(sctx->parent_root, ino, in get_cur_path()
2322 ret = __get_cur_name_and_parent(sctx, ino, gen, in get_cur_path()
2325 if (ret) in get_cur_path()
2329 if (ret < 0) in get_cur_path()
2332 ret = fs_path_add_path(dest, name); in get_cur_path()
2333 if (ret < 0) in get_cur_path()
2342 if (!ret) in get_cur_path()
2344 return ret; in get_cur_path()
2352 int ret; in send_subvol_begin() local
2376 ret = btrfs_search_slot_for_read(send_root->fs_info->tree_root, in send_subvol_begin()
2378 if (ret < 0) in send_subvol_begin()
2380 if (ret) { in send_subvol_begin()
2381 ret = -ENOENT; in send_subvol_begin()
2389 ret = -ENOENT; in send_subvol_begin()
2398 ret = begin_cmd(sctx, BTRFS_SEND_C_SNAPSHOT); in send_subvol_begin()
2399 if (ret < 0) in send_subvol_begin()
2402 ret = begin_cmd(sctx, BTRFS_SEND_C_SUBVOL); in send_subvol_begin()
2403 if (ret < 0) in send_subvol_begin()
2429 ret = send_cmd(sctx); in send_subvol_begin()
2435 return ret; in send_subvol_begin()
2441 int ret = 0; in send_truncate() local
2450 ret = begin_cmd(sctx, BTRFS_SEND_C_TRUNCATE); in send_truncate()
2451 if (ret < 0) in send_truncate()
2454 ret = get_cur_path(sctx, ino, gen, p); in send_truncate()
2455 if (ret < 0) in send_truncate()
2460 ret = send_cmd(sctx); in send_truncate()
2465 return ret; in send_truncate()
2471 int ret = 0; in send_chmod() local
2480 ret = begin_cmd(sctx, BTRFS_SEND_C_CHMOD); in send_chmod()
2481 if (ret < 0) in send_chmod()
2484 ret = get_cur_path(sctx, ino, gen, p); in send_chmod()
2485 if (ret < 0) in send_chmod()
2490 ret = send_cmd(sctx); in send_chmod()
2495 return ret; in send_chmod()
2501 int ret = 0; in send_chown() local
2511 ret = begin_cmd(sctx, BTRFS_SEND_C_CHOWN); in send_chown()
2512 if (ret < 0) in send_chown()
2515 ret = get_cur_path(sctx, ino, gen, p); in send_chown()
2516 if (ret < 0) in send_chown()
2522 ret = send_cmd(sctx); in send_chown()
2527 return ret; in send_chown()
2533 int ret = 0; in send_utimes() local
2549 ret = -ENOMEM; in send_utimes()
2556 ret = btrfs_search_slot(NULL, sctx->send_root, &key, path, 0, 0); in send_utimes()
2557 if (ret > 0) in send_utimes()
2558 ret = -ENOENT; in send_utimes()
2559 if (ret < 0) in send_utimes()
2566 ret = begin_cmd(sctx, BTRFS_SEND_C_UTIMES); in send_utimes()
2567 if (ret < 0) in send_utimes()
2570 ret = get_cur_path(sctx, ino, gen, p); in send_utimes()
2571 if (ret < 0) in send_utimes()
2579 ret = send_cmd(sctx); in send_utimes()
2585 return ret; in send_utimes()
2596 int ret = 0; in send_create_inode() local
2610 ret = get_inode_info(sctx->send_root, ino, NULL, &gen, &mode, in send_create_inode()
2612 if (ret < 0) in send_create_inode()
2635 ret = -EOPNOTSUPP; in send_create_inode()
2639 ret = begin_cmd(sctx, cmd); in send_create_inode()
2640 if (ret < 0) in send_create_inode()
2643 ret = gen_unique_name(sctx, ino, gen, p); in send_create_inode()
2644 if (ret < 0) in send_create_inode()
2652 ret = read_symlink(sctx->send_root, ino, p); in send_create_inode()
2653 if (ret < 0) in send_create_inode()
2662 ret = send_cmd(sctx); in send_create_inode()
2663 if (ret < 0) in send_create_inode()
2670 return ret; in send_create_inode()
2680 int ret = 0; in did_create_dir() local
2691 ret = -ENOMEM; in did_create_dir()
2698 ret = btrfs_search_slot(NULL, sctx->send_root, &key, path, 0, 0); in did_create_dir()
2699 if (ret < 0) in did_create_dir()
2706 ret = btrfs_next_leaf(sctx->send_root, path); in did_create_dir()
2707 if (ret < 0) { in did_create_dir()
2709 } else if (ret > 0) { in did_create_dir()
2710 ret = 0; in did_create_dir()
2719 ret = 0; in did_create_dir()
2728 ret = 1; in did_create_dir()
2737 return ret; in did_create_dir()
2748 int ret; in send_create_inode_if_needed() local
2751 ret = did_create_dir(sctx, sctx->cur_ino); in send_create_inode_if_needed()
2752 if (ret < 0) in send_create_inode_if_needed()
2754 if (ret) { in send_create_inode_if_needed()
2755 ret = 0; in send_create_inode_if_needed()
2760 ret = send_create_inode(sctx, sctx->cur_ino); in send_create_inode_if_needed()
2761 if (ret < 0) in send_create_inode_if_needed()
2765 return ret; in send_create_inode_if_needed()
2847 int ret; in orphanize_inode() local
2854 ret = gen_unique_name(sctx, ino, gen, orphan); in orphanize_inode()
2855 if (ret < 0) in orphanize_inode()
2858 ret = send_rename(sctx, path, orphan); in orphanize_inode()
2862 return ret; in orphanize_inode()
2945 int ret = 0; in can_rmdir() local
2972 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in can_rmdir()
2973 if (ret < 0) in can_rmdir()
2980 ret = btrfs_next_leaf(root, path); in can_rmdir()
2981 if (ret < 0) in can_rmdir()
2983 else if (ret > 0) in can_rmdir()
3001 ret = PTR_ERR(odi); in can_rmdir()
3008 ret = 0; in can_rmdir()
3015 ret = PTR_ERR(odi); in can_rmdir()
3020 ret = 0; in can_rmdir()
3028 ret = 1; in can_rmdir()
3032 return ret; in can_rmdir()
3114 int ret; in add_pending_dir_move() local
3140 ret = dup_ref(cur, &pm->update_refs); in add_pending_dir_move()
3141 if (ret < 0) in add_pending_dir_move()
3145 ret = dup_ref(cur, &pm->update_refs); in add_pending_dir_move()
3146 if (ret < 0) in add_pending_dir_move()
3150 ret = add_waiting_dir_move(sctx, pm->ino, is_orphan); in add_pending_dir_move()
3151 if (ret) in add_pending_dir_move()
3160 ret = 0; in add_pending_dir_move()
3162 if (ret) { in add_pending_dir_move()
3166 return ret; in add_pending_dir_move()
3190 int ret = 0; in path_loop() local
3204 ret = get_first_ref(sctx->parent_root, ino, in path_loop()
3207 ret = __get_cur_name_and_parent(sctx, ino, gen, in path_loop()
3210 if (ret > 0) { in path_loop()
3211 ret = 0; in path_loop()
3215 if (ret < 0) in path_loop()
3218 ret = 1; in path_loop()
3226 return ret; in path_loop()
3242 int ret; in apply_dir_move() local
3247 ret = -ENOMEM; in apply_dir_move()
3259 ret = gen_unique_name(sctx, pm->ino, in apply_dir_move()
3262 ret = get_first_ref(sctx->parent_root, pm->ino, in apply_dir_move()
3264 if (ret < 0) in apply_dir_move()
3266 ret = get_cur_path(sctx, parent_ino, parent_gen, in apply_dir_move()
3268 if (ret < 0) in apply_dir_move()
3270 ret = fs_path_add_path(from_path, name); in apply_dir_move()
3272 if (ret < 0) in apply_dir_move()
3276 ret = path_loop(sctx, name, pm->ino, pm->gen, &ancestor); in apply_dir_move()
3277 if (ret < 0) in apply_dir_move()
3279 if (ret) { in apply_dir_move()
3282 ret = add_pending_dir_move(sctx, pm->ino, pm->gen, ancestor, in apply_dir_move()
3285 if (ret < 0) in apply_dir_move()
3298 ret = get_cur_path(sctx, pm->ino, pm->gen, to_path); in apply_dir_move()
3299 if (ret < 0) in apply_dir_move()
3302 ret = send_rename(sctx, from_path, to_path); in apply_dir_move()
3303 if (ret < 0) in apply_dir_move()
3317 ret = can_rmdir(sctx, rmdir_ino, gen, sctx->cur_ino); in apply_dir_move()
3318 if (ret < 0) in apply_dir_move()
3320 if (!ret) in apply_dir_move()
3325 ret = -ENOMEM; in apply_dir_move()
3328 ret = get_cur_path(sctx, rmdir_ino, gen, name); in apply_dir_move()
3329 if (ret < 0) in apply_dir_move()
3331 ret = send_rmdir(sctx, name); in apply_dir_move()
3332 if (ret < 0) in apply_dir_move()
3337 ret = send_utimes(sctx, pm->ino, pm->gen); in apply_dir_move()
3338 if (ret < 0) in apply_dir_move()
3349 ret = get_inode_info(sctx->send_root, cur->dir, NULL, in apply_dir_move()
3351 if (ret == -ENOENT) { in apply_dir_move()
3352 ret = 0; in apply_dir_move()
3355 if (ret < 0) in apply_dir_move()
3358 ret = send_utimes(sctx, cur->dir, cur->dir_gen); in apply_dir_move()
3359 if (ret < 0) in apply_dir_move()
3369 return ret; in apply_dir_move()
3405 int ret = 0; in apply_children_dir_moves() local
3417 ret = apply_dir_move(sctx, pm); in apply_children_dir_moves()
3419 if (ret) in apply_children_dir_moves()
3432 return ret; in apply_children_dir_moves()
3482 int ret = 0; in wait_for_dest_dir_move() local
3496 ret = btrfs_search_slot(NULL, sctx->parent_root, &key, path, 0, 0); in wait_for_dest_dir_move()
3497 if (ret < 0) { in wait_for_dest_dir_move()
3499 } else if (ret > 0) { in wait_for_dest_dir_move()
3500 ret = 0; in wait_for_dest_dir_move()
3507 ret = 0; in wait_for_dest_dir_move()
3520 ret = 0; in wait_for_dest_dir_move()
3524 ret = get_inode_info(sctx->parent_root, di_key.objectid, NULL, in wait_for_dest_dir_move()
3526 if (ret < 0) in wait_for_dest_dir_move()
3528 ret = get_inode_info(sctx->send_root, di_key.objectid, NULL, in wait_for_dest_dir_move()
3530 if (ret < 0) { in wait_for_dest_dir_move()
3531 if (ret == -ENOENT) in wait_for_dest_dir_move()
3532 ret = 0; in wait_for_dest_dir_move()
3538 ret = 0; in wait_for_dest_dir_move()
3544 ret = add_pending_dir_move(sctx, in wait_for_dest_dir_move()
3551 if (!ret) in wait_for_dest_dir_move()
3552 ret = 1; in wait_for_dest_dir_move()
3556 return ret; in wait_for_dest_dir_move()
3578 int ret; in check_ino_in_path() local
3581 ret = get_first_ref(root, ino, &parent, &parent_gen, fs_path); in check_ino_in_path()
3582 if (ret < 0) in check_ino_in_path()
3583 return ret; in check_ino_in_path()
3603 int ret = 0; in is_ancestor() local
3616 ret = -ENOMEM; in is_ancestor()
3624 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in is_ancestor()
3625 if (ret < 0) in is_ancestor()
3635 ret = btrfs_next_leaf(root, path); in is_ancestor()
3636 if (ret < 0) in is_ancestor()
3638 if (ret > 0) in is_ancestor()
3672 ret = get_inode_info(root, parent, NULL, &parent_gen, in is_ancestor()
3674 if (ret < 0) in is_ancestor()
3676 ret = check_ino_in_path(root, ino1, ino1_gen, in is_ancestor()
3678 if (ret) in is_ancestor()
3683 ret = 0; in is_ancestor()
3688 return ret; in is_ancestor()
3695 int ret = 0; in wait_for_parent_move() local
3706 ret = -ENOMEM; in wait_for_parent_move()
3731 ret = is_ancestor(sctx->parent_root, in wait_for_parent_move()
3734 if (ret) in wait_for_parent_move()
3741 ret = get_first_ref(sctx->send_root, ino, &parent_ino_after, in wait_for_parent_move()
3743 if (ret < 0) in wait_for_parent_move()
3745 ret = get_first_ref(sctx->parent_root, ino, &parent_ino_before, in wait_for_parent_move()
3747 if (ret < 0 && ret != -ENOENT) { in wait_for_parent_move()
3749 } else if (ret == -ENOENT) { in wait_for_parent_move()
3750 ret = 0; in wait_for_parent_move()
3761 ret = get_inode_info(sctx->parent_root, ino, NULL, in wait_for_parent_move()
3764 if (ret < 0) in wait_for_parent_move()
3767 ret = 1; in wait_for_parent_move()
3779 if (ret == 1) { in wait_for_parent_move()
3780 ret = add_pending_dir_move(sctx, in wait_for_parent_move()
3787 if (!ret) in wait_for_parent_move()
3788 ret = 1; in wait_for_parent_move()
3791 return ret; in wait_for_parent_move()
3796 int ret; in update_ref_path() local
3807 ret = get_cur_path(sctx, ref->dir, ref->dir_gen, new_path); in update_ref_path()
3808 if (ret < 0) { in update_ref_path()
3810 return ret; in update_ref_path()
3812 ret = fs_path_add(new_path, ref->name, ref->name_len); in update_ref_path()
3813 if (ret < 0) { in update_ref_path()
3815 return ret; in update_ref_path()
3868 int ret; in refresh_ref_path() local
3875 ret = get_cur_path(sctx, ref->dir, ref->dir_gen, ref->full_path); in refresh_ref_path()
3876 if (ret < 0) in refresh_ref_path()
3879 ret = fs_path_add(ref->full_path, name, ref->name_len); in refresh_ref_path()
3880 if (ret < 0) in refresh_ref_path()
3887 return ret; in refresh_ref_path()
3896 int ret = 0; in process_recorded_refs() local
3922 ret = -ENOMEM; in process_recorded_refs()
3938 ret = did_overwrite_first_ref(sctx, sctx->cur_ino, in process_recorded_refs()
3940 if (ret < 0) in process_recorded_refs()
3942 if (ret) in process_recorded_refs()
3946 ret = gen_unique_name(sctx, sctx->cur_ino, in process_recorded_refs()
3948 if (ret < 0) in process_recorded_refs()
3952 ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, in process_recorded_refs()
3954 if (ret < 0) in process_recorded_refs()
3997 ret = get_cur_inode_state(sctx, cur->dir, cur->dir_gen); in process_recorded_refs()
3998 if (ret < 0) in process_recorded_refs()
4000 if (ret == inode_state_will_create) in process_recorded_refs()
4009 ret = will_overwrite_ref(sctx, cur->dir, cur->dir_gen, in process_recorded_refs()
4012 if (ret < 0) in process_recorded_refs()
4014 if (ret) { in process_recorded_refs()
4015 ret = is_first_ref(sctx->parent_root, in process_recorded_refs()
4018 if (ret < 0) in process_recorded_refs()
4020 if (ret) { in process_recorded_refs()
4025 ret = refresh_ref_path(sctx, cur); in process_recorded_refs()
4026 if (ret < 0) in process_recorded_refs()
4030 ret = orphanize_inode(sctx, ow_inode, ow_gen, in process_recorded_refs()
4032 if (ret < 0) in process_recorded_refs()
4073 ret = is_ancestor(sctx->parent_root, in process_recorded_refs()
4076 if (ret > 0) { in process_recorded_refs()
4079 ret = get_cur_path(sctx, sctx->cur_ino, in process_recorded_refs()
4083 if (ret < 0) in process_recorded_refs()
4093 ret = refresh_ref_path(sctx, cur); in process_recorded_refs()
4094 if (ret < 0) in process_recorded_refs()
4097 ret = send_unlink(sctx, cur->full_path); in process_recorded_refs()
4098 if (ret < 0) in process_recorded_refs()
4113 ret = get_cur_inode_state(sctx, cur->dir, cur->dir_gen); in process_recorded_refs()
4114 if (ret < 0) in process_recorded_refs()
4116 if (ret == inode_state_will_create) { in process_recorded_refs()
4117 ret = 0; in process_recorded_refs()
4126 ret = 1; in process_recorded_refs()
4135 if (!ret) in process_recorded_refs()
4136 ret = did_create_dir(sctx, cur->dir); in process_recorded_refs()
4137 if (ret < 0) in process_recorded_refs()
4139 if (!ret) { in process_recorded_refs()
4140 ret = send_create_inode(sctx, cur->dir); in process_recorded_refs()
4141 if (ret < 0) in process_recorded_refs()
4147 ret = wait_for_dest_dir_move(sctx, cur, is_orphan); in process_recorded_refs()
4148 if (ret < 0) in process_recorded_refs()
4150 if (ret == 1) { in process_recorded_refs()
4158 ret = wait_for_parent_move(sctx, cur, is_orphan); in process_recorded_refs()
4159 if (ret < 0) in process_recorded_refs()
4161 if (ret == 1) { in process_recorded_refs()
4173 ret = send_rename(sctx, valid_path, cur->full_path); in process_recorded_refs()
4174 if (ret < 0) in process_recorded_refs()
4177 ret = fs_path_copy(valid_path, cur->full_path); in process_recorded_refs()
4178 if (ret < 0) in process_recorded_refs()
4187 ret = send_rename(sctx, valid_path, in process_recorded_refs()
4189 if (!ret) in process_recorded_refs()
4190 ret = fs_path_copy(valid_path, in process_recorded_refs()
4192 if (ret < 0) in process_recorded_refs()
4203 ret = update_ref_path(sctx, cur); in process_recorded_refs()
4204 if (ret < 0) in process_recorded_refs()
4207 ret = send_link(sctx, cur->full_path, in process_recorded_refs()
4209 if (ret < 0) in process_recorded_refs()
4213 ret = dup_ref(cur, &check_dirs); in process_recorded_refs()
4214 if (ret < 0) in process_recorded_refs()
4225 ret = can_rmdir(sctx, sctx->cur_ino, sctx->cur_inode_gen, in process_recorded_refs()
4227 if (ret < 0) in process_recorded_refs()
4229 if (ret) { in process_recorded_refs()
4230 ret = send_rmdir(sctx, valid_path); in process_recorded_refs()
4231 if (ret < 0) in process_recorded_refs()
4234 ret = orphanize_inode(sctx, sctx->cur_ino, in process_recorded_refs()
4236 if (ret < 0) in process_recorded_refs()
4242 ret = dup_ref(cur, &check_dirs); in process_recorded_refs()
4243 if (ret < 0) in process_recorded_refs()
4253 ret = dup_ref(cur, &check_dirs); in process_recorded_refs()
4254 if (ret < 0) in process_recorded_refs()
4263 ret = did_overwrite_ref(sctx, cur->dir, cur->dir_gen, in process_recorded_refs()
4266 if (ret < 0) in process_recorded_refs()
4268 if (!ret) { in process_recorded_refs()
4277 ret = update_ref_path(sctx, cur); in process_recorded_refs()
4278 if (ret < 0) in process_recorded_refs()
4281 ret = send_unlink(sctx, cur->full_path); in process_recorded_refs()
4282 if (ret < 0) in process_recorded_refs()
4285 ret = dup_ref(cur, &check_dirs); in process_recorded_refs()
4286 if (ret < 0) in process_recorded_refs()
4298 ret = send_unlink(sctx, valid_path); in process_recorded_refs()
4299 if (ret < 0) in process_recorded_refs()
4319 ret = get_cur_inode_state(sctx, cur->dir, cur->dir_gen); in process_recorded_refs()
4320 if (ret < 0) in process_recorded_refs()
4323 if (ret == inode_state_did_create || in process_recorded_refs()
4324 ret == inode_state_no_change) { in process_recorded_refs()
4326 ret = send_utimes(sctx, cur->dir, cur->dir_gen); in process_recorded_refs()
4327 if (ret < 0) in process_recorded_refs()
4329 } else if (ret == inode_state_did_delete && in process_recorded_refs()
4331 ret = can_rmdir(sctx, cur->dir, cur->dir_gen, in process_recorded_refs()
4333 if (ret < 0) in process_recorded_refs()
4335 if (ret) { in process_recorded_refs()
4336 ret = get_cur_path(sctx, cur->dir, in process_recorded_refs()
4338 if (ret < 0) in process_recorded_refs()
4340 ret = send_rmdir(sctx, valid_path); in process_recorded_refs()
4341 if (ret < 0) in process_recorded_refs()
4348 ret = 0; in process_recorded_refs()
4354 return ret; in process_recorded_refs()
4360 int ret = 0; in record_ref() local
4369 ret = get_inode_info(root, dir, NULL, &gen, NULL, NULL, in record_ref()
4371 if (ret < 0) in record_ref()
4374 ret = get_cur_path(sctx, dir, gen, p); in record_ref()
4375 if (ret < 0) in record_ref()
4377 ret = fs_path_add_path(p, name); in record_ref()
4378 if (ret < 0) in record_ref()
4381 ret = __record_ref(refs, dir, gen, p); in record_ref()
4384 if (ret) in record_ref()
4386 return ret; in record_ref()
4409 int ret; in record_new_ref() local
4411 ret = iterate_inode_ref(sctx->send_root, sctx->left_path, in record_new_ref()
4413 if (ret < 0) in record_new_ref()
4415 ret = 0; in record_new_ref()
4418 return ret; in record_new_ref()
4423 int ret; in record_deleted_ref() local
4425 ret = iterate_inode_ref(sctx->parent_root, sctx->right_path, in record_deleted_ref()
4427 if (ret < 0) in record_deleted_ref()
4429 ret = 0; in record_deleted_ref()
4432 return ret; in record_deleted_ref()
4449 int ret; in __find_iref() local
4457 ret = get_inode_info(ctx->root, dir, NULL, &dir_gen, NULL, in __find_iref()
4459 if (ret) in __find_iref()
4460 return ret; in __find_iref()
4474 int ret; in find_iref() local
4483 ret = iterate_inode_ref(root, path, key, 0, __find_iref, &ctx); in find_iref()
4484 if (ret < 0) in find_iref()
4485 return ret; in find_iref()
4498 int ret; in __record_changed_new_ref() local
4501 ret = get_inode_info(sctx->send_root, dir, NULL, &dir_gen, NULL, in __record_changed_new_ref()
4503 if (ret) in __record_changed_new_ref()
4504 return ret; in __record_changed_new_ref()
4506 ret = find_iref(sctx->parent_root, sctx->right_path, in __record_changed_new_ref()
4508 if (ret == -ENOENT) in __record_changed_new_ref()
4509 ret = __record_new_ref(num, dir, index, name, sctx); in __record_changed_new_ref()
4510 else if (ret > 0) in __record_changed_new_ref()
4511 ret = 0; in __record_changed_new_ref()
4513 return ret; in __record_changed_new_ref()
4521 int ret; in __record_changed_deleted_ref() local
4524 ret = get_inode_info(sctx->parent_root, dir, NULL, &dir_gen, NULL, in __record_changed_deleted_ref()
4526 if (ret) in __record_changed_deleted_ref()
4527 return ret; in __record_changed_deleted_ref()
4529 ret = find_iref(sctx->send_root, sctx->left_path, sctx->cmp_key, in __record_changed_deleted_ref()
4531 if (ret == -ENOENT) in __record_changed_deleted_ref()
4532 ret = __record_deleted_ref(num, dir, index, name, sctx); in __record_changed_deleted_ref()
4533 else if (ret > 0) in __record_changed_deleted_ref()
4534 ret = 0; in __record_changed_deleted_ref()
4536 return ret; in __record_changed_deleted_ref()
4541 int ret = 0; in record_changed_ref() local
4543 ret = iterate_inode_ref(sctx->send_root, sctx->left_path, in record_changed_ref()
4545 if (ret < 0) in record_changed_ref()
4547 ret = iterate_inode_ref(sctx->parent_root, sctx->right_path, in record_changed_ref()
4549 if (ret < 0) in record_changed_ref()
4551 ret = 0; in record_changed_ref()
4554 return ret; in record_changed_ref()
4564 int ret; in process_all_refs() local
4587 ret = -EINVAL; in process_all_refs()
4594 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in process_all_refs()
4595 if (ret < 0) in process_all_refs()
4602 ret = btrfs_next_leaf(root, path); in process_all_refs()
4603 if (ret < 0) in process_all_refs()
4605 else if (ret > 0) in process_all_refs()
4617 ret = iterate_inode_ref(root, path, &found_key, 0, cb, sctx); in process_all_refs()
4618 if (ret < 0) in process_all_refs()
4630 ret = process_recorded_refs(sctx, &pending_move); in process_all_refs()
4633 return ret; in process_all_refs()
4641 int ret = 0; in send_set_xattr() local
4643 ret = begin_cmd(sctx, BTRFS_SEND_C_SET_XATTR); in send_set_xattr()
4644 if (ret < 0) in send_set_xattr()
4651 ret = send_cmd(sctx); in send_set_xattr()
4655 return ret; in send_set_xattr()
4662 int ret = 0; in send_remove_xattr() local
4664 ret = begin_cmd(sctx, BTRFS_SEND_C_REMOVE_XATTR); in send_remove_xattr()
4665 if (ret < 0) in send_remove_xattr()
4671 ret = send_cmd(sctx); in send_remove_xattr()
4675 return ret; in send_remove_xattr()
4683 int ret; in __process_new_xattr() local
4712 ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p); in __process_new_xattr()
4713 if (ret < 0) in __process_new_xattr()
4716 ret = send_set_xattr(sctx, p, name, name_len, data, data_len); in __process_new_xattr()
4720 return ret; in __process_new_xattr()
4728 int ret; in __process_deleted_xattr() local
4736 ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p); in __process_deleted_xattr()
4737 if (ret < 0) in __process_deleted_xattr()
4740 ret = send_remove_xattr(sctx, p, name, name_len); in __process_deleted_xattr()
4744 return ret; in __process_deleted_xattr()
4749 int ret = 0; in process_new_xattr() local
4751 ret = iterate_dir_item(sctx->send_root, sctx->left_path, in process_new_xattr()
4754 return ret; in process_new_xattr()
4796 int ret; in find_xattr() local
4805 ret = iterate_dir_item(root, path, __find_xattr, &ctx); in find_xattr()
4806 if (ret < 0) in find_xattr()
4807 return ret; in find_xattr()
4826 int ret; in __process_changed_new_xattr() local
4831 ret = find_xattr(sctx->parent_root, sctx->right_path, in __process_changed_new_xattr()
4834 if (ret == -ENOENT) { in __process_changed_new_xattr()
4835 ret = __process_new_xattr(num, di_key, name, name_len, data, in __process_changed_new_xattr()
4837 } else if (ret >= 0) { in __process_changed_new_xattr()
4840 ret = __process_new_xattr(num, di_key, name, name_len, in __process_changed_new_xattr()
4843 ret = 0; in __process_changed_new_xattr()
4848 return ret; in __process_changed_new_xattr()
4856 int ret; in __process_changed_deleted_xattr() local
4859 ret = find_xattr(sctx->send_root, sctx->left_path, sctx->cmp_key, in __process_changed_deleted_xattr()
4861 if (ret == -ENOENT) in __process_changed_deleted_xattr()
4862 ret = __process_deleted_xattr(num, di_key, name, name_len, data, in __process_changed_deleted_xattr()
4864 else if (ret >= 0) in __process_changed_deleted_xattr()
4865 ret = 0; in __process_changed_deleted_xattr()
4867 return ret; in __process_changed_deleted_xattr()
4872 int ret = 0; in process_changed_xattr() local
4874 ret = iterate_dir_item(sctx->send_root, sctx->left_path, in process_changed_xattr()
4876 if (ret < 0) in process_changed_xattr()
4878 ret = iterate_dir_item(sctx->parent_root, sctx->right_path, in process_changed_xattr()
4882 return ret; in process_changed_xattr()
4887 int ret; in process_all_new_xattrs() local
4904 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in process_all_new_xattrs()
4905 if (ret < 0) in process_all_new_xattrs()
4912 ret = btrfs_next_leaf(root, path); in process_all_new_xattrs()
4913 if (ret < 0) { in process_all_new_xattrs()
4915 } else if (ret > 0) { in process_all_new_xattrs()
4916 ret = 0; in process_all_new_xattrs()
4925 ret = 0; in process_all_new_xattrs()
4929 ret = iterate_dir_item(root, path, __process_new_xattr, sctx); in process_all_new_xattrs()
4930 if (ret < 0) in process_all_new_xattrs()
4938 return ret; in process_all_new_xattrs()
4968 int ret; in put_file_data() local
4970 ret = put_data_header(sctx, len); in put_file_data()
4971 if (ret) in put_file_data()
4972 return ret; in put_file_data()
4996 ret = -ENOMEM; in put_file_data()
5016 ret = -EIO; in put_file_data()
5031 return ret; in put_file_data()
5041 int ret = 0; in send_write() local
5050 ret = begin_cmd(sctx, BTRFS_SEND_C_WRITE); in send_write()
5051 if (ret < 0) in send_write()
5054 ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p); in send_write()
5055 if (ret < 0) in send_write()
5060 ret = put_file_data(sctx, offset, len); in send_write()
5061 if (ret < 0) in send_write()
5064 ret = send_cmd(sctx); in send_write()
5069 return ret; in send_write()
5079 int ret = 0; in send_clone() local
5092 ret = begin_cmd(sctx, BTRFS_SEND_C_CLONE); in send_clone()
5093 if (ret < 0) in send_clone()
5096 ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p); in send_clone()
5097 if (ret < 0) in send_clone()
5105 ret = get_inode_info(sctx->send_root, clone_root->ino, NULL, in send_clone()
5107 if (ret < 0) in send_clone()
5109 ret = get_cur_path(sctx, clone_root->ino, gen, p); in send_clone()
5111 ret = get_inode_path(clone_root->root, clone_root->ino, p); in send_clone()
5113 if (ret < 0) in send_clone()
5137 ret = send_cmd(sctx); in send_clone()
5142 return ret; in send_clone()
5151 int ret = 0; in send_update_extent() local
5158 ret = begin_cmd(sctx, BTRFS_SEND_C_UPDATE_EXTENT); in send_update_extent()
5159 if (ret < 0) in send_update_extent()
5162 ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p); in send_update_extent()
5163 if (ret < 0) in send_update_extent()
5170 ret = send_cmd(sctx); in send_update_extent()
5175 return ret; in send_update_extent()
5183 int ret = 0; in send_hole() local
5206 ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p); in send_hole()
5207 if (ret < 0) in send_hole()
5212 ret = begin_cmd(sctx, BTRFS_SEND_C_WRITE); in send_hole()
5213 if (ret < 0) in send_hole()
5217 ret = put_data_header(sctx, len); in send_hole()
5218 if (ret < 0) in send_hole()
5222 ret = send_cmd(sctx); in send_hole()
5223 if (ret < 0) in send_hole()
5230 return ret; in send_hole()
5245 int ret; in send_extent_data() local
5247 ret = send_write(sctx, offset + sent, size); in send_extent_data()
5248 if (ret < 0) in send_extent_data()
5249 return ret; in send_extent_data()
5271 int ret = 0; in send_capabilities() local
5283 ret = PTR_ERR(di); in send_capabilities()
5293 ret = -ENOMEM; in send_capabilities()
5297 ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, fspath); in send_capabilities()
5298 if (ret < 0) in send_capabilities()
5304 ret = send_set_xattr(sctx, fspath, XATTR_NAME_CAPS, in send_capabilities()
5310 return ret; in send_capabilities()
5322 int ret; in clone_range() local
5352 ret = __get_inode_info(clone_root->root, path, clone_root->ino, in clone_range()
5355 if (ret < 0) in clone_range()
5383 ret = btrfs_search_slot(NULL, clone_root->root, &key, path, 0, 0); in clone_range()
5384 if (ret < 0) in clone_range()
5386 if (ret > 0 && path->slots[0] > 0) { in clone_range()
5404 ret = btrfs_next_leaf(clone_root->root, path); in clone_range()
5405 if (ret < 0) in clone_range()
5407 else if (ret > 0) in clone_range()
5440 ret = send_extent_data(sctx, offset, hole_len); in clone_range()
5441 if (ret < 0) in clone_range()
5510 ret = send_clone(sctx, offset, slen, in clone_range()
5512 if (ret < 0) in clone_range()
5515 ret = send_extent_data(sctx, offset + slen, in clone_range()
5518 ret = send_clone(sctx, offset, clone_len, in clone_range()
5541 ret = send_extent_data(sctx, offset, clone_len); in clone_range()
5544 if (ret < 0) in clone_range()
5573 ret = send_extent_data(sctx, offset, len); in clone_range()
5575 ret = 0; in clone_range()
5578 return ret; in clone_range()
5586 int ret = 0; in send_write_or_clone() local
5604 ret = clone_range(sctx, clone_root, disk_byte, data_offset, in send_write_or_clone()
5607 ret = send_extent_data(sctx, offset, end - offset); in send_write_or_clone()
5610 return ret; in send_write_or_clone()
5617 int ret = 0; in is_extent_unchanged() local
5646 ret = 0; in is_extent_unchanged()
5678 ret = btrfs_search_slot_for_read(sctx->parent_root, &key, path, 0, 0); in is_extent_unchanged()
5679 if (ret < 0) in is_extent_unchanged()
5681 if (ret) { in is_extent_unchanged()
5682 ret = 0; in is_extent_unchanged()
5695 ret = (left_disknr) ? 0 : 1; in is_extent_unchanged()
5708 ret = 0; in is_extent_unchanged()
5725 ret = (left_disknr) ? 0 : 1; in is_extent_unchanged()
5738 ret = 0; in is_extent_unchanged()
5761 ret = 0; in is_extent_unchanged()
5768 ret = btrfs_next_item(sctx->parent_root, path); in is_extent_unchanged()
5769 if (ret < 0) in is_extent_unchanged()
5771 if (!ret) { in is_extent_unchanged()
5776 if (ret || found_key.objectid != key.objectid || in is_extent_unchanged()
5782 ret = 0; in is_extent_unchanged()
5793 ret = 1; in is_extent_unchanged()
5795 ret = 0; in is_extent_unchanged()
5800 return ret; in is_extent_unchanged()
5808 int ret; in get_last_extent() local
5819 ret = btrfs_search_slot_for_read(root, &key, path, 0, 1); in get_last_extent()
5820 if (ret < 0) in get_last_extent()
5822 ret = 0; in get_last_extent()
5830 return ret; in get_last_extent()
5841 int ret; in range_is_hole_in_parent() local
5850 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in range_is_hole_in_parent()
5851 if (ret < 0) in range_is_hole_in_parent()
5853 if (ret > 0 && path->slots[0] > 0) in range_is_hole_in_parent()
5863 ret = btrfs_next_leaf(root, path); in range_is_hole_in_parent()
5864 if (ret < 0) in range_is_hole_in_parent()
5866 else if (ret > 0) in range_is_hole_in_parent()
5888 ret = 0; in range_is_hole_in_parent()
5893 ret = 1; in range_is_hole_in_parent()
5896 return ret; in range_is_hole_in_parent()
5902 int ret = 0; in maybe_send_hole() local
5908 ret = get_last_extent(sctx, key->offset - 1); in maybe_send_hole()
5909 if (ret) in maybe_send_hole()
5910 return ret; in maybe_send_hole()
5922 ret = get_last_extent(sctx, key->offset - 1); in maybe_send_hole()
5923 if (ret) in maybe_send_hole()
5924 return ret; in maybe_send_hole()
5928 ret = range_is_hole_in_parent(sctx, in maybe_send_hole()
5931 if (ret < 0) in maybe_send_hole()
5932 return ret; in maybe_send_hole()
5933 else if (ret == 0) in maybe_send_hole()
5934 ret = send_hole(sctx, key->offset); in maybe_send_hole()
5936 ret = 0; in maybe_send_hole()
5939 return ret; in maybe_send_hole()
5947 int ret = 0; in process_extent() local
5953 ret = is_extent_unchanged(sctx, path, key); in process_extent()
5954 if (ret < 0) in process_extent()
5956 if (ret) { in process_extent()
5957 ret = 0; in process_extent()
5976 ret = 0; in process_extent()
5982 ret = 0; in process_extent()
5988 ret = find_extent_clone(sctx, path, key->objectid, key->offset, in process_extent()
5990 if (ret != -ENOENT && ret < 0) in process_extent()
5993 ret = send_write_or_clone(sctx, path, key, found_clone); in process_extent()
5994 if (ret) in process_extent()
5997 ret = maybe_send_hole(sctx, path, key); in process_extent()
5999 return ret; in process_extent()
6004 int ret; in process_all_extents() local
6020 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in process_all_extents()
6021 if (ret < 0) in process_all_extents()
6029 ret = btrfs_next_leaf(root, path); in process_all_extents()
6030 if (ret < 0) { in process_all_extents()
6032 } else if (ret > 0) { in process_all_extents()
6033 ret = 0; in process_all_extents()
6043 ret = 0; in process_all_extents()
6047 ret = process_extent(sctx, path, &found_key); in process_all_extents()
6048 if (ret < 0) in process_all_extents()
6056 return ret; in process_all_extents()
6063 int ret = 0; in process_recorded_refs_if_needed() local
6073 ret = process_recorded_refs(sctx, pending_move); in process_recorded_refs_if_needed()
6074 if (ret < 0) in process_recorded_refs_if_needed()
6079 return ret; in process_recorded_refs_if_needed()
6084 int ret = 0; in finish_inode_if_needed() local
6100 ret = process_recorded_refs_if_needed(sctx, at_end, &pending_move, in finish_inode_if_needed()
6102 if (ret < 0) in finish_inode_if_needed()
6125 ret = get_inode_info(sctx->send_root, sctx->cur_ino, NULL, NULL, in finish_inode_if_needed()
6127 if (ret < 0) in finish_inode_if_needed()
6139 ret = get_inode_info(sctx->parent_root, sctx->cur_ino, in finish_inode_if_needed()
6142 if (ret < 0) in finish_inode_if_needed()
6160 ret = get_last_extent(sctx, (u64)-1); in finish_inode_if_needed()
6161 if (ret) in finish_inode_if_needed()
6166 ret = send_hole(sctx, sctx->cur_inode_size); in finish_inode_if_needed()
6167 if (ret) in finish_inode_if_needed()
6172 ret = send_truncate(sctx, sctx->cur_ino, in finish_inode_if_needed()
6175 if (ret < 0) in finish_inode_if_needed()
6181 ret = send_chown(sctx, sctx->cur_ino, sctx->cur_inode_gen, in finish_inode_if_needed()
6183 if (ret < 0) in finish_inode_if_needed()
6187 ret = send_chmod(sctx, sctx->cur_ino, sctx->cur_inode_gen, in finish_inode_if_needed()
6189 if (ret < 0) in finish_inode_if_needed()
6193 ret = send_capabilities(sctx); in finish_inode_if_needed()
6194 if (ret < 0) in finish_inode_if_needed()
6202 ret = apply_children_dir_moves(sctx); in finish_inode_if_needed()
6203 if (ret) in finish_inode_if_needed()
6213 ret = send_utimes(sctx, sctx->cur_ino, sctx->cur_inode_gen); in finish_inode_if_needed()
6214 if (ret < 0) in finish_inode_if_needed()
6219 return ret; in finish_inode_if_needed()
6246 int ret; in btrfs_unlink_all_paths() local
6255 ret = btrfs_search_slot(NULL, sctx->parent_root, &key, path, 0, 0); in btrfs_unlink_all_paths()
6256 if (ret < 0) in btrfs_unlink_all_paths()
6267 ret = btrfs_next_leaf(sctx->parent_root, path); in btrfs_unlink_all_paths()
6268 if (ret < 0) in btrfs_unlink_all_paths()
6270 else if (ret > 0) in btrfs_unlink_all_paths()
6282 ret = iterate_inode_ref(sctx->parent_root, path, &key, 1, in btrfs_unlink_all_paths()
6284 if (ret < 0) in btrfs_unlink_all_paths()
6294 ret = send_unlink(sctx, ref->full_path); in btrfs_unlink_all_paths()
6295 if (ret < 0) in btrfs_unlink_all_paths()
6301 ret = 0; in btrfs_unlink_all_paths()
6304 if (ret) in btrfs_unlink_all_paths()
6306 return ret; in btrfs_unlink_all_paths()
6312 int ret = 0; in changed_inode() local
6386 ret = btrfs_unlink_all_paths(sctx); in changed_inode()
6402 ret = send_create_inode_if_needed(sctx); in changed_inode()
6430 ret = process_all_refs(sctx, in changed_inode()
6432 if (ret < 0) in changed_inode()
6447 ret = send_create_inode_if_needed(sctx); in changed_inode()
6448 if (ret < 0) in changed_inode()
6451 ret = process_all_refs(sctx, BTRFS_COMPARE_TREE_NEW); in changed_inode()
6452 if (ret < 0) in changed_inode()
6464 ret = process_all_extents(sctx); in changed_inode()
6465 if (ret < 0) in changed_inode()
6467 ret = process_all_new_xattrs(sctx); in changed_inode()
6468 if (ret < 0) in changed_inode()
6483 return ret; in changed_inode()
6499 int ret = 0; in changed_ref() local
6509 ret = record_new_ref(sctx); in changed_ref()
6511 ret = record_deleted_ref(sctx); in changed_ref()
6513 ret = record_changed_ref(sctx); in changed_ref()
6516 return ret; in changed_ref()
6527 int ret = 0; in changed_xattr() local
6536 ret = process_new_xattr(sctx); in changed_xattr()
6538 ret = process_deleted_xattr(sctx); in changed_xattr()
6540 ret = process_changed_xattr(sctx); in changed_xattr()
6543 return ret; in changed_xattr()
6554 int ret = 0; in changed_extent() local
6574 ret = process_extent(sctx, sctx->left_path, in changed_extent()
6578 return ret; in changed_extent()
6584 int ret; in dir_changed() local
6586 ret = get_inode_info(sctx->send_root, dir, NULL, &new_gen, NULL, NULL, in dir_changed()
6588 if (ret) in dir_changed()
6589 return ret; in dir_changed()
6591 ret = get_inode_info(sctx->parent_root, dir, NULL, &orig_gen, NULL, in dir_changed()
6593 if (ret) in dir_changed()
6594 return ret; in dir_changed()
6609 int ret = 0; in compare_refs() local
6615 ret = dir_changed(sctx, dirid); in compare_refs()
6630 ret = dir_changed(sctx, dirid); in compare_refs()
6631 if (ret) in compare_refs()
6636 return ret; in compare_refs()
6649 int ret = 0; in changed_cb() local
6698 ret = compare_refs(sctx, left_path, key); in changed_cb()
6699 if (!ret) in changed_cb()
6701 if (ret < 0) in changed_cb()
6702 return ret; in changed_cb()
6709 ret = 0; in changed_cb()
6716 ret = finish_inode_if_needed(sctx, 0); in changed_cb()
6717 if (ret < 0) in changed_cb()
6726 ret = changed_inode(sctx, result); in changed_cb()
6730 ret = changed_ref(sctx, result); in changed_cb()
6732 ret = changed_xattr(sctx, result); in changed_cb()
6734 ret = changed_extent(sctx, result); in changed_cb()
6738 return ret; in changed_cb()
6746 int ret; in search_key_again() local
6758 ret = btrfs_search_slot(NULL, root, key, path, 0, 0); in search_key_again()
6759 ASSERT(ret <= 0); in search_key_again()
6760 if (ret > 0) { in search_key_again()
6771 return ret; in search_key_again()
6776 int ret; in full_send_tree() local
6795 ret = btrfs_search_slot_for_read(send_root, &key, path, 1, 0); in full_send_tree()
6796 if (ret < 0) in full_send_tree()
6798 if (ret) in full_send_tree()
6804 ret = changed_cb(path, NULL, &key, in full_send_tree()
6806 if (ret < 0) in full_send_tree()
6824 ret = search_key_again(sctx, send_root, path, &key); in full_send_tree()
6825 if (ret < 0) in full_send_tree()
6831 ret = btrfs_next_item(send_root, path); in full_send_tree()
6832 if (ret < 0) in full_send_tree()
6834 if (ret) { in full_send_tree()
6835 ret = 0; in full_send_tree()
6841 ret = finish_inode_if_needed(sctx, 1); in full_send_tree()
6845 return ret; in full_send_tree()
6906 int ret = 0; in tree_move_next_or_upnext() local
6926 ret = 1; in tree_move_next_or_upnext()
6928 return ret; in tree_move_next_or_upnext()
6941 int ret; in tree_advance() local
6944 ret = tree_move_next_or_upnext(path, level, root_level); in tree_advance()
6946 ret = tree_move_down(path, level, reada_min_gen); in tree_advance()
6962 return ret; in tree_advance()
7018 int ret; in restart_after_relocation() local
7032 ret = search_key_again(sctx, sctx->send_root, left_path, left_key); in restart_after_relocation()
7033 if (ret < 0) in restart_after_relocation()
7034 return ret; in restart_after_relocation()
7037 ret = search_key_again(sctx, sctx->parent_root, right_path, right_key); in restart_after_relocation()
7038 if (ret < 0) in restart_after_relocation()
7039 return ret; in restart_after_relocation()
7048 ret = replace_node_with_clone(left_path, 0); in restart_after_relocation()
7049 if (ret < 0) in restart_after_relocation()
7050 return ret; in restart_after_relocation()
7054 ret = replace_node_with_clone(right_path, 0); in restart_after_relocation()
7055 if (ret < 0) in restart_after_relocation()
7056 return ret; in restart_after_relocation()
7066 ret = replace_node_with_clone(left_path, root_level); in restart_after_relocation()
7067 if (ret < 0) in restart_after_relocation()
7068 return ret; in restart_after_relocation()
7073 ret = replace_node_with_clone(right_path, root_level); in restart_after_relocation()
7074 if (ret < 0) in restart_after_relocation()
7075 return ret; in restart_after_relocation()
7098 int ret; in btrfs_compare_trees() local
7121 ret = -ENOMEM; in btrfs_compare_trees()
7126 ret = -ENOMEM; in btrfs_compare_trees()
7132 ret = -ENOMEM; in btrfs_compare_trees()
7190 ret = -ENOMEM; in btrfs_compare_trees()
7199 ret = -ENOMEM; in btrfs_compare_trees()
7235 ret = restart_after_relocation(left_path, right_path, in btrfs_compare_trees()
7239 if (ret < 0) in btrfs_compare_trees()
7245 ret = tree_advance(left_path, &left_level, in btrfs_compare_trees()
7249 if (ret == -1) in btrfs_compare_trees()
7251 else if (ret < 0) in btrfs_compare_trees()
7256 ret = tree_advance(right_path, &right_level, in btrfs_compare_trees()
7260 if (ret == -1) in btrfs_compare_trees()
7262 else if (ret < 0) in btrfs_compare_trees()
7268 ret = 0; in btrfs_compare_trees()
7273 ret = changed_cb(left_path, right_path, in btrfs_compare_trees()
7277 if (ret < 0) in btrfs_compare_trees()
7286 ret = changed_cb(left_path, right_path, in btrfs_compare_trees()
7290 if (ret < 0) in btrfs_compare_trees()
7302 ret = changed_cb(left_path, right_path, in btrfs_compare_trees()
7308 ret = changed_cb(left_path, right_path, in btrfs_compare_trees()
7317 ret = tree_compare_item(left_path, right_path, in btrfs_compare_trees()
7319 if (ret) in btrfs_compare_trees()
7323 ret = changed_cb(left_path, right_path, in btrfs_compare_trees()
7329 if (ret < 0) in btrfs_compare_trees()
7377 return ret; in btrfs_compare_trees()
7382 int ret; in send_subvol() local
7385 ret = send_header(sctx); in send_subvol()
7386 if (ret < 0) in send_subvol()
7390 ret = send_subvol_begin(sctx); in send_subvol()
7391 if (ret < 0) in send_subvol()
7395 ret = btrfs_compare_trees(sctx->send_root, sctx->parent_root, sctx); in send_subvol()
7396 if (ret < 0) in send_subvol()
7398 ret = finish_inode_if_needed(sctx, 1); in send_subvol()
7399 if (ret < 0) in send_subvol()
7402 ret = full_send_tree(sctx); in send_subvol()
7403 if (ret < 0) in send_subvol()
7409 return ret; in send_subvol()
7468 int ret; in flush_delalloc_roots() local
7472 ret = btrfs_start_delalloc_snapshot(root, false); in flush_delalloc_roots()
7473 if (ret) in flush_delalloc_roots()
7474 return ret; in flush_delalloc_roots()
7480 ret = btrfs_start_delalloc_snapshot(root, false); in flush_delalloc_roots()
7481 if (ret) in flush_delalloc_roots()
7482 return ret; in flush_delalloc_roots()
7513 int ret = 0; in btrfs_ioctl_send() local
7545 ret = -EPERM; in btrfs_ioctl_send()
7556 ret = -EINVAL; in btrfs_ioctl_send()
7561 ret = -EOPNOTSUPP; in btrfs_ioctl_send()
7567 ret = -ENOMEM; in btrfs_ioctl_send()
7580 ret = -EBADF; in btrfs_ioctl_send()
7590 ret = -EPERM; in btrfs_ioctl_send()
7599 ret = -ENOMEM; in btrfs_ioctl_send()
7611 ret = -ENOMEM; in btrfs_ioctl_send()
7621 ret = -ENOMEM; in btrfs_ioctl_send()
7625 ret = copy_from_user(clone_sources_tmp, arg->clone_sources, in btrfs_ioctl_send()
7627 if (ret) { in btrfs_ioctl_send()
7628 ret = -EFAULT; in btrfs_ioctl_send()
7636 ret = PTR_ERR(clone_root); in btrfs_ioctl_send()
7644 ret = -EPERM; in btrfs_ioctl_send()
7651 ret = -EAGAIN; in btrfs_ioctl_send()
7668 ret = PTR_ERR(sctx->parent_root); in btrfs_ioctl_send()
7677 ret = -EPERM; in btrfs_ioctl_send()
7683 ret = -EAGAIN; in btrfs_ioctl_send()
7703 ret = flush_delalloc_roots(sctx); in btrfs_ioctl_send()
7704 if (ret) in btrfs_ioctl_send()
7707 ret = ensure_commit_roots_uptodate(sctx); in btrfs_ioctl_send()
7708 if (ret) in btrfs_ioctl_send()
7711 ret = send_subvol(sctx); in btrfs_ioctl_send()
7712 if (ret < 0) in btrfs_ioctl_send()
7716 ret = begin_cmd(sctx, BTRFS_SEND_C_END); in btrfs_ioctl_send()
7717 if (ret < 0) in btrfs_ioctl_send()
7719 ret = send_cmd(sctx); in btrfs_ioctl_send()
7720 if (ret < 0) in btrfs_ioctl_send()
7725 WARN_ON(sctx && !ret && !RB_EMPTY_ROOT(&sctx->pending_dir_moves)); in btrfs_ioctl_send()
7742 WARN_ON(sctx && !ret && !RB_EMPTY_ROOT(&sctx->waiting_dir_moves)); in btrfs_ioctl_send()
7753 WARN_ON(sctx && !ret && !RB_EMPTY_ROOT(&sctx->orphan_dirs)); in btrfs_ioctl_send()
7797 return ret; in btrfs_ioctl_send()