Lines Matching full:snapshot
16 #include "snapshot.h"
28 u32 snapshot) in bch2_count_inode_sectors() argument
33 SPOS(inum, 0, snapshot), in bch2_count_inode_sectors()
45 u32 snapshot) in bch2_count_subdirs() argument
50 SPOS(inum, 0, snapshot), in bch2_count_subdirs()
63 u32 *snapshot, u64 *inum) in subvol_lookup() argument
70 *snapshot = le32_to_cpu(s.snapshot); in subvol_lookup()
104 u32 *snapshot) in lookup_inode() argument
111 SPOS(0, inode_nr, *snapshot), 0); in lookup_inode()
120 *snapshot = iter.pos.snapshot; in lookup_inode()
129 u64 *target, unsigned *type, u32 snapshot) in lookup_dirent_in_snapshot() argument
134 &hash_info, dir, name, 0, snapshot); in lookup_dirent_in_snapshot()
147 u32 snapshot) in __write_inode() argument
156 inode_p->inode.k.p.snapshot = snapshot; in __write_inode()
165 u32 snapshot) in fsck_write_inode() argument
168 __write_inode(trans, inode, snapshot)); in fsck_write_inode()
199 static int lookup_lostfound(struct btree_trans *trans, u32 snapshot, in lookup_lostfound() argument
210 bch2_snapshot_tree(c, snapshot), &st); in lookup_lostfound()
225 u32 root_inode_snapshot = snapshot; in lookup_lostfound()
234 &lostfound_str, &inum, &d_type, snapshot); in lookup_lostfound()
251 ret = lookup_inode(trans, inum, lostfound, &snapshot); in lookup_lostfound()
252 bch_err_msg(c, ret, "looking up lost+found %llu:%u in (root inode %llu, snapshot root %u)", in lookup_lostfound()
253 inum, snapshot, root_inum.inum, bch2_snapshot_root(c, snapshot)); in lookup_lostfound()
261 bch_notice(c, "creating lost+found in snapshot %u", le32_to_cpu(st.root_snapshot)); in lookup_lostfound()
273 ret = bch2_inode_create(trans, &lostfound_iter, lostfound, snapshot, cpu); in lookup_lostfound()
277 bch2_btree_iter_set_snapshot(&lostfound_iter, snapshot); in lookup_lostfound()
283 root_inode.bi_inum, snapshot, &root_hash_info, in lookup_lostfound()
402 .id = pos.snapshot, in snapshots_seen_update()
403 .equiv = bch2_snapshot_equiv(c, pos.snapshot), in snapshots_seen_update()
411 s->pos.snapshot = n.equiv; in snapshots_seen_update()
418 * We currently don't rigorously track for snapshot cleanup in snapshots_seen_update()
422 bch_err(c, "snapshot deletion did not finish:\n" in snapshots_seen_update()
444 * @seen: list of snapshot ids already seen at current position
445 * @id: descendent snapshot id
446 * @ancestor: ancestor snapshot id
448 * Returns: whether key in @ancestor snapshot is visible in @id snapshot
459 /* @ancestor should be the snapshot most recently added to @seen */ in key_visible_in_snapshot()
460 EBUG_ON(ancestor != seen->pos.snapshot); in key_visible_in_snapshot()
475 * numerically, since snapshot ID lists are kept sorted, so if we find in key_visible_in_snapshot()
489 * ref_visible - given a key with snapshot id @src that points to a key with
490 * snapshot id @dst, test whether there is some snapshot in which @dst is
494 * @s: list of snapshot IDs already seen at @src
495 * @src: snapshot ID of src key
496 * @dst: snapshot ID of dst key
497 * Returns: true if there is some snapshot in which @dst is visible
525 (_i)->snapshot <= (_snapshot); _i++) \
526 if (key_visible_in_snapshot(_c, _s, _i->snapshot, _snapshot))
530 u32 snapshot; member
562 .snapshot = bch2_snapshot_equiv(c, inode.k->p.snapshot), in add_inode()
596 u32 snapshot, bool is_whiteout) in lookup_inode_for_snapshot() argument
600 snapshot = bch2_snapshot_equiv(c, snapshot); in lookup_inode_for_snapshot()
603 if (bch2_snapshot_is_ancestor(c, snapshot, i->snapshot)) in lookup_inode_for_snapshot()
608 BUG_ON(snapshot > i->snapshot); in lookup_inode_for_snapshot()
610 if (snapshot != i->snapshot && !is_whiteout) { in lookup_inode_for_snapshot()
615 new.snapshot = snapshot; in lookup_inode_for_snapshot()
618 bch_info(c, "have key for inode %llu:%u but have inode in ancestor snapshot %u", in lookup_inode_for_snapshot()
619 w->last_pos.inode, snapshot, i->snapshot); in lookup_inode_for_snapshot()
621 while (i > w->inodes.data && i[-1].snapshot > snapshot) in lookup_inode_for_snapshot()
650 return lookup_inode_for_snapshot(trans->c, w, pos.snapshot, is_whiteout); in walk_inode()
667 u32 equiv = bch2_snapshot_equiv(c, k.k->p.snapshot); in __get_visible_inodes()
672 if (!ref_visible(c, s, s->pos.snapshot, equiv)) in __get_visible_inodes()
678 if (equiv >= s->pos.snapshot) in __get_visible_inodes()
694 if (mustfix_fsck_err_on(!bch2_snapshot_equiv(c, k.k->p.snapshot), c, in check_key_has_snapshot()
696 "key in missing snapshot: %s", in check_key_has_snapshot()
727 k.k->p.snapshot, tmp, in hash_redo_key()
757 SPOS(hash_k.k->p.inode, hash, hash_k.k->p.snapshot), in hash_check_key()
864 ret = __write_inode(trans, &u, iter->pos.snapshot); in check_inode()
881 u.bi_inum, k.k->p.snapshot); in check_inode()
890 ret = bch2_inode_rm_snapshot(trans, u.bi_inum, iter->pos.snapshot); in check_inode()
908 iter->pos.snapshot), in check_inode()
935 sectors = bch2_count_inode_sectors(trans, u.bi_inum, iter->pos.snapshot); in check_inode()
954 ret = __write_inode(trans, &u, iter->pos.snapshot); in check_inode()
1018 count2 = bch2_count_inode_sectors(trans, w->last_pos.inode, i->snapshot); in check_i_sectors()
1025 w->last_pos.inode, i->snapshot, i->count, count2); in check_i_sectors()
1032 w->last_pos.inode, i->snapshot, in check_i_sectors()
1035 ret = fsck_write_inode(trans, &i->inode, i->snapshot); in check_i_sectors()
1046 u32 snapshot; member
1081 .snapshot = k.k->p.snapshot, in extent_ends_at()
1092 if (i->snapshot == k.k->p.snapshot) { in extent_ends_at()
1098 if (i->snapshot >= k.k->p.snapshot) in extent_ends_at()
1169 pos1.snapshot >= pos2.p.snapshot ? "first" : "second"); in overlapping_extents_found()
1176 if (pos1.snapshot < pos2.p.snapshot) { in overlapping_extents_found()
1194 if (pos1.snapshot == pos2.p.snapshot) { in overlapping_extents_found()
1197 * in the same snapshot: in overlapping_extents_found()
1200 } else if (pos1.snapshot > pos2.p.snapshot) { in overlapping_extents_found()
1202 * We overwrote the first extent in pos2's snapshot: in overlapping_extents_found()
1204 ret = snapshots_seen_add_inorder(c, pos1_seen, pos2.p.snapshot); in overlapping_extents_found()
1244 k.k->p.snapshot, seen, in check_overlapping_extents()
1245 i->snapshot, &i->seen)) in check_overlapping_extents()
1251 i->snapshot), in check_overlapping_extents()
1301 equiv.snapshot = bch2_snapshot_equiv(c, k.k->p.snapshot); in check_extent()
1342 equiv.snapshot, iter, in check_extent()
1350 * starting from the inode that matches this extent's snapshot. If we in check_extent()
1359 if (i->snapshot > equiv.snapshot || in check_extent()
1360 !key_visible_in_snapshot(c, s, i->snapshot, equiv.snapshot)) in check_extent()
1369 i->inode.bi_inum, i->snapshot, i->inode.bi_size, in check_extent()
1374 bch2_btree_iter_set_snapshot(&iter2, i->snapshot); in check_extent()
1467 count2 = bch2_count_subdirs(trans, w->last_pos.inode, i->snapshot); in check_subdir_count()
1482 w->last_pos.inode, i->snapshot, i->inode.bi_nlink, i->count)) { in check_subdir_count()
1484 ret = fsck_write_inode(trans, &i->inode, i->snapshot); in check_subdir_count()
1647 equiv.snapshot = bch2_snapshot_equiv(c, k.k->p.snapshot); in check_dirent()
1764 equiv.snapshot, in check_dirent()
1775 &i->inode, i->snapshot); in check_dirent()
1782 for_each_visible_inode(c, s, dir, equiv.snapshot, i) in check_dirent()
1883 u32 snapshot; in check_root_trans() local
1887 ret = subvol_lookup(trans, BCACHEFS_ROOT_SUBVOL, &snapshot, &inum); in check_root_trans()
1895 snapshot = U32_MAX; in check_root_trans()
1901 root_subvol.v.snapshot = cpu_to_le32(snapshot); in check_root_trans()
1909 ret = lookup_inode(trans, BCACHEFS_ROOT_INO, &root_inode, &snapshot); in check_root_trans()
1922 ret = __write_inode(trans, &root_inode, snapshot); in check_root_trans()
1941 u32 snapshot; member
1946 static bool path_is_dup(pathbuf *p, u64 inum, u32 snapshot) in path_is_dup() argument
1950 i->snapshot == snapshot) in path_is_dup()
1956 u64 inum, u32 snapshot) in path_down() argument
1960 .snapshot = snapshot, in path_down()
1977 u32 snapshot) in check_path() argument
1982 snapshot = bch2_snapshot_equiv(c, snapshot); in check_path()
1989 u32 parent_snapshot = snapshot; in check_path()
2015 inode->bi_inum, snapshot, in check_path()
2020 ret = reattach_inode(trans, inode, snapshot); in check_path()
2029 ret = path_down(c, p, inode->bi_inum, snapshot); in check_path()
2035 snapshot = parent_snapshot; in check_path()
2037 ret = lookup_inode(trans, inode->bi_dir, inode, &snapshot); in check_path()
2045 if (path_is_dup(p, inode->bi_inum, snapshot)) { in check_path()
2050 pr_err("%llu:%u", i->inum, i->snapshot); in check_path()
2051 pr_err("%llu:%u", inode->bi_inum, snapshot); in check_path()
2062 ret = reattach_inode(trans, inode, snapshot); in check_path()
2098 check_path(trans, &path, &u, iter.pos.snapshot); in bch2_check_directory_structure()
2112 u32 snapshot; member
2118 u64 inum, u32 snapshot) in add_nlink() argument
2141 .snapshot = snapshot, in add_nlink()
2157 u64 range_start, u64 range_end, u64 inum, u32 snapshot) in inc_link() argument
2160 .inum = inum, .snapshot = U32_MAX, in inc_link()
2175 if (ref_visible(c, s, snapshot, link->snapshot)) { in inc_link()
2177 if (link->snapshot >= snapshot) in inc_link()
2210 ret = add_nlink(c, t, k.k->p.offset, k.k->p.snapshot); in check_nlinks_find_hardlinks()
2247 bch2_snapshot_equiv(c, d.k->p.snapshot)); in check_nlinks_walk_dirents()
2283 cmp_int(link->snapshot, k.k->p.snapshot)) < 0) { in check_nlinks_update_inode()
2294 ret = __write_inode(trans, &u, k.k->p.snapshot); in check_nlinks_update_inode()