From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:33047) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tv9h8-0002Xn-7F for qemu-devel@nongnu.org; Tue, 15 Jan 2013 11:49:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tv9h5-0005c5-3f for qemu-devel@nongnu.org; Tue, 15 Jan 2013 11:49:02 -0500 Received: from mx1.redhat.com ([209.132.183.28]:18250) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tv9h4-0005bc-Ss for qemu-devel@nongnu.org; Tue, 15 Jan 2013 11:48:59 -0500 From: Stefan Hajnoczi Date: Tue, 15 Jan 2013 17:48:25 +0100 Message-Id: <1358268511-27061-10-git-send-email-stefanha@redhat.com> In-Reply-To: <1358268511-27061-1-git-send-email-stefanha@redhat.com> References: <1358268511-27061-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH 09/15] block: clear dirty bitmap when discarding List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Anthony Liguori , Stefan Hajnoczi From: Paolo Bonzini Note that resetting bits in the dirty bitmap is done _before_ actually processing the request. Writes, instead, set bits after the request is completed. This way, when there are concurrent write and discard requests, the outcome will always be that the blocks are marked dirty. This scenario should never happen, but it is safer to do it this way. Signed-off-by: Paolo Bonzini Signed-off-by: Stefan Hajnoczi --- block.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 4a90dd1..6fa7c90 100644 --- a/block.c +++ b/block.c @@ -4170,7 +4170,13 @@ int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num, return -EIO; } else if (bs->read_only) { return -EROFS; - } else if (bs->drv->bdrv_co_discard) { + } + + if (bs->dirty_bitmap) { + set_dirty_bitmap(bs, sector_num, nb_sectors, 0); + } + + if (bs->drv->bdrv_co_discard) { return bs->drv->bdrv_co_discard(bs, sector_num, nb_sectors); } else if (bs->drv->bdrv_aio_discard) { BlockDriverAIOCB *acb; -- 1.8.0.2