qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>
Cc: qemu-devel@nongnu.org, famz@redhat.com, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 11/11] block/snapshot: do not take AioContext lock
Date: Mon, 10 Jul 2017 18:27:27 +0200	[thread overview]
Message-ID: <c5efa0c6-92a1-76f6-c1ba-34b36ef93cbd@redhat.com> (raw)
In-Reply-To: <20170710162419.GS14195@stefanha-x1.localdomain>

[-- Attachment #1: Type: text/plain, Size: 3308 bytes --]

On 10/07/2017 18:24, Stefan Hajnoczi wrote:
> On Thu, Jul 06, 2017 at 06:38:28PM +0200, Paolo Bonzini wrote:
>> Snapshots are only created/destroyed/loaded under the BQL, while no
>> other I/O is happening.  Snapshot information could be accessed while
>> other I/O is happening, but also under the BQL so they cannot be
>> modified concurrently.  The AioContext lock is overkill.  If needed,
>> in the future the BQL could be split to a separate lock covering all
>> snapshot operations, and the create/destroy/goto callbacks changed
>> to run in a coroutine (so the driver can do mutual exclusion as usual).
>>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>>  block/snapshot.c          | 28 +---------------------------
>>  blockdev.c                | 43 ++++++++++++-------------------------------
>>  hmp.c                     |  7 -------
>>  include/block/block_int.h |  5 +++++
>>  include/block/snapshot.h  |  4 +---
>>  migration/savevm.c        | 22 ----------------------
>>  monitor.c                 | 10 ++--------
>>  7 files changed, 21 insertions(+), 98 deletions(-)
>>
>> diff --git a/block/snapshot.c b/block/snapshot.c
>> index a46564e7b7..08c59d6166 100644
>> --- a/block/snapshot.c
>> +++ b/block/snapshot.c
>> @@ -384,9 +384,7 @@ int bdrv_snapshot_load_tmp_by_id_or_name(BlockDriverState *bs,
>>  }
>>  
>>  
>> -/* Group operations. All block drivers are involved.
>> - * These functions will properly handle dataplane (take aio_context_acquire
>> - * when appropriate for appropriate block drivers) */
>> +/* Group operations. All block drivers are involved.  */
> 
> Perhaps "These functions must be called under the BQL"?
> 
> My concern with this patch series in general is that it will lead to
> bugs due to inconsistencies and lack of locking documentation:
> 
> bdrv_all_delete_snapshot() is called by hmp_delvm() outside a
> bdrv_drained_begin() region.  That's okay because internally
> bdrv_snapshot_delete() will call bdrv_drained_begin() for the crucial
> operations that require a quiesced BDS.
> 
> Compare that with bdrv_all_goto_snapshot(), which is called inside a
> bdrv_drained_begin() region by load_snapshot().  Internally it doesn't
> drain.

I think generally we should move bdrv_drained_begin/end calls _out_ of
block.c and into qmp_*.  If you agree, I can add this before this patch.

> Previously the bdrv_all_*() functions behaved consistently.  We could
> say that they will acquire AioContexts themselves.  Now they behave
> inconsistently and while the code currently happens to work, there is no
> structure that will keep it working as it is modified.
> 
> I think we're reaching a point where every BlockDriver callback and
> every bdrv_*() function needs the following information:
> 
> 1. Must be called under BQL?
> 2. Can I/O requests be in flight?
> 3. Is it thread-safe?
> 
> Otherwise it will be a nightmare to modify the code since these
> constraints are not enforced by the compiler and undocumented.

Good point.  Are (1) and (3) different ways to say the same thing or do
you have other differences in mind?

More long term, I think snapshot functions should be changed to run in
coroutines.  This way they can just take the driver CoMutex.

Paolo


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2017-07-10 16:27 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-06 16:38 [Qemu-devel] [RFC PATCH 00/11] Block layer thread-safety, next part Paolo Bonzini
2017-07-06 16:38 ` [Qemu-devel] [PATCH 01/11] block: prepare write threshold code for thread safety Paolo Bonzini
2017-07-06 16:51   ` Eric Blake
2017-07-10 13:21   ` Stefan Hajnoczi
2017-07-10 16:16     ` Paolo Bonzini
2017-07-10 16:22       ` Eric Blake
2017-07-06 16:38 ` [Qemu-devel] [PATCH 02/11] block: make write-threshold thread-safe Paolo Bonzini
2017-07-06 16:52   ` Eric Blake
2017-07-10 15:42   ` Stefan Hajnoczi
2017-07-06 16:38 ` [Qemu-devel] [PATCH 03/11] util: use RCU accessors for notifiers Paolo Bonzini
2017-07-10 15:52   ` Stefan Hajnoczi
2017-07-10 16:06     ` Paolo Bonzini
2017-07-11  9:45       ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2017-07-06 16:38 ` [Qemu-devel] [PATCH 04/11] block: make before-write notifiers thread-safe Paolo Bonzini
2017-07-10 15:50   ` Stefan Hajnoczi
2017-07-06 16:38 ` [Qemu-devel] [PATCH 05/11] block-backup: add reqs_lock Paolo Bonzini
2017-07-10 15:57   ` Stefan Hajnoczi
2017-07-06 16:38 ` [Qemu-devel] [PATCH 06/11] block: add a few more notes on locking Paolo Bonzini
2017-07-10 15:57   ` Stefan Hajnoczi
2017-07-06 16:38 ` [Qemu-devel] [PATCH 07/11] block: do not acquire AioContext in check_to_replace_node Paolo Bonzini
2017-07-10 15:58   ` Stefan Hajnoczi
2017-07-06 16:38 ` [Qemu-devel] [PATCH 08/11] block: drain I/O around key management Paolo Bonzini
2017-07-10 16:01   ` Stefan Hajnoczi
2017-07-06 16:38 ` [Qemu-devel] [PATCH 09/11] block/replication: do not acquire AioContext Paolo Bonzini
2017-07-06 16:38 ` [Qemu-devel] [PATCH 10/11] block: do not take AioContext around reopen Paolo Bonzini
2017-07-06 16:38 ` [Qemu-devel] [PATCH 11/11] block/snapshot: do not take AioContext lock Paolo Bonzini
2017-07-10 16:24   ` Stefan Hajnoczi
2017-07-10 16:27     ` Paolo Bonzini [this message]
2017-07-11  9:43       ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2017-07-11  9:48         ` Paolo Bonzini
2017-07-12 10:42           ` Stefan Hajnoczi
2017-07-06 23:48 ` [Qemu-devel] [RFC PATCH 00/11] Block layer thread-safety, next part no-reply
2017-07-07  0:06   ` Fam Zheng
2017-07-10 16:25 ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c5efa0c6-92a1-76f6-c1ba-34b36ef93cbd@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=famz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).