All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] Assertion failure on qcow2 disk with cluster_size != 64k
@ 2016-10-21  0:24 Ed Swierk
  2016-10-21  1:38 ` Eric Blake
  2016-10-24 21:21 ` Eric Blake
  0 siblings, 2 replies; 12+ messages in thread
From: Ed Swierk @ 2016-10-21  0:24 UTC (permalink / raw)
  To: qemu-block, qemu-devel; +Cc: Kevin Wolf, Denis V. Lunev

Shortly after I start qemu 2.7.0 with a qcow2 disk image created with
-o cluster_size=1048576, it prints the following and dies:

block/qcow2.c:2451: qcow2_co_pwrite_zeroes: Assertion `head + count <=
s->cluster_size' failed.

I narrowed the problem to bdrv_co_do_pwrite_zeroes(), called by
bdrv_aligned_pwritev() with flags & BDRV_REQ_ZERO_WRITE set.

On the first loop iteration, offset=8003584, count=2093056,
head=663552, tail=659456 and num=2093056. qcow2_co_pwrite_zeroes() is
called with offset=8003584 and count=385024 and finds that the head
portion is not already zero, so it returns -ENOTSUP.
bdrv_co_do_pwrite_zeroes() falls back to a normal write, with
max_transfer=65536.

The next iteration starts with offset incremented by 65536, count and
num decremented by 65536, and head=0, violating the assumption that
the entire 385024 bytes of the head remainder had been zeroed the
first time around. Then it calls qcow2_co_pwrite_zeroes() with an
unaligned offset=8069120 and a count=1368064 greater than the cluster
size, triggering the assertion failure.

Changing max_transfer in the normal write case to
MIN_NON_ZERO(alignment, MAX_WRITE_ZEROES_BOUNCE_BUFFER) appears to fix
the problem, but I don't pretend to understand all the subtleties
here.

--Ed

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-11-14 16:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-21  0:24 [Qemu-devel] Assertion failure on qcow2 disk with cluster_size != 64k Ed Swierk
2016-10-21  1:38 ` Eric Blake
2016-10-21 13:14   ` Ed Swierk
2016-10-24 20:32     ` Eric Blake
2016-11-14  9:50       ` Kevin Wolf
2016-11-14 15:46         ` Eric Blake
2016-11-14 15:54           ` Kevin Wolf
2016-11-14 16:59             ` Eric Blake
2016-10-24 21:21 ` Eric Blake
2016-10-24 23:06   ` Ed Swierk
2016-10-25  8:39     ` Kevin Wolf
2016-10-25 13:51       ` Eric Blake

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.