diff options
author | Alberto Garcia <berto@igalia.com> | 2018-02-05 16:33:13 +0200 |
---|---|---|
committer | Max Reitz <mreitz@redhat.com> | 2018-02-13 16:59:59 +0100 |
commit | 3c2e511a24b51c5bfc70d365b54ad8c612d3b07c (patch) | |
tree | acaa8bfc760dd6b9904c151f25ffb65bc07edabc | |
parent | 05b5b6ee54cf69e7053c73286aac354be754235e (diff) | |
download | qemu-3c2e511a24b51c5bfc70d365b54ad8c612d3b07c.zip qemu-3c2e511a24b51c5bfc70d365b54ad8c612d3b07c.tar.gz qemu-3c2e511a24b51c5bfc70d365b54ad8c612d3b07c.tar.bz2 |
qcow2: Add l2_slice_size field to BDRVQcow2State
The BDRVQcow2State structure contains an l2_size field, which stores
the number of 64-bit entries in an L2 table.
For efficiency reasons we want to be able to load slices instead of
full L2 tables, so we need to know how many entries an L2 slice can
hold.
An L2 slice is the portion of an L2 table that is loaded by the qcow2
cache. At the moment that cache can only load complete tables,
therefore an L2 slice has the same size as an L2 table (one cluster)
and l2_size == l2_slice_size.
Later we'll allow smaller slices, but until then we have to use this
new l2_slice_size field to make the rest of the code ready for that.
Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: adb048595f9fb5dfb110c802a8b3c3be3b937f37.1517840877.git.berto@igalia.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
-rw-r--r-- | block/qcow2.c | 3 | ||||
-rw-r--r-- | block/qcow2.h | 1 |
2 files changed, 4 insertions, 0 deletions
diff --git a/block/qcow2.c b/block/qcow2.c index 461cc7a..ba8d71c 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -807,6 +807,7 @@ static void read_cache_sizes(BlockDriverState *bs, QemuOpts *opts, typedef struct Qcow2ReopenState { Qcow2Cache *l2_table_cache; Qcow2Cache *refcount_block_cache; + int l2_slice_size; /* Number of entries in a slice of the L2 table */ bool use_lazy_refcounts; int overlap_check; bool discard_passthrough[QCOW2_DISCARD_MAX]; @@ -888,6 +889,7 @@ static int qcow2_update_options_prepare(BlockDriverState *bs, } } + r->l2_slice_size = s->cluster_size / sizeof(uint64_t); r->l2_table_cache = qcow2_cache_create(bs, l2_cache_size); r->refcount_block_cache = qcow2_cache_create(bs, refcount_cache_size); if (r->l2_table_cache == NULL || r->refcount_block_cache == NULL) { @@ -1051,6 +1053,7 @@ static void qcow2_update_options_commit(BlockDriverState *bs, } s->l2_table_cache = r->l2_table_cache; s->refcount_block_cache = r->refcount_block_cache; + s->l2_slice_size = r->l2_slice_size; s->overlap_check = r->overlap_check; s->use_lazy_refcounts = r->use_lazy_refcounts; diff --git a/block/qcow2.h b/block/qcow2.h index d9ba57c..45fb7f4 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -251,6 +251,7 @@ typedef struct BDRVQcow2State { int cluster_bits; int cluster_size; int cluster_sectors; + int l2_slice_size; int l2_bits; int l2_size; int l1_size; |