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 <[email protected]> > --- > 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 <[email protected]>
(The effort of special-casing this to delete the export immediately if
we already run in the main thread doesn’t look worth it.)
signature.asc
Description: OpenPGP digital signature
