From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: qemu-block@nongnu.org, Hanna Reitz <hreitz@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>, John Snow <jsnow@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
Wen Congyang <wencongyang2@huawei.com>,
Xie Changlong <xiechanglong.d@gmail.com>,
Markus Armbruster <armbru@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>, Fam Zheng <fam@euphon.net>,
qemu-devel@nongnu.org
Subject: Re: [PATCH v6 06/18] jobs: protect jobs with job_lock/unlock
Date: Tue, 7 Jun 2022 15:17:55 +0200 [thread overview]
Message-ID: <e1e6a510-1b3d-e126-b9d8-a8e1bbca637f@redhat.com> (raw)
In-Reply-To: <Ypo5lHwqTc2FtyNh@redhat.com>
Am 03/06/2022 um 18:40 schrieb Kevin Wolf:
> Am 14.03.2022 um 14:36 hat Emanuele Giuseppe Esposito geschrieben:
>> Introduce the job locking mechanism through the whole job API,
>> following the comments in job.h and requirements of job-monitor
>> (like the functions in job-qmp.c, assume lock is held) and
>> job-driver (like in mirror.c and all other JobDriver, lock is not held).
>>
>> Use the _locked helpers introduced before to differentiate
>> between functions called with and without job_mutex.
>> This only applies to function that are called under both
>> cases, all the others will be renamed later.
>>
>> job_{lock/unlock} is independent from real_job_{lock/unlock}.
>>
>> Note: at this stage, job_{lock/unlock} and job lock guard macros
>> are *nop*.
>>
>> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
>> ---
>> block.c | 18 ++++---
>> block/replication.c | 8 ++-
>> blockdev.c | 17 ++++--
>> blockjob.c | 56 +++++++++++++-------
>> job-qmp.c | 2 +
>> job.c | 125 +++++++++++++++++++++++++++++++-------------
>> monitor/qmp-cmds.c | 6 ++-
>> qemu-img.c | 41 +++++++++------
>> 8 files changed, 187 insertions(+), 86 deletions(-)
>>
>> diff --git a/block.c b/block.c
>> index 718e4cae8b..5dc46fde11 100644
>> --- a/block.c
>> +++ b/block.c
>> @@ -4978,7 +4978,9 @@ static void bdrv_close(BlockDriverState *bs)
>>
>> void bdrv_close_all(void)
>> {
>> - assert(job_next(NULL) == NULL);
>> + WITH_JOB_LOCK_GUARD() {
>> + assert(job_next(NULL) == NULL);
>> + }
>> GLOBAL_STATE_CODE();
>
> This series seems really hard to review patch by patch, in this case
> because I would have to know whether you intended job_next() to be
> called with the lock held or not. Nothing in job.h indicates either way
> at this point in the series.
Well if it's under lock it means all its calls will be under lock. If
some cases will be under lock and some other not, I use the _locked
version, as described in the commit description.
>
> Patch 11 answers this by actually renaming it job_next_locked(), but
> always having to refer to the final state after the whole series is
> applied is really not how things should work. We're splitting the work
> into individual patches so that the state after each single patch makes
> sense on its own. Otherwise the whole series could as well be a single
> patch. :-(
The various function and ordering has changed pretty much in each of the
6 version I sent, because it is very difficult to understand what comes
first and what can go afterwards.
Anyways, I see what you mean but I would not move patch 11 before this
one, because otherwise we would have _locked functions used without
having even a fake lock around, and the next reviewer would complain. In
fact, I think I put it afterwards because someone initially suggested so.
Ideally we want both patches together, but then it will be a total mess
to read, so I would leave it as it is.
In addition, I don't think it would hurt to have "normal" (ie without
_locked) functions wrapped by a nop macro.
Emanuele
>
> So I'd argue that patch 11 should probably come before this one.
>
> Anyway, I guess I'll try to make my way to the end of the series quickly
> and then somehow try to verify whatever the state is then.
>
> Kevin
>
next prev parent reply other threads:[~2022-06-07 13:22 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-14 13:36 [PATCH v6 00/18] job: replace AioContext lock with job_mutex Emanuele Giuseppe Esposito
2022-03-14 13:36 ` [PATCH v6 01/18] job.c: make job_mutex and job_lock/unlock() public Emanuele Giuseppe Esposito
2022-03-14 13:36 ` [PATCH v6 02/18] job.h: categorize fields in struct Job Emanuele Giuseppe Esposito
2022-06-03 16:00 ` Kevin Wolf
2022-06-07 13:20 ` Emanuele Giuseppe Esposito
2022-06-07 15:41 ` Paolo Bonzini
2022-06-08 7:28 ` Emanuele Giuseppe Esposito
2022-03-14 13:36 ` [PATCH v6 03/18] job.c: API functions not used outside should be static Emanuele Giuseppe Esposito
2022-06-09 9:16 ` Stefan Hajnoczi
2022-03-14 13:36 ` [PATCH v6 04/18] aio-wait.h: introduce AIO_WAIT_WHILE_UNLOCKED Emanuele Giuseppe Esposito
2022-03-14 13:36 ` [PATCH v6 05/18] job.h: add _locked duplicates for job API functions called with and without job_mutex Emanuele Giuseppe Esposito
2022-06-03 16:17 ` Kevin Wolf
2022-06-07 13:23 ` Emanuele Giuseppe Esposito
2022-06-09 9:32 ` Stefan Hajnoczi
2022-03-14 13:36 ` [PATCH v6 06/18] jobs: protect jobs with job_lock/unlock Emanuele Giuseppe Esposito
2022-06-03 16:40 ` Kevin Wolf
2022-06-07 13:17 ` Emanuele Giuseppe Esposito [this message]
2022-03-14 13:36 ` [PATCH v6 07/18] jobs: add job lock in find_* functions Emanuele Giuseppe Esposito
2022-03-14 13:36 ` [PATCH v6 08/18] jobs: use job locks also in the unit tests Emanuele Giuseppe Esposito
2022-03-14 13:36 ` [PATCH v6 09/18] block/mirror.c: use of job helpers in drivers to avoid TOC/TOU Emanuele Giuseppe Esposito
2022-03-14 13:36 ` [PATCH v6 10/18] jobs: rename static functions called with job_mutex held Emanuele Giuseppe Esposito
2022-06-09 9:47 ` Stefan Hajnoczi
2022-03-14 13:37 ` [PATCH v6 11/18] job.h: rename job API " Emanuele Giuseppe Esposito
2022-06-09 9:48 ` Stefan Hajnoczi
2022-03-14 13:37 ` [PATCH v6 12/18] block_job: rename block_job " Emanuele Giuseppe Esposito
2022-06-09 9:47 ` Stefan Hajnoczi
2022-03-14 13:37 ` [PATCH v6 13/18] job.h: define unlocked functions Emanuele Giuseppe Esposito
2022-06-09 9:41 ` Stefan Hajnoczi
2022-03-14 13:37 ` [PATCH v6 14/18] commit and mirror: create new nodes using bdrv_get_aio_context, and not the job aiocontext Emanuele Giuseppe Esposito
2022-03-14 13:37 ` [PATCH v6 15/18] job: detect change of aiocontext within job coroutine Emanuele Giuseppe Esposito
2022-06-03 16:59 ` Kevin Wolf
2022-06-07 13:28 ` Emanuele Giuseppe Esposito
2022-03-14 13:37 ` [PATCH v6 16/18] jobs: protect job.aio_context with BQL and job_mutex Emanuele Giuseppe Esposito
2022-03-14 13:37 ` [PATCH v6 17/18] job.c: enable job lock/unlock and remove Aiocontext locks Emanuele Giuseppe Esposito
2022-03-14 13:37 ` [PATCH v6 18/18] block_job_query: remove atomic read Emanuele Giuseppe Esposito
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e1e6a510-1b3d-e126-b9d8-a8e1bbca637f@redhat.com \
--to=eesposit@redhat.com \
--cc=armbru@redhat.com \
--cc=fam@euphon.net \
--cc=hreitz@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=vsementsov@virtuozzo.com \
--cc=wencongyang2@huawei.com \
--cc=xiechanglong.d@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).