From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cDkAd-00080U-TB for qemu-devel@nongnu.org; Sun, 04 Dec 2016 22:42:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cDkAc-0007nz-U8 for qemu-devel@nongnu.org; Sun, 04 Dec 2016 22:42:27 -0500 References: <1476971860-20860-1-git-send-email-zhang.zhanghailiang@huawei.com> <1476971860-20860-5-git-send-email-zhang.zhanghailiang@huawei.com> <5810097E.7010907@cn.fujitsu.com> From: Hailiang Zhang Message-ID: <5844E1F8.9020007@huawei.com> Date: Mon, 5 Dec 2016 11:41:44 +0800 MIME-Version: 1.0 In-Reply-To: <5810097E.7010907@cn.fujitsu.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH RFC 4/7] replication: Split out backup_do_checkpoint() from secondary_do_checkpoint() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Changlong Xie , qemu-devel@nongnu.org, qemu-block@nongnu.org Cc: stefanha@redhat.com, kwolf@redhat.com, mreitz@redhat.com, pbonzini@redhat.com, wency@cn.fujitsu.com On 2016/10/26 9:40, Changlong Xie wrote: > On 10/20/2016 09:57 PM, zhanghailiang wrote: >> The helper backup_do_checkpoint() will be used for primary related >> codes. Here we split it out from secondary_do_checkpoint(). >> >> Besides, it is unnecessary to call backup_do_checkpoint() in >> replication starting and normally stop replication path. > > This patch is unnecessary. We *really* need clean > backup_job->done_bitmap in replication_start/stop path. > After we support internal job ('BLOCK_JOB_INTERNAL'), do we still need to call backup_do? IMHO, we don't have to clean 'done_bitmap', because its initial value is zero, and we don't have to call it in stop path either, the backup job will be cleaned. >> We only need call it while do real checkpointing. >> >> Signed-off-by: zhanghailiang >> --- >> block/replication.c | 36 +++++++++++++++++++----------------- >> 1 file changed, 19 insertions(+), 17 deletions(-) >> >> diff --git a/block/replication.c b/block/replication.c >> index 2a2fdb2..d687ffc 100644 >> --- a/block/replication.c >> +++ b/block/replication.c >> @@ -320,20 +320,8 @@ static bool replication_recurse_is_first_non_filter(BlockDriverState *bs, >> >> static void secondary_do_checkpoint(BDRVReplicationState *s, Error **errp) >> { >> - Error *local_err = NULL; >> int ret; >> >> - if (!s->secondary_disk->bs->job) { >> - error_setg(errp, "Backup job was cancelled unexpectedly"); >> - return; >> - } >> - >> - backup_do_checkpoint(s->secondary_disk->bs->job, &local_err); >> - if (local_err) { >> - error_propagate(errp, local_err); >> - return; >> - } >> - >> ret = s->active_disk->bs->drv->bdrv_make_empty(s->active_disk->bs); >> if (ret < 0) { >> error_setg(errp, "Cannot make active disk empty"); >> @@ -539,6 +527,8 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, >> aio_context_release(aio_context); >> return; >> } >> + >> + secondary_do_checkpoint(s, errp); >> break; >> default: >> aio_context_release(aio_context); >> @@ -547,10 +537,6 @@ static void replication_start(ReplicationState *rs, ReplicationMode mode, >> >> s->replication_state = BLOCK_REPLICATION_RUNNING; >> >> - if (s->mode == REPLICATION_MODE_SECONDARY) { >> - secondary_do_checkpoint(s, errp); >> - } >> - >> s->error = 0; >> aio_context_release(aio_context); >> } >> @@ -560,13 +546,29 @@ static void replication_do_checkpoint(ReplicationState *rs, Error **errp) >> BlockDriverState *bs = rs->opaque; >> BDRVReplicationState *s; >> AioContext *aio_context; >> + Error *local_err = NULL; >> >> aio_context = bdrv_get_aio_context(bs); >> aio_context_acquire(aio_context); >> s = bs->opaque; >> >> - if (s->mode == REPLICATION_MODE_SECONDARY) { >> + switch (s->mode) { >> + case REPLICATION_MODE_PRIMARY: >> + break; >> + case REPLICATION_MODE_SECONDARY: >> + if (!s->secondary_disk->bs->job) { >> + error_setg(errp, "Backup job was cancelled unexpectedly"); >> + break; >> + } >> + backup_do_checkpoint(s->secondary_disk->bs->job, &local_err); >> + if (local_err) { >> + error_propagate(errp, local_err); >> + break; >> + } >> secondary_do_checkpoint(s, errp); >> + break; >> + default: >> + abort(); >> } >> aio_context_release(aio_context); >> } >> > > > > . >