[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v9 15/21] job.c: enable job lock/unlock and remove Aiocontext
From: |
Emanuele Giuseppe Esposito |
Subject: |
Re: [PATCH v9 15/21] job.c: enable job lock/unlock and remove Aiocontext locks |
Date: |
Tue, 19 Jul 2022 14:51:14 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 |
Am 11/07/2022 um 16:33 schrieb Vladimir Sementsov-Ogievskiy:
> On 7/6/22 23:15, Emanuele Giuseppe Esposito wrote:
>> Change the job_{lock/unlock} and macros to use job_mutex.
>>
>> Now that they are not nop anymore, remove the aiocontext
>> to avoid deadlocks.
>>
>> Therefore:
>> - when possible, remove completely the aiocontext lock/unlock pair
>> - if it is used by some other function too, reduce the locking
>> section as much as possible, leaving the job API outside.
>> - change AIO_WAIT_WHILE in AIO_WAIT_WHILE_UNLOCKED, since we
>> are not using the aiocontext lock anymore
>>
>> There is only one JobDriver callback, ->free() that assumes that
>> the aiocontext lock is held (because it calls bdrv_unref), so for
>> now keep that under aiocontext lock.
>>
>> Also remove real_job_{lock/unlock}, as they are replaced by the
>> public functions.
>>
>> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
>> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
>> ---
>
> [..]
>
>> static int job_finalize_single_locked(Job *job)
>> {
>> int job_ret;
>> + AioContext *ctx = job->aio_context;
>> assert(job_is_completed_locked(job));
>> /* Ensure abort is called for late-transactional failures */
>> job_update_rc_locked(job);
>> + aio_context_acquire(ctx);
>
> so here we acquire aio-context under job_mutex lock? Wouldn't that
> dead-lock?
I'll change it so that job_commit/clean/abort do not take the lock, but
just the aiocontext.
Emanuele
>
>> +
>> if (!job->ret) {
>> job_commit_locked(job);
>> } else {
>
>
>
- Re: [PATCH v9 09/21] jobs: use job locks also in the unit tests, (continued)
- [PATCH v9 14/21] jobs: protect job.aio_context with BQL and job_mutex, Emanuele Giuseppe Esposito, 2022/07/06
- [PATCH v9 15/21] job.c: enable job lock/unlock and remove Aiocontext locks, Emanuele Giuseppe Esposito, 2022/07/06
- [PATCH v9 13/21] job: detect change of aiocontext within job coroutine, Emanuele Giuseppe Esposito, 2022/07/06
- [PATCH v9 12/21] commit and mirror: create new nodes using bdrv_get_aio_context, and not the job aiocontext, Emanuele Giuseppe Esposito, 2022/07/06
- [PATCH v9 03/21] job.c: API functions not used outside should be static, Emanuele Giuseppe Esposito, 2022/07/06
- [PATCH v9 10/21] block/mirror.c: use of job helpers in drivers to avoid TOC/TOU, Emanuele Giuseppe Esposito, 2022/07/06
- [PATCH v9 19/21] blockjob: protect iostatus field in BlockJob struct, Emanuele Giuseppe Esposito, 2022/07/06