Re: [Qemu-block] [PATCH v3 4/4] qcow2: Avoid memory over-allocation on compressed images

2018-02-26 Thread Alberto Garcia
On Thu 22 Feb 2018 08:02:44 PM CET, Eric Blake wrote: > On 02/22/2018 10:23 AM, Alberto Garcia wrote: >> On Thu 22 Feb 2018 04:59:22 PM CET, Eric Blake wrote: >>> sector_offset = coffset & 511; >>> csize = nb_csectors * 512 - sector_offset; >> [...] >>> +

Re: [Qemu-block] [PATCH v3 4/4] qcow2: Avoid memory over-allocation on compressed images

2018-02-22 Thread Eric Blake
On 02/22/2018 10:23 AM, Alberto Garcia wrote: On Thu 22 Feb 2018 04:59:22 PM CET, Eric Blake wrote: sector_offset = coffset & 511; csize = nb_csectors * 512 - sector_offset; [...] +assert(csize < 2 * s->cluster_size); I think it should be <= If

Re: [Qemu-block] [PATCH v3 4/4] qcow2: Avoid memory over-allocation on compressed images

2018-02-22 Thread Alberto Garcia
On Thu 22 Feb 2018 04:59:22 PM CET, Eric Blake wrote: > sector_offset = coffset & 511; > csize = nb_csectors * 512 - sector_offset; [...] > +assert(csize < 2 * s->cluster_size); I think it should be <= If sector_offset is 0 and nb_csector is the maximum

[Qemu-block] [PATCH v3 4/4] qcow2: Avoid memory over-allocation on compressed images

2018-02-22 Thread Eric Blake
When reading a compressed image, we were allocating s->cluster_data to 32*cluster_size + 512 (possibly over 64 megabytes, for an image with 2M clusters). Let's check out the history: Back when qcow2 was first written, we used s->cluster_data for everything, including copy_sectors() and