From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49773) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1ccI-0002GS-KP for qemu-devel@nongnu.org; Wed, 25 Nov 2015 11:08:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1ccH-00035p-L2 for qemu-devel@nongnu.org; Wed, 25 Nov 2015 11:08:22 -0500 References: <1447108773-6836-1-git-send-email-mreitz@redhat.com> <1447108773-6836-14-git-send-email-mreitz@redhat.com> <20151125160356.GF12581@noname.str.redhat.com> From: Max Reitz Message-ID: <5655DCEB.20404@redhat.com> Date: Wed, 25 Nov 2015 17:08:11 +0100 MIME-Version: 1.0 In-Reply-To: <20151125160356.GF12581@noname.str.redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="6KopdDck27fMoRaMQx9i018dxNsGVE2VE" Subject: Re: [Qemu-devel] [PATCH v7 13/24] virtio-scsi: Catch BDS-BB removal/insertion List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: Alberto Garcia , qemu-block@nongnu.org, John Snow , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi , Paolo Bonzini This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --6KopdDck27fMoRaMQx9i018dxNsGVE2VE Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 25.11.2015 17:03, Kevin Wolf wrote: > Am 09.11.2015 um 23:39 hat Max Reitz geschrieben: >> Make use of the BDS-BB removal and insertion notifiers to remove or se= t >> up, respectively, virtio-scsi's op blockers. >> >> Signed-off-by: Max Reitz >=20 >> @@ -797,6 +830,29 @@ static void virtio_scsi_hotunplug(HotplugHandler = *hotplug_dev, DeviceState *dev, >> if (s->ctx) { >> blk_op_unblock_all(sd->conf.blk, s->blocker); >> } >> + >> + QTAILQ_FOREACH(insert_notifier, &s->insert_notifiers, next) { >> + if (insert_notifier->sd =3D=3D sd) { >> + break; >> + } >> + } >> + if (insert_notifier) { >> + notifier_remove(&insert_notifier->n); >> + QTAILQ_REMOVE(&s->insert_notifiers, insert_notifier, next); >> + g_free(insert_notifier); >> + } >=20 > Why a separate if block instead of just doing that inside the loop? Because I unconsciously try to reduce indentation. Also, because when I wrote the code, to me it was "Find the relevant notifier -- destroy that notifier", and that's how this pattern came abou= t. I personally still like it more the way I did it, but I can very well imagine that I'm the only one who thinks so. Therefore, I wouldn't mind changing it (besides the effort involved to change it). Max >> + QTAILQ_FOREACH(remove_notifier, &s->remove_notifiers, next) { >> + if (remove_notifier->sd =3D=3D sd) { >> + break; >> + } >> + } >> + if (remove_notifier) { >> + notifier_remove(&remove_notifier->n); >> + QTAILQ_REMOVE(&s->remove_notifiers, remove_notifier, next); >> + g_free(remove_notifier); >> + } >> + >> qdev_simple_device_unplug_cb(hotplug_dev, dev, errp); >> } >=20 > Kevin >=20 --6KopdDck27fMoRaMQx9i018dxNsGVE2VE 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 iQEcBAEBCAAGBQJWVdzsAAoJEDuxQgLoOKyt0ZkIAJex7GlMM+t0vas2kC9vLIg+ GG4578Rs7nGI+6cGvN0WM7RJ3aLDqR8Jlw+3eupcU+Eblu5eD7agB60i4GNCJLmf u2ufox2eWFw92VzZni42S6inYWY3zIyigW3gbcSajnGT/kXWS0HL8ppYCui11K3j lgz7hqwgo71EjVGQkpJ7mFzDxOc38np4bQ6l8c2bikGYK10ajvBD4Qlaeg6r1Mnm jCbho+D1zV6QY00GGoQoxoRsoWJlkKy2PK1/X0ZOG5J4tY9YiHzE9GUszi2lLp/C kHeWNoOZEuyFhNyhzlvV3+vicPC/hPpnfWw4OtENDbOHxILsduiG8hWrRVw5Fs8= =nec4 -----END PGP SIGNATURE----- --6KopdDck27fMoRaMQx9i018dxNsGVE2VE--