All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC PATCH 0/5] move bdrv_invalidate_cache, bdrv_check to coroutines
@ 2017-07-10 16:58 Paolo Bonzini
  2017-07-10 16:58 ` [Qemu-devel] [PATCH 1/5] qcow2: make qcow2_do_open a coroutine_fn Paolo Bonzini
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Paolo Bonzini @ 2017-07-10 16:58 UTC (permalink / raw)
  To: qemu-devel; +Cc: marcandre.lureau, kwolf

bdrv_invalidate_cache and bdrv_check are reading/processing metadata,
which is usually protected by a lock (CoMutex).  However, they are
not called from coroutine context, so they are not using the same
protection.  This series moves these functions into coroutine context,
as suggested by Kevin for bdrv_check, so that they can take the CoMutex
just like everyone else.

In addition, bdrv_invalidate_cache is already being called from coroutine
context when doing incoming migration; making this explicit is cleaner.

This is particularly important for QED which, unlike QCOW2, drops the
lock while reading metadata; this series lets it make the
qemu_co_mutex_release/acquire unconditional, instead of wrapping it
with qemu_in_coroutine.  It will help Marc-André's effort to validate
coroutine_fn with clang's -Wthread-safety.

This series of course doesn't change the fact that concurrent I/O is
not a very good idea for either bdrv_invalidate_cache or bdrv_check:
in the case of bdrv_invalidate_cache, you should not do I/O prior to
invalidation, while the case of bdrv_check corrupted metadata may cause
all sorts of misbehavior.  However, it would now be possible to do
multiple bdrv_invalidate_cache in parallel if we were so inclined.

Note: I'm fairly sure of the qed changes, but a bit less of the qcow2
parts.  Patch 4 should make sure that there is no recursive locking,
and qemu-iotests is happy.

Paolo

Paolo Bonzini (5):
  qcow2: make qcow2_do_open a coroutine_fn
  qed: make bdrv_qed_do_open a coroutine_fn
  block: convert bdrv_invalidate_cache callback to coroutine_fn
  qcow2: introduce qcow2_write_caches and qcow2_flush_caches
  block: convert bdrv_check callback to coroutine_fn

 block.c                   | 84 +++++++++++++++++++++++++++++++++++++----
 block/iscsi.c             |  6 +--
 block/nfs.c               |  6 +--
 block/parallels.c         | 17 ++++++---
 block/qcow2-refcount.c    | 28 ++++++++++++++
 block/qcow2.c             | 95 +++++++++++++++++++++++++++++++++--------------
 block/qcow2.h             |  2 +
 block/qed-check.c         |  1 +
 block/qed-table.c         | 26 +++++--------
 block/qed.c               | 66 ++++++++++++++++++++++++--------
 block/rbd.c               |  6 +--
 block/vdi.c               |  6 +--
 block/vhdx.c              |  7 ++--
 block/vmdk.c              |  7 ++--
 include/block/block_int.h |  8 ++--
 15 files changed, 272 insertions(+), 93 deletions(-)

-- 
2.13.0

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

end of thread, other threads:[~2017-07-11  9:09 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-10 16:58 [Qemu-devel] [RFC PATCH 0/5] move bdrv_invalidate_cache, bdrv_check to coroutines Paolo Bonzini
2017-07-10 16:58 ` [Qemu-devel] [PATCH 1/5] qcow2: make qcow2_do_open a coroutine_fn Paolo Bonzini
2017-07-11  8:28   ` Kevin Wolf
2017-07-11  8:34     ` Paolo Bonzini
2017-07-11  9:07       ` Kevin Wolf
2017-07-11  9:09         ` Paolo Bonzini
2017-07-10 16:58 ` [Qemu-devel] [PATCH 2/5] qed: make bdrv_qed_do_open " Paolo Bonzini
2017-07-10 16:58 ` [Qemu-devel] [PATCH 3/5] block: convert bdrv_invalidate_cache callback to coroutine_fn Paolo Bonzini
2017-07-11  8:24   ` Kevin Wolf
2017-07-11  8:33     ` Paolo Bonzini
2017-07-11  8:39       ` Kevin Wolf
2017-07-11  8:41         ` Paolo Bonzini
2017-07-11  9:03           ` Kevin Wolf
2017-07-10 16:58 ` [Qemu-devel] [PATCH 4/5] qcow2: introduce qcow2_write_caches and qcow2_flush_caches Paolo Bonzini
2017-07-10 16:58 ` [Qemu-devel] [PATCH 5/5] block: convert bdrv_check callback to coroutine_fn Paolo Bonzini

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.