On 06/03/2016 11:21 AM, Kevin Wolf wrote: > In preparation for implementing .bdrv_co_pwritev in qcow2. > > Signed-off-by: Kevin Wolf <kw...@redhat.com> > --- > block/qcow2-cluster.c | 32 ++++++++++++-------------------- > block/qcow2.h | 13 +++---------- > 2 files changed, 15 insertions(+), 30 deletions(-) >
> @@ -1192,25 +1191,20 @@ static int handle_alloc(BlockDriverState *bs, > uint64_t guest_offset, > /* > * Save info needed for meta data update. > * > - * requested_sectors: Number of sectors from the start of the first > + * requested_sectors: Number of bytes from the start of the first This comment seems like an incomplete conversion. Is it sectors or bytes? > - int requested_sectors = > - (*bytes + offset_into_cluster(s, guest_offset)) > - >> BDRV_SECTOR_BITS; > - int avail_sectors = nb_clusters > - << (s->cluster_bits - BDRV_SECTOR_BITS); > - int alloc_n_start = offset_into_cluster(s, guest_offset) > - >> BDRV_SECTOR_BITS; > - int nb_sectors = MIN(requested_sectors, avail_sectors); > + int requested_bytes = *bytes + offset_into_cluster(s, guest_offset); > + int avail_bytes = nb_clusters << s->cluster_bits; Can this ever overflow? Otherwise looks correct. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature