All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/1] Block layer patch for 2.11.0-rc4
@ 2017-12-04 17:01 Kevin Wolf
  2017-12-04 17:01 ` [Qemu-devel] [PULL 1/1] blockjob: Make block_job_pause_all() keep a reference to the jobs Kevin Wolf
  2017-12-04 18:03 ` [Qemu-devel] [PULL 0/1] Block layer patch for 2.11.0-rc4 Peter Maydell
  0 siblings, 2 replies; 3+ messages in thread
From: Kevin Wolf @ 2017-12-04 17:01 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, peter.maydell, berto, qemu-devel

The following changes since commit 495566ec38817e6625294e6909cffb4de040c8e7:

  Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.11-20171204' into staging (2017-12-04 11:27:53 +0000)

are available in the git repository at:

  git://repo.or.cz/qemu/kevin.git tags/for-upstream

for you to fetch changes up to 3d5d319e1221082974711af1d09d82f0755c1698:

  blockjob: Make block_job_pause_all() keep a reference to the jobs (2017-12-04 17:44:51 +0100)

----------------------------------------------------------------
Block layer patches for 2.11.0-rc4

----------------------------------------------------------------
Alberto Garcia (1):
      blockjob: Make block_job_pause_all() keep a reference to the jobs

 blockjob.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

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

* [Qemu-devel] [PULL 1/1] blockjob: Make block_job_pause_all() keep a reference to the jobs
  2017-12-04 17:01 [Qemu-devel] [PULL 0/1] Block layer patch for 2.11.0-rc4 Kevin Wolf
@ 2017-12-04 17:01 ` Kevin Wolf
  2017-12-04 18:03 ` [Qemu-devel] [PULL 0/1] Block layer patch for 2.11.0-rc4 Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2017-12-04 17:01 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, peter.maydell, berto, qemu-devel

From: Alberto Garcia <berto@igalia.com>

Starting from commit 40840e419be31e6a32e6ea24511c74b389d5e0e4 we are
pausing all block jobs during bdrv_reopen_multiple() to prevent any of
them from finishing and removing nodes from the graph while they are
being reopened.

It turns out that pausing a block job doesn't necessarily prevent it
from finishing: a paused block job can still run its exit function
from the main loop and call block_job_completed(). The mirror block
job in particular always goes to the main loop while it is paused (by
virtue of the bdrv_drained_begin() call in mirror_run()).

Destroying a paused block job during bdrv_reopen_multiple() has two
consequences:

   1) The references to the nodes involved in the job are released,
      possibly destroying some of them. If those nodes were in the
      reopen queue this would trigger the problem originally described
      in commit 40840e419be, crashing QEMU.

   2) At the end of bdrv_reopen_multiple(), bdrv_drain_all_end() would
      not be doing all necessary bdrv_parent_drained_end() calls.

I can reproduce problem 1) easily with iotest 030 by increasing
STREAM_BUFFER_SIZE from 512KB to 8MB in block/stream.c, or by tweaking
the iotest like in this example:

   https://lists.gnu.org/archive/html/qemu-block/2017-11/msg00934.html

This patch keeps an additional reference to all block jobs between
block_job_pause_all() and block_job_resume_all(), guaranteeing that
they are kept alive.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 blockjob.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/blockjob.c b/blockjob.c
index 0ed50b953b..715c2c2680 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -730,6 +730,7 @@ void block_job_pause_all(void)
         AioContext *aio_context = blk_get_aio_context(job->blk);
 
         aio_context_acquire(aio_context);
+        block_job_ref(job);
         block_job_pause(job);
         aio_context_release(aio_context);
     }
@@ -808,12 +809,14 @@ void coroutine_fn block_job_pause_point(BlockJob *job)
 
 void block_job_resume_all(void)
 {
-    BlockJob *job = NULL;
-    while ((job = block_job_next(job))) {
+    BlockJob *job, *next;
+
+    QLIST_FOREACH_SAFE(job, &block_jobs, job_list, next) {
         AioContext *aio_context = blk_get_aio_context(job->blk);
 
         aio_context_acquire(aio_context);
         block_job_resume(job);
+        block_job_unref(job);
         aio_context_release(aio_context);
     }
 }
-- 
2.13.6

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

* Re: [Qemu-devel] [PULL 0/1] Block layer patch for 2.11.0-rc4
  2017-12-04 17:01 [Qemu-devel] [PULL 0/1] Block layer patch for 2.11.0-rc4 Kevin Wolf
  2017-12-04 17:01 ` [Qemu-devel] [PULL 1/1] blockjob: Make block_job_pause_all() keep a reference to the jobs Kevin Wolf
@ 2017-12-04 18:03 ` Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2017-12-04 18:03 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: Qemu-block, Alberto Garcia, QEMU Developers

On 4 December 2017 at 17:01, Kevin Wolf <kwolf@redhat.com> wrote:
> The following changes since commit 495566ec38817e6625294e6909cffb4de040c8e7:
>
>   Merge remote-tracking branch 'remotes/dgibson/tags/ppc-for-2.11-20171204' into staging (2017-12-04 11:27:53 +0000)
>
> are available in the git repository at:
>
>   git://repo.or.cz/qemu/kevin.git tags/for-upstream
>
> for you to fetch changes up to 3d5d319e1221082974711af1d09d82f0755c1698:
>
>   blockjob: Make block_job_pause_all() keep a reference to the jobs (2017-12-04 17:44:51 +0100)
>
> ----------------------------------------------------------------
> Block layer patches for 2.11.0-rc4
>
> ----------------------------------------------------------------
> Alberto Garcia (1):
>       blockjob: Make block_job_pause_all() keep a reference to the jobs
>
>  blockjob.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)

Applied, thanks.

-- PMM

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

end of thread, other threads:[~2017-12-04 18:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-04 17:01 [Qemu-devel] [PULL 0/1] Block layer patch for 2.11.0-rc4 Kevin Wolf
2017-12-04 17:01 ` [Qemu-devel] [PULL 1/1] blockjob: Make block_job_pause_all() keep a reference to the jobs Kevin Wolf
2017-12-04 18:03 ` [Qemu-devel] [PULL 0/1] Block layer patch for 2.11.0-rc4 Peter Maydell

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.