Lines Matching full:snapshot

13 #include "snapshot.h"
18 * Snapshot trees:
20 * Keys in BTREE_ID_snapshot_trees identify a whole tree of snapshot nodes; they
21 * exist to provide a stable identifier for the whole lifetime of a snapshot
30 prt_printf(out, "subvol %u root snapshot %u", in bch2_snapshot_tree_to_text()
93 /* Snapshot nodes: */
355 BTREE_ITER_with_updates, snapshot, s); in bch2_snapshot_lookup()
427 if (!bch2_snapshot_is_ancestor(c, le32_to_cpu(s.v->snapshot), snapshot_root)) in bch2_snapshot_tree_master_subvol()
476 POS(0, root_id), 0, snapshot); in check_snapshot_tree()
488 "snapshot tree points to missing/incorrect snapshot:\n%s", in check_snapshot_tree()
508 "snapshot tree points to missing subvolume:\n%s", in check_snapshot_tree()
512 le32_to_cpu(subvol.snapshot), in check_snapshot_tree()
515 "snapshot tree points to subvolume that does not point to snapshot in this tree:\n%s", in check_snapshot_tree()
520 "snapshot tree points to snapshot subvolume:\n%s", in check_snapshot_tree()
554 * For each snapshot_tree, make sure it points to the root of a snapshot tree
555 * and that snapshot entry points back to it, or delete it.
557 * And, make sure it points to a subvolume within that snapshot tree, or correct
558 * it to point to the oldest subvolume within that snapshot tree.
573 * Look up snapshot tree for @tree_id and find root,
623 * snapshot_tree pointer was incorrect: look up root snapshot node, make sure
642 BTREE_ITER_with_updates, snapshot); in snapshot_tree_ptr_repair()
654 u = bch2_bkey_make_mut_typed(trans, &root_iter, &root.s_c, 0, snapshot); in snapshot_tree_ptr_repair()
668 u = bch2_bkey_make_mut_typed(trans, iter, &k, 0, snapshot); in snapshot_tree_ptr_repair()
706 bch_err(c, "snapshot with nonexistent parent:\n %s", in check_snapshot()
713 bch_err(c, "snapshot parent %u missing pointer to child %llu", in check_snapshot()
725 bch_err(c, "snapshot node %llu has nonexistent child %u", in check_snapshot()
731 bch_err(c, "snapshot child %u has wrong parent (got %u should be %llu)", in check_snapshot()
745 bch_err(c, "snapshot points to nonexistent subvolume:\n %s", in check_snapshot()
750 if (BCH_SNAPSHOT_SUBVOL(&s) != (le32_to_cpu(subvol.snapshot) == k.k->p.offset)) { in check_snapshot()
751 bch_err(c, "snapshot node %llu has wrong BCH_SNAPSHOT_SUBVOL", in check_snapshot()
759 "snapshot should not point to subvol:\n%s", in check_snapshot()
761 u = bch2_bkey_make_mut_typed(trans, iter, &k, 0, snapshot); in check_snapshot()
777 "snapshot points to missing/incorrect tree:\n%s", in check_snapshot()
789 "snapshot with incorrect depth field, should be %u:\n%s", in check_snapshot()
791 u = bch2_bkey_make_mut_typed(trans, iter, &k, 0, snapshot); in check_snapshot()
806 "snapshot with bad skiplist field:\n%s", in check_snapshot()
808 u = bch2_bkey_make_mut_typed(trans, iter, &k, 0, snapshot); in check_snapshot()
870 struct bkey_i_snapshot *snapshot = bch2_trans_kmalloc(trans, sizeof(*snapshot)); in check_snapshot_exists() local
871 ret = PTR_ERR_OR_ZERO(snapshot); in check_snapshot_exists()
875 bkey_snapshot_init(&snapshot->k_i); in check_snapshot_exists()
876 snapshot->k.p = POS(0, id); in check_snapshot_exists()
877 snapshot->v.tree = cpu_to_le32(tree_id); in check_snapshot_exists()
878 snapshot->v.btime.lo = cpu_to_le64(bch2_current_time(c)); in check_snapshot_exists()
882 if (le32_to_cpu(bkey_s_c_to_subvolume(k).v->snapshot) == id) { in check_snapshot_exists()
883 snapshot->v.subvol = cpu_to_le32(k.k->p.offset); in check_snapshot_exists()
884 SET_BCH_SNAPSHOT_SUBVOL(&snapshot->v, true); in check_snapshot_exists()
890 return bch2_btree_insert_trans(trans, BTREE_ID_snapshots, &snapshot->k_i, 0) ?: in check_snapshot_exists()
892 bkey_s_c_null, bkey_i_to_s(&snapshot->k_i), 0); in check_snapshot_exists()
895 /* Figure out which snapshot nodes belong in the same tree: */
960 return snapshot_list_add_nodup(c, &r->cur_ids, pos.snapshot); in get_snapshot_trees()
992 "snapshot node %u from tree %s missing, recreate?", *id, buf.buf)) { in bch2_reconstruct_snapshots()
994 bch_err(c, "cannot reconstruct snapshot trees with multiple nodes"); in bch2_reconstruct_snapshots()
1023 if (fsck_err_on(!bch2_snapshot_exists(c, k.k->p.snapshot), in bch2_check_key_has_snapshot()
1025 "key in missing snapshot %s, delete?", in bch2_check_key_has_snapshot()
1037 * Mark a snapshot as deleted, for future cleanup:
1045 0, snapshot); in bch2_snapshot_node_set_deleted()
1049 trans->c, "missing snapshot %u", id); in bch2_snapshot_node_set_deleted()
1083 BTREE_ITER_intent, snapshot); in bch2_snapshot_node_delete()
1086 "missing snapshot %u", id); in bch2_snapshot_node_delete()
1101 0, snapshot); in bch2_snapshot_node_delete()
1104 "missing snapshot %u", parent_id); in bch2_snapshot_node_delete()
1114 "snapshot %u missing child pointer to %u", in bch2_snapshot_node_delete()
1128 0, snapshot); in bch2_snapshot_node_delete()
1131 "missing snapshot %u", child_id); in bch2_snapshot_node_delete()
1146 * We're deleting the root of a snapshot tree: update the in bch2_snapshot_node_delete()
1148 * this is the last snapshot ID in this tree: in bch2_snapshot_node_delete()
1209 n = bch2_bkey_alloc(trans, &iter, 0, snapshot); in create_snapids()
1241 * Create new snapshot IDs as children of an existing snapshot ID:
1254 0, snapshot); in bch2_snapshot_node_create_children()
1258 bch_err(trans->c, "snapshot %u not found", parent); in bch2_snapshot_node_create_children()
1263 bch_err(trans->c, "Trying to add child snapshot nodes to parent that already has children"); in bch2_snapshot_node_create_children()
1283 * Create a snapshot node that is the root of a new tree:
1322 * If we have an unlinked inode in an internal snapshot node, and the inode
1329 * also: unlinked inode in internal snapshot appears to not be getting deleted
1334 * for a key in an interior snapshot node that needs work to be done that
1336 * that key to snapshot leaf nodes, where we can mutate it
1395 if (snapshot_list_has_id(delete_leaves, k.k->p.snapshot)) in delete_dead_snapshots_process_key()
1399 u32 live_child = interior_delete_has_id(delete_interior, k.k->p.snapshot); in delete_dead_snapshots_process_key()
1406 new->k.p.snapshot = live_child; in delete_dead_snapshots_process_key()
1431 * For a given snapshot, if it doesn't have a subvolume that points to it, and
1432 * it doesn't have child snapshot nodes - it's now redundant and we can mark it
1465 bch_err(c, "error finding live child of snapshot %u", d.id); in check_should_delete_snapshot()
1507 s = bch2_bkey_make_mut_noupdate_typed(trans, k, snapshot); in bch2_fix_child_of_deleted_snapshot()
1559 * For every snapshot node: If we have no live children and it's not in bch2_delete_dead_snapshots()
1614 bch_err_msg(c, ret, "deleting snapshot %u", *i); in bch2_delete_dead_snapshots()
1635 bch_err_msg(c, ret, "deleting snapshot %u", i->id); in bch2_delete_dead_snapshots()
1685 if (bch2_snapshot_is_ancestor(c, k.k->p.snapshot, pos.snapshot)) { in __bch2_key_has_snapshot_overwrites()
1730 * otherwise, we could end up deleting keys with missing snapshot nodes in bch2_snapshots_read()