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 > --- > 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 > 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.