qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Alberto Garcia <berto@igalia.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
	Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 3/5] block: Simplify bdrv_reopen_abort()
Date: Tue, 14 Aug 2018 12:59:29 +0200	[thread overview]
Message-ID: <20180814105929.GG5025@dhcp-200-186.str.redhat.com> (raw)
In-Reply-To: <w5136vhp83y.fsf@maestria.local.igalia.com>

Am 14.08.2018 um 12:15 hat Alberto Garcia geschrieben:
> On Tue 14 Aug 2018 11:07:42 AM CEST, Kevin Wolf wrote:
> > Am 29.06.2018 um 13:37 hat Alberto Garcia geschrieben:
> >> If a bdrv_reopen_multiple() call fails, then the explicit_options
> >> QDict has to be deleted for every entry in the reopen queue. This must
> >> happen regardless of whether that entry's bdrv_reopen_prepare() call
> >> succeeded or not.
> >> 
> >> This patch simplifies the cleanup code a bit.
> >> 
> >> Signed-off-by: Alberto Garcia <berto@igalia.com>
> >> ---
> >>  block.c | 9 ++++-----
> >>  1 file changed, 4 insertions(+), 5 deletions(-)
> >> 
> >> diff --git a/block.c b/block.c
> >> index 5aaed424b9..48e8f4814c 100644
> >> --- a/block.c
> >> +++ b/block.c
> >> @@ -3060,9 +3060,10 @@ int bdrv_reopen_multiple(AioContext *ctx, BlockReopenQueue *bs_queue, Error **er
> >>  
> >>  cleanup:
> >>      QSIMPLEQ_FOREACH_SAFE(bs_entry, bs_queue, entry, next) {
> >> -        if (ret && bs_entry->prepared) {
> >> -            bdrv_reopen_abort(&bs_entry->state);
> >> -        } else if (ret) {
> >> +        if (ret) {
> >> +            if (bs_entry->prepared) {
> >> +                bdrv_reopen_abort(&bs_entry->state);
> >> +            }
> >>              qobject_unref(bs_entry->state.explicit_options);
> >>          }
> >>          qobject_unref(bs_entry->state.options);
> >> @@ -3351,8 +3352,6 @@ void bdrv_reopen_abort(BDRVReopenState *reopen_state)
> >>          drv->bdrv_reopen_abort(reopen_state);
> >>      }
> >>  
> >> -    qobject_unref(reopen_state->explicit_options);
> >> -
> >>      bdrv_abort_perm_update(reopen_state->bs);
> >>  }
> >
> > I think this is only correct if we make bdrv_reopen_prepare/commit/abort
> > private. At the moment they are public interfaces, so we must have
> > thought that some callers might want to integrate them into other
> > transactions.
> 
> But that's not a problem as long as the new callers unref
> state.explicit_options when bdrv_reopen_prepare() fails. They need to do
> it with state.options anyway.

Actually that makes sense because the code creating the object isn't
even in bdrv_reopen_prepare(), but in bdrv_reopen_queue_child(). So it's
the caller that owns the object and should free them too. I just
confused the two functions.

Kevin

  reply	other threads:[~2018-08-14 10:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-29 11:36 [Qemu-devel] [PATCH 0/5] Some bs->options fixes Alberto Garcia
2018-06-29 11:36 ` [Qemu-devel] [PATCH 1/5] qdict: Make qdict_extract_subqdict() accept dst = NULL Alberto Garcia
2018-06-29 11:37 ` [Qemu-devel] [PATCH 2/5] block: Remove children options from bs->{options, explicit_options} Alberto Garcia
2018-06-29 11:37 ` [Qemu-devel] [PATCH 3/5] block: Simplify bdrv_reopen_abort() Alberto Garcia
2018-08-14  9:07   ` Kevin Wolf
2018-08-14 10:15     ` Alberto Garcia
2018-08-14 10:59       ` Kevin Wolf [this message]
2018-06-29 11:37 ` [Qemu-devel] [PATCH 4/5] block: Update bs->options if bdrv_reopen() succeeds Alberto Garcia
2018-06-29 11:37 ` [Qemu-devel] [PATCH 5/5] block: Simplify append_open_options() Alberto Garcia
2018-08-14  9:17   ` Kevin Wolf
2018-08-14 10:52     ` Alberto Garcia
2018-08-14 11:14       ` Kevin Wolf
2018-08-14 11:48         ` Alberto Garcia
2018-08-14 12:08           ` Kevin Wolf
2018-08-14 13:15             ` Alberto Garcia
2018-08-13 14:36 ` [Qemu-devel] [PATCH 0/5] Some bs->options fixes Alberto Garcia
2018-08-14 14:04 ` Kevin Wolf

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=20180814105929.GG5025@dhcp-200-186.str.redhat.com \
    --to=kwolf@redhat.com \
    --cc=berto@igalia.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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).