From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57711) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zlvaa-0001Rt-NF for qemu-devel@nongnu.org; Tue, 13 Oct 2015 05:09:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZlvaZ-0006p6-Js for qemu-devel@nongnu.org; Tue, 13 Oct 2015 05:09:44 -0400 References: <1443161858-20533-1-git-send-email-wency@cn.fujitsu.com> <1443161858-20533-9-git-send-email-wency@cn.fujitsu.com> <20151012163103.GD4053@stefanha-thinkpad.redhat.com> From: Wen Congyang Message-ID: <561CCA4D.1040507@cn.fujitsu.com> Date: Tue, 13 Oct 2015 17:09:33 +0800 MIME-Version: 1.0 In-Reply-To: <20151012163103.GD4053@stefanha-thinkpad.redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [Qemu-block] [PATCH v10 08/10] Implement new driver for block replication List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Fam Zheng , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Michael R. Hines" , Max Reitz , Gonglei , Stefan Hajnoczi , Paolo Bonzini , Yang Hongyang , "Dr. David Alan Gilbert" On 10/13/2015 12:31 AM, Stefan Hajnoczi wrote: > On Fri, Sep 25, 2015 at 02:17:36PM +0800, Wen Congyang wrote: >> +static void replication_start(BlockDriverState *bs, ReplicationMode mode, >> + Error **errp) >> +{ >> + BDRVReplicationState *s = bs->opaque; >> + int64_t active_length, hidden_length, disk_length; >> + AioContext *aio_context; >> + Error *local_err = NULL; >> + >> + if (s->replication_state != BLOCK_REPLICATION_NONE) { >> + error_setg(errp, "Block replication is running or done"); >> + return; >> + } >> + >> + if (s->mode != mode) { >> + error_setg(errp, "The parameter mode's value is invalid, needs %d," >> + " but receives %d", s->mode, mode); >> + return; >> + } >> + >> + switch (s->mode) { >> + case REPLICATION_MODE_PRIMARY: >> + break; >> + case REPLICATION_MODE_SECONDARY: >> + s->active_disk = bs->file; >> + if (!bs->file->backing_hd) { >> + error_setg(errp, "Active disk doesn't have backing file"); >> + return; >> + } >> + >> + s->hidden_disk = s->active_disk->backing_hd; >> + if (!s->hidden_disk->backing_hd) { >> + error_setg(errp, "Hidden disk doesn't have backing file"); >> + return; >> + } >> + >> + s->secondary_disk = s->hidden_disk->backing_hd; >> + if (!s->secondary_disk->blk) { >> + error_setg(errp, "The secondary disk doesn't have block backend"); >> + return; >> + } > ... >> + aio_context = bdrv_get_aio_context(bs); >> + aio_context_acquire(aio_context); >> + bdrv_set_aio_context(s->secondary_disk, aio_context); > > Why is this bdrv_set_aio_context() call necessary? > > Child BDS nodes are in the same AioContext as their parents. Other > block jobs need something like this because they operate on a second BDS > which is not bs' backing file chain. I think you have a different > situation here so it's not needed. I think you are right. I will check it and remove it. Thanks Wen Congyang > . >