qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 17/29] block/export: Add blk_exp_close_all(_type)


From: Max Reitz
Subject: Re: [PATCH 17/29] block/export: Add blk_exp_close_all(_type)
Date: Thu, 10 Sep 2020 15:22:53 +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:
> This adds a function to shut down all block exports, and another one to
> shut down the block exports of a single type. The latter is used for now
> when stopping the NBD server. As soon as we implement support for
> multiple NBD servers, we'll need a per-server list of exports and it
> will be replaced by a function using that.
> 
> As a side effect, the BlockExport layer has a list tracking all existing
> exports now. closed_exports loses its only user and can go away.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  include/block/export.h | 15 ++++++++
>  include/block/nbd.h    |  2 --
>  block.c                |  2 +-
>  block/export/export.c  | 79 ++++++++++++++++++++++++++++++++++++++++--
>  blockdev-nbd.c         |  2 +-
>  nbd/server.c           | 34 +++---------------
>  qemu-nbd.c             |  2 +-
>  7 files changed, 100 insertions(+), 36 deletions(-)

[...]

>  /* Callers must hold exp->ctx lock */
>  void blk_exp_unref(BlockExport *exp)
>  {
>      assert(exp->refcount > 0);
>      if (--exp->refcount == 0) {
> -        exp->drv->delete(exp);
> -        g_free(exp);
> +        /* Touch the block_exports list only in the main thread */
> +        aio_bh_schedule_oneshot(qemu_get_aio_context(), blk_exp_delete_bh,
> +                                exp);

Looks safe.

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

(The effort of special-casing this to delete the export immediately if
we already run in the main thread doesn’t look worth it.)

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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