qcow2: update_refcount(): Reset old_table_index after qcow2_cache_put()

In the case that update_refcount() frees a refcount block, it evicts it
from the metadata cache. Before doing so, however, it returns the
currently used refcount block to the cache because it might be the same.
Returning the refcount block early means that we need to reset
old_table_index so that we reload the refcount block in the next
iteration if it is actually still in use.

Fixes: f71c08ea8e
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20200211094900.17315-2-kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit dea9052ef1)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
stable-4.2
Kevin Wolf 2020-02-11 10:48:58 +01:00 committed by Michael Roth
parent e49ae74a24
commit f9854de0d8
1 changed files with 1 additions and 0 deletions

View File

@ -889,6 +889,7 @@ static int QEMU_WARN_UNUSED_RESULT update_refcount(BlockDriverState *bs,
offset);
if (table != NULL) {
qcow2_cache_put(s->refcount_block_cache, &refcount_block);
old_table_index = -1;
qcow2_cache_discard(s->refcount_block_cache, table);
}