From: Anthony Liguori <anthony@codemonkey.ws>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] fix bdrv_aio_read API breakage in qcow2
Date: Mon, 27 Oct 2008 08:49:58 -0500 [thread overview]
Message-ID: <4905C706.7040408@codemonkey.ws> (raw)
In-Reply-To: <20081022141459.GA26426@duo.random>
Andrea Arcangeli wrote:
> From: Andrea Arcangeli <aarcange@redhat.com>
>
> I noticed the qemu_aio_flush was doing nothing at all. And a flood of
> cmd_writeb commands leading to a noop-invocation of qemu_aio_flush
> were executed.
>
> In short all 'memset;goto redo' places must be fixed to use the bh and
> not to call the callback in the context of bdrv_aio_read or the
> bdrv_aio_read model falls apart. Reading from qcow2 holes is possible
> with phyisical readahead (kind of breada in linux buffer cache).
>
> This is needed at least for scsi, ide is lucky (or it has been
> band-aided against this API breakage by fixing the symptom and not the
> real bug).
>
> Same bug exists in qcow of course, can be fixed later as it's less
> urgent.
>
> Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
>
You've got whitespace damage (tabs instead of spaces).
Regards,
Anthony Liguori
> --
>
> Index: block-qcow2.c
> ===================================================================
> --- block-qcow2.c (revision 5506)
> +++ block-qcow2.c (working copy)
> @@ -1165,8 +1165,18 @@
> uint64_t cluster_offset;
> uint8_t *cluster_data;
> BlockDriverAIOCB *hd_aiocb;
> + QEMUBH *bh;
> } QCowAIOCB;
>
> +static void qcow_aio_read_cb(void *opaque, int ret);
> +static void qcow_aio_read_bh(void *opaque)
> +{
> + QCowAIOCB *acb = opaque;
> + qemu_bh_delete(acb->bh);
> + acb->bh = NULL;
> + qcow_aio_read_cb(opaque, 0);
> +}
> +
> static void qcow_aio_read_cb(void *opaque, int ret)
> {
> QCowAIOCB *acb = opaque;
> @@ -1182,7 +1192,6 @@
> return;
> }
>
> - redo:
> /* post process the read buffer */
> if (!acb->cluster_offset) {
> /* nothing to do */
> @@ -1223,12 +1232,30 @@
> if (acb->hd_aiocb == NULL)
> goto fail;
> } else {
> - goto redo;
> + if (acb->bh) {
> + ret = -EIO;
> + goto fail;
> + }
> + acb->bh = qemu_bh_new(qcow_aio_read_bh, acb);
> + if (!acb->bh) {
> + ret = -EIO;
> + goto fail;
> + }
> + qemu_bh_schedule(acb->bh);
> }
> } else {
> /* Note: in this case, no need to wait */
> memset(acb->buf, 0, 512 * acb->n);
> - goto redo;
> + if (acb->bh) {
> + ret = -EIO;
> + goto fail;
> + }
> + acb->bh = qemu_bh_new(qcow_aio_read_bh, acb);
> + if (!acb->bh) {
> + ret = -EIO;
> + goto fail;
> + }
> + qemu_bh_schedule(acb->bh);
> }
> } else if (acb->cluster_offset & QCOW_OFLAG_COMPRESSED) {
> /* add AIO support for compressed blocks ? */
> @@ -1236,7 +1263,16 @@
> goto fail;
> memcpy(acb->buf,
> s->cluster_cache + index_in_cluster * 512, 512 * acb->n);
> - goto redo;
> + if (acb->bh) {
> + ret = -EIO;
> + goto fail;
> + }
> + acb->bh = qemu_bh_new(qcow_aio_read_bh, acb);
> + if (!acb->bh) {
> + ret = -EIO;
> + goto fail;
> + }
> + qemu_bh_schedule(acb->bh);
> } else {
> if ((acb->cluster_offset & 511) != 0) {
> ret = -EIO;
>
>
>
next prev parent reply other threads:[~2008-10-27 13:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-29 13:52 [Qemu-devel] [PATCH] ide_dma_cancel will result in partial DMA transfer Andrea Arcangeli
2008-09-01 10:43 ` [Qemu-devel] [PATCH 1/2] " Andrea Arcangeli
2008-09-01 10:53 ` [Qemu-devel] [PATCH 2/2] fix bdrv_aio_read API breakage in qcow2 Andrea Arcangeli
2008-10-22 14:14 ` [Qemu-devel] [PATCH] " Andrea Arcangeli
2008-10-27 13:49 ` Anthony Liguori [this message]
2008-10-31 17:32 ` Anthony Liguori
2009-01-14 18:06 ` [Qemu-devel] [PATCH] ide_dma_cancel will result in partial DMA transfer Andrea Arcangeli
2009-01-16 16:41 ` Ian Jackson
2009-01-22 19:02 ` Anthony Liguori
2009-02-26 16:43 ` Andrea Arcangeli
2008-09-01 11:21 ` Ian Jackson
2008-09-01 12:13 ` Andrea Arcangeli
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=4905C706.7040408@codemonkey.ws \
--to=anthony@codemonkey.ws \
--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 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.