From: Kevin Wolf <kwolf@redhat.com>
To: Stefan Reiter <s.reiter@proxmox.com>
Cc: vsementsov@virtuozzo.com, t.lamprecht@proxmox.com,
slp@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org,
mreitz@redhat.com, stefanha@redhat.com, jsnow@redhat.com,
dietmar@proxmox.com
Subject: Re: [PATCH for-5.0 v5 1/3] job: take each job's lock individually in job_txn_apply
Date: Tue, 7 Apr 2020 15:26:48 +0200 [thread overview]
Message-ID: <20200407132648.GE7695@linux.fritz.box> (raw)
In-Reply-To: <20200407115651.69472-2-s.reiter@proxmox.com>
Am 07.04.2020 um 13:56 hat Stefan Reiter geschrieben:
> All callers of job_txn_apply hold a single job's lock, but different
> jobs within a transaction can have different contexts, thus we need to
> lock each one individually before applying the callback function.
>
> Similar to job_completed_txn_abort this also requires releasing the
> caller's context before and reacquiring it after to avoid recursive
> locks which might break AIO_WAIT_WHILE in the callback. This is safe, since
> existing code would already have to take this into account, lest
> job_completed_txn_abort might have broken.
>
> This also brings to light a different issue: When a callback function in
> job_txn_apply moves it's job to a different AIO context, callers will
> try to release the wrong lock (now that we re-acquire the lock
> correctly, previously it would just continue with the old lock, leaving
> the job unlocked for the rest of the return path). Fix this by not caching
> the job's context.
>
> This is only necessary for qmp_block_job_finalize, qmp_job_finalize and
> job_exit, since everyone else calls through job_exit.
job_cancel() doesn't go through job_exit(). It calls job_completed()
onyl for jobs that are not started yet, and it sets job->cancelled, so
that job_completed() takes the job_completed_txn_abort() path, which is
not changed by this patch.
I _think_ this is okay, but it shows that the whole job completion
infrastructure is becoming way too complicated. We're late for 5.0, so
let's take this patch for now, but I think we should use the 5.1 release
cycle to clean up this mess a bit.
> One test needed adapting, since it calls job_finalize directly, so it
> manually needs to acquire the correct context.
>
> Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
Kevin
next prev parent reply other threads:[~2020-04-07 13:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-07 11:56 [PATCH for-5.0 v5 0/3] Fix some AIO context locking in jobs Stefan Reiter
2020-04-07 11:56 ` [PATCH for-5.0 v5 1/3] job: take each job's lock individually in job_txn_apply Stefan Reiter
2020-04-07 13:26 ` Kevin Wolf [this message]
2020-04-07 11:56 ` [PATCH for-5.0 v5 2/3] replication: assert we own context before job_cancel_sync Stefan Reiter
2020-04-07 11:56 ` [PATCH for-5.0 v5 3/3] backup: don't acquire aio_context in backup_clean Stefan Reiter
2020-04-07 14:22 ` [PATCH for-5.0 v5 0/3] Fix some AIO context locking in jobs Kevin Wolf
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=20200407132648.GE7695@linux.fritz.box \
--to=kwolf@redhat.com \
--cc=dietmar@proxmox.com \
--cc=jsnow@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=s.reiter@proxmox.com \
--cc=slp@redhat.com \
--cc=stefanha@redhat.com \
--cc=t.lamprecht@proxmox.com \
--cc=vsementsov@virtuozzo.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.