From: Stefan Hajnoczi <stefanha@redhat.com>
To: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
Cc: qemu devel <qemu-devel@nongnu.org>, Fam Zheng <famz@redhat.com>,
Max Reitz <mreitz@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Kevin Wolf <kwolf@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Dong Eddie <eddie.dong@intel.com>,
Jiang Yunhong <yunhong.jiang@intel.com>,
Wen Congyang <wency@cn.fujitsu.com>,
qemu block <qemu-block@nongnu.org>,
"Michael R. Hines" <mrhines@linux.vnet.ibm.com>,
Eric Blake <eblake@redhat.com>,
zhanghailiang <zhang.zhanghailiang@huawei.com>,
Gonglei <arei.gonglei@huawei.com>
Subject: Re: [Qemu-devel] [PATCH v17 7/8] Implement new driver for block replication
Date: Wed, 13 Apr 2016 14:02:25 +0100 [thread overview]
Message-ID: <20160413130225.GD9272@stefanha-x1.localdomain> (raw)
In-Reply-To: <1460362979-15146-8-git-send-email-xiecl.fnst@cn.fujitsu.com>
[-- Attachment #1: Type: text/plain, Size: 1849 bytes --]
On Mon, Apr 11, 2016 at 04:22:58PM +0800, Changlong Xie wrote:
> +static coroutine_fn int replication_co_writev(BlockDriverState *bs,
> + int64_t sector_num,
> + int remaining_sectors,
> + QEMUIOVector *qiov)
> +{
> + BDRVReplicationState *s = bs->opaque;
> + QEMUIOVector hd_qiov;
> + uint64_t bytes_done = 0;
> + BdrvChild *top = bs->file;
> + BdrvChild *base = s->secondary_disk;
> + BlockDriverState *target;
> + int ret, n;
> +
> + ret = replication_get_io_status(s);
> + if (ret < 0) {
> + return ret;
> + }
> +
> + if (ret == 0) {
> + ret = bdrv_co_writev(top->bs, sector_num,
> + remaining_sectors, qiov);
> + return replication_return_value(s, ret);
> + }
> +
> + /*
> + * Failover failed, only write to active disk if the sectors
> + * have already been allocated in active disk/hidden disk.
> + */
> + qemu_iovec_init(&hd_qiov, qiov->niov);
> + while (remaining_sectors > 0) {
> + ret = bdrv_is_allocated_above(top->bs, base->bs, sector_num,
> + remaining_sectors, &n);
> + if (ret < 0) {
> + return ret;
> + }
> +
> + qemu_iovec_reset(&hd_qiov);
> + qemu_iovec_concat(&hd_qiov, qiov, bytes_done, n * BDRV_SECTOR_SIZE);
> +
> + target = ret ? (top->bs) : (base->bs);
> + ret = bdrv_co_writev(target, sector_num, n, &hd_qiov);
> + if (ret < 0) {
> + return ret;
> + }
> +
> + remaining_sectors -= n;
> + sector_num += n;
> + bytes_done += n * BDRV_SECTOR_SIZE;
> + }
> +
> + return 0;
qemu_iovec_destroy(&hd_qiov) is missing (also in error cases).
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2016-04-13 13:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-11 8:22 [Qemu-devel] [PATCH v17 0/8] Block replication for continuous checkpoints Changlong Xie
2016-04-11 8:22 ` [Qemu-devel] [PATCH v17 1/8] unblock backup operations in backing file Changlong Xie
2016-04-11 8:22 ` [Qemu-devel] [PATCH v17 2/8] Backup: clear all bitmap when doing block checkpoint Changlong Xie
2016-04-11 8:22 ` [Qemu-devel] [PATCH v17 3/8] Link backup into block core Changlong Xie
2016-04-11 8:22 ` [Qemu-devel] [PATCH v17 4/8] docs: block replication's description Changlong Xie
2016-04-11 8:22 ` [Qemu-devel] [PATCH v17 5/8] auto complete active commit Changlong Xie
2016-04-11 8:22 ` [Qemu-devel] [PATCH v17 6/8] Introduce new APIs to do replication operation Changlong Xie
2016-04-13 12:47 ` Stefan Hajnoczi
2016-04-14 1:47 ` Changlong Xie
2016-04-11 8:22 ` [Qemu-devel] [PATCH v17 7/8] Implement new driver for block replication Changlong Xie
2016-04-13 13:02 ` Stefan Hajnoczi [this message]
2016-04-14 3:46 ` Changlong Xie
2016-04-11 8:22 ` [Qemu-devel] [PATCH v17 8/8] support replication driver in blockdev-add Changlong Xie
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=20160413130225.GD9272@stefanha-x1.localdomain \
--to=stefanha@redhat.com \
--cc=arei.gonglei@huawei.com \
--cc=dgilbert@redhat.com \
--cc=eblake@redhat.com \
--cc=eddie.dong@intel.com \
--cc=famz@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=mrhines@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=wency@cn.fujitsu.com \
--cc=xiecl.fnst@cn.fujitsu.com \
--cc=yunhong.jiang@intel.com \
--cc=zhang.zhanghailiang@huawei.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).