mirror_qemu/block
Alberto Garcia 52253998ec qcow2: Give the refcount cache the minimum possible size by default
The L2 and refcount caches have default sizes that can be overridden
using the l2-cache-size and refcount-cache-size (an additional
parameter named cache-size sets the combined size of both caches).

Unless forced by one of the aforementioned parameters, QEMU will set
the unspecified sizes so that the L2 cache is 4 times larger than the
refcount cache.

This is based on the premise that the refcount metadata needs to be
only a fourth of the L2 metadata to cover the same amount of disk
space. This is incorrect for two reasons:

 a) The amount of disk covered by an L2 table depends solely on the
    cluster size, but in the case of a refcount block it depends on
    the cluster size *and* the width of each refcount entry.
    The 4/1 ratio is only valid with 16-bit entries (the default).

 b) When we talk about disk space and L2 tables we are talking about
    guest space (L2 tables map guest clusters to host clusters),
    whereas refcount blocks are used for host clusters (including
    L1/L2 tables and the refcount blocks themselves). On a fully
    populated (and uncompressed) qcow2 file, image size > virtual size
    so there are more refcount entries than L2 entries.

Problem (a) could be fixed by adjusting the algorithm to take into
account the refcount entry width. Problem (b) could be fixed by
increasing a bit the refcount cache size to account for the clusters
used for qcow2 metadata.

However this patch takes a completely different approach and instead
of keeping a ratio between both cache sizes it assigns as much as
possible to the L2 cache and the remainder to the refcount cache.

The reason is that L2 tables are used for every single I/O request
from the guest and the effect of increasing the cache is significant
and clearly measurable. Refcount blocks are however only used for
cluster allocation and internal snapshots and in practice are accessed
sequentially in most cases, so the effect of increasing the cache is
negligible (even when doing random writes from the guest).

