[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 43/60] qcow2: Fix avail_sectors in cluster allocati
From: |
Michael Tokarev |
Subject: |
[Qemu-stable] [PATCH 43/60] qcow2: Fix avail_sectors in cluster allocation code |
Date: |
Mon, 4 Feb 2013 14:40:53 +0400 |
From: Kevin Wolf <address@hidden>
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>
(cherry picked from commit b7ab0fea37c15ca9e249c42c46f5c48fd1a0943c)
Signed-off-by: Michael Tokarev <address@hidden>
---
block/qcow2-cluster.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index c173fcd..58e7e24 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -949,8 +949,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.10.4
- [Qemu-stable] [PATCH 14/60] fpu/softfloat.c: Return correctly signed values from uint64_to_float32, (continued)
- [Qemu-stable] [PATCH 14/60] fpu/softfloat.c: Return correctly signed values from uint64_to_float32, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 52/60] uhci: Don't queue up packets after one with the SPD flag set, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 08/60] eepro100: Fix network hang when rx buffers run out, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 53/60] hw/qxl: qxl_send_events: nop if stopped, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 12/60] intel_hda: do not call msi_reset when only device state needs resetting, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 24/60] qxl: always update displaysurface on resize, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 36/60] PPC: Bamboo: Fix memory size DT property, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 17/60] net: notify iothread after flushing queue, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 31/60] linux-user: fix emulation of getdents, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 44/60] qcow2: Fix refcount table size calculation, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 43/60] qcow2: Fix avail_sectors in cluster allocation code,
Michael Tokarev <=
- [Qemu-stable] [PATCH 06/60] fix doc of using raw values with sendkey, Michael Tokarev, 2013/02/04
- [Qemu-stable] [PATCH 48/60] ide: Fix crash with too long PRD, Michael Tokarev, 2013/02/04
- Re: [Qemu-stable] Patch queue for qemu-1.1.3 stable release, Doug Goldstein, 2013/02/04
- Re: [Qemu-stable] [Qemu-devel] Patch queue for qemu-1.1.3 stable release, Michael Tokarev, 2013/02/19