[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 1/8] virtio_queue_aio_attach_host_notifier: remove AioContext
From: |
Emanuele Giuseppe Esposito |
Subject: |
Re: [PATCH 1/8] virtio_queue_aio_attach_host_notifier: remove AioContext lock |
Date: |
Fri, 8 Jul 2022 11:01:37 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 |
Am 05/07/2022 um 16:11 schrieb Stefan Hajnoczi:
> On Thu, Jun 09, 2022 at 10:37:20AM -0400, Emanuele Giuseppe Esposito wrote:
>> @@ -146,7 +147,6 @@ int virtio_scsi_dataplane_start(VirtIODevice *vdev)
>>
>> s->dataplane_starting = false;
>> s->dataplane_started = true;
>> - aio_context_release(s->ctx);
>> return 0;
>
> This looks risky because s->dataplane_started is accessed by IO code and
> there is a race condition here. Maybe you can refactor the code along
> the lines of virtio-blk to avoid the race.
>
Uhmm could you explain why is virtio-blk also safe here?
And what is currently protecting dataplane_started (in both blk and
scsi, as I don't see any other AioContext lock taken)?
Because I see that for example virtio_blk_req_complete is IO_CODE, so it
could theoretically read dataplane_started while it is being changed in
dataplane_stop? Even though I guess it doesn't because we disable and
clean the host notifier before modifying it?
But if so, I don't get what is the difference with scsi code, and why we
need to protect only that instance with the aiocontext lock?
Thank you,
Emanuele