[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH 03/54] mirror: Resize active commit base in mirr
From: |
Fam Zheng |
Subject: |
Re: [Qemu-block] [PATCH 03/54] mirror: Resize active commit base in mirror_run() |
Date: |
Thu, 23 Feb 2017 19:31:34 +0800 |
User-agent: |
Mutt/1.7.1 (2016-10-04) |
On Tue, 02/21 15:57, Kevin Wolf wrote:
> diff --git a/block/mirror.c b/block/mirror.c
> index 698a54e..13f793e 100644
> --- a/block/mirror.c
> +++ b/block/mirror.c
> @@ -657,7 +657,28 @@ static void coroutine_fn mirror_run(void *opaque)
> if (s->bdev_length < 0) {
> ret = s->bdev_length;
> goto immediate_exit;
> - } else if (s->bdev_length == 0) {
> + }
> +
> + /* Active commit must resize the base image if its size differs from the
> + * active layer. */
> + if (s->base == blk_bs(s->target)) {
> + int64_t base_length;
> +
> + base_length = blk_getlength(s->target);
> + if (base_length < 0) {
> + ret = base_length;
> + goto immediate_exit;
> + }
> +
> + if (s->bdev_length > base_length) {
> + ret = blk_truncate(s->target, s->bdev_length);
> + if (ret < 0) {
> + goto immediate_exit;
> + }
> + }
> + }
> +
> + if (s->bdev_length == 0) {
> /* Report BLOCK_JOB_READY and wait for complete. */
> block_job_event_ready(&s->common);
> s->synced = true;
This has a slight behavior change of commit job that previously upon resize
failure the job wouldn't start, but now it will, then immediately end with an
error. Not an problem, though.
Fam
- [Qemu-block] [PATCH 00/54] New op blocker system, part 1, Kevin Wolf, 2017/02/21
- [Qemu-block] [PATCH 02/54] qcow2: Use BB for resizing in qcow2_amend_options(), Kevin Wolf, 2017/02/21
- [Qemu-block] [PATCH 03/54] mirror: Resize active commit base in mirror_run(), Kevin Wolf, 2017/02/21
- [Qemu-block] [PATCH 04/54] block: Pass BdrvChild to bdrv_truncate(), Kevin Wolf, 2017/02/21
- [Qemu-block] [PATCH 06/54] block: Factor out bdrv_open_child_bs(), Kevin Wolf, 2017/02/21
- [Qemu-block] [PATCH 05/54] block: Attach bs->file only during .bdrv_open(), Kevin Wolf, 2017/02/21
- [Qemu-block] [PATCH 07/54] block: Use BlockBackend for image probing, Kevin Wolf, 2017/02/21
- [Qemu-block] [PATCH 01/54] blockdev: Use BlockBackend to resize in qmp_block_resize(), Kevin Wolf, 2017/02/21