[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 15/69] qcow2: Add two new fields to BDRVQcowState
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 15/69] qcow2: Add two new fields to BDRVQcowState |
Date: |
Fri, 27 Feb 2015 18:18:13 +0000 |
From: Max Reitz <address@hidden>
Add two new fields regarding refcount information (the bit width of
every entry and the maximum refcount value) to the BDRVQcowState.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2-refcount.c | 4 ++--
block/qcow2.c | 3 +++
block/qcow2.h | 2 ++
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 9b80ca7..e124a54 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -584,7 +584,7 @@ static int QEMU_WARN_UNUSED_RESULT
update_refcount(BlockDriverState *bs,
refcount = be16_to_cpu(refcount_block[block_index]);
refcount += addend;
- if (refcount < 0 || refcount > 0xffff) {
+ if (refcount < 0 || refcount > s->refcount_max) {
ret = -EINVAL;
goto fail;
}
@@ -775,7 +775,7 @@ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size)
return refcount;
}
- if (refcount == 0xffff) {
+ if (refcount == s->refcount_max) {
offset = 0;
}
}
diff --git a/block/qcow2.c b/block/qcow2.c
index 2ed8d95..2c01e25 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -684,6 +684,9 @@ static int qcow2_open(BlockDriverState *bs, QDict *options,
int flags,
goto fail;
}
s->refcount_order = header.refcount_order;
+ s->refcount_bits = 1 << s->refcount_order;
+ s->refcount_max = UINT64_C(1) << (s->refcount_bits - 1);
+ s->refcount_max += s->refcount_max - 1;
if (header.crypt_method > QCOW_CRYPT_AES) {
error_setg(errp, "Unsupported encryption method: %" PRIu32,
diff --git a/block/qcow2.h b/block/qcow2.h
index 0fee29b..55138c9 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -258,6 +258,8 @@ typedef struct BDRVQcowState {
int qcow_version;
bool use_lazy_refcounts;
int refcount_order;
+ int refcount_bits;
+ uint64_t refcount_max;
bool discard_passthrough[QCOW2_DISCARD_MAX];
--
2.1.0
- [Qemu-devel] [PULL 05/69] vpc: Implement bdrv_co_get_block_status(), (continued)
- [Qemu-devel] [PULL 05/69] vpc: Implement bdrv_co_get_block_status(), Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 08/69] qcow2: Remove unused struct QCowCreateState, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 09/69] virtio-blk: Check return value of blk_aio_ioctl, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 11/69] tests: Prepare virtio-blk-test for multi-arch implementation, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 10/69] libqos: Change use of pointers to uint64_t in virtio, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 12/69] libqos: Remove PCI assumptions in constants of virtio driver, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 13/69] libqos: Add malloc generic, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 06/69] sheepdog: selectable object size support, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 16/69] qcow2: Add refcount_bits to format-specific info, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 14/69] libqos: Add virtio MMIO support, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 15/69] qcow2: Add two new fields to BDRVQcowState,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 18/69] qcow2: Only return status from qcow2_get_refcount, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 20/69] qcow2: Use 64 bits for refcount values, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 17/69] qcow2: Do not return new value after refcount update, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 19/69] qcow2: Use unsigned addend for update_refcount(), Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 21/69] qcow2: Helper for refcount array reallocation, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 22/69] qcow2: Helper function for refcount modification, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 24/69] qcow2: Open images with refcount order != 4, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 26/69] qcow2: Use symbolic macros in qcow2_amend_options, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 23/69] qcow2: More helpers for refcount modification, Stefan Hajnoczi, 2015/02/27
- [Qemu-devel] [PULL 25/69] qcow2: refcount_order parameter for qcow2_create2, Stefan Hajnoczi, 2015/02/27