qemu-commits
[Top][All Lists]
Advanced

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

[Qemu-commits] [qemu/qemu] 14e955: block: Make bdrv_parent_drained_begin


From: GitHub
Subject: [Qemu-commits] [qemu/qemu] 14e955: block: Make bdrv_parent_drained_begin/end public
Date: Tue, 11 Apr 2017 06:30:10 -0700

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

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

  Log Message:
  -----------
  block: Make bdrv_parent_drained_begin/end public

Signed-off-by: Fam Zheng <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Acked-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>


  Commit: aabf591007a83dc6520329bce929570115849286
      
https://github.com/qemu/qemu/commit/aabf591007a83dc6520329bce929570115849286
  Author: Fam Zheng <address@hidden>
  Date:   2017-04-11 (Tue, 11 Apr 2017)

  Changed paths:
    M block.c

  Log Message:
  -----------
  block: Quiesce old aio context during bdrv_set_aio_context

The fact that the bs->aio_context is changing can confuse the dataplane
iothread, because of the now fine granularity aio context lock.
bdrv_drain should rather be a bdrv_drained_begin/end pair, but since
bs->aio_context is changing, we can just use aio_disable_external and
bdrv_parent_drained_begin.

Reported-by: Ed Swierk <address@hidden>
Signed-off-by: Fam Zheng <address@hidden>
Acked-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>


  Commit: d90fce944647f8b2759f016b0f86bf36dffe34c8
      
https://github.com/qemu/qemu/commit/d90fce944647f8b2759f016b0f86bf36dffe34c8
  Author: Fam Zheng <address@hidden>
  Date:   2017-04-11 (Tue, 11 Apr 2017)

  Changed paths:
    M tests/test-blockjob-txn.c

  Log Message:
  -----------
  tests/block-job-txn: Don't start block job before adding to txn

Previously, before test_block_job_start returns, the job can already
complete, as a result, the transactional state of other jobs added to
the same txn later cannot be handled correctly.

Move the block_job_start() calls to callers after
block_job_txn_add_job() calls.

Signed-off-by: Fam Zheng <address@hidden>
Acked-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>


  Commit: ba9e75ceef93000e624ae55faf2e498f96be2ec7
      
https://github.com/qemu/qemu/commit/ba9e75ceef93000e624ae55faf2e498f96be2ec7
  Author: Fam Zheng <address@hidden>
  Date:   2017-04-11 (Tue, 11 Apr 2017)

  Changed paths:
    M include/qemu/coroutine.h
    M util/qemu-coroutine.c
    M util/trace-events

  Log Message:
  -----------
  coroutine: Extract qemu_aio_coroutine_enter

It's a variant of qemu_coroutine_enter with an explicit AioContext
parameter.

Signed-off-by: Fam Zheng <address@hidden>
Acked-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>


  Commit: 8865852e00557925f60eb6e26d797833422ee86d
      
https://github.com/qemu/qemu/commit/8865852e00557925f60eb6e26d797833422ee86d
  Author: Fam Zheng <address@hidden>
  Date:   2017-04-11 (Tue, 11 Apr 2017)

  Changed paths:
    M include/block/aio.h
    M util/async.c

  Log Message:
  -----------
  async: Introduce aio_co_enter

They start the coroutine on the specified context.

Signed-off-by: Fam Zheng <address@hidden>
Acked-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>


  Commit: 052a75721fb38b9aa0e71ea6420b462c0e356e74
      
https://github.com/qemu/qemu/commit/052a75721fb38b9aa0e71ea6420b462c0e356e74
  Author: Fam Zheng <address@hidden>
  Date:   2017-04-11 (Tue, 11 Apr 2017)

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

  Log Message:
  -----------
  block: Introduce bdrv_coroutine_enter

Signed-off-by: Fam Zheng <address@hidden>
Acked-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>


  Commit: aef4278c5a835c555ffe065f9e480190fd076675
      
https://github.com/qemu/qemu/commit/aef4278c5a835c555ffe065f9e480190fd076675
  Author: Fam Zheng <address@hidden>
  Date:   2017-04-11 (Tue, 11 Apr 2017)

  Changed paths:
    M blockjob.c

  Log Message:
  -----------
  blockjob: Use bdrv_coroutine_enter to start coroutine

Resuming and especially starting of the block job coroutine, could be issued in
the main thread.  However the coroutine's "home" ctx should be set to the same
context as job->blk. Use bdrv_coroutine_enter to ensure that.

Signed-off-by: Fam Zheng <address@hidden>
Acked-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>


  Commit: 324ec3e4f26e0a2a422478db4b9992f8aad3bde4
      
https://github.com/qemu/qemu/commit/324ec3e4f26e0a2a422478db4b9992f8aad3bde4
  Author: Fam Zheng <address@hidden>
  Date:   2017-04-11 (Tue, 11 Apr 2017)

  Changed paths:
    M qemu-io-cmds.c

  Log Message:
  -----------
  qemu-io-cmds: Use bdrv_coroutine_enter

qemu_coroutine_create associates @co to qemu_aio_context but we poll
blk's context below. If the coroutine yields, it may never get resumed
again.

Use bdrv_coroutine_enter to make sure we are starting the I/O on the
right context.

Signed-off-by: Fam Zheng <address@hidden>
Acked-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>


  Commit: e92f0e1910f0655a0edd8d87c5a7262d36517a89
      
https://github.com/qemu/qemu/commit/e92f0e1910f0655a0edd8d87c5a7262d36517a89
  Author: Fam Zheng <address@hidden>
  Date:   2017-04-11 (Tue, 11 Apr 2017)

  Changed paths:
    M block/block-backend.c
    M block/io.c
    M tests/qemu-iotests/109.out

  Log Message:
  -----------
  block: Use bdrv_coroutine_enter to start I/O coroutines

