qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
	Fam Zheng <famz@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Eric Blake <eblake@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 for-2.11] block: Make bdrv_next() keep strong references
Date: Fri, 17 Nov 2017 17:08:36 +0100	[thread overview]
Message-ID: <5effaf53-cd83-b74d-e68b-78faae56ce26@redhat.com> (raw)
In-Reply-To: <20171110172545.32609-1-mreitz@redhat.com>

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

On 2017-11-10 18:25, Max Reitz wrote:
> On one hand, it is a good idea for bdrv_next() to return a strong
> reference because ideally nearly every pointer should be refcounted.
> This fixes intermittent failure of iotest 194.
> 
> On the other, it is absolutely necessary for bdrv_next() itself to keep
> a strong reference to both the BB (in its first phase) and the BDS (at
> least in the second phase) because when called the next time, it will
> dereference those objects to get a link to the next one.  Therefore, it
> needs these objects to stay around until then.  Just storing the pointer
> to the next in the iterator is not really viable because that pointer
> might become invalid as well.
> 
> Both arguments taken together means we should probably just invoke
> bdrv_ref() and blk_ref() in bdrv_next().  This means we have to assert
> that bdrv_next() is always called from the main loop, but that was
> probably necessary already before this patch and judging from the
> callers, it also looks to actually be the case.
> 
> Keeping these strong references means however that callers need to give
> them up if they decide to abort the iteration early.  They can do so
> through the new bdrv_next_cleanup() function.
> 
> Suggested-by: Kevin Wolf <kwolf@redhat.com>
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
> v2: Instead of keeping the strong reference in bdrv_drain_all_*() only,
>     have them for all callers of bdrv_next() [Fam, Kevin]
>     (Completely different patch now, so no git-backport-diff included
>      here)
> ---
>  include/block/block.h |  1 +
>  block.c               |  3 +++
>  block/block-backend.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
>  block/snapshot.c      |  6 ++++++
>  migration/block.c     |  1 +
>  5 files changed, 57 insertions(+), 2 deletions(-)

Due to one supporter and otherwise lack of resistance: Applied to my
block branch (https://github.com/XanClic/qemu/commits/block).

Max


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

      parent reply	other threads:[~2017-11-17 16:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-10 17:25 [Qemu-devel] [PATCH v2 for-2.11] block: Make bdrv_next() keep strong references Max Reitz
2017-11-11  0:08 ` Paolo Bonzini
2017-11-13 16:18   ` Max Reitz
2017-11-13 14:30 ` Stefan Hajnoczi
2017-11-17 16:08 ` Max Reitz [this message]

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=5effaf53-cd83-b74d-e68b-78faae56ce26@redhat.com \
    --to=mreitz@redhat.com \
    --cc=eblake@redhat.com \
    --cc=famz@redhat.com \
    --cc=kwolf@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).