qemu-block
[Top][All Lists]
Advanced

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

Re: [Qemu-block] [PATCH v3 3/9] qcow2: Implement copy offloading


From: Fam Zheng
Subject: Re: [Qemu-block] [PATCH v3 3/9] qcow2: Implement copy offloading
Date: Thu, 10 May 2018 22:51:32 +0800
User-agent: Mutt/1.9.2 (2017-12-15)

On Thu, 05/10 10:25, Stefan Hajnoczi wrote:
> On Wed, May 09, 2018 at 10:58:09PM +0800, Fam Zheng wrote:
> > +static int qcow2_co_copy_range_from(BlockDriverState *bs,
> > +                                    BdrvChild *src, uint64_t src_offset,
> > +                                    BdrvChild *dst, uint64_t dst_offset,
> > +                                    uint64_t bytes, BdrvRequestFlags flags)
> > +{
> > +    BDRVQcow2State *s = bs->opaque;
> > +    int offset_in_cluster;
> > +    int ret;
> > +    unsigned int cur_bytes; /* number of bytes in current iteration */
> > +    uint64_t cluster_offset = 0;
> > +    BdrvChild *child = NULL;
> > +
> > +    assert(!bs->encrypted);
> > +    qemu_co_mutex_lock(&s->lock);
> > +
> > +    while (bytes != 0) {
> > +
> > +        /* prepare next request */
> > +        cur_bytes = MIN(bytes, INT_MAX);
> > +
> > +        ret = qcow2_get_cluster_offset(bs, src_offset, &cur_bytes, 
> > &cluster_offset);
> > +        if (ret < 0) {
> > +            goto out;
> > +        }
> > +
> > +        offset_in_cluster = offset_into_cluster(s, src_offset);
> > +
> > +        switch (ret) {
> > +        case QCOW2_CLUSTER_UNALLOCATED:
> > +            if (bs->backing) {
> > +                child = bs->backing;
> > +            } else {
> > +                flags |= BDRV_REQ_ZERO_WRITE;
> > +            }
> > +            break;
> 
> Do we need a special case if the backing file is shorter than this
> image?

Yes, we should take the BDRV_REQ_ZERO_WRITE path if the range is fully beyond
EOF, otherwise clip cur_bytes at the backing image offset.

Fam





reply via email to

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