[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v10 09/21] jobs: use job locks also in the unit tests
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
Re: [PATCH v10 09/21] jobs: use job locks also in the unit tests |
Date: |
Wed, 27 Jul 2022 17:29:11 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 |
On 7/25/22 10:38, Emanuele Giuseppe Esposito wrote:
Add missing job synchronization in the unit tests, with
explicit locks.
We are deliberately using _locked functions wrapped by a guard
instead of a normal call because the normal call will be removed
in future, as the only usage is limited to the tests.
In other words, if a function like job_pause() is/will be only used
in tests to avoid:
WITH_JOB_LOCK_GUARD(){
job_pause_locked();
}
then it is not worth keeping job_pause(), and just use the guard.
Note: at this stage, job_{lock/unlock} and job lock guard macros
are *nop*.
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
actually, patch is modified enough to drop r-b.
---
tests/unit/test-bdrv-drain.c | 76 +++++++++++++-------
tests/unit/test-block-iothread.c | 8 ++-
tests/unit/test-blockjob-txn.c | 24 ++++---
tests/unit/test-blockjob.c | 116 +++++++++++++++++++------------
4 files changed, 141 insertions(+), 83 deletions(-)
[..]
@@ -459,36 +477,44 @@ static void test_complete_in_standby(void)
bjob = mk_job(blk, "job", &test_yielding_driver, true,
JOB_MANUAL_FINALIZE | JOB_MANUAL_DISMISS);
job = &bjob->job;
- assert(job->status == JOB_STATUS_CREATED);
+ /* Job did not start, so status is safe to read*/
comment is not needed now, let's drop it.
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
--
Best regards,
Vladimir
- Re: [PATCH v10 04/21] aio-wait.h: introduce AIO_WAIT_WHILE_UNLOCKED, (continued)
- [PATCH v10 03/21] job.c: API functions not used outside should be static, Emanuele Giuseppe Esposito, 2022/07/25
- [PATCH v10 01/21] job.c: make job_mutex and job_lock/unlock() public, Emanuele Giuseppe Esposito, 2022/07/25
- [PATCH v10 06/21] job: move and update comments from blockjob.c, Emanuele Giuseppe Esposito, 2022/07/25
- [PATCH v10 11/21] jobs: group together API calls under the same job lock, Emanuele Giuseppe Esposito, 2022/07/25
- [PATCH v10 07/21] blockjob: introduce block_job _locked() APIs, Emanuele Giuseppe Esposito, 2022/07/25
- [PATCH v10 08/21] jobs: add job lock in find_* functions, Emanuele Giuseppe Esposito, 2022/07/25
- [PATCH v10 09/21] jobs: use job locks also in the unit tests, Emanuele Giuseppe Esposito, 2022/07/25
- Re: [PATCH v10 09/21] jobs: use job locks also in the unit tests,
Vladimir Sementsov-Ogievskiy <=
- [PATCH v10 10/21] block/mirror.c: use of job helpers in drivers to avoid TOC/TOU, Emanuele Giuseppe Esposito, 2022/07/25
- [PATCH v10 16/21] blockjob: rename notifier callbacks as _locked, Emanuele Giuseppe Esposito, 2022/07/25
- [PATCH v10 13/21] job: detect change of aiocontext within job coroutine, Emanuele Giuseppe Esposito, 2022/07/25
- [PATCH v10 12/21] commit and mirror: create new nodes using bdrv_get_aio_context, and not the job aiocontext, Emanuele Giuseppe Esposito, 2022/07/25
- [PATCH v10 05/21] job.c: add job_lock/unlock while keeping job.h intact, Emanuele Giuseppe Esposito, 2022/07/25
- [PATCH v10 15/21] blockjob.h: categorize fields in struct BlockJob, Emanuele Giuseppe Esposito, 2022/07/25
- [PATCH v10 18/21] job.c: enable job lock/unlock and remove Aiocontext locks, Emanuele Giuseppe Esposito, 2022/07/25