[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 01/16] qcow2: Round QCowL2Meta.offset down to cl
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [RFC PATCH 01/16] qcow2: Round QCowL2Meta.offset down to cluster boundary |
Date: |
Tue, 18 Sep 2012 13:40:27 +0200 |
The offset within the cluster is already present as n_start and this is
what the code uses. QCowL2Meta.offset is only needed at a cluster
granularity.
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2-cluster.c | 4 ++--
block/qcow2.h | 22 ++++++++++++++++++++++
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index e179211..d17a37c 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -631,7 +631,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs,
QCowL2Meta *m)
old_cluster = g_malloc(m->nb_clusters * sizeof(uint64_t));
/* copy content of unmodified sectors */
- start_sect = (m->offset & ~(s->cluster_size - 1)) >> 9;
+ start_sect = m->offset >> 9;
if (m->n_start) {
cow = true;
qemu_co_mutex_unlock(&s->lock);
@@ -966,7 +966,7 @@ again:
.cluster_offset = keep_clusters == 0 ?
alloc_cluster_offset : cluster_offset,
.alloc_offset = alloc_cluster_offset,
- .offset = alloc_offset,
+ .offset = alloc_offset & ~(s->cluster_size - 1),
.n_start = keep_clusters == 0 ? n_start : 0,
.nb_clusters = nb_clusters,
.nb_available = MIN(requested_sectors, avail_sectors),
diff --git a/block/qcow2.h b/block/qcow2.h
index b4eb654..2a406a7 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -199,12 +199,34 @@ struct QCowAIOCB;
/* XXX This could be private for qcow2-cluster.c */
typedef struct QCowL2Meta
{
+ /** Guest offset of the first newly allocated cluster */
uint64_t offset;
+
+ /** Host offset of the first cluster of the request */
uint64_t cluster_offset;
+
+ /** Host offset of the first newly allocated cluster */
uint64_t alloc_offset;
+
+ /**
+ * Number of sectors between the start of the first allocated cluster and
+ * the area that the guest actually writes to.
+ */
int n_start;
+
+ /**
+ * Number of sectors from the start of the first allocated cluster to
+ * the end of the (possibly shortened) request
+ */
int nb_available;
+
+ /** Number of newly allocated clusters */
int nb_clusters;
+
+ /**
+ * Requests that overlap with this allocation and wait to be restarted
+ * when the allocating request has completed.
+ */
CoQueue dependent_requests;
QLIST_ENTRY(QCowL2Meta) next_in_flight;
--
1.7.6.5
- [Qemu-devel] [RFC PATCH 00/16] qcow2: Delayed COW, Kevin Wolf, 2012/09/18
- [Qemu-devel] [RFC PATCH 03/16] qcow2: Allocate l2meta dynamically, Kevin Wolf, 2012/09/18
- [Qemu-devel] [RFC PATCH 08/16] qcow2: Reading from areas not in L2 tables yet, Kevin Wolf, 2012/09/18
- [Qemu-devel] [RFC PATCH 16/16] [BROKEN] qcow2: Overwrite COW and allocate new cluster at the same time, Kevin Wolf, 2012/09/18
- [Qemu-devel] [RFC PATCH 02/16] qcow2: Introduce Qcow2COWRegion, Kevin Wolf, 2012/09/18
- [Qemu-devel] [RFC PATCH 01/16] qcow2: Round QCowL2Meta.offset down to cluster boundary,
Kevin Wolf <=
- [Qemu-devel] [RFC PATCH 04/16] qcow2: Drop l2meta.cluster_offset, Kevin Wolf, 2012/09/18
- [Qemu-devel] [RFC PATCH 07/16] qcow2: Factor out handle_dependencies(), Kevin Wolf, 2012/09/18
- [Qemu-devel] [RFC PATCH 06/16] qcow2: Enable dirty flag in qcow2_alloc_cluster_link_l2, Kevin Wolf, 2012/09/18
- [Qemu-devel] [RFC PATCH 05/16] qcow2: Allocate l2meta only for cluster allocations, Kevin Wolf, 2012/09/18
- [Qemu-devel] [RFC PATCH 12/16] qcow2: Handle dependencies earlier, Kevin Wolf, 2012/09/18
- [Qemu-devel] [RFC PATCH 14/16] qcow2: Execute run_dependent_requests() without lock, Kevin Wolf, 2012/09/18
- [Qemu-devel] [RFC PATCH 09/16] qcow2: Move COW and L2 update into own coroutine, Kevin Wolf, 2012/09/18