From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:34084) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REK5Z-0001NX-OW for qemu-devel@nongnu.org; Thu, 13 Oct 2011 08:08:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1REK5V-00034T-Nj for qemu-devel@nongnu.org; Thu, 13 Oct 2011 08:08:41 -0400 Received: from mtagate3.uk.ibm.com ([194.196.100.163]:36772) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REK5V-00034F-FP for qemu-devel@nongnu.org; Thu, 13 Oct 2011 08:08:37 -0400 Received: from d06nrmr1507.portsmouth.uk.ibm.com (d06nrmr1507.portsmouth.uk.ibm.com [9.149.38.233]) by mtagate3.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p9DC8ax4026488 for ; Thu, 13 Oct 2011 12:08:36 GMT Received: from d06av12.portsmouth.uk.ibm.com (d06av12.portsmouth.uk.ibm.com [9.149.37.247]) by d06nrmr1507.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p9DC8aL52629644 for ; Thu, 13 Oct 2011 13:08:36 +0100 Received: from d06av12.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av12.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p9DC8aHJ002837 for ; Thu, 13 Oct 2011 06:08:36 -0600 From: Stefan Hajnoczi Date: Thu, 13 Oct 2011 13:08:24 +0100 Message-Id: <1318507705-13840-5-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1318507705-13840-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1318507705-13840-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v2 4/5] 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 , Stefan Hajnoczi 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 e94fa61..02e15ca 100644 --- a/block.c +++ b/block.c @@ -1311,6 +1311,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; @@ -1322,6 +1323,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); } @@ -1330,7 +1333,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