[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 04/14] aio: make aio_context_acquire()/aio_context_release
From: |
Kevin Wolf |
Subject: |
Re: [PATCH v2 04/14] aio: make aio_context_acquire()/aio_context_release() a no-op |
Date: |
Wed, 20 Dec 2023 10:32:21 +0100 |
Am 19.12.2023 um 22:23 hat Stefan Hajnoczi geschrieben:
> The following hack makes the test pass but there are larger safety
> issues that I'll need to look at on Wednesday:
I see, you're taking the same approach as in the SCSI layer: Don't make
things thread-safe, but just always access them from the same thread.
In theory this should be okay, but I'm almost sure that at least
nbd_drained_poll() must then run in the same AioContext, too.
> diff --git a/nbd/server.c b/nbd/server.c
> index 895cf0a752..cf4b7d5c6d 100644
> --- a/nbd/server.c
> +++ b/nbd/server.c
> @@ -1617,7 +1617,7 @@ static void nbd_drained_begin(void *opaque)
> }
> }
>
> -static void nbd_drained_end(void *opaque)
> +static void nbd_resume_clients(void *opaque)
> {
> NBDExport *exp = opaque;
> NBDClient *client;
> @@ -1628,6 +1628,15 @@ static void nbd_drained_end(void *opaque)
> }
> }
>
> +static void nbd_drained_end(void *opaque)
> +{
> + NBDExport *exp = opaque;
> +
> + /* TODO how to make sure exp doesn't go away? */
blk_exp_ref()?
> + /* TODO what if AioContext changes before this runs? */
> + aio_bh_schedule_oneshot(nbd_export_aio_context(exp),
> nbd_resume_clients, exp);
We could increase client->nb_requests if we change it to be accessed
atomically. Then nbd_drained_poll() will make any AioContext change wait
for the BH.
Or maybe aio_wait_bh_oneshot() would already solve both problems?
> +}
> +
Kevin
- [PATCH v2 02/14] scsi: assert that callbacks run in the correct AioContext, (continued)
- [PATCH v2 02/14] scsi: assert that callbacks run in the correct AioContext, Stefan Hajnoczi, 2023/12/05
- [PATCH v2 01/14] virtio-scsi: replace AioContext lock with tmf_bh_lock, Stefan Hajnoczi, 2023/12/05
- [PATCH v2 07/14] block: remove bdrv_co_lock(), Stefan Hajnoczi, 2023/12/05
- [PATCH v2 03/14] tests: remove aio_context_acquire() tests, Stefan Hajnoczi, 2023/12/05
- [PATCH v2 04/14] aio: make aio_context_acquire()/aio_context_release() a no-op, Stefan Hajnoczi, 2023/12/05
- Re: [PATCH v2 04/14] aio: make aio_context_acquire()/aio_context_release() a no-op, Stefan Hajnoczi, 2023/12/20
[PATCH v2 05/14] graph-lock: remove AioContext locking, Stefan Hajnoczi, 2023/12/05
[PATCH v2 08/14] scsi: remove AioContext locking, Stefan Hajnoczi, 2023/12/05
[PATCH v2 06/14] block: remove AioContext locking, Stefan Hajnoczi, 2023/12/05
[PATCH v2 10/14] aio: remove aio_context_acquire()/aio_context_release() API, Stefan Hajnoczi, 2023/12/05