qcow2: add option to clean unused cache entries after some time

This adds a new 'cache-clean-interval' option that cleans all qcow2
cache entries that haven't been used in a certain interval, given in
seconds.

This allows setting a large L2 cache size so it can handle scenarios
with lots of I/O and at the same time use little memory during periods
of inactivity.

This feature currently relies on MADV_DONTNEED to free that memory, so
it is not useful in systems that don't follow that behavior.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: a70d12da60433df9360ada648b3f34b8f6f354ce.1438690126.git.berto@igalia.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
Alberto Garcia 2015-08-04 15:14:40 +03:00 committed by Max Reitz
parent 355ee2d0e8
commit 279621c046
4 changed files with 109 additions and 1 deletions

View file

@ -1592,6 +1592,10 @@
# @refcount-cache-size: #optional the maximum size of the refcount block cache
# in bytes (since 2.2)
#
# @cache-clean-interval: #optional clean unused entries in the L2 and refcount
# caches. The interval is in seconds. The default value
# is 0 and it disables this feature (since 2.5)
#
# Since: 1.7
##
{ 'struct': 'BlockdevOptionsQcow2',
@ -1603,7 +1607,8 @@
'*overlap-check': 'Qcow2OverlapChecks',
'*cache-size': 'int',
'*l2-cache-size': 'int',
'*refcount-cache-size': 'int' } }
'*refcount-cache-size': 'int',
'*cache-clean-interval': 'int' } }
##