[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH v8 06/16] nbd: Switch from close to eject notifi
From: |
Fam Zheng |
Subject: |
Re: [Qemu-block] [PATCH v8 06/16] nbd: Switch from close to eject notifier |
Date: |
Thu, 28 Jan 2016 11:26:34 +0800 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Wed, 01/27 18:59, Max Reitz wrote:
> The NBD code uses the BDS close notifier to determine when a medium is
> ejected. However, now it should use the BB's BDS removal notifier for
> that instead of the BDS's close notifier.
>
> Signed-off-by: Max Reitz <address@hidden>
> ---
> blockdev-nbd.c | 40 +++++-----------------------------------
> nbd/server.c | 13 +++++++++++++
> 2 files changed, 18 insertions(+), 35 deletions(-)
>
> diff --git a/blockdev-nbd.c b/blockdev-nbd.c
> index 4a758ac..9d6a21c 100644
> --- a/blockdev-nbd.c
> +++ b/blockdev-nbd.c
> @@ -45,37 +45,11 @@ void qmp_nbd_server_start(SocketAddress *addr, Error
> **errp)
> }
> }
>
> -/*
> - * Hook into the BlockBackend notifiers to close the export when the
> - * backend is closed.
> - */
> -typedef struct NBDCloseNotifier {
> - Notifier n;
> - NBDExport *exp;
> - QTAILQ_ENTRY(NBDCloseNotifier) next;
> -} NBDCloseNotifier;
> -
> -static QTAILQ_HEAD(, NBDCloseNotifier) close_notifiers =
> - QTAILQ_HEAD_INITIALIZER(close_notifiers);
> -
> -static void nbd_close_notifier(Notifier *n, void *data)
> -{
> - NBDCloseNotifier *cn = DO_UPCAST(NBDCloseNotifier, n, n);
> -
> - notifier_remove(&cn->n);
> - QTAILQ_REMOVE(&close_notifiers, cn, next);
> -
> - nbd_export_close(cn->exp);
> - nbd_export_put(cn->exp);
> - g_free(cn);
> -}
> -
> void qmp_nbd_server_add(const char *device, bool has_writable, bool writable,
> Error **errp)
> {
> BlockBackend *blk;
> NBDExport *exp;
> - NBDCloseNotifier *n;
>
> if (server_fd == -1) {
> error_setg(errp, "NBD server not running");
> @@ -113,19 +87,15 @@ void qmp_nbd_server_add(const char *device, bool
> has_writable, bool writable,
>
> nbd_export_set_name(exp, device);
>
> - n = g_new0(NBDCloseNotifier, 1);
> - n->n.notify = nbd_close_notifier;
> - n->exp = exp;
> - blk_add_close_notifier(blk, &n->n);
> - QTAILQ_INSERT_TAIL(&close_notifiers, n, next);
> + /* The list of named exports has a strong reference to this export now
> and
> + * our only way of accessing it is through nbd_export_find(), so we can
> drop
> + * the strong reference that is @exp. */
Not quite sure about the meaning of "the strong reference that is @exp", I
guess you mean the one reference born in nbd_export_new(), which would match
the code. Other than this,
Reviewed-by: Fam Zheng <address@hidden>
- Re: [Qemu-block] [PATCH v8 01/16] block: Release dirty bitmaps in bdrv_close(), (continued)
- [Qemu-block] [PATCH v8 02/16] iotests: Add test for eject under NBD server, Max Reitz, 2016/01/27
- [Qemu-block] [PATCH v8 03/16] block: Add BB-BDS remove/insert notifiers, Max Reitz, 2016/01/27
- [Qemu-block] [PATCH v8 04/16] virtio-blk: Functions for op blocker management, Max Reitz, 2016/01/27
- [Qemu-block] [PATCH v8 06/16] nbd: Switch from close to eject notifier, Max Reitz, 2016/01/27
- Re: [Qemu-block] [PATCH v8 06/16] nbd: Switch from close to eject notifier,
Fam Zheng <=
- [Qemu-block] [PATCH v8 05/16] virtio-scsi: Catch BDS-BB removal/insertion, Max Reitz, 2016/01/27
- [Qemu-block] [PATCH v8 07/16] block: Remove BDS close notifier, Max Reitz, 2016/01/27
- [Qemu-block] [PATCH v8 08/16] block: Use blk_remove_bs() in blk_delete(), Max Reitz, 2016/01/27
- [Qemu-block] [PATCH v8 11/16] block: Add list of all BlockDriverStates, Max Reitz, 2016/01/27