From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42397) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aqKRQ-00006q-LI for qemu-devel@nongnu.org; Wed, 13 Apr 2016 09:02:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aqKRK-0003z6-RZ for qemu-devel@nongnu.org; Wed, 13 Apr 2016 09:02:44 -0400 Date: Wed, 13 Apr 2016 14:02:25 +0100 From: Stefan Hajnoczi Message-ID: <20160413130225.GD9272@stefanha-x1.localdomain> References: <1460362979-15146-1-git-send-email-xiecl.fnst@cn.fujitsu.com> <1460362979-15146-8-git-send-email-xiecl.fnst@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="AkbCVLjbJ9qUtAXD" Content-Disposition: inline In-Reply-To: <1460362979-15146-8-git-send-email-xiecl.fnst@cn.fujitsu.com> Subject: Re: [Qemu-devel] [PATCH v17 7/8] Implement new driver for block replication List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Changlong Xie Cc: qemu devel , Fam Zheng , Max Reitz , Paolo Bonzini , Kevin Wolf , "Dr. David Alan Gilbert" , Dong Eddie , Jiang Yunhong , Wen Congyang , qemu block , "Michael R. Hines" , Eric Blake , zhanghailiang , Gonglei --AkbCVLjbJ9qUtAXD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Apr 11, 2016 at 04:22:58PM +0800, Changlong Xie wrote: > +static coroutine_fn int replication_co_writev(BlockDriverState *bs, > + int64_t sector_num, > + int remaining_sectors, > + QEMUIOVector *qiov) > +{ > + BDRVReplicationState *s = bs->opaque; > + QEMUIOVector hd_qiov; > + uint64_t bytes_done = 0; > + BdrvChild *top = bs->file; > + BdrvChild *base = s->secondary_disk; > + BlockDriverState *target; > + int ret, n; > + > + ret = replication_get_io_status(s); > + if (ret < 0) { > + return ret; > + } > + > + if (ret == 0) { > + ret = bdrv_co_writev(top->bs, sector_num, > + remaining_sectors, qiov); > + return replication_return_value(s, ret); > + } > + > + /* > + * Failover failed, only write to active disk if the sectors > + * have already been allocated in active disk/hidden disk. > + */ > + qemu_iovec_init(&hd_qiov, qiov->niov); > + while (remaining_sectors > 0) { > + ret = bdrv_is_allocated_above(top->bs, base->bs, sector_num, > + remaining_sectors, &n); > + if (ret < 0) { > + return ret; > + } > + > + qemu_iovec_reset(&hd_qiov); > + qemu_iovec_concat(&hd_qiov, qiov, bytes_done, n * BDRV_SECTOR_SIZE); > + > + target = ret ? (top->bs) : (base->bs); > + ret = bdrv_co_writev(target, sector_num, n, &hd_qiov); > + if (ret < 0) { > + return ret; > + } > + > + remaining_sectors -= n; > + sector_num += n; > + bytes_done += n * BDRV_SECTOR_SIZE; > + } > + > + return 0; qemu_iovec_destroy(&hd_qiov) is missing (also in error cases). --AkbCVLjbJ9qUtAXD Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJXDkNhAAoJEJykq7OBq3PIqQwH/AuZzE6OwBNlHlP75x4KuZms JJxfq0IuhtKFXUkEAzJckai2OmWUZ+4mT/uCTYRMt1WYzJbG3r327hmZnda7ByXl DndGSemiyTgdDG17cTF80t0cCUgw0kbfnbJNnCcC0CIHyg30xT6n4oshhPSqRvPJ zjP7LKma50xxl4z9eIzTcjqPEkJXpp0oWXmeA/I3sjgvXi734bx1ctMSdeiS166p YgxZNTjpo7Sz6In2E3QRqLRWbN6d0n+JaU/HhHo3138RdGUGEK5w8XwoCO/lpJCj Igvenz7AxaqWreTrlEB+vgMzRL94eWy5Tw9ZQcFwAPWwUw0PM1YWP5EbzInnSmc= =YwUp -----END PGP SIGNATURE----- --AkbCVLjbJ9qUtAXD--