Nova pre-allocation of qcow2 is flawed

Bug #1510328 reported by Daniel Berrange
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Confirmed
Low
Unassigned

Bug Description

The nova/virt/libvirt/imagebackend.py file contains code for pre-allocating image files, so that sufficient space is guaranteed available for the VM's full disk size. As well as preventing accidental out-of-space conditions, this is important for maximising performance.

It currently just calls 'qemu-img info' to get the virtual image size, and then calls 'fallocate' to allocate file system blocks to match this size. This is fine for raw files, but is significantly flawed for qcow2 files.

 - QCow2 files have extra space overhead beyond the logical image size. There is header metadata, cluster lookup tables and so forth. As a result Nova is not allocating sufficient space for qcow2 files.

 - The qcow2 internal metadata is not being pre-allocated. Since the allocation was done as the FS level, qcow2 file doesn't know it has all this space pre-allocated, so its internal metadata still setup to assume it is a (mostly) empty file. This will have a runtime performance overhead on guest writes, since further internal metadata will have to be updated.

 - The file will suffer from fragmentation. Again since the internal metadat does not know the FS has full pre-allocated its size, as the guest writes blocks, they will be allocated in the internal metadata on a first-come-first-served basis. This will caused the layout of the virtual disk blocks to be random inside the qcow2 file. This causes significant fragmentation which will be bad for performance.

The solution to all these problems is to use qemu-img to do the preallocation, so the qcow2 file internals are fully in sync with the filesystem size.

Tags: libvirt
tags: added: libvirt
Mark Doffman (mjdoffma)
Changed in nova:
assignee: nobody → Mark Doffman (mjdoffma)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/241401

Changed in nova:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on nova (master)

Change abandoned by Mark Doffman (<email address hidden>) on branch: master
Review: https://review.openstack.org/241401
Reason: After discussion with Daniel found that this patch is fatally broken as the preallocate=metadata apparently will not work with backing files.

Changed in nova:
assignee: Mark Doffman (mjdoffma) → nobody
status: In Progress → Confirmed
Revision history for this message
Anseela M M (anseela-m00) wrote :

Can you please mention the version which you found this error?

Revision history for this message
Anseela M M (anseela-m00) wrote :

hi

Please let me know how to reproduce this bug.

Changed in nova:
assignee: nobody → Gregory Hooks (gregoryhooksjr)
Changed in nova:
assignee: Gregory Hooks (gregoryhooksjr) → nobody
Changed in nova:
assignee: nobody → Anseela M M (anseela-m00)
Changed in nova:
assignee: Anseela M M (anseela-m00) → nobody
Changed in nova:
importance: Undecided → Medium
importance: Medium → Low
Changed in nova:
assignee: nobody → Silvan Kaiser (2-silvan)
status: Confirmed → In Progress
Revision history for this message
Sean Dague (sdague) wrote :

There are no currently open reviews on this bug, changing the status back to the previous state and unassigning. If there are active reviews related to this bug, please include links in comments.

Changed in nova:
status: In Progress → Confirmed
assignee: Silvan Kaiser (2-silvan) → nobody
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Silvan Kaiser (<email address hidden>) on branch: master
Review: https://review.openstack.org/480464

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.