From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aP9Gg-0004xW-Nh for qemu-devel@nongnu.org; Fri, 29 Jan 2016 08:39:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aP9Gf-0006Ak-Dv for qemu-devel@nongnu.org; Fri, 29 Jan 2016 08:39:18 -0500 References: <1453917600-2663-1-git-send-email-mreitz@redhat.com> <1453917600-2663-7-git-send-email-mreitz@redhat.com> <20160128032634.GI7877@ad.usersys.redhat.com> From: Max Reitz Message-ID: <56AB6B7C.5030000@redhat.com> Date: Fri, 29 Jan 2016 14:39:08 +0100 MIME-Version: 1.0 In-Reply-To: <20160128032634.GI7877@ad.usersys.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="gQRhMDj0XE5vODM0JwXl4OkVsa3TOTQla" Subject: Re: [Qemu-devel] [PATCH v8 06/16] nbd: Switch from close to eject notifier List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, John Snow , qemu-devel@nongnu.org, Paolo Bonzini This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --gQRhMDj0XE5vODM0JwXl4OkVsa3TOTQla Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 28.01.2016 04:26, Fam Zheng wrote: > 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 >> --- >> 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, Err= or **errp) >> } >> } >> =20 >> -/* >> - * 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 =3D >> - QTAILQ_HEAD_INITIALIZER(close_notifiers); >> - >> -static void nbd_close_notifier(Notifier *n, void *data) >> -{ >> - NBDCloseNotifier *cn =3D 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 w= ritable, >> Error **errp) >> { >> BlockBackend *blk; >> NBDExport *exp; >> - NBDCloseNotifier *n; >> =20 >> if (server_fd =3D=3D -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, >> =20 >> nbd_export_set_name(exp, device); >> =20 >> - n =3D g_new0(NBDCloseNotifier, 1); >> - n->n.notify =3D nbd_close_notifier; >> - n->exp =3D 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 expor= t now and >> + * our only way of accessing it is through nbd_export_find(), so = we can drop >> + * the strong reference that is @exp. */ >=20 > 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, Yes, the reference returned by nbd_export_new(), which is then stored in @exp. This is a strong reference, so once @exp goes out of scope, the reference counter has to be decremented. Max > Reviewed-by: Fam Zheng --gQRhMDj0XE5vODM0JwXl4OkVsa3TOTQla Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWq2t8AAoJEDuxQgLoOKytdKsIAJbVemlPn+7MMWGVyfdCJlsV vI5YIiZh9FLwuhDVZ0nDmMMu3Jjq2D0TdbcBUEiOFbb3EViGww+f1KrG7uhYGHH5 fFzlIJ8lioHC1NdtME8jyrKBN8akvupWf3W9ouV22Dq3HIqyIPo4C5S1YzkqIQh+ voCqY3Xx/SFWhljAECxq1qGFNUqsy1O8AM+duhVp6+J9c0We5HYhclFUYNUIalbS OFZCDakNoi+c7a6dOOOi+3XkmKt3VblXvRKCyoSz+vFKDjR6ZzkbNoY6bKtRc47a WXhDQReaCS547395rZRn8CyzvFNkEBLHk+KSalr+9na9TxEFQTkw9/9PTSXn6IY= =otp+ -----END PGP SIGNATURE----- --gQRhMDj0XE5vODM0JwXl4OkVsa3TOTQla--