From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:46822) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RBU9u-0003G3-GO for qemu-devel@nongnu.org; Wed, 05 Oct 2011 12:17:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RBU9s-0002Mo-N2 for qemu-devel@nongnu.org; Wed, 05 Oct 2011 12:17:26 -0400 Received: from mtagate2.uk.ibm.com ([194.196.100.162]:59385) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RBU9s-0002MZ-F1 for qemu-devel@nongnu.org; Wed, 05 Oct 2011 12:17:24 -0400 Received: from d06nrmr1307.portsmouth.uk.ibm.com (d06nrmr1307.portsmouth.uk.ibm.com [9.149.38.129]) by mtagate2.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p95GHNlX000389 for ; Wed, 5 Oct 2011 16:17:23 GMT Received: from d06av10.portsmouth.uk.ibm.com (d06av10.portsmouth.uk.ibm.com [9.149.37.251]) by d06nrmr1307.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p95GHNen1011852 for ; Wed, 5 Oct 2011 17:17:23 +0100 Received: from d06av10.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av10.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p95GHMZ8017204 for ; Wed, 5 Oct 2011 10:17:23 -0600 From: Stefan Hajnoczi Date: Wed, 5 Oct 2011 17:17:06 +0100 Message-Id: <1317831427-477-6-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1317831427-477-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1317831427-477-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 5/6] block: mark blocks dirty on coroutine write completion List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Anthony Liguori , Stefan Hajnoczi , Marcelo Tosatti , Zhi Yong Wu , Avi Kivity , Christoph Hellwig The aio write operation marks blocks dirty when the write operation completes. The coroutine write operation marks blocks dirty before issuing the write operation. It seems safest to mark the block dirty when the operation completes so that anything tracking dirty blocks will not act before the change has been made to the image file. Make the coroutine write operation dirty blocks on write completion. Signed-off-by: Stefan Hajnoczi --- block.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/block.c b/block.c index b83e911..5d6e17f 100644 --- a/block.c +++ b/block.c @@ -1307,6 +1307,7 @@ static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { BlockDriver *drv = bs->drv; + int ret; if (!bs->drv) { return -ENOMEDIUM; @@ -1318,6 +1319,8 @@ static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs, return -EIO; } + ret = drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov); + if (bs->dirty_bitmap) { set_dirty_bitmap(bs, sector_num, nb_sectors, 1); } @@ -1326,7 +1329,7 @@ static int coroutine_fn bdrv_co_do_writev(BlockDriverState *bs, bs->wr_highest_sector = sector_num + nb_sectors - 1; } - return drv->bdrv_co_writev(bs, sector_num, nb_sectors, qiov); + return ret; } int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num, -- 1.7.6.3