From 83403857898530568e4341a2d097073bfc131738 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Tue, 14 Feb 2012 11:14:44 +0100 Subject: [PATCH 79/99] block: mark blocks dirty on coroutine write completion RH-Author: Kevin Wolf Message-id: <1329218101-24213-80-git-send-email-kwolf@redhat.com> Patchwork-id: 37264 O-Subject: [RHEL-6.3 qemu-kvm PATCH v2 79/96] block: mark blocks dirty on coroutine write completion Bugzilla: 783950 RH-Acked-by: Paolo Bonzini RH-Acked-by: Marcelo Tosatti RH-Acked-by: Laszlo Ersek From: Stefan Hajnoczi Bugzilla: 783950 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 Signed-off-by: Kevin Wolf (cherry picked from commit 6b7cb2479b2b8ac2a3368ade3e72bfd8121675c2) --- block.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) Signed-off-by: Michal Novotny --- block.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/block.c b/block.c index 9276301..ba101e1 100644 --- a/block.c +++ b/block.c @@ -1260,6 +1260,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; @@ -1271,6 +1272,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); } @@ -1279,7 +1282,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.7.5