[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 2/7] qcow2: Use unsigned int for both members of Qco
From: |
Alberto Garcia |
Subject: |
[Qemu-block] [PATCH 2/7] qcow2: Use unsigned int for both members of Qcow2COWRegion |
Date: |
Tue, 23 May 2017 13:22:57 +0200 |
Qcow2COWRegion has two attributes:
- The offset of the COW region from the start of the first cluster
touched by the I/O request. Since it's always going to be positive
and the maximum request size is at most INT_MAX, we can use a
regular unsigned int to store this offset.
- The size of the COW region in bytes. This is guaranteed to be >= 0,
so we should use an unsigned type instead.
In x86_64 this reduces the size of Qcow2COWRegion from 16 to 8 bytes.
It will also help keep some assertions simpler now that we know that
there are no negative numbers.
The prototype of do_perform_cow() is also updated to reflect these
changes.
Signed-off-by: Alberto Garcia <address@hidden>
---
block/qcow2-cluster.c | 4 ++--
block/qcow2.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 3dc170e421..6757875ec9 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -406,8 +406,8 @@ int qcow2_encrypt_sectors(BDRVQcow2State *s, int64_t
sector_num,
static int coroutine_fn do_perform_cow(BlockDriverState *bs,
uint64_t src_cluster_offset,
uint64_t cluster_offset,
- int offset_in_cluster,
- int bytes)
+ unsigned offset_in_cluster,
+ unsigned bytes)
{
BDRVQcow2State *s = bs->opaque;
QEMUIOVector qiov;
diff --git a/block/qcow2.h b/block/qcow2.h
index 1801dc30dc..c26ee0a33d 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -301,10 +301,10 @@ typedef struct Qcow2COWRegion {
* Offset of the COW region in bytes from the start of the first cluster
* touched by the request.
*/
- uint64_t offset;
+ unsigned offset;
/** Number of bytes to copy */
- int nb_bytes;
+ unsigned nb_bytes;
} Qcow2COWRegion;
/**
--
2.11.0
- [Qemu-block] [PATCH 0/7] qcow2: Reduce the number of I/O ops when doing COW, Alberto Garcia, 2017/05/23
- [Qemu-block] [PATCH 1/7] qcow2: Remove unused Error in do_perform_cow(), Alberto Garcia, 2017/05/23
- [Qemu-block] [PATCH 5/7] qcow2: Allow reading both COW regions with only one request, Alberto Garcia, 2017/05/23
- [Qemu-block] [PATCH 6/7] qcow2: Pass a QEMUIOVector to do_perform_cow_{read, write}(), Alberto Garcia, 2017/05/23
- [Qemu-block] [PATCH 2/7] qcow2: Use unsigned int for both members of Qcow2COWRegion,
Alberto Garcia <=
- [Qemu-block] [PATCH 7/7] qcow2: Merge the writing of the COW regions with the guest data, Alberto Garcia, 2017/05/23
- Re: [Qemu-block] [PATCH 7/7] qcow2: Merge the writing of the COW regions with the guest data, Alberto Garcia, 2017/05/26
[Qemu-block] [PATCH 3/7] qcow2: Make perform_cow() call do_perform_cow() twice, Alberto Garcia, 2017/05/23
[Qemu-block] [PATCH 4/7] qcow2: Split do_perform_cow() into _read(), _encrypt() and _write(), Alberto Garcia, 2017/05/23