From: Kevin Wolf <kwolf@redhat.com>
To: Frediano Ziglio <freddy77@gmail.com>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] Suspicious code in qcow2.
Date: Thu, 08 Sep 2011 10:07:38 +0200 [thread overview]
Message-ID: <4E6877CA.3030309@redhat.com> (raw)
In-Reply-To: <CAHt6W4dvhNLsRMdLkMW=DtNcPi04Ewe3h-HpBrQkVWsWqcUd-w@mail.gmail.com>
Am 07.09.2011 18:42, schrieb Frediano Ziglio:
> Actually it does not cause problems but this code order seems a bit
> wrong to me (block/qcow2-cluster.c)
>
>
> QLIST_INSERT_HEAD(&s->cluster_allocs, m, next_in_flight);
>
> /* allocate a new cluster */
>
> cluster_offset = qcow2_alloc_clusters(bs, nb_clusters * s->cluster_size);
> if (cluster_offset < 0) {
> ret = cluster_offset;
> goto fail;
> }
>
> /* save info needed for meta data update */
> m->offset = offset;
> m->n_start = n_start;
> m->nb_clusters = nb_clusters;
>
>
> current metadata (m) get inserted in cluster allocation list with
> nb_clusters set to 0. Loop on cluster_allocs "ignore" (wait for this
> allocation or just skip it depending on dirty data in offset field)
> this metadata. Currently all occur in a CoMutex so this does not cause
> problems but in case qcow2_alloc_clusters unlock the mutex it can
> occur to insert two overlapping updates into cluster_allocs. Perhaps a
> better order would be
>
>
> /* save info needed for meta data update */
> m->offset = offset;
> m->n_start = n_start;
> m->nb_clusters = nb_clusters;
>
> QLIST_INSERT_HEAD(&s->cluster_allocs, m, next_in_flight);
>
> /* allocate a new cluster */
>
> cluster_offset = qcow2_alloc_clusters(bs, nb_clusters * s->cluster_size);
> if (cluster_offset < 0) {
> ret = cluster_offset;
> goto fail;
> }
>
>
> (tested successfully with iotests suite)
Yes, that makes sense. Once we run this code without holding the
CoMutex, this becomes a real problem. Care to send a patch?
Kevin
prev parent reply other threads:[~2011-09-08 8:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-07 16:42 [Qemu-devel] Suspicious code in qcow2 Frediano Ziglio
2011-09-08 8:07 ` Kevin Wolf [this message]
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=4E6877CA.3030309@redhat.com \
--to=kwolf@redhat.com \
--cc=freddy77@gmail.com \
--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).