[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 28/39] qcow2: Fix avail_sectors in cluster allocatio
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 28/39] qcow2: Fix avail_sectors in cluster allocation code |
Date: |
Fri, 15 Jun 2012 15:33:28 +0200 |
avail_sectors should really be the number of sectors from the start of
the allocation, not from the start of the write request.
We're lucky enough that this mistake didn't cause any real bug.
avail_sectors is only used in the intialiser of QCowL2Meta:
.nb_available = MIN(requested_sectors, avail_sectors),
m->nb_available in turn is only used for COW at the end of the
allocation. A COW occurs only if the request wasn't cluster aligned,
which in turn would imply that requested_sectors was less than
avail_sectors (both in the original and in the fixed version). In this
case avail_sectors is ignored and therefore the mistake doesn't cause
any misbehaviour.
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2-cluster.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 98fba71..d7e0e19 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -947,8 +947,16 @@ again:
/* save info needed for meta data update */
if (nb_clusters > 0) {
+ /*
+ * requested_sectors: Number of sectors from the start of the first
+ * newly allocated cluster to the end of the (possibly shortened
+ * before) write request.
+ *
+ * avail_sectors: Number of sectors from the start of the first
+ * newly allocated to the end of the last newly allocated cluster.
+ */
int requested_sectors = n_end - keep_clusters * s->cluster_sectors;
- int avail_sectors = (keep_clusters + nb_clusters)
+ int avail_sectors = nb_clusters
<< (s->cluster_bits - BDRV_SECTOR_BITS);
*m = (QCowL2Meta) {
--
1.7.6.5
- [Qemu-devel] [PATCH 19/39] qemu-iotests: start vms in qtest mode, (continued)
- [Qemu-devel] [PATCH 19/39] qemu-iotests: start vms in qtest mode, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 25/39] ide: support enable/disable write cache, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 20/39] block: flush in writethrough mode after writes, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 36/39] fdc: fix implied seek while there is no media in drive, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 38/39] qemu-iotests: add qcow2.py set-feature-bit command, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 39/39] qemu-iotests: add 036 autoclear feature bit test, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 30/39] qemu-iotests: COW with many AIO requests on the same cluster, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 31/39] qemu-img: document qed format on qemu-img man page, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 35/39] qcow2: fix autoclear image header update, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 37/39] fdc-test: introduced qtest read_without_media, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 28/39] qcow2: Fix avail_sectors in cluster allocation code,
Kevin Wolf <=
- [Qemu-devel] [PATCH 24/39] block: always open drivers in writeback mode, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 33/39] xen: Don't change -drive if=xen device name during machine init, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 29/39] qemu-iotests: Some backing file COW tests, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 26/39] qcow2: always operate caches in writeback mode, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 32/39] block: Replace bdrv_get_format() by bdrv_get_format_name(), Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 34/39] xen: Don't peek behind the BlockDriverState abstraction, Kevin Wolf, 2012/06/15
- [Qemu-devel] [PATCH 27/39] qcow2: Simplify calculation for COW area at the end, Kevin Wolf, 2012/06/15
- Re: [Qemu-devel] [PULL 00/39] Block patches, Anthony Liguori, 2012/06/20