From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqNY0-0002Fn-QA for qemu-devel@nongnu.org; Thu, 07 May 2015 11:17:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YqNXw-000765-SC for qemu-devel@nongnu.org; Thu, 07 May 2015 11:17:12 -0400 From: Zhe Qiu Date: Thu, 7 May 2015 23:16:58 +0800 Message-Id: <1431011818-15822-1-git-send-email-phoeagon@gmail.com> In-Reply-To: <1430971496-32659-1-git-send-email-phoeagon@gmail.com> References: <1430971496-32659-1-git-send-email-phoeagon@gmail.com> Subject: [Qemu-devel] [PATCH v4] block/vdi: Use bdrv_flush after metadata updates List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, Zhe Qiu , qemu-block@nongnu.org, sw@weilnetz.de, mreitz@redhat.com In reference to b0ad5a45...078a458e, metadata writes to qcow2/cow/qcow/vpc/vmdk are all synced prior to succeeding writes. Only when write is successful that bdrv_flush is called. Signed-off-by: Zhe Qiu --- block/vdi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/vdi.c b/block/vdi.c index 7642ef3..dfe8ade 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -713,6 +713,9 @@ static int vdi_co_write(BlockDriverState *bs, logout("will write %u block map sectors starting from entry %u\n", n_sectors, bmap_first); ret = bdrv_write(bs->file, offset, base, n_sectors); + if (ret >= 0) { + ret = bdrv_flush(bs->file); + } } return ret; -- 2.4.0