]> git.proxmox.com Git - mirror_qemu.git/commit - block/qcow2-cache.c
qcow2: avoid extra flushes in qcow2
authorDenis V. Lunev <den@openvz.org>
Thu, 2 Jun 2016 15:58:15 +0000 (18:58 +0300)
committerKevin Wolf <kwolf@redhat.com>
Wed, 8 Jun 2016 08:21:09 +0000 (10:21 +0200)
commitf3c3b87dae44ac6c82246ceb3953793951800a9a
tree5e2ecaaf97b3fa9f224277c719464b7b62becc57
parent6f6071745bd0366221f5a0160ed7d18d0e38b9f7
qcow2: avoid extra flushes in qcow2

The problem with excessive flushing was found by a couple of performance
tests:
  - parallel directory tree creation (from 2 processes)
  - 32 cached writes + fsync at the end in a loop

For the first one results improved from 2.6 loops/sec to 3.5 loops/sec.
Each loop creates 10^3 directories with 10 files in each.

For the second one results improved from ~600 fsync/sec to ~1100
fsync/sec. Though, it was run on SSD so it probably won't show such
performance gain on rotational media.

qcow2_cache_flush() calls bdrv_flush() unconditionally after writing
cache entries of a particular cache. This can lead to as many as
2 additional fdatasyncs inside bdrv_flush.

We can simply skip all fdatasync calls inside qcow2_co_flush_to_os
as bdrv_flush for sure will do the job. These flushes are necessary to
keep the right order of writes to the different caches. Though this is
not necessary in the current code base as this ordering is ensured through
the flush in qcow2_cache_flush_dependency().

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Pavel Borzenkov <pborzenkov@virtuozzo.com>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/qcow2-cache.c
block/qcow2.c
block/qcow2.h