job: replace AioContext lock with job_mutex
Status from this message: Thanks, applied to the block branch.
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v12 Latest21 patches 5 repliesApplied
- v1121 patches 18 repliesSuperseded
- v1021 patches 49 repliesSuperseded
Earlier versions · 9
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v9 | 21 patches | 31 replies | Superseded | |
| v8 | 20 patches | 38 replies | Superseded | |
| v7 | 18 patches | 29 replies | Superseded | |
| v6 | 18 patches | 16 replies | Superseded | |
| v5 | 20 patches | 28 replies | Superseded | |
| v4 | 19 patches | 1 reply | Superseded | |
| v3 | 16 patches | 21 replies | Superseded | |
| v2 RFC | 14 patches | 19 replies | Superseded | |
| v1 RFC | 15 patches | 12 replies | Superseded |
Changes in v12 from the cover letter
* Apply Vladimir feedbacks (minor comment adjustments)
* Add aiocontext release + acquire in block/replication.c
Patches in v12 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/21 | job.c: make job_mutex and job_lock/unlock() publicinclude/ job.c | +47 | 0 replies | |
| 2/21 | job.h: categorize fields in struct Jobinclude/ | +36 | 0 replies | |
| 3/21 | job.c: API functions not used outside should be staticinclude/ job.c | +19 | 0 replies | |
| 4/21 | aio-wait.h: introduce AIO_WAIT_WHILE_UNLOCKEDinclude/ | +13 | 0 replies | |
| 5/21 | job.c: add job_lock/unlock while keeping job.h intactinclude/ job.c | +561 | 0 replies | |
| 6/21 | job: move and update comments from blockjob.cblockjob.c job.c | +16 | 0 replies | |
| 7/21 | blockjob: introduce block_job _locked() APIsblockjob.c include/ | +60 | 0 replies | |
| 8/21 | jobs: add job lock in find_* functionsblockdev.c job-qmp.c | +86 | 0 replies | |
| 9/21 | jobs: use job locks also in the unit teststests/ tests/ tests/ +1 more | +140 | 0 replies | |
| 10/21 | block/mirror.c: use of job helpers in driversblock/ | +9 | 0 replies | |
| 11/21 | jobs: group together API calls under the same job lockblock.c blockdev.c blockjob.c +3 more | +63 | 0 replies | |
| 12/21 | job: detect change of aiocontext within job coroutinejob.c | +17 | 0 replies | |
| 13/21 | jobs: protect job.aio_context with BQL and job_mutexblock/ blockjob.c include/ +1 more | +35 | 1 reply | |
| 14/21 | blockjob.h: categorize fields in struct BlockJobinclude/ | +26 | 0 replies | |
| 15/21 | blockjob: rename notifier callbacks as _lockedblockjob.c | +15 | 0 replies | |
| 16/21 | blockjob: protect iostatus field in BlockJob structblock/ blockjob.c | +8 | 1 reply | |
| 17/21 | job.h: categorize JobDriver callbacks that need the AioContext lockinclude/ | +25 | 0 replies | |
| 18/21 | job.c: enable job lock/unlock and remove Aiocontext locksblock/ blockdev.c include/ +6 more | +72 | 1 reply | |
| 19/21 | block_job_query: remove atomic readblockjob.c | +1 | 0 replies | |
| 20/21 | blockjob: remove unused functionsblockjob.c include/ | +14 | 0 replies | |
| 21/21 | job: remove unused functionsinclude/ job.c tests/ | +46 | 1 reply |
Reviews trailers per patch
All 21 patches have a Reviewed-by or Acked-by.
| Patch | Stefan Hajnoczi | Vladimir Sementsov-Ogievskiy | Kevin Wolf |
|---|---|---|---|
| 1/21 | R-b | R-b | |
| 2/21 | R-b | R-b | R-b |
| 3/21 | R-b | R-b | R-b |
| 4/21 | R-b | R-b | |
| 5/21 | R-b | R-b | R-b |
| 6/21 | R-b | R-b | |
| 7/21 | R-b | R-b | R-b |
| 8/21 | R-b | R-b | R-b |
| 9/21 | R-b | R-b | |
| 10/21 | R-b | ||
| 11/21 | R-b | ||
| 12/21 | R-b | R-b | |
| 13/21 | R-b | ||
| 14/21 | R-b | ||
| 15/21 | R-b | R-b | R-b |
| 16/21 | R-b | R-b | |
| 17/21 | R-b | ||
| 18/21 | R-b | ||
| 19/21 | R-b | R-b | R-b |
| 20/21 | R-b | R-b | R-b |
| 21/21 | R-b | R-b | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.
Cover letter [PATCH v12 00/21] job: replace AioContext lock with job_mutex
In this series, we want to remove the AioContext lock and instead use the already existent job_mutex to protect the job structures and list. This is part of the work to get rid of AioContext lock usage in favour of smaller granularity locks.
In order to simplify reviewer's job, job lock/unlock functions and macros are added as empty prototypes (nop) in patch 1. They are converted to use the actual job mutex only in the last patch. In this way we can freely create locking sections without worrying about deadlocks with the aiocontext lock.
Patch 2 defines what fields in the job structure need protection. Patches 3-6 are in preparation to the job locks, moving functions from global to static and introducing helpers.
Patch 7-9 introduce the (nop) job lock into the job API and its users, and patches 10-13 categorize respectively locked and unlocked functions in the job API.
Patches 14-17 take care of protecting job->aio_context, and finally patch 18 makes the prototypes in patch 1 use the job_mutex and removes all aiocontext lock at the same time.
Tested this series by running unit tests, qemu-iotests and qtests (x86_64).
---
v12:
* Apply Vladimir feedbacks (minor comment adjustments)
* Add aiocontext release + acquire in block/replication.c
v11:
* Apply Kevin and Vladimir feedbacks
* job_set_aio_context: check coroutine is quiescent if job_is_completed
* Rephrased commit message in patch 13
v10:
* protect job->status in unit tests
* patch 11: change commit description and avoid using lock guard for a single function call
* move patch 19 before patch 15
v9:
* merge patch 6 and 7 to 5.
* additional "taken with job lock/unlock" added and propagated in callers
* protect iostatus field of BlockJobs
* move all blockjob patches torward the end of the serie
v8:
* reorganize patch ordering according with Vladimir proposal
* minor nitpicks
v7:
* s/temporary/temporarly
* double identical locking comment to the same function
* patch 2: add "Protected by AioContext lock" to better categorize fields in job.h
* use same comment style in all function headers ("Just like {funct}, but called between job_lock and job_unlock")
v6:
* patch 4 and 6 squashed with patch 19 (enable job lock and reduce/remove AioContext lock)
* patch 19: job_unref_locked read the aiocontext inside the job lock.
v5:
* just restructured patches a little bit better, as there were functions used before they were defined.
* rebased on kwolf/block branch and API split serie
v4:
* move "protected by job_mutex" from patch 2 to 15, where the job_mutex is actually added.
* s/aio_co_enter/aio_co_schedule in job.c, and adjust tests accordingly.
* remove job_get_aio_context, add job_set_aio_context. Use "fake rwlock" to protect job->aiocontext.
* get rid of useless getters method, namely:
job_get_status
job_get_pause_count
job_get_paused
job_get_busy
They are all used only by tests, and such getter is pretty useless. Replace with job_lock(); assert(); job_unlock();
* use job lock macros instead of job lock/unlock in unit tests.
* convert also blockjob functions to have _locked
* put the job_lock/unlock patches before the _locked ones
* replace aio_co_enter in job.c and detect change of context
v3:
* add "_locked" suffix to the functions called under job_mutex lock
* rename _job_lock in real_job_lock
* job_mutex is now public, and drivers like monitor use it directly
* introduce and protect job_get_aio_context
* remove mirror-specific APIs and just use WITH_JOB_GUARD
* more extensive use of WITH_JOB_GUARD and JOB_LOCK_GUARD
RFC v2:
* use JOB_LOCK_GUARD and WITH_JOB_LOCK_GUARD
* mu(u)ltiple typos in commit messages
* job API split patches are sent separately in another series
* use of empty job_{lock/unlock} and JOB_LOCK_GUARD/WITH_JOB_LOCK_GUARD to avoid deadlocks and simplify the reviewer job
* move patch 11 (block_job_query: remove atomic read) as last
Emanuele Giuseppe Esposito (20):
job.c: make job_mutex and job_lock/unlock() public job.h: categorize fields in struct Job
job.c: API functions not used outside should be static aio-wait.h: introduce AIO_WAIT_WHILE_UNLOCKED
job.c: add job_lock/unlock while keeping job.h intact
job: move and update comments from blockjob.c
blockjob: introduce block_job _locked() APIs
jobs: add job lock in find_* functions
jobs: use job locks also in the unit tests block/mirror.c: use of job helpers in drivers
jobs: group together API calls under the same job lock
jobs: protect job.aio_context with BQL and job_mutex blockjob.h: categorize fields in struct BlockJob
blockjob: rename notifier callbacks as _locked
blockjob: protect iostatus field in BlockJob struct job.h: categorize JobDriver callbacks that need the AioContext lock job.c: enable job lock/unlock and remove Aiocontext locks
block_job_query: remove atomic read
blockjob: remove unused functions
job: remove unused functions
Paolo Bonzini (1):
job: detect change of aiocontext within job coroutine
block.c | 17 +- block/mirror.c | 20 +- block/replication.c | 3 + blockdev.c | 129 +++--- blockjob.c | 132 +++--- include/block/aio-wait.h | 17 +- include/block/blockjob.h | 59 ++- include/qemu/job.h | 304 ++++++++++---- job-qmp.c | 92 ++--- job.c | 672 +++++++++++++++++++------------ monitor/qmp-cmds.c | 7 +- qemu-img.c | 17 +- tests/unit/test-bdrv-drain.c | 80 ++-- tests/unit/test-block-iothread.c | 8 +- tests/unit/test-blockjob-txn.c | 24 +- tests/unit/test-blockjob.c | 136 ++++--- 16 files changed, 1074 insertions(+), 643 deletions(-)
Signature · 1 line
2.31.1