qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH 13/22] block/export: Move refcount from NBDExport to Bloc


From: Max Reitz
Subject: Re: [RFC PATCH 13/22] block/export: Move refcount from NBDExport to BlockExport
Date: Mon, 17 Aug 2020 16:49:26 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

On 13.08.20 18:29, Kevin Wolf wrote:
> Having a refcount makes sense for all types of block exports. It is also
> a prerequisite for keeping a list of all exports at the BlockExport
> level.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  include/block/export.h | 10 ++++++
>  include/block/nbd.h    |  2 --
>  block/export/export.c  | 14 ++++++++
>  blockdev-nbd.c         |  2 +-
>  nbd/server.c           | 72 +++++++++++++++++++-----------------------
>  5 files changed, 58 insertions(+), 42 deletions(-)

[...]

> diff --git a/blockdev-nbd.c b/blockdev-nbd.c
> index 8dd127af52..a8b7b785e7 100644
> --- a/blockdev-nbd.c
> +++ b/blockdev-nbd.c
> @@ -232,7 +232,7 @@ BlockExport *nbd_export_create(BlockExportOptions 
> *exp_args, Error **errp)
>      /* The list of named exports has a strong reference to this export now 
> and
>       * our only way of accessing it is through nbd_export_find(), so we can 
> drop
>       * the strong reference that is @exp. */
> -    nbd_export_put(exp);
> +    blk_exp_unref((BlockExport*) exp);

:/

Less so because of the asterisk, but more so because of “another
instance of a cast because we can’t access a BlockExport’s fields.

>   out:
>      aio_context_release(aio_context);
> diff --git a/nbd/server.c b/nbd/server.c
> index 4c594e6558..2bf30bb731 100644
> --- a/nbd/server.c
> +++ b/nbd/server.c

[...]

> @@ -1537,7 +1536,8 @@ NBDExport *nbd_export_new(BlockDriverState *bs,
>  
>      exp = g_new0(NBDExport, 1);
>      exp->common = (BlockExport) {
> -        .drv = &blk_exp_nbd,
> +        .drv        = &blk_exp_nbd,
> +        .refcount   = 1,
>      };

This makes me wish...  Ah, for patch 16, I see. :)

Reviewed-by: Max Reitz <mreitz@redhat.com>

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]