So, make the refcount cache as small as possible unless the user
explicitly asks for a larger one.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: 9695182c2eb11b77cb319689a1ebaa4e7c9d6591.1523968389.git.berto@igalia.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
2018-05-15 16:15:21 +02:00
..
Makefile.objs block: x-blockdev-create QMP command 2018-03-09 15:17:47 +01:00
accounting.c block/accounting: introduce latency histogram 2018-03-19 14:58:37 -05:00
backup.c blockjob: Add block_job_driver() 2018-05-15 16:11:50 +02:00
blkdebug.c qobject: Modify qobject_ref() to return obj 2018-05-04 08:27:53 +02:00
blkreplay.c block/blkreplay: Remove protocol-related fields 2018-03-26 12:16:00 +02:00
blkverify.c qobject: Modify qobject_ref() to return obj 2018-05-04 08:27:53 +02:00
block-backend.c block-backend: simplify blk_get_aio_context 2018-05-15 16:11:41 +02:00
bochs.c block: Deprecate bdrv_set_read_only() and users 2017-11-17 13:35:59 +01:00
cloop.c block: Deprecate bdrv_set_read_only() and users 2017-11-17 13:35:59 +01:00
commit.c blockjob: Introduce block_job_ratelimit_get_delay() 2018-05-15 16:11:50 +02:00
create.c block: x-blockdev-create QMP command 2018-03-09 15:17:47 +01:00
crypto.c qobject: Replace qobject_incref/QINCREF qobject_decref/QDECREF 2018-05-04 08:27:53 +02:00
crypto.h qcow: convert QCow to use QCryptoBlock for encryption 2017-07-11 17:44:56 +02:00
curl.c Move include qemu/option.h from qemu-common.h to actual users 2018-02-09 13:52:16 +01:00
dirty-bitmap.c dirty-bitmap: add locked state 2018-03-13 17:05:00 -04:00
dmg-bz2.c dmg: Move libbz2 code to dmg-bz2.so 2016-10-07 14:14:06 +02:00
dmg.c block: Deprecate bdrv_set_read_only() and users 2017-11-17 13:35:59 +01:00
dmg.h block: remove "qemu/osdep.h" from header file 2017-12-18 17:07:02 +03:00
file-posix.c block/file-posix: add x-check-page-cache=on|off option 2018-05-11 16:43:05 +01:00
file-win32.c file-win32: Switch to byte-based callbacks 2018-05-15 16:11:41 +02:00
gluster.c block: Merge .bdrv_co_writev{,_flags} in drivers 2018-05-15 16:11:41 +02:00
io.c block: Merge .bdrv_co_writev{,_flags} in drivers 2018-05-15 16:11:41 +02:00
iscsi-opts.c Move include qemu/option.h from qemu-common.h to actual users 2018-02-09 13:52:16 +01:00
iscsi.c block: Merge .bdrv_co_writev{,_flags} in drivers 2018-05-15 16:11:41 +02:00
linux-aio.c block: explicitly acquire aiocontext in aio callbacks that need it 2017-02-21 11:39:39 +00:00
mirror.c blockjob: Introduce block_job_ratelimit_get_delay() 2018-05-15 16:11:50 +02:00
nbd-client.c nbd/client: Relax handling of large NBD_CMD_BLOCK_STATUS reply 2018-05-04 08:23:39 -05:00
nbd-client.h nbd: BLOCK_STATUS for standard get_block_status function: client part 2018-03-13 15:43:48 -05:00
nbd.c qobject: Replace qobject_incref/QINCREF qobject_decref/QDECREF 2018-05-04 08:27:53 +02:00
nfs.c qobject: Replace qobject_incref/QINCREF qobject_decref/QDECREF 2018-05-04 08:27:53 +02:00
null.c null: Switch to byte-based read/write 2018-05-15 16:11:41 +02:00
nvme.c qobject: Modify qobject_ref() to return obj 2018-05-04 08:27:53 +02:00
parallels.c block: Merge .bdrv_co_writev{,_flags} in drivers 2018-05-15 16:11:41 +02:00
parallels.h Clean up includes 2018-02-09 05:05:11 +01:00
qapi.c qobject: Replace qobject_incref/QINCREF qobject_decref/QDECREF 2018-05-04 08:27:53 +02:00
qcow.c block: Merge .bdrv_co_writev{,_flags} in drivers 2018-05-15 16:11:41 +02:00
qcow2-bitmap.c qcow2-bitmap: add qcow2_reopen_bitmaps_rw_hint() 2018-03-26 21:17:24 +02:00
qcow2-cache.c qcow2: Allow configuring the L2 slice size 2018-02-13 17:00:00 +01:00
qcow2-cluster.c qcow2: Check L1 table parameters in qcow2_expand_zero_clusters() 2018-03-09 15:17:47 +01:00
qcow2-refcount.c Fix error message about compressed clusters with OFLAG_COPIED 2018-05-15 16:15:21 +02:00
qcow2-snapshot.c qcow2: Check snapshot L1 table in qcow2_snapshot_delete() 2018-03-09 15:17:47 +01:00
qcow2.c qcow2: Give the refcount cache the minimum possible size by default 2018-05-15 16:15:21 +02:00
qcow2.h qcow2: Give the refcount cache the minimum possible size by default 2018-05-15 16:15:21 +02:00
qed-check.c block: convert bdrv_check callback to coroutine_fn 2018-03-09 15:17:47 +01:00
qed-cluster.c qed: protect table cache with CoMutex 2017-07-17 11:34:11 +08:00
qed-l2-cache.c qed: protect table cache with CoMutex 2017-07-17 11:34:11 +08:00
qed-table.c block: convert bdrv_check callback to coroutine_fn 2018-03-09 15:17:47 +01:00
qed.c block: Merge .bdrv_co_writev{,_flags} in drivers 2018-05-15 16:11:41 +02:00
qed.h qed: protect table cache with CoMutex 2017-07-17 11:34:11 +08:00
quorum.c qobject: Modify qobject_ref() to return obj 2018-05-04 08:27:53 +02:00
raw-format.c block: rename .bdrv_create() to .bdrv_co_create_opts() 2018-03-02 18:39:07 +01:00
rbd.c rbd: Switch to byte-based callbacks 2018-05-15 16:11:41 +02:00
replication.c block: Merge .bdrv_co_writev{,_flags} in drivers 2018-05-15 16:11:41 +02:00
sheepdog.c block: Merge .bdrv_co_writev{,_flags} in drivers 2018-05-15 16:11:41 +02:00
snapshot.c qobject: Replace qobject_incref/QINCREF qobject_decref/QDECREF 2018-05-04 08:27:53 +02:00
ssh.c block: Merge .bdrv_co_writev{,_flags} in drivers 2018-05-15 16:11:41 +02:00
stream.c blockjob: Introduce block_job_ratelimit_get_delay() 2018-05-15 16:11:50 +02:00
throttle-groups.c Include less of the generated modular QAPI headers 2018-03-02 13:45:50 -06:00
throttle.c block/throttle: Remove protocol-related fields 2018-03-26 12:16:00 +02:00
trace-events blockjobs: add block-job-finalize 2018-03-19 12:01:24 +01:00
vdi.c qobject: Replace qobject_incref/QINCREF qobject_decref/QDECREF 2018-05-04 08:27:53 +02:00
vhdx-endian.c vhdx: Use QEMU UUID API 2016-09-23 11:42:52 +08:00
vhdx-log.c vhdx: use QEMU_ALIGN_DOWN 2017-08-31 12:29:07 +02:00
vhdx.c block: Merge .bdrv_co_writev{,_flags} in drivers 2018-05-15 16:11:41 +02:00
vhdx.h block: vhdx - update PAYLOAD_BLOCK_UNMAPPED value to match 1.00 spec 2014-12-12 15:42:22 +00:00
vmdk.c vmdk: return ERROR when cluster sector is larger than vmdk limitation 2018-03-26 21:17:24 +02:00
vpc.c qobject: Replace qobject_incref/QINCREF qobject_decref/QDECREF 2018-05-04 08:27:53 +02:00
vvfat.c qobject: Replace qobject_incref/QINCREF qobject_decref/QDECREF 2018-05-04 08:27:53 +02:00
vxhs.c vxhs: Switch to byte-based callbacks 2018-05-15 16:11:41 +02:00
win32-aio.c file-win32: Switch to byte-based callbacks 2018-05-15 16:11:41 +02:00
write-threshold.c Include less of the generated modular QAPI headers 2018-03-02 13:45:50 -06:00