From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:58827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1Eow-0004av-K6 for qemu-devel@nongnu.org; Wed, 07 Sep 2011 05:53:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R1Eov-0006Yq-Lk for qemu-devel@nongnu.org; Wed, 07 Sep 2011 05:53:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:5468) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1Eov-0006Yh-AP for qemu-devel@nongnu.org; Wed, 07 Sep 2011 05:53:25 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p879rOcp025182 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 7 Sep 2011 05:53:24 -0400 Message-ID: <4E673FC6.60007@redhat.com> Date: Wed, 07 Sep 2011 11:56:22 +0200 From: Kevin Wolf MIME-Version: 1.0 References: <1315387463-14623-1-git-send-email-avi@redhat.com> In-Reply-To: <1315387463-14623-1-git-send-email-avi@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] qcow2: make cache=unsafe usable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Avi Kivity Cc: qemu-devel@nongnu.org Am 07.09.2011 11:24, schrieb Avi Kivity: > Currently cache=unsafe is unsafe to the point of unusability - the > caches are never written to disk except on exit so anything except > an orderly exit -- including live migration -- leaves the disk image > corrupted. > > Fix by interpreting flush requests and doing everything except flushing > the underlying file. The contents of the metadata cache are transferred > to the host pagecache, so that qemu aborts keep the disk in a consistent > state, and live migration (on the same host, or if using a coherent > filesystem) works. > > Signed-off-by: Avi Kivity > --- > > Untested - is this the right approach? Hm, could work, even though I don't like it very much. The alternative approach would be something like this (not only untested, but won't even compile): diff --git a/block.c b/block.c index a8c789a..1aa5967 100644 --- a/block.c +++ b/block.c @@ -1723,10 +1723,6 @@ const char *bdrv_get_device_name(BlockDriverState *bs) int bdrv_flush(BlockDriverState *bs) { - if (bs->open_flags & BDRV_O_NO_FLUSH) { - return 0; - } - if (bs->drv && bdrv_has_async_flush(bs->drv) && qemu_in_coroutine()) { return bdrv_co_flush_em(bs); } @@ -2624,10 +2620,6 @@ BlockDriverAIOCB *bdrv_aio_flush(BlockDriverState *bs, trace_bdrv_aio_flush(bs, opaque); - if (bs->open_flags & BDRV_O_NO_FLUSH) { - return bdrv_aio_noop_em(bs, cb, opaque); - } - if (!drv) return NULL; return drv->bdrv_aio_flush(bs, cb, opaque); diff --git a/block/raw-posix.c b/block/raw-posix.c index bcf50b2..bb0c0c5 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -629,6 +629,10 @@ static BlockDriverAIOCB *raw_aio_flush(BlockDriverState *bs, { BDRVRawState *s = bs->opaque; + if (bs->open_flags & BDRV_O_NO_FLUSH) { + return bdrv_aio_noop_em(bs, cb, opaque); + } + if (fd_open(bs) < 0) return NULL; @@ -839,6 +843,11 @@ static int raw_create(const char *filename, QEMUOptionParameter *options) static int raw_flush(BlockDriverState *bs) { BDRVRawState *s = bs->opaque; + + if (bs->open_flags & BDRV_O_NO_FLUSH) { + return 0; + } + return qemu_fdatasync(s->fd); }