From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MIhYR-000434-UB for qemu-devel@nongnu.org; Mon, 22 Jun 2009 07:19:15 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MIhYM-00042q-CS for qemu-devel@nongnu.org; Mon, 22 Jun 2009 07:19:14 -0400 Received: from [199.232.76.173] (port=36388 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MIhYM-00042n-6n for qemu-devel@nongnu.org; Mon, 22 Jun 2009 07:19:10 -0400 Received: from mx2.redhat.com ([66.187.237.31]:35179) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MIhYL-0004MC-Py for qemu-devel@nongnu.org; Mon, 22 Jun 2009 07:19:10 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n5MBJ8dL020832 for ; Mon, 22 Jun 2009 07:19:08 -0400 From: Kevin Wolf Date: Mon, 22 Jun 2009 13:18:03 +0200 Message-Id: <1245669483-7076-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH] block-raw: Make cache=off default again List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf Since the patch that suggested it woudl revert qcow2 to writeback caching, in fact none of the drivers has had cache=off as default any more. This patch restores the desired behaviour. Signed-off-by: Kevin Wolf --- block/raw-posix.c | 4 ++++ block/raw-win32.c | 8 ++++++++ 2 files changed, 12 insertions(+), 0 deletions(-) diff --git a/block/raw-posix.c b/block/raw-posix.c index fa1a394..513e8e8 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -143,6 +143,10 @@ static int raw_open_common(BlockDriverState *bs, const char *filename, /* Use O_DSYNC for write-through caching, no flags for write-back caching, * and O_DIRECT for no caching. */ + if (bdrv_flags & BDRV_O_CACHE_DEF) { + bdrv_flags = (bdrv_flags & ~BDRV_O_CACHE_MASK) | BDRV_O_NOCACHE; + } + if ((bdrv_flags & BDRV_O_NOCACHE)) s->open_flags |= O_DIRECT; else if (!(bdrv_flags & BDRV_O_CACHE_WB)) diff --git a/block/raw-win32.c b/block/raw-win32.c index 72acad5..5da957c 100644 --- a/block/raw-win32.c +++ b/block/raw-win32.c @@ -92,6 +92,10 @@ static int raw_open(BlockDriverState *bs, const char *filename, int flags) create_flags = OPEN_EXISTING; } overlapped = FILE_ATTRIBUTE_NORMAL; + + if (flags & BDRV_O_CACHE_DEF) { + flags = (flags & ~BDRV_O_CACHE_MASK) | BDRV_O_NOCACHE; + } if ((flags & BDRV_O_NOCACHE)) overlapped |= FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH; else if (!(flags & BDRV_O_CACHE_WB)) @@ -345,6 +349,10 @@ static int hdev_open(BlockDriverState *bs, const char *filename, int flags) create_flags = OPEN_EXISTING; overlapped = FILE_ATTRIBUTE_NORMAL; + + if (flags & BDRV_O_CACHE_DEF) { + flags = (flags & ~BDRV_O_CACHE_MASK) | BDRV_O_NOCACHE; + } if ((flags & BDRV_O_NOCACHE)) overlapped |= FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH; else if (!(flags & BDRV_O_CACHE_WB)) -- 1.6.0.6