From: Philipp Hahn <hahn@univention.de>
To: qemu-devel@nongnu.org, Michael Tokarev <mjt@tls.msk.ru>
Cc: Kevin Wolf <kwolf@redhat.com>
Subject: [Qemu-devel] [BUG] qemu-1.1.2 [FIXED-BY] qcow2: Fix avail_sectors in cluster allocation code
Date: Wed, 12 Dec 2012 14:25:36 +0100 [thread overview]
Message-ID: <201212121425.41850.hahn@univention.de> (raw)
In-Reply-To: <1339767219-24297-29-git-send-email-kwolf@redhat.com>
[-- Attachment #1.1: Type: text/plain, Size: 1593 bytes --]
Hello Kevin, hello Michael, hello *,
we noticed a data corruption bug in qemu-1.1.2, which will be shipped by
Debian and our own Debian based distibution.
The corruption mostly manifests while installing large Debian package files
and seems to be reladed to memory preasure: As long as the file is still in
the page cache, everything looks fine, but when the file is re-read from the
virtual hard disk using a qcow2 file backed by another qcow2 file, the file
is corrupted: dpkg complains that the .tar.gz file inside the Debian archive
file is corrupted and the md5sum no longer matches.
I tracked this down using "git bisect" to your patch attached below, which
fixed this bug, so everything is fine with qemu-kvm-1.2.0.
From my reading this seems to explain our problems, since during my own
testing during development I never used backing chains and the problem only
showed up when my collegues started using qemu-kvm-1.1.2 with their VMs using
backing chains.
@Kevin: Do you thinks that's a valid explanation and your patch should fix
that problem?
I'd like to get your expertise before filing a bug with Debian and asking
Michael to include that patch with his next stable update for 1.1.
Thanks in advance.
Sincerely
Philipp
--
Philipp Hahn Open Source Software Engineer hahn@univention.de
Univention GmbH be open. fon: +49 421 22 232- 0
Mary-Somerville-Str.1 D-28359 Bremen fax: +49 421 22 232-99
http://www.univention.de/
[-- Attachment #1.2: Kevin Wolf <kwolf@redhat.com>: [Qemu-devel] [PATCH 28/39] qcow2: Fix avail_sectors in cluster allocation code --]
[-- Type: message/rfc822, Size: 6469 bytes --]
From: Kevin Wolf <kwolf@redhat.com>
To: anthony@codemonkey.ws
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 28/39] qcow2: Fix avail_sectors in cluster allocation code
Date: Fri, 15 Jun 2012 15:33:28 +0200
Message-ID: <1339767219-24297-29-git-send-email-kwolf@redhat.com>
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 <kwolf@redhat.com>
---
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
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
next prev parent reply other threads:[~2012-12-12 13:26 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-15 13:33 [Qemu-devel] [PULL 00/39] Block patches Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 01/39] qcow2: remove a line of unnecessary code Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 02/39] qcow2: fix endianness conversion Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 03/39] block: implement is_allocated for raw Kevin Wolf
2012-06-19 12:37 ` Alexander Graf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 04/39] stream: tweak usage of bdrv_co_is_allocated Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 05/39] stream: move is_allocated_above to block.c Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 06/39] stream: move rate limiting to a separate header file Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 07/39] xtensa_lx60: add missing #include "blockdev.h" Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 08/39] Un-inline fdctrl_init_isa() Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 09/39] qemu-img check -r for repairing images Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 10/39] qemu-img check: Print fixed clusters and recheck Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 11/39] qcow2: Support for fixing refcount inconsistencies Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 12/39] rbd: hook up cache options Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 13/39] sheepdog: add coroutine_fn markers to coroutine functions Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 14/39] block: Simplify how drive_init() computes default ID Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 15/39] Prevent disk data loss when closing qemu Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 16/39] block: New bdrv_get_flags() Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 17/39] scsi-disk: Don't peek behind the BlockDriverState abstraction Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 18/39] qemu-iotests: fill streaming test image with data Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 19/39] qemu-iotests: start vms in qtest mode Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 20/39] block: flush in writethrough mode after writes Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 21/39] savevm: flush after saving vm state Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 22/39] block: copy enable_write_cache in bdrv_append Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 23/39] block: add bdrv_set_enable_write_cache Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 24/39] block: always open drivers in writeback mode Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 25/39] ide: support enable/disable write cache Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 26/39] qcow2: always operate caches in writeback mode Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 27/39] qcow2: Simplify calculation for COW area at the end Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 28/39] qcow2: Fix avail_sectors in cluster allocation code Kevin Wolf
2012-12-12 13:25 ` Philipp Hahn [this message]
2012-12-12 13:41 ` [Qemu-devel] [BUG] qemu-1.1.2 [FIXED-BY] " Kevin Wolf
2012-12-12 14:09 ` Philipp Hahn
2012-12-12 16:54 ` Kevin Wolf
2012-12-12 17:29 ` Philipp Hahn
2012-12-14 13:03 ` Philipp Hahn
2012-12-18 9:46 ` Philipp Hahn
2012-12-18 12:12 ` Michael Tokarev
2012-06-15 13:33 ` [Qemu-devel] [PATCH 29/39] qemu-iotests: Some backing file COW tests Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 30/39] qemu-iotests: COW with many AIO requests on the same cluster Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 31/39] qemu-img: document qed format on qemu-img man page Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 32/39] block: Replace bdrv_get_format() by bdrv_get_format_name() Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 33/39] xen: Don't change -drive if=xen device name during machine init Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 34/39] xen: Don't peek behind the BlockDriverState abstraction Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 35/39] qcow2: fix autoclear image header update Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 36/39] fdc: fix implied seek while there is no media in drive Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 37/39] fdc-test: introduced qtest read_without_media Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 38/39] qemu-iotests: add qcow2.py set-feature-bit command Kevin Wolf
2012-06-15 13:33 ` [Qemu-devel] [PATCH 39/39] qemu-iotests: add 036 autoclear feature bit test Kevin Wolf
2012-06-20 13:09 ` [Qemu-devel] [PULL 00/39] Block patches Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201212121425.41850.hahn@univention.de \
--to=hahn@univention.de \
--cc=kwolf@redhat.com \
--cc=mjt@tls.msk.ru \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).