On 09.07.2014 23:22, Paolo Bonzini wrote:
Il 05/07/2014 19:47, Max Reitz ha scritto:
bdrv_make_empty() is currently only called if the current image
represents an external snapshot that has been committed to its base
image; it is therefore unlikely to have internal snapshots. In this
case, bdrv_make_empty() can be greatly sped up by creating an empty L1
table and dropping all data clusters at once by recreating the refcount
structure accordingly instead of normally discarding all clusters.

If there are snapshots, fall back to the simple implementation (discard
all clusters).

How much of this code could be reused by bdrv_create?

Currently, none. The latest version of Hu Tao's preallocation series reuses minimal_blob_size().

The point of this code is to empty an image at runtime while keeping it consistent all the time. bdrv_open() does not have that problem; there are no pre-existing structures, therefore it can just go and create them. bdrv_make_empty() has to be careful (in this version) not to overwrite any data or metadata while relocating the structures.

Kevin proposed another version which just marks the image dirty, clears the L1 table, relocates it and then writes minimal refcount structures. This will be shorted and in principle similar to how bdrv_open() works, but isn't worth sharing either.

Max

Reply via email to