Snapshot Fundamentals

Non-Ceph Storage QCOW2 External Snapshot Mechanism

For non-Ceph storage including LocalStorage, NFS, Shared Mount Point, and Shared Block, ZStack Cloud uses QCOW2 (QEMU Copy On Write, Version 2) external snapshot mechanism.

  1. Snapshot Tree and Snapshot Chain

    A volume corresponds to a snapshot chain. ZStack Cloud allows you to create a snapshot tree for a volume. Each branch of the snapshot tree is a snapshot chain.

    Figure 1. Snapshot Tree


    A snapshot tree includes the following information:
    • Snapshot chain: a chain of snapshots of a volume that are associated with each other. Each branch of a snapshot tree is a snapshot chain.
    • Snapshot node: a node in a snapshot chain that represents a snapshot of a volume.
    • Snapshot size: the storage space that a snapshot occupies. You can view the total size of all snapshots in a snapshot tree and the size of an individual snapshot node.
    Note:
    • For non-Ceph storage, a snapshot node can have a maximum of 128 nodes by default. You can customize the maximum length of a snapshot chain Global Setting by setting Maximum Incremental Volume Snapshot. For Ceph storage, a snapshot node can have a maximum of 32 nodes, including the auto-created and manually-created nodes.
    • If the length of a snapshot chain reaches the threshold:
      • If an auto-snapshot is created, the system automatically deletes the snapshot that was created at the earliest time.
      • If you manually create a snapshot, you need to manually delete the snapshot that you do not need.
    • In the production environment, we recommend that you limit the number of snapshots created for a volume to 5. Too many snapshots will lower VM and volume performance, increase data security risks, and occupy storage space of primary storage. To back up data for the long term, you can use Backup Service.
  2. Create Snapshot

    When an external snapshot is created, an empty qcow2 file is created. The backing file of the empty file points to the previous qcow2 file. This qcow2 file is set to read-only and become a snapshot. Data is written to the empty qcow2 file.

    • Create single-chain snapshots based on the backing file.
      Figure 2. Create Single-Chain Snapshots


      Suppose you have a raw image. You use the image to create a VM instance named VM 1 and then create snapshot 1A and 1B for VM 1.
      • Raw image: a disk image file that includes a complete operating system and boot process. The image is a read-only file used as the base file.
      • VM 1: creates an empty file named Overlay-1. The backing file of the empty file points to the base file. The base file is kept read-only and becomes a snapshot. Data is written to Overlay-1.
      • Snapshot 1A: creates an empty file named Overlay-1A. The backing file of the empty file points to Overlay-1. Overlay-1 is set to read-only and becomes a snapshot. Data is written to Overlay-1A.
      • Snapshot 1B: creates an empty file named Overlay-1B. The backing file of the empty file points to Overlay-1A. Overlay-1A is set to read-only and becomes a snapshot. Data is written to Overlay-1B. Overlay-1B is the last snapshot in the snapshot chain and is in Active state. VM 1 uses the disk file that corresponds to the snapshot Overlay-1B.
    • Create a multi-chain snapshot chain based on the backing file.
      Figure 3. Create Multi-Chain Snapshots


      Suppose you have a raw image. You use the image to create VM instances named VM 1, VM 2, and VM 3 and then create snapshot 1A and 1B for VM 1, snapshot 2 for VM 2, and snapshot 3A for VM 3.
      • Raw image: a disk image file that includes a complete operating system and boot process. The image is a read-only file used as the base file.
      • Snapshot chain 1:
        • VM 1: creates an empty file named Overlay-1. The backing file of the empty file points to the base file. The base file is kept read-only and becomes a snapshot. Data is written to Overlay-1.
        • Snapshot 1A: creates an empty file named Overlay-1A. The backing file of the empty file points to Overlay-1. Overlay-1 is set to read-only and becomes a snapshot. Data is written to Overlay-1A.
        • Snapshot 1B: creates an empty file named Overlay-1B. The backing file of the empty file points to Overlay-1A. Overlay-1A is set to read-only and becomes a snapshot. Data is written to Overlay-1B. Overlay-1B is the last snapshot in the snapshot chain and is in Active state. VM 1 uses the disk file that corresponds to the snapshot Overlay-1B.
      • Snapshot chain 2:
        • VM 2: creates an empty file named Overlay-2. The backing file of the empty file points to the base file. The base file is kept read-only and becomes a snapshot. Data is written to Overlay-2.
        • Snapshot 2A: creates an empty file named Overlay-2A. The backing file of the empty file points to Overlay-2. Overlay-2 is set to read-only and becomes a snapshot. Data is written to Overlay-2A. Overlay-2A is the last snapshot in the snapshot chain and is in Active state. VM 1 uses the disk file that corresponds to the snapshot Overlay-2A.
      • Snapshot chain 3:
        • VM 2: creates an empty file named Overlay-3. The backing file of the empty file points to the base file. The base file is kept read-only and becomes a snapshot. Data is written to Overlay-3.
        • Snapshot 3A: creates an empty file named Overlay-3A. The backing file of the empty file points to Overlay-3. Overlay-3 is set to read-only and becomes a snapshot. Data is written to Overlay-3A. Overlay-3A is the last snapshot in the snapshot chain and is in Active state. VM 1 uses the disk file that corresponds to the snapshot Overlay-3A.
  3. Consolidate Snapshots

    External snapshots are interdependent with each overlay snapshot depending on its backing file. Each snapshot captures certain amounts of data. You cannot directly delete a snapshot to shorten a snapshot chain. To shorten a snapshot chain, you can blockcommit or blockpull external snapshots.

    • Blockcommit

      Consolidate overlay snapshots of a snapshot chain into backing files.

      Figure 4. Blockcommit


      Suppose you have a raw image. You use the image to create VM instance named VM 1 then create three dependent snapshots named 1A, 1B, and 1C for VM 1. Then you blockcommit snapshot 1A and 1B to VM 1. This makes the backing file of snapshot 1C which is in Active state points to VM 1 and shortens the snapshot chain. Snapshot 1A and 1B are no longer useful and you can delete the two snapshots.

    • Blockpull

      Consolidate backing files of a snapshot chain into overlay snapshots.

      Figure 5. Blockpull


      Suppose you have a raw image. You use the image to create VM instance named VM 1 then create three dependent snapshots named 1A, 1B, and 1C for VM 1. Then you blockpull snapshot 1A and 1B to snapshot 1C of VM 1. This makes the backing file of snapshot 1C which is in Active state points to VM 1 and shortens the snapshot chain. Snapshot 1A and 1B are no longer useful and you can delete the two snapshots.

Ceph Storage Snapshot Mechanism

For Ceph storage, ZStack Cloud uses the mainstream ROW (Redirect-On-Write) snapshot mechanism of Ceph.