[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 16/29] block/export: Allocate BlockExport in blk_exp_add()
From: |
Max Reitz |
Subject: |
Re: [PATCH 16/29] block/export: Allocate BlockExport in blk_exp_add() |
Date: |
Wed, 16 Sep 2020 12:56:44 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 |
On 07.09.20 20:19, Kevin Wolf wrote:
> Instead of letting the driver allocate and return the BlockExport
> object, allocate it already in blk_exp_add() and pass it. This allows us
> to initialise the generic part before calling into the driver so that
> the driver can just use these values instead of having to parse the
> options a second time.
>
> For symmetry, move freeing the BlockExport to blk_exp_unref().
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> Reviewed-by: Max Reitz <mreitz@redhat.com>
> ---
> include/block/export.h | 8 +++++++-
> include/block/nbd.h | 11 ++++++-----
> block/export/export.c | 18 +++++++++++++++++-
> blockdev-nbd.c | 26 ++++++++++++++------------
> nbd/server.c | 30 +++++++++++++-----------------
> 5 files changed, 57 insertions(+), 36 deletions(-)
[...]
> diff --git a/block/export/export.c b/block/export/export.c
> index 8635318ef1..03ff155f97 100644
> --- a/block/export/export.c
> +++ b/block/export/export.c
> @@ -39,6 +39,8 @@ static const BlockExportDriver
> *blk_exp_find_driver(BlockExportType type)
> BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp)
> {
> const BlockExportDriver *drv;
> + BlockExport *exp;
> + int ret;
>
> drv = blk_exp_find_driver(export->type);
> if (!drv) {
> @@ -46,7 +48,20 @@ BlockExport *blk_exp_add(BlockExportOptions *export, Error
> **errp)
> return NULL;
> }
>
> - return drv->create(export, errp);
> + assert(drv->instance_size >= sizeof(BlockExport));
> + exp = g_malloc0(drv->instance_size);
> + *exp = (BlockExport) {
> + .drv = &blk_exp_nbd,
Only noticed now when trying to base my FUSE stuff on this series:
s/blk_exp_nbd/drv/.
(I’d like to say “obviously”, but, well. Evidently not obvious enough
for me.)
Max
signature.asc
Description: OpenPGP digital signature
- Re: [PATCH 07/29] block/export: Remove magic from block-export-add, (continued)
- [PATCH 09/29] nbd: Add writethrough to block-export-add, Kevin Wolf, 2020/09/07
- [PATCH 10/29] nbd: Remove NBDExport.close callback, Kevin Wolf, 2020/09/07
- [PATCH 11/29] qemu-nbd: Use blk_exp_add() to create the export, Kevin Wolf, 2020/09/07
- [PATCH 12/29] nbd/server: Simplify export shutdown, Kevin Wolf, 2020/09/07
- [PATCH 13/29] block/export: Move refcount from NBDExport to BlockExport, Kevin Wolf, 2020/09/07
- [PATCH 14/29] block/export: Move AioContext from NBDExport to BlockExport, Kevin Wolf, 2020/09/07
- [PATCH 16/29] block/export: Allocate BlockExport in blk_exp_add(), Kevin Wolf, 2020/09/07
- Re: [PATCH 16/29] block/export: Allocate BlockExport in blk_exp_add(),
Max Reitz <=
- [PATCH 15/29] block/export: Add node-name to BlockExportOptions, Kevin Wolf, 2020/09/07
- [PATCH 17/29] block/export: Add blk_exp_close_all(_type), Kevin Wolf, 2020/09/07
- [PATCH 19/29] block/export: Move strong user reference to block_exports, Kevin Wolf, 2020/09/07
- [PATCH 20/29] block/export: Add block-export-del, Kevin Wolf, 2020/09/07
- [PATCH 18/29] block/export: Add 'id' option to block-export-add, Kevin Wolf, 2020/09/07