On Wed, May 07, 2014 at 09:45:17AM +0800, Fam Zheng wrote:
> On Tue, 05/06 10:32, Fam Zheng wrote:
> > @@ -1110,12 +1111,20 @@ static int get_cluster_offset(BlockDriverState *bs,
> >          }
> >  
> >          /* Avoid the L2 tables update for the images that have snapshots. 
> > */
> > -        *cluster_offset = bdrv_getlength(extent->file);
> > +        ret = bdrv_getlength(extent->file);
> > +        if (ret < 0 ||
> > +            ret & ((extent->cluster_sectors << BDRV_SECTOR_BITS) - 1)) {
> > +            return VMDK_ERROR;
> > +        }
> > +        *cluster_offset = ret;
> >          if (!extent->compressed) {
> > -            bdrv_truncate(
> > -                extent->file,
> > -                *cluster_offset + (extent->cluster_sectors << 9)
> > -            );
> > +            ret = bdrv_write_zeroes(extent->file,
> > +                                    *cluster_offset >> BDRV_SECTOR_BITS,
> > +                                    extent->cluster_sectors,
> > +                                    0);
> 
> Hi Stefan,
> 
> By considering a bdrv_write_zeroes as a pre-write, it in general doubles the
> write for the whole image, so it's not a good solution.
> 
> A better way would be removing the bdrv_truncate and require the caller to do
> full cluster write (with a bounce buffer if necessary).
> 
> So let's drop this patch.

Okay, thanks for investigating this.

Stefan

Reply via email to