[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [PATCH v7 13/24] virtio-scsi: Catch BDS-BB removal/inse
From: |
Max Reitz |
Subject: |
Re: [Qemu-block] [PATCH v7 13/24] virtio-scsi: Catch BDS-BB removal/insertion |
Date: |
Wed, 25 Nov 2015 17:08:11 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
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 set
>> up, respectively, virtio-scsi's op blockers.
>>
>> Signed-off-by: Max Reitz <address@hidden>
>
>> @@ -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 == sd) {
>> + break;
>> + }
>> + }
>> + if (insert_notifier) {
>> + notifier_remove(&insert_notifier->n);
>> + QTAILQ_REMOVE(&s->insert_notifiers, insert_notifier, next);
>> + g_free(insert_notifier);
>> + }
>
> 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 about.
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 == 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);
>> }
>
> Kevin
>
signature.asc
Description: OpenPGP digital signature
- [Qemu-block] [PATCH v7 11/24] block: Add BB-BDS remove/insert notifiers, (continued)
- [Qemu-block] [PATCH v7 11/24] block: Add BB-BDS remove/insert notifiers, Max Reitz, 2015/11/09
- [Qemu-block] [PATCH v7 12/24] virtio-blk: Functions for op blocker management, Max Reitz, 2015/11/09
- Re: [Qemu-block] [PATCH v7 12/24] virtio-blk: Functions for op blocker management, Kevin Wolf, 2015/11/25
- Re: [Qemu-block] [PATCH v7 12/24] virtio-blk: Functions for op blocker management, Max Reitz, 2015/11/25
- Re: [Qemu-block] [PATCH v7 12/24] virtio-blk: Functions for op blocker management, Kevin Wolf, 2015/11/25
- Re: [Qemu-block] [PATCH v7 12/24] virtio-blk: Functions for op blocker management, Max Reitz, 2015/11/25
- Re: [Qemu-block] [PATCH v7 12/24] virtio-blk: Functions for op blocker management, Stefan Hajnoczi, 2015/11/26
- Re: [Qemu-block] [PATCH v7 12/24] virtio-blk: Functions for op blocker management, Kevin Wolf, 2015/11/26
[Qemu-block] [PATCH v7 13/24] virtio-scsi: Catch BDS-BB removal/insertion, Max Reitz, 2015/11/09
[Qemu-block] [PATCH v7 14/24] nbd: Switch from close to eject notifier, Max Reitz, 2015/11/09
[Qemu-block] [PATCH v7 15/24] block: Remove BDS close notifier, Max Reitz, 2015/11/09
[Qemu-block] [PATCH v7 16/24] block: Use blk_remove_bs() in blk_delete(), Max Reitz, 2015/11/09
[Qemu-block] [PATCH v7 17/24] blockdev: Use blk_remove_bs() in do_drive_del(), Max Reitz, 2015/11/09
[Qemu-block] [PATCH v7 18/24] block: Make bdrv_close() static, Max Reitz, 2015/11/09
[Qemu-block] [PATCH v7 19/24] block: Add list of all BlockDriverStates, Max Reitz, 2015/11/09