qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] a77fd4: block: Fix bdrv_drain in coroutine


From: GitHub
Subject: [Qemu-commits] [qemu/qemu] a77fd4: block: Fix bdrv_drain in coroutine
Date: Tue, 12 Apr 2016 03:00:08 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: a77fd4bb2988c05953fdc9f1524085870ec1c939
      
https://github.com/qemu/qemu/commit/a77fd4bb2988c05953fdc9f1524085870ec1c939
  Author: Fam Zheng <address@hidden>
  Date:   2016-04-11 (Mon, 11 Apr 2016)

  Changed paths:
    M block/io.c
    M include/block/block.h

  Log Message:
  -----------
  block: Fix bdrv_drain in coroutine

Using the nested aio_poll() in coroutine is a bad idea. This patch
replaces the aio_poll loop in bdrv_drain with a BH, if called in
coroutine.

For example, the bdrv_drain() in mirror.c can hang when a guest issued
request is pending on it in qemu_co_mutex_lock().

Mirror coroutine in this case has just finished a request, and the block
job is about to complete. It calls bdrv_drain() which waits for the
other coroutine to complete. The other coroutine is a scsi-disk request.
The deadlock happens when the latter is in turn pending on the former to
yield/terminate, in qemu_co_mutex_lock(). The state flow is as below
(assuming a qcow2 image):

  mirror coroutine               scsi-disk coroutine
  -------------------------------------------------------------
  do last write

    qcow2:qemu_co_mutex_lock()
    ...
                           scsi disk read
                              tracked request begin
                              qcow2:qemu_co_mutex_lock.enter

    qcow2:qemu_co_mutex_unlock()

  bdrv_drain
    while (has tracked request)
      aio_poll()

In the scsi-disk coroutine, the qemu_co_mutex_lock() will never return
because the mirror coroutine is blocked in the aio_poll(blocking=true).

With this patch, the added qemu_coroutine_yield() allows the scsi-disk
coroutine to make progress as expected:

  mirror coroutine               scsi-disk coroutine
  -------------------------------------------------------------
  do last write

    qcow2:qemu_co_mutex_lock()
    ...
                           scsi disk read
                              tracked request begin
                              qcow2:qemu_co_mutex_lock.enter

    qcow2:qemu_co_mutex_unlock()

  bdrv_drain.enter
>   schedule BH
>   qemu_coroutine_yield()
>                                  qcow2:qemu_co_mutex_lock.return
>                                  ...
                             tracked request end
    ...
    (resumed from BH callback)
  bdrv_drain.return
  ...

Reported-by: Laurent Vivier <address@hidden>
Signed-off-by: Fam Zheng <address@hidden>
Message-id: address@hidden
Suggested-by: Paolo Bonzini <address@hidden>
Signed-off-by: Fam Zheng <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: 39bf92dd703efb04fc516aad1376986aea7d96bf
      
https://github.com/qemu/qemu/commit/39bf92dd703efb04fc516aad1376986aea7d96bf
  Author: Fam Zheng <address@hidden>
  Date:   2016-04-11 (Mon, 11 Apr 2016)

  Changed paths:
    M block/mirror.c

  Log Message:
  -----------
  mirror: Replace bdrv_drain(bs) with bdrv_co_drain(bs)

Suggested-by: Stefan Hajnoczi <address@hidden>
Signed-off-by: Fam Zheng <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: 9ca3003df3c9882925c023c1411ab3b2041d7db5
      
https://github.com/qemu/qemu/commit/9ca3003df3c9882925c023c1411ab3b2041d7db5
  Author: Fam Zheng <address@hidden>
  Date:   2016-04-11 (Mon, 11 Apr 2016)

  Changed paths:
    M MAINTAINERS

  Log Message:
  -----------
  MAINTAINERS: Add Fam Zheng as a co-maintainer of block I/O path

As agreed with Stefan, I'm listing myself a co-maintainer of block I/O
path and assist with the maintainership.

Signed-off-by: Fam Zheng <address@hidden>
Message-id: address@hidden
Signed-off-by: Stefan Hajnoczi <address@hidden>


  Commit: 42bb626f7ebc9197d2943b897a99e127315275ab
      
https://github.com/qemu/qemu/commit/42bb626f7ebc9197d2943b897a99e127315275ab
  Author: Peter Maydell <address@hidden>
  Date:   2016-04-12 (Tue, 12 Apr 2016)

  Changed paths:
    M MAINTAINERS
    M block/io.c
    M block/mirror.c
    M include/block/block.h

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into 
staging

# gpg: Signature made Tue 12 Apr 2016 09:29:54 BST using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <address@hidden>"
# gpg:                 aka "Stefan Hajnoczi <address@hidden>"

* remotes/stefanha/tags/block-pull-request:
  MAINTAINERS: Add Fam Zheng as a co-maintainer of block I/O path
  mirror: Replace bdrv_drain(bs) with bdrv_co_drain(bs)
  block: Fix bdrv_drain in coroutine

Signed-off-by: Peter Maydell <address@hidden>


Compare: https://github.com/qemu/qemu/compare/4e71220387e8...42bb626f7ebc

reply via email to

[Prev in Thread] Current Thread [Next in Thread]