qemu-block
[Top][All Lists]
Advanced

[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
> 


Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]