[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v17 7/8] Implement new driver for block replicat
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] [PATCH v17 7/8] Implement new driver for block replication |
Date: |
Wed, 13 Apr 2016 14:02:25 +0100 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
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).
signature.asc
Description: PGP signature
- [Qemu-devel] [PATCH v17 1/8] unblock backup operations in backing file, (continued)
- [Qemu-devel] [PATCH v17 1/8] unblock backup operations in backing file, Changlong Xie, 2016/04/11
- [Qemu-devel] [PATCH v17 3/8] Link backup into block core, Changlong Xie, 2016/04/11
- [Qemu-devel] [PATCH v17 5/8] auto complete active commit, Changlong Xie, 2016/04/11
- [Qemu-devel] [PATCH v17 2/8] Backup: clear all bitmap when doing block checkpoint, Changlong Xie, 2016/04/11
- [Qemu-devel] [PATCH v17 6/8] Introduce new APIs to do replication operation, Changlong Xie, 2016/04/11
- [Qemu-devel] [PATCH v17 8/8] support replication driver in blockdev-add, Changlong Xie, 2016/04/11
- [Qemu-devel] [PATCH v17 4/8] docs: block replication's description, Changlong Xie, 2016/04/11
- [Qemu-devel] [PATCH v17 7/8] Implement new driver for block replication, Changlong Xie, 2016/04/11
- Re: [Qemu-devel] [PATCH v17 7/8] Implement new driver for block replication,
Stefan Hajnoczi <=