From: Stefan Hajnoczi <stefanha@redhat.com>
To: Fam Zheng <famz@redhat.com>
Cc: qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
	Ronnie Sahlberg <ronniesahlberg@gmail.com>,
	qemu-block@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
	Peter Lieven <pl@kamp.de>, Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 3/9] qcow2: Implement copy offloading
Date: Thu, 10 May 2018 10:25:50 +0100	[thread overview]
Message-ID: <20180510092550.GL1296@stefanha-x1.localdomain> (raw)
In-Reply-To: <20180509145815.3330-4-famz@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1334 bytes --]
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?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
next prev parent reply	other threads:[~2018-05-10  9:25 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-09 14:58 [Qemu-devel] [PATCH v3 0/9] qemu-img convert with copy offloading Fam Zheng
2018-05-09 14:58 ` [Qemu-devel] [PATCH v3 1/9] block: Introduce API for " Fam Zheng
2018-05-10  8:44   ` Stefan Hajnoczi
2018-05-09 14:58 ` [Qemu-devel] [PATCH v3 2/9] raw: Implement " Fam Zheng
2018-05-09 15:17   ` Eric Blake
2018-05-11  6:19     ` Fam Zheng
2018-05-09 14:58 ` [Qemu-devel] [PATCH v3 3/9] qcow2: " Fam Zheng
2018-05-10  9:25   ` Stefan Hajnoczi [this message]
2018-05-10 14:51     ` Fam Zheng
2018-05-09 14:58 ` [Qemu-devel] [PATCH v3 4/9] file-posix: Implement bdrv_co_copy_range Fam Zheng
2018-05-10  8:50   ` Stefan Hajnoczi
2018-05-11  7:20     ` Fam Zheng
2018-05-09 14:58 ` [Qemu-devel] [PATCH v3 5/9] iscsi: Query and save device designator when opening Fam Zheng
2018-05-10  8:54   ` Stefan Hajnoczi
2018-05-09 14:58 ` [Qemu-devel] [PATCH v3 6/9] iscsi: Create and use iscsi_co_wait_for_task Fam Zheng
2018-05-09 15:19   ` Eric Blake
2018-05-10  8:58   ` Stefan Hajnoczi
2018-05-09 14:58 ` [Qemu-devel] [PATCH v3 7/9] iscsi: Implement copy offloading Fam Zheng
2018-05-10  9:04   ` Stefan Hajnoczi
2018-05-09 14:58 ` [Qemu-devel] [PATCH v3 8/9] block-backend: Add blk_co_copy_range Fam Zheng
2018-05-10  9:05   ` Stefan Hajnoczi
2018-05-09 14:58 ` [Qemu-devel] [PATCH v3 9/9] qemu-img: Convert with copy offloading Fam Zheng
2018-05-10  9:08   ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox
  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):
  git send-email \
    --in-reply-to=20180510092550.GL1296@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=pl@kamp.de \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=ronniesahlberg@gmail.com \
    /path/to/YOUR_REPLY
  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
  Be sure your reply has a Subject: header at the top and a blank line
  before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).