All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: mreitz@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org,
	qemu-block@nongnu.org, qemu-stable@nongnu.org
Subject: Re: [PATCH 1/3] block: Simplify qmp_block_resize() error paths
Date: Tue, 8 Dec 2020 18:26:15 +0100	[thread overview]
Message-ID: <20201208172615.GB24068@merkur.fritz.box> (raw)
In-Reply-To: <68405fb1-59db-f9ee-852b-52a77cc2a2ce@virtuozzo.com>

Am 08.12.2020 um 15:15 hat Vladimir Sementsov-Ogievskiy geschrieben:
> 03.12.2020 20:23, Kevin Wolf wrote:
> > The only thing that happens after the 'out:' label is blk_unref(blk).
> > However, blk = NULL in all of the error cases, so instead of jumping to
> > 'out:', we can just return directly.
> > 
> > Cc: qemu-stable@nongnu.org
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
> >   blockdev.c | 7 +++----
> >   1 file changed, 3 insertions(+), 4 deletions(-)
> > 
> > diff --git a/blockdev.c b/blockdev.c
> > index fe6fb5dc1d..229d2cce1b 100644
> > --- a/blockdev.c
> > +++ b/blockdev.c
> > @@ -2468,17 +2468,17 @@ void coroutine_fn qmp_block_resize(bool has_device, const char *device,
> >       if (size < 0) {
> >           error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "size", "a >0 size");
> > -        goto out;
> > +        return;
> >       }
> >       if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_RESIZE, NULL)) {
> >           error_setg(errp, QERR_DEVICE_IN_USE, device);
> > -        goto out;
> > +        return;
> >       }
> >       blk = blk_new_with_bs(bs, BLK_PERM_RESIZE, BLK_PERM_ALL, errp);
> >       if (!blk) {
> > -        goto out;
> > +        return;
> >       }
> >       bdrv_drained_begin(bs);
> > @@ -2487,7 +2487,6 @@ void coroutine_fn qmp_block_resize(bool has_device, const char *device,
> >       bdrv_co_leave(bs, old_ctx);
> >       bdrv_drained_end(bs);
> > -out:
> >       bdrv_co_lock(bs);
> >       blk_unref(blk);
> >       bdrv_co_unlock(bs);
> > 
> 
> Initialization of blk to NULL becomes redundant with this patch, so
> may be dropped too.

Good catch, I'll change this while applying.

Kevin



  reply	other threads:[~2020-12-08 17:34 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-03 17:23 [PATCH 0/3] block: Fix block_resize deadlock with iothreads Kevin Wolf
2020-12-03 17:23 ` [PATCH 1/3] block: Simplify qmp_block_resize() error paths Kevin Wolf
2020-12-08 14:15   ` Vladimir Sementsov-Ogievskiy
2020-12-08 17:26     ` Kevin Wolf [this message]
2020-12-03 17:23 ` [PATCH 2/3] block: Fix locking in qmp_block_resize() Kevin Wolf
2020-12-08 14:46   ` Vladimir Sementsov-Ogievskiy
2020-12-08 16:30     ` Kevin Wolf
2020-12-03 17:23 ` [PATCH 3/3] block: Fix deadlock in bdrv_co_yield_to_drain() Kevin Wolf
2020-12-08 15:33   ` Vladimir Sementsov-Ogievskiy
2020-12-08 17:37     ` 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=20201208172615.GB24068@merkur.fritz.box \
    --to=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=vsementsov@virtuozzo.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 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.