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 <[email protected]> > --- > 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 <[email protected]>
signature.asc
Description: OpenPGP digital signature
