[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v5 09/20] jobs: add job lock in find_* functions
From: |
Stefan Hajnoczi |
Subject: |
Re: [PATCH v5 09/20] jobs: add job lock in find_* functions |
Date: |
Thu, 17 Feb 2022 15:00:06 +0000 |
On Tue, Feb 08, 2022 at 09:35:02AM -0500, Emanuele Giuseppe Esposito wrote:
> diff --git a/blockdev.c b/blockdev.c
> index c5fba4d157..08408cd44b 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -3311,7 +3311,10 @@ out:
> aio_context_release(aio_context);
> }
>
> -/* Get a block job using its ID and acquire its AioContext */
> +/*
> + * Get a block job using its ID and acquire its AioContext.
> + * Returns with job_lock held on success.
The caller needs to deal with unlocking anyway, so maybe ask the caller
to acquire the lock too? That would make the function simpler to reason
about.
> @@ -60,6 +65,7 @@ void qmp_job_cancel(const char *id, Error **errp)
> trace_qmp_job_cancel(job);
> job_user_cancel(job, true, errp);
> aio_context_release(aio_context);
> + job_unlock();
> }
Is job_mutex -> AioContext lock ordering correct? I thought the
AioContext must be held before taking the job lock according to "jobs:
remove aiocontext locks since the functions are under BQL"?
signature.asc
Description: PGP signature
- Re: [PATCH v5 04/20] job.c: move inner aiocontext lock in callbacks, (continued)
- [PATCH v5 07/20] job.h: add _locked duplicates for job API functions called with and without job_mutex, Emanuele Giuseppe Esposito, 2022/02/08
- [PATCH v5 17/20] job: detect change of aiocontext within job coroutine, Emanuele Giuseppe Esposito, 2022/02/08
- [PATCH v5 03/20] job.c: API functions not used outside should be static, Emanuele Giuseppe Esposito, 2022/02/08
- [PATCH v5 14/20] block_job: rename block_job functions called with job_mutex held, Emanuele Giuseppe Esposito, 2022/02/08
- [PATCH v5 09/20] jobs: add job lock in find_* functions, Emanuele Giuseppe Esposito, 2022/02/08
- Re: [PATCH v5 09/20] jobs: add job lock in find_* functions,
Stefan Hajnoczi <=
- [PATCH v5 10/20] jobs: use job locks also in the unit tests, Emanuele Giuseppe Esposito, 2022/02/08
- [PATCH v5 16/20] commit and mirror: create new nodes using bdrv_get_aio_context, and not the job aiocontext, Emanuele Giuseppe Esposito, 2022/02/08
- [PATCH v5 13/20] job.h: rename job API functions called with job_mutex held, Emanuele Giuseppe Esposito, 2022/02/08
- [PATCH v5 05/20] aio-wait.h: introduce AIO_WAIT_WHILE_UNLOCKED, Emanuele Giuseppe Esposito, 2022/02/08
- [PATCH v5 08/20] jobs: protect jobs with job_lock/unlock, Emanuele Giuseppe Esposito, 2022/02/08