All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org, hreitz@redhat.com,
	den@openvz.org, alexander.ivanov@virtuozzo.com
Subject: Re: [PATCH v8 1/5] blockdev: refactor transaction to use Transaction API
Date: Wed, 10 May 2023 13:10:54 +0200	[thread overview]
Message-ID: <ZFt7vgF/JTmbwZoK@redhat.com> (raw)
In-Reply-To: <20230421115327.907104-2-vsementsov@yandex-team.ru>

Am 21.04.2023 um 13:53 hat Vladimir Sementsov-Ogievskiy geschrieben:
> We are going to add more block-graph modifying transaction actions,
> and block-graph modifying functions are already based on Transaction
> API.
> 
> Next, we'll need to separately update permissions after several
> graph-modifying actions, and this would be simple with help of
> Transaction API.
> 
> So, now let's just transform what we have into new-style transaction
> actions.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
>  blockdev.c | 317 +++++++++++++++++++++++++++++++----------------------
>  1 file changed, 186 insertions(+), 131 deletions(-)

> diff --git a/blockdev.c b/blockdev.c
> index d7b5c18f0a..293f6a958e 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -1380,10 +1384,9 @@ static void internal_snapshot_abort(BlkActionState *common)
>      aio_context_release(aio_context);
>  }
>  
> -static void internal_snapshot_clean(BlkActionState *common)
> +static void internal_snapshot_clean(void *opaque)
>  {
> -    InternalSnapshotState *state = DO_UPCAST(InternalSnapshotState,
> -                                             common, common);
> +    InternalSnapshotState *state = opaque;
>      AioContext *aio_context;
>  
>      if (!state->bs) {
> @@ -1396,6 +1399,8 @@ static void internal_snapshot_clean(BlkActionState *common)
>      bdrv_drained_end(state->bs);
>  
>      aio_context_release(aio_context);
> +
> +    g_free(state);
>  }

state is leaked if we take the early return a few lines above:

    if (!state->bs) {
        return;
    }

>  /* external snapshot private data */
> @@ -1657,6 +1670,8 @@ static void external_snapshot_clean(BlkActionState *common)
>      bdrv_unref(state->new_bs);
>  
>      aio_context_release(aio_context);
> +
> +    g_free(state);
>  }

Same potential leak of state.

>  typedef struct DriveBackupState {
> @@ -1856,6 +1883,8 @@ static void drive_backup_clean(BlkActionState *common)
>      bdrv_drained_end(state->bs);
>  
>      aio_context_release(aio_context);
> +
> +    g_free(state);
>  }

Here as well.

>  typedef struct BlockdevBackupState {
> @@ -1950,6 +1991,8 @@ static void blockdev_backup_clean(BlkActionState *common)
>      bdrv_drained_end(state->bs);
>  
>      aio_context_release(aio_context);
> +
> +    g_free(state);
>  }

And here.

Other than that, the patch looks good to me.

Kevin



  reply	other threads:[~2023-05-10 11:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-21 11:53 [PATCH v8 0/5] block: refactor blockdev transactions Vladimir Sementsov-Ogievskiy
2023-04-21 11:53 ` [PATCH v8 1/5] blockdev: refactor transaction to use Transaction API Vladimir Sementsov-Ogievskiy
2023-05-10 11:10   ` Kevin Wolf [this message]
2023-04-21 11:53 ` [PATCH v8 2/5] blockdev: transactions: rename some things Vladimir Sementsov-Ogievskiy
2023-05-10 11:16   ` Kevin Wolf
2023-04-21 11:53 ` [PATCH v8 3/5] blockdev: qmp_transaction: refactor loop to classic for Vladimir Sementsov-Ogievskiy
2023-05-10 11:17   ` Kevin Wolf
2023-04-21 11:53 ` [PATCH v8 4/5] blockdev: transaction: refactor handling transaction properties Vladimir Sementsov-Ogievskiy
2023-05-10 11:21   ` Kevin Wolf
2023-04-21 11:53 ` [PATCH v8 5/5] blockdev: qmp_transaction: drop extra generic layer Vladimir Sementsov-Ogievskiy
2023-05-10 11:47   ` Kevin Wolf
2023-05-10 13:37     ` Vladimir Sementsov-Ogievskiy

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=ZFt7vgF/JTmbwZoK@redhat.com \
    --to=kwolf@redhat.com \
    --cc=alexander.ivanov@virtuozzo.com \
    --cc=den@openvz.org \
    --cc=hreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@yandex-team.ru \
    /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.