Commit 0aa217e46124e873f75501f7187657e063f5903b
Committed by
Anthony Liguori
1 parent
fc5b81d1
qcow2: Make cache=writethrough default
The performance of qcow2 has improved meanwhile, so we don't need to special-case it any more. Switch the default to write-through caching like all other block drivers. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing
4 changed files
with
3 additions
and
16 deletions
block.h
| @@ -37,9 +37,8 @@ typedef struct QEMUSnapshotInfo { | @@ -37,9 +37,8 @@ typedef struct QEMUSnapshotInfo { | ||
| 37 | bdrv_file_open()) */ | 37 | bdrv_file_open()) */ |
| 38 | #define BDRV_O_NOCACHE 0x0020 /* do not use the host page cache */ | 38 | #define BDRV_O_NOCACHE 0x0020 /* do not use the host page cache */ |
| 39 | #define BDRV_O_CACHE_WB 0x0040 /* use write-back caching */ | 39 | #define BDRV_O_CACHE_WB 0x0040 /* use write-back caching */ |
| 40 | -#define BDRV_O_CACHE_DEF 0x0080 /* use default caching */ | ||
| 41 | 40 | ||
| 42 | -#define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_CACHE_WB | BDRV_O_CACHE_DEF) | 41 | +#define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_CACHE_WB) |
| 43 | 42 | ||
| 44 | void bdrv_info(Monitor *mon); | 43 | void bdrv_info(Monitor *mon); |
| 45 | void bdrv_info_stats(Monitor *mon); | 44 | void bdrv_info_stats(Monitor *mon); |
block/qcow2.c
| @@ -145,14 +145,6 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags) | @@ -145,14 +145,6 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags) | ||
| 145 | QCowHeader header; | 145 | QCowHeader header; |
| 146 | uint64_t ext_end; | 146 | uint64_t ext_end; |
| 147 | 147 | ||
| 148 | - /* Performance is terrible right now with cache=writethrough due mainly | ||
| 149 | - * to reference count updates. If the user does not explicitly specify | ||
| 150 | - * a caching type, force to writeback caching. | ||
| 151 | - */ | ||
| 152 | - if ((flags & BDRV_O_CACHE_DEF)) { | ||
| 153 | - flags |= BDRV_O_CACHE_WB; | ||
| 154 | - flags &= ~BDRV_O_CACHE_DEF; | ||
| 155 | - } | ||
| 156 | ret = bdrv_file_open(&s->hd, filename, flags); | 148 | ret = bdrv_file_open(&s->hd, filename, flags); |
| 157 | if (ret < 0) | 149 | if (ret < 0) |
| 158 | return ret; | 150 | return ret; |
qemu-options.hx
| @@ -148,9 +148,7 @@ an internal copy of the data. | @@ -148,9 +148,7 @@ an internal copy of the data. | ||
| 148 | 148 | ||
| 149 | Some block drivers perform badly with @option{cache=writethrough}, most notably, | 149 | Some block drivers perform badly with @option{cache=writethrough}, most notably, |
| 150 | qcow2. If performance is more important than correctness, | 150 | qcow2. If performance is more important than correctness, |
| 151 | -@option{cache=writeback} should be used with qcow2. By default, if no explicit | ||
| 152 | -caching is specified for a qcow2 disk image, @option{cache=writeback} will be | ||
| 153 | -used. For all other disk types, @option{cache=writethrough} is the default. | 151 | +@option{cache=writeback} should be used with qcow2. |
| 154 | 152 | ||
| 155 | Instead of @option{-cdrom} you can use: | 153 | Instead of @option{-cdrom} you can use: |
| 156 | @example | 154 | @example |
vl.c
| @@ -2239,7 +2239,7 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque) | @@ -2239,7 +2239,7 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque) | ||
| 2239 | unit_id = -1; | 2239 | unit_id = -1; |
| 2240 | translation = BIOS_ATA_TRANSLATION_AUTO; | 2240 | translation = BIOS_ATA_TRANSLATION_AUTO; |
| 2241 | index = -1; | 2241 | index = -1; |
| 2242 | - cache = 3; | 2242 | + cache = 1; |
| 2243 | 2243 | ||
| 2244 | if (machine->use_scsi) { | 2244 | if (machine->use_scsi) { |
| 2245 | type = IF_SCSI; | 2245 | type = IF_SCSI; |
| @@ -2557,8 +2557,6 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque) | @@ -2557,8 +2557,6 @@ int drive_init(struct drive_opt *arg, int snapshot, void *opaque) | ||
| 2557 | bdrv_flags |= BDRV_O_NOCACHE; | 2557 | bdrv_flags |= BDRV_O_NOCACHE; |
| 2558 | else if (cache == 2) /* write-back */ | 2558 | else if (cache == 2) /* write-back */ |
| 2559 | bdrv_flags |= BDRV_O_CACHE_WB; | 2559 | bdrv_flags |= BDRV_O_CACHE_WB; |
| 2560 | - else if (cache == 3) /* not specified */ | ||
| 2561 | - bdrv_flags |= BDRV_O_CACHE_DEF; | ||
| 2562 | if (bdrv_open2(bdrv, file, bdrv_flags, drv) < 0) { | 2560 | if (bdrv_open2(bdrv, file, bdrv_flags, drv) < 0) { |
| 2563 | fprintf(stderr, "qemu: could not open disk image %s\n", | 2561 | fprintf(stderr, "qemu: could not open disk image %s\n", |
| 2564 | file); | 2562 | file); |