On Mon, Aug 21, 2017 at 02:55:30PM +0100, Stefan Hajnoczi wrote: > Most qcow2 files are uncompressed so it is wasteful to allocate (32 + 1) > * cluster_size + 512 bytes upfront. Allocate s->cluster_cache and > s->cluster_data when the first read operation is performance on a > compressed cluster. > > The buffers are freed in .bdrv_close(). .bdrv_open() no longer has any > code paths that can allocate these buffers, so remove the free functions > in the error code path. > > This patch can result in significant memory savings when many qcow2 > disks are attached or backing file chains are long: > > Before 12.81% (1,023,193,088B) > After 5.36% (393,893,888B) > > Reported-by: Alexey Kardashevskiy <a...@ozlabs.ru> > Tested-by: Alexey Kardashevskiy <a...@ozlabs.ru> > Cc: Kevin Wolf <kw...@redhat.com> > Signed-off-by: Stefan Hajnoczi <stefa...@redhat.com> > --- > v2: > * Changed EIO to ENOMEM [Eric] > * Added Alexey's Tested-by > --- > block/qcow2-cluster.c | 17 +++++++++++++++++ > block/qcow2.c | 12 ------------ > 2 files changed, 17 insertions(+), 12 deletions(-)
Thanks, applied to my block-next tree: https://github.com/stefanha/qemu/commits/block-next Stefan