BDRV_POLL_WHILE waits for the started I/O by releasing bs's ctx then polling
the main context, which relies on the yielded coroutine continuing on bs->ctx
before notifying qemu_aio_context with bdrv_wakeup().

Thus, using qemu_coroutine_enter to start I/O is wrong because if the coroutine
is entered from main loop, co->ctx will be qemu_aio_context, as a result of the
"release, poll, acquire" loop of BDRV_POLL_WHILE, race conditions happen when
both main thread and the iothread access the same BDS:

  main loop                                iothread
-----------------------------------------------------------------------
  blockdev_snapshot
    aio_context_acquire(bs->ctx)
                                     virtio_scsi_data_plane_handle_cmd
    bdrv_drained_begin(bs->ctx)
    bdrv_flush(bs)
      bdrv_co_flush(bs)                      aio_context_acquire(bs->ctx).enter
  ...
  qemu_coroutine_yield(co)
      BDRV_POLL_WHILE()
  aio_context_release(bs->ctx)
                                       aio_context_acquire(bs->ctx).return
                                         ...
                                           aio_co_wake(co)
  aio_poll(qemu_aio_context)               ...
    co_schedule_bh_cb()                    ...
      qemu_coroutine_enter(co)             ...
         /* (A) bdrv_co_flush(bs)           /* (B) I/O on bs */
                continues... */
                                       aio_context_release(bs->ctx)
  aio_context_acquire(bs->ctx)

Note that in above case, bdrv_drained_begin() doesn't do the "release,
poll, acquire" in BDRV_POLL_WHILE, because bs->in_flight == 0.

Fix this by using bdrv_coroutine_enter and enter coroutine in the right
context.

iotests 109 output is updated because the coroutine reenter flow during
mirror job complete is different (now through co_queue_wakeup, instead
of the unconditional qemu_coroutine_switch before), making the end job
len different.

Signed-off-by: Fam Zheng <address@hidden>
Acked-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>


  Commit: 49ca6259131c6b0555845fcac3e34467c8ac37eb
      
https://github.com/qemu/qemu/commit/49ca6259131c6b0555845fcac3e34467c8ac37eb
  Author: Fam Zheng <address@hidden>
  Date:   2017-04-11 (Tue, 11 Apr 2017)

  Changed paths:
    M block/io.c

  Log Message:
  -----------
  block: Fix bdrv_co_flush early return

bdrv_inc_in_flight and bdrv_dec_in_flight are mandatory for
BDRV_POLL_WHILE to work, even for the shortcut case where flush is
unnecessary. Move the if block to below bdrv_dec_in_flight, and BTW fix
the variable declaration position.

Signed-off-by: Fam Zheng <address@hidden>
Acked-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Kevin Wolf <address@hidden>
Reviewed-by: Paolo Bonzini <address@hidden>


  Commit: 76296dff97864ebb15fa65cc56a6f890ee0c5a28
      
https://github.com/qemu/qemu/commit/76296dff97864ebb15fa65cc56a6f890ee0c5a28
  Author: Fam Zheng <address@hidden>
  Date:   2017-04-11 (Tue, 11 Apr 2017)

  Changed paths:
    M block/sheepdog.c

  Log Message:
  -----------
  sheepdog: Use bdrv_coroutine_enter before BDRV_POLL_WHILE

When called from main thread, the coroutine should run in the context of
bs. Use bdrv_coroutine_enter to ensure that.

Signed-off-by: Fam Zheng <address@hidden>


  Commit: aa388ddc36e8032f41cd17bef88cc3ebaeba77c9
      
https://github.com/qemu/qemu/commit/aa388ddc36e8032f41cd17bef88cc3ebaeba77c9
  Author: Peter Maydell <address@hidden>
  Date:   2017-04-11 (Tue, 11 Apr 2017)

  Changed paths:
    M block.c
    M block/block-backend.c
    M block/io.c
    M block/sheepdog.c
    M blockjob.c
    M include/block/aio.h
    M include/block/block.h
    M include/qemu/coroutine.h
    M qemu-io-cmds.c
    M tests/qemu-iotests/109.out
    M tests/test-blockjob-txn.c
    M util/async.c
    M util/qemu-coroutine.c
    M util/trace-events

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

# gpg: Signature made Tue 11 Apr 2017 13:10:55 BST
# gpg:                using RSA key 0xCA35624C6A9171C6
# gpg: Good signature from "Fam Zheng <address@hidden>"
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg:          It is not certain that the signature belongs to the owner.
# Primary key fingerprint: 5003 7CB7 9706 0F76 F021  AD56 CA35 624C 6A91 71C6

* remotes/famz/tags/block-pull-request:
  sheepdog: Use bdrv_coroutine_enter before BDRV_POLL_WHILE
  block: Fix bdrv_co_flush early return
  block: Use bdrv_coroutine_enter to start I/O coroutines
  qemu-io-cmds: Use bdrv_coroutine_enter
  blockjob: Use bdrv_coroutine_enter to start coroutine
  block: Introduce bdrv_coroutine_enter
  async: Introduce aio_co_enter
  coroutine: Extract qemu_aio_coroutine_enter
  tests/block-job-txn: Don't start block job before adding to txn
  block: Quiesce old aio context during bdrv_set_aio_context
  block: Make bdrv_parent_drained_begin/end public

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


Compare: https://github.com/qemu/qemu/compare/17fa24b79cea...aa388ddc36e8

reply via email to

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