[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH 17/22] block/export: Add blk_exp_close_all(_type)
From: |
Max Reitz |
Subject: |
Re: [RFC PATCH 17/22] block/export: Add blk_exp_close_all(_type) |
Date: |
Tue, 18 Aug 2020 17:00:00 +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:
> 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 | 8 +++++++
> include/block/nbd.h | 2 --
> block.c | 2 +-
> block/export/export.c | 52 ++++++++++++++++++++++++++++++++++++++++++
> blockdev-nbd.c | 2 +-
> nbd/server.c | 34 ++++-----------------------
> qemu-nbd.c | 2 +-
> 7 files changed, 68 insertions(+), 34 deletions(-)
Reviewed-by: Max Reitz <mreitz@redhat.com>
> diff --git a/block/export/export.c b/block/export/export.c
> index 9de108cbc1..675db9a8b9 100644
> --- a/block/export/export.c
> +++ b/block/export/export.c
[...]
> +/* type == BLOCK_EXPORT_TYPE__MAX for all types */
> +void blk_exp_close_all_type(BlockExportType type)
> +{
> + BlockExport *exp, *next;
> +
> + QLIST_FOREACH_SAFE(exp, &block_exports, next, next) {
> + if (type != BLOCK_EXPORT_TYPE__MAX && exp->drv->type != type) {
> + continue;
> + }
> + blk_exp_request_shutdown(exp);
> + }
> +
> + AIO_WAIT_WHILE(NULL, blk_exp_has_type(type));
> +}
> +
> +void blk_exp_close_all(void)
> +{
> + blk_exp_close_all_type(BLOCK_EXPORT_TYPE__MAX);
What’s interesting about this is that I saw from the header file that
you added both this and the type-specific function and wondered “Why not
just pass __MAX to close_all_type() to close all?” And then I thought
“Because that would be stupid as an external interface”.
So I see you had the same thinking.
signature.asc
Description: OpenPGP digital signature
- Re: [RFC PATCH 13/22] block/export: Move refcount from NBDExport to BlockExport, (continued)
- [RFC PATCH 18/22] block/export: Add 'id' option to block-export-add, Kevin Wolf, 2020/08/13
- [RFC PATCH 17/22] block/export: Add blk_exp_close_all(_type), Kevin Wolf, 2020/08/13
- Re: [RFC PATCH 17/22] block/export: Add blk_exp_close_all(_type),
Max Reitz <=
- [RFC PATCH 20/22] block/export: Add block-export-del, Kevin Wolf, 2020/08/13
- [RFC PATCH 22/22] block/export: Add query-block-exports, Kevin Wolf, 2020/08/13
- [RFC PATCH 21/22] block/export: Move blk to BlockExport, Kevin Wolf, 2020/08/13