qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] vmdk: Optimize cluster allocation


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH v2] vmdk: Optimize cluster allocation
Date: Wed, 7 May 2014 10:04:56 +0200
User-agent: Mutt/1.5.21 (2010-09-15)

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

[Prev in Thread] Current Thread [Next in Thread]