On Fri, Jun 19, 2020 at 1:40 PM Max Reitz <mre...@redhat.com> wrote: > > Hi, > > As discussed here: > > https://lists.nongnu.org/archive/html/qemu-block/2020-02/msg00644.html > https://lists.nongnu.org/archive/html/qemu-block/2020-04/msg00329.html > https://lists.nongnu.org/archive/html/qemu-block/2020-06/msg00240.html > > I think that qcow2 images with data-file-raw should always have > preallocated 1:1 L1/L2 tables, so that the image always looks the same > whether you respect or ignore the qcow2 metadata.
I don't know the internals of qcow2 data_file, but are we really using qcow2 metadata when accessing the data file? This may have unwanted performance consequences. If I understand correctly, qcow2 metadata is needed only for keeping bitmaps (or maybe future extensions) for raw data file, and reading from the qcow2 image should be read directly from the raw file without any extra work. Writing to the data file should also bypass the qcow2 metadata, since the bitmap is updated in memory. > The easiest way to > achieve that is to enforce at least metadata preallocation whenever > data-file-raw is given. But preallocation is not free, even on file systems, it can be even slow (NFS < 4.2). With block storage this means you need to allocate the entire image size on storage for writing the metadata. While oVirt does not use qcow2 with data_file, having preallocated qcow2 will make this very hard to use, for example for 500 GiB disk we will have to allocate 500 GiB disk for the raw data file and 500 GiB disk for the qcow2 metadata disk which will be 99% unused. I don't think that kubevirt is planning to use this either, but if they decide to use this it may be a problem for them as well when using block storage. It looks like we abuse preallocation for getting the side effect that the backing file will be rejected, instead of adding the validation rejecting backing file in this case. Nir Nir > Max Reitz (2): > qcow2: Force preallocation with data-file-raw > iotests/244: Test preallocation for data-file-raw > > block/qcow2.c | 22 +++++++++++++ > tests/qemu-iotests/244 | 65 ++++++++++++++++++++++++++++++++++++++ > tests/qemu-iotests/244.out | 32 ++++++++++++++++--- > 3 files changed, 114 insertions(+), 5 deletions(-) > > -- > 2.26.2 > >