[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-stable] [PATCH 07/53] qcow2: Flush pending discards before allocat
From: |
Michael Roth |
Subject: |
[Qemu-stable] [PATCH 07/53] qcow2: Flush pending discards before allocating cluster |
Date: |
Thu, 30 Jul 2015 06:32:22 -0500 |
From: Kevin Wolf <address@hidden>
Before a freed cluster can be reused, pending discards for this cluster
must be processed.
The original assumption was that this was not a problem because discards
are only cached during discard/write zeroes operations, which are
synchronous so that no concurrent write requests can cause cluster
allocations.
However, the discard/write zeroes operation itself can allocate a new L2
table (and it has to in order to put zero flags there), so make sure we
can cope with the situation.
This fixes https://bugs.launchpad.net/bugs/1349972.
Cc: address@hidden
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
(cherry picked from commit ecbda7a22576591a84f44de1be0150faf6001f1c)
Signed-off-by: Michael Roth <address@hidden>
---
block/qcow2-refcount.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 6cbae1d..63c0085 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -833,6 +833,11 @@ static int64_t alloc_clusters_noref(BlockDriverState *bs,
uint64_t size)
uint64_t i, nb_clusters, refcount;
int ret;
+ /* We can't allocate clusters if they may still be queued for discard. */
+ if (s->cache_discards) {
+ qcow2_process_discards(bs, 0);
+ }
+
nb_clusters = size_to_clusters(s, size);
retry:
for(i = 0; i < nb_clusters; i++) {
--
1.9.1
- [Qemu-stable] [PATCH 47/53] vfio/pci: Fix bootindex, (continued)
- [Qemu-stable] [PATCH 47/53] vfio/pci: Fix bootindex, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 50/53] block: qemu-iotests - add check for multiplication overflow in vpc, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 49/53] block: vpc - prevent overflow if max_table_entries >= 0x40000000, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 04/53] nbd/trivial: fix type cast for ioctl, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 41/53] Fix irq route entries exceeding KVM_MAX_IRQ_ROUTES, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 51/53] ide: Check array bounds before writing to io_buffer (CVE-2015-5154), Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 52/53] ide/atapi: Fix START STOP UNIT command completion, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 53/53] ide: Clear DRQ after handling all expected accesses, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 06/53] vmdk: Fix overflow if l1_size is 0x20000000, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 05/53] vmdk: Fix next_cluster_sector for compressed write, Michael Roth, 2015/07/30
- [Qemu-stable] [PATCH 07/53] qcow2: Flush pending discards before allocating cluster,
Michael Roth <=
- [Qemu-stable] [PATCH 08/53] usb: fix usb-net segfault, Michael Roth, 2015/07/30