qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskij <etendren@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] bdrv_read race
Date: Thu, 28 Aug 2014 15:52:38 +0400	[thread overview]
Message-ID: <CADNrJiTPsiyEc32yyTWtQsSApH6cfdigQDoY+ZorLnMHmGithw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1381 bytes --]

calling bdrv_read in a loop leads to the follwing situation:

bs->drv->bdrv_aio_readv is called, and finally calls bdrv_co_io_em_complete
in other thread context.
there is a possibility of calling bdrv_co_io_em_complete before
calling qemu_coroutine_yield in bdrv_co_io_em. And qemu fails with
"co-routine re-entered recursively".

static void bdrv_co_io_em_complete(void *opaque, int ret)
{
    CoroutineIOCompletion *co = opaque;

    co->ret = ret;
    qemu_coroutine_enter(co->coroutine, NULL);
}

static int coroutine_fn bdrv_co_io_em(BlockDriverState *bs, int64_t
sector_num,
                                      int nb_sectors, QEMUIOVector *iov,
                                      bool is_write)
{
    CoroutineIOCompletion co = {
        .coroutine = qemu_coroutine_self(),
    };
    BlockDriverAIOCB *acb;

    if (is_write) {
        acb = bs->drv->bdrv_aio_writev(bs, sector_num, iov, nb_sectors,
                                       bdrv_co_io_em_complete, &co);
    } else {
        acb = bs->drv->bdrv_aio_readv(bs, sector_num, iov, nb_sectors,
                                      bdrv_co_io_em_complete, &co);
    }

    trace_bdrv_co_io_em(bs, sector_num, nb_sectors, is_write, acb);
    if (!acb) {
        return -EIO;
    }
    qemu_coroutine_yield();

    return co.ret;
}

is it a bug, or may be I don't understand something?

Best regards,
Vladimir

[-- Attachment #2: Type: text/html, Size: 2059 bytes --]

             reply	other threads:[~2014-08-28 11:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-28 11:52 Vladimir Sementsov-Ogievskij [this message]
2014-08-29 16:05 ` [Qemu-devel] bdrv_read race Stefan Hajnoczi

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=CADNrJiTPsiyEc32yyTWtQsSApH6cfdigQDoY+ZorLnMHmGithw@mail.gmail.com \
    --to=etendren@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).