* [Qemu-devel] [PATCH] qcow2: Flush pending discards before allocating cluster
@ 2015-05-06 11:29 Kevin Wolf
2015-05-06 13:31 ` Max Reitz
2015-05-08 10:55 ` Kevin Wolf
0 siblings, 2 replies; 3+ messages in thread
From: Kevin Wolf @ 2015-05-06 11:29 UTC (permalink / raw)
To: qemu-block; +Cc: kwolf, qemu-devel, mreitz
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.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/qcow2-refcount.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index f47260b..83467c3 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.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] qcow2: Flush pending discards before allocating cluster
2015-05-06 11:29 [Qemu-devel] [PATCH] qcow2: Flush pending discards before allocating cluster Kevin Wolf
@ 2015-05-06 13:31 ` Max Reitz
2015-05-08 10:55 ` Kevin Wolf
1 sibling, 0 replies; 3+ messages in thread
From: Max Reitz @ 2015-05-06 13:31 UTC (permalink / raw)
To: Kevin Wolf, qemu-block; +Cc: qemu-devel
On 06.05.2015 13:29, Kevin Wolf wrote:
> 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.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> block/qcow2-refcount.c | 5 +++++
> 1 file changed, 5 insertions(+)
Reviewed-by: Max Reitz <mreitz@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] qcow2: Flush pending discards before allocating cluster
2015-05-06 11:29 [Qemu-devel] [PATCH] qcow2: Flush pending discards before allocating cluster Kevin Wolf
2015-05-06 13:31 ` Max Reitz
@ 2015-05-08 10:55 ` Kevin Wolf
1 sibling, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2015-05-08 10:55 UTC (permalink / raw)
To: qemu-block; +Cc: qemu-stable, qemu-devel, mreitz
Am 06.05.2015 um 13:29 hat Kevin Wolf geschrieben:
> 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.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-stable@nongnu.org
Applied to my block branch.
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-05-08 10:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-06 11:29 [Qemu-devel] [PATCH] qcow2: Flush pending discards before allocating cluster Kevin Wolf
2015-05-06 13:31 ` Max Reitz
2015-05-08 10:55 ` Kevin Wolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).