qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [Bug 1362635] [NEW] bdrv_read co-routine re-entered recursively
@ 2014-08-28 14:19 senya
  2014-08-29 11:16 ` [Qemu-devel] [Bug 1362635] " senya
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: senya @ 2014-08-28 14:19 UTC (permalink / raw)
  To: qemu-devel

Public bug reported:

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?

** Affects: qemu
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1362635

Title:
  bdrv_read co-routine re-entered recursively

Status in QEMU:
  New

Bug description:
  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?

To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1362635/+subscriptions

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

end of thread, other threads:[~2018-04-13 22:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-28 14:19 [Qemu-devel] [Bug 1362635] [NEW] bdrv_read co-routine re-entered recursively senya
2014-08-29 11:16 ` [Qemu-devel] [Bug 1362635] " senya
2014-08-29 15:54   ` Stefan Hajnoczi
2014-09-01  7:55 ` senya
2014-09-01 15:44   ` Stefan Hajnoczi
2014-09-01 13:38 ` senya
2014-09-08  8:01 ` senya
2014-09-08  9:54   ` Stefan Hajnoczi
2018-04-13 21:41 ` Thomas Huth

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).