Commit 137519ce2e269915de0f67a13ac32b67605cad72
1 parent
b8dbdddc
qemu-img: open files with cache=writeback
Data integrity is not important in qemu-img, so open the files with cache=writeback. This fixes the performance regression seen with qemu-img since revision 5485, and most particularly with the qcow2 format. Signed-off-by: Aurelien Jarno <aurelien@aurel32.net> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5839 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
6 additions
and
3 deletions
qemu-img.c
... | ... | @@ -30,6 +30,9 @@ |
30 | 30 | #include <windows.h> |
31 | 31 | #endif |
32 | 32 | |
33 | +/* Default to cache=writeback as data integrity is not important for qemu-tcg. */ | |
34 | +#define BRDV_O_FLAGS BDRV_O_CACHE_WB | |
35 | + | |
33 | 36 | static void __attribute__((noreturn)) error(const char *fmt, ...) |
34 | 37 | { |
35 | 38 | va_list ap; |
... | ... | @@ -186,7 +189,7 @@ static BlockDriverState *bdrv_new_open(const char *filename, |
186 | 189 | } else { |
187 | 190 | drv = NULL; |
188 | 191 | } |
189 | - if (bdrv_open2(bs, filename, 0, drv) < 0) { | |
192 | + if (bdrv_open2(bs, filename, BRDV_O_FLAGS, drv) < 0) { | |
190 | 193 | error("Could not open '%s'", filename); |
191 | 194 | } |
192 | 195 | if (bdrv_is_encrypted(bs)) { |
... | ... | @@ -317,7 +320,7 @@ static int img_commit(int argc, char **argv) |
317 | 320 | } else { |
318 | 321 | drv = NULL; |
319 | 322 | } |
320 | - if (bdrv_open2(bs, filename, 0, drv) < 0) { | |
323 | + if (bdrv_open2(bs, filename, BRDV_O_FLAGS, drv) < 0) { | |
321 | 324 | error("Could not open '%s'", filename); |
322 | 325 | } |
323 | 326 | ret = bdrv_commit(bs); |
... | ... | @@ -691,7 +694,7 @@ static int img_info(int argc, char **argv) |
691 | 694 | } else { |
692 | 695 | drv = NULL; |
693 | 696 | } |
694 | - if (bdrv_open2(bs, filename, 0, drv) < 0) { | |
697 | + if (bdrv_open2(bs, filename, BRDV_O_FLAGS, drv) < 0) { | |
695 | 698 | error("Could not open '%s'", filename); |
696 | 699 | } |
697 | 700 | bdrv_get_format(bs, fmt_name, sizeof(fmt_name)); | ... | ... |