ceph

Is it dangerous for a cloned image to be flattened while being used as a volume?


I am currently learning about Ceph.

I found an interesting feature called flatten in the official documentation, and I have a question about this feature, so I'm asking.

Assuming that Openstack's Cinder service uses Ceph as backend storage, I have seen that clone images can be flattened while being used as volumes.

Doesn't it happen that data is corrupted if flattened while data is actively being written to the volume?

I'm wondering if flatten is a completely safe feature.

If it's safe, may I know the proof?

Thanks for reading the question. :)


Solution

  • Yes, flattening can be performed on a live image and it is not a dangerous operation.

    As to why, you need to study how Ceph stores block volumes, how snapshots and clones are created, and why flattening of clones is useful (it de-couples a cloned image from its parent snapshot). These topics are all interconnected, and are covered here.

    The short version is that as clones of a volume are created, Ceph references allocation units in the parent for all data except those allocation units that differ between the parent and the clone. This is called COW (copy on write), and saves a lot of space wherever many clones of a golden image are present (e.g. copies of Ubuntu 22.04). Flattening creates a separate copy of these common volume blocks that is dedicated to the clone, decoupling parent and clone. This is useful if one wishes to delete the parent volume.