replication: pass BlockDriverState to reopen_backing_file
This will be needed in the next patch to retrieve the AioContext. Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <1477565348-5458-14-git-send-email-pbonzini@redhat.com> Signed-off-by: Fam Zheng <famz@redhat.com>
This commit is contained in:
parent
d16341fa69
commit
8dd9006e9b
|
@ -322,9 +322,10 @@ static void secondary_do_checkpoint(BDRVReplicationState *s, Error **errp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reopen_backing_file(BDRVReplicationState *s, bool writable,
|
static void reopen_backing_file(BlockDriverState *bs, bool writable,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
|
BDRVReplicationState *s = bs->opaque;
|
||||||
BlockReopenQueue *reopen_queue = NULL;
|
BlockReopenQueue *reopen_queue = NULL;
|
||||||
int orig_hidden_flags, orig_secondary_flags;
|
int orig_hidden_flags, orig_secondary_flags;
|
||||||
int new_hidden_flags, new_secondary_flags;
|
int new_hidden_flags, new_secondary_flags;
|
||||||
|
@ -364,8 +365,9 @@ static void reopen_backing_file(BDRVReplicationState *s, bool writable,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void backup_job_cleanup(BDRVReplicationState *s)
|
static void backup_job_cleanup(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
|
BDRVReplicationState *s = bs->opaque;
|
||||||
BlockDriverState *top_bs;
|
BlockDriverState *top_bs;
|
||||||
|
|
||||||
top_bs = bdrv_lookup_bs(s->top_id, s->top_id, NULL);
|
top_bs = bdrv_lookup_bs(s->top_id, s->top_id, NULL);
|
||||||
|
@ -374,19 +376,20 @@ static void backup_job_cleanup(BDRVReplicationState *s)
|
||||||
}
|
}
|
||||||
bdrv_op_unblock_all(top_bs, s->blocker);
|
bdrv_op_unblock_all(top_bs, s->blocker);
|
||||||
error_free(s->blocker);
|
error_free(s->blocker);
|
||||||
reopen_backing_file(s, false, NULL);
|
reopen_backing_file(bs, false, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void backup_job_completed(void *opaque, int ret)
|
static void backup_job_completed(void *opaque, int ret)
|
||||||
{
|
{
|
||||||
BDRVReplicationState *s = opaque;
|
BlockDriverState *bs = opaque;
|
||||||
|
BDRVReplicationState *s = bs->opaque;
|
||||||
|
|
||||||
if (s->replication_state != BLOCK_REPLICATION_FAILOVER) {
|
if (s->replication_state != BLOCK_REPLICATION_FAILOVER) {
|
||||||
/* The backup job is cancelled unexpectedly */
|
/* The backup job is cancelled unexpectedly */
|
||||||
s->error = -EIO;
|
s->error = -EIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
backup_job_cleanup(s);
|
backup_job_cleanup(bs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool check_top_bs(BlockDriverState *top_bs, BlockDriverState *bs)
|
static bool check_top_bs(BlockDriverState *top_bs, BlockDriverState *bs)
|
||||||
|
@ -482,7 +485,7 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* reopen the backing file in r/w mode */
|
/* reopen the backing file in r/w mode */
|
||||||
reopen_backing_file(s, true, &local_err);
|
reopen_backing_file(bs, true, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_propagate(errp, local_err);
|
error_propagate(errp, local_err);
|
||||||
aio_context_release(aio_context);
|
aio_context_release(aio_context);
|
||||||
|
@ -497,7 +500,7 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode,
|
||||||
if (!top_bs || !bdrv_is_root_node(top_bs) ||
|
if (!top_bs || !bdrv_is_root_node(top_bs) ||
|
||||||
!check_top_bs(top_bs, bs)) {
|
!check_top_bs(top_bs, bs)) {
|
||||||
error_setg(errp, "No top_bs or it is invalid");
|
error_setg(errp, "No top_bs or it is invalid");
|
||||||
reopen_backing_file(s, false, NULL);
|
reopen_backing_file(bs, false, NULL);
|
||||||
aio_context_release(aio_context);
|
aio_context_release(aio_context);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -507,10 +510,10 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode,
|
||||||
backup_start("replication-backup", s->secondary_disk->bs,
|
backup_start("replication-backup", s->secondary_disk->bs,
|
||||||
s->hidden_disk->bs, 0, MIRROR_SYNC_MODE_NONE, NULL, false,
|
s->hidden_disk->bs, 0, MIRROR_SYNC_MODE_NONE, NULL, false,
|
||||||
BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
|
BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT,
|
||||||
backup_job_completed, s, NULL, &local_err);
|
backup_job_completed, bs, NULL, &local_err);
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_propagate(errp, local_err);
|
error_propagate(errp, local_err);
|
||||||
backup_job_cleanup(s);
|
backup_job_cleanup(bs);
|
||||||
aio_context_release(aio_context);
|
aio_context_release(aio_context);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue