block/mirror: Use source as a BdrvChild
With this, the mirror_top_bs is no longer just a technically required node in the BDS graph but actually represents the block job operation. Also, drop MirrorBlockJob.source, as we can reach it through mirror_top_bs->backing. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Reviewed-by: Alberto Garcia <berto@igalia.com> Message-id: 20180613181823.13618-6-mreitz@redhat.com Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
1181e19a6d
commit
138f9fffb8
|
@ -41,7 +41,6 @@ typedef struct MirrorBlockJob {
|
||||||
BlockJob common;
|
BlockJob common;
|
||||||
BlockBackend *target;
|
BlockBackend *target;
|
||||||
BlockDriverState *mirror_top_bs;
|
BlockDriverState *mirror_top_bs;
|
||||||
BlockDriverState *source;
|
|
||||||
BlockDriverState *base;
|
BlockDriverState *base;
|
||||||
|
|
||||||
/* The name of the graph node to replace */
|
/* The name of the graph node to replace */
|
||||||
|
@ -299,7 +298,6 @@ static void coroutine_fn mirror_co_read(void *opaque)
|
||||||
{
|
{
|
||||||
MirrorOp *op = opaque;
|
MirrorOp *op = opaque;
|
||||||
MirrorBlockJob *s = op->s;
|
MirrorBlockJob *s = op->s;
|
||||||
BlockBackend *source = s->common.blk;
|
|
||||||
int nb_chunks;
|
int nb_chunks;
|
||||||
uint64_t ret;
|
uint64_t ret;
|
||||||
uint64_t max_bytes;
|
uint64_t max_bytes;
|
||||||
|
@ -349,7 +347,8 @@ static void coroutine_fn mirror_co_read(void *opaque)
|
||||||
s->bytes_in_flight += op->bytes;
|
s->bytes_in_flight += op->bytes;
|
||||||
trace_mirror_one_iteration(s, op->offset, op->bytes);
|
trace_mirror_one_iteration(s, op->offset, op->bytes);
|
||||||
|
|
||||||
ret = blk_co_preadv(source, op->offset, op->bytes, &op->qiov, 0);
|
ret = bdrv_co_preadv(s->mirror_top_bs->backing, op->offset, op->bytes,
|
||||||
|
&op->qiov, 0);
|
||||||
mirror_read_complete(op, ret);
|
mirror_read_complete(op, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,7 +426,7 @@ static unsigned mirror_perform(MirrorBlockJob *s, int64_t offset,
|
||||||
|
|
||||||
static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s)
|
static uint64_t coroutine_fn mirror_iteration(MirrorBlockJob *s)
|
||||||
{
|
{
|
||||||
BlockDriverState *source = s->source;
|
BlockDriverState *source = s->mirror_top_bs->backing->bs;
|
||||||
MirrorOp *pseudo_op;
|
MirrorOp *pseudo_op;
|
||||||
int64_t offset;
|
int64_t offset;
|
||||||
uint64_t delay_ns = 0, ret = 0;
|
uint64_t delay_ns = 0, ret = 0;
|
||||||
|
@ -601,7 +600,7 @@ static void mirror_exit(Job *job, void *opaque)
|
||||||
BlockJob *bjob = &s->common;
|
BlockJob *bjob = &s->common;
|
||||||
MirrorExitData *data = opaque;
|
MirrorExitData *data = opaque;
|
||||||
AioContext *replace_aio_context = NULL;
|
AioContext *replace_aio_context = NULL;
|
||||||
BlockDriverState *src = s->source;
|
BlockDriverState *src = s->mirror_top_bs->backing->bs;
|
||||||
BlockDriverState *target_bs = blk_bs(s->target);
|
BlockDriverState *target_bs = blk_bs(s->target);
|
||||||
BlockDriverState *mirror_top_bs = s->mirror_top_bs;
|
BlockDriverState *mirror_top_bs = s->mirror_top_bs;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
|
@ -716,7 +715,7 @@ static int coroutine_fn mirror_dirty_init(MirrorBlockJob *s)
|
||||||
{
|
{
|
||||||
int64_t offset;
|
int64_t offset;
|
||||||
BlockDriverState *base = s->base;
|
BlockDriverState *base = s->base;
|
||||||
BlockDriverState *bs = s->source;
|
BlockDriverState *bs = s->mirror_top_bs->backing->bs;
|
||||||
BlockDriverState *target_bs = blk_bs(s->target);
|
BlockDriverState *target_bs = blk_bs(s->target);
|
||||||
int ret;
|
int ret;
|
||||||
int64_t count;
|
int64_t count;
|
||||||
|
@ -798,7 +797,7 @@ static void coroutine_fn mirror_run(void *opaque)
|
||||||
{
|
{
|
||||||
MirrorBlockJob *s = opaque;
|
MirrorBlockJob *s = opaque;
|
||||||
MirrorExitData *data;
|
MirrorExitData *data;
|
||||||
BlockDriverState *bs = s->source;
|
BlockDriverState *bs = s->mirror_top_bs->backing->bs;
|
||||||
BlockDriverState *target_bs = blk_bs(s->target);
|
BlockDriverState *target_bs = blk_bs(s->target);
|
||||||
bool need_drain = true;
|
bool need_drain = true;
|
||||||
int64_t length;
|
int64_t length;
|
||||||
|
@ -1293,7 +1292,6 @@ static void mirror_start_job(const char *job_id, BlockDriverState *bs,
|
||||||
/* The block job now has a reference to this node */
|
/* The block job now has a reference to this node */
|
||||||
bdrv_unref(mirror_top_bs);
|
bdrv_unref(mirror_top_bs);
|
||||||
|
|
||||||
s->source = bs;
|
|
||||||
s->mirror_top_bs = mirror_top_bs;
|
s->mirror_top_bs = mirror_top_bs;
|
||||||
|
|
||||||
/* No resize for the target either; while the mirror is still running, a
|
/* No resize for the target either; while the mirror is still running, a
|
||||||
|
|
Loading…
Reference in New Issue