From: Max Reitz <mreitz@redhat.com>
To: Sergio Lopez <slp@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
qemu-block@nongnu.org
Subject: Re: [PATCH v4 4/5] blockdev: honor bdrv_try_set_aio_context() context requirements
Date: Wed, 27 Nov 2019 18:10:29 +0100 [thread overview]
Message-ID: <7742b8ea-1e9e-7acc-6af2-3155b8d11af2@redhat.com> (raw)
In-Reply-To: <20191121135759.101655-5-slp@redhat.com>
[-- Attachment #1.1: Type: text/plain, Size: 2616 bytes --]
On 21.11.19 14:57, Sergio Lopez wrote:
> bdrv_try_set_aio_context() requires that the old context is held, and
> the new context is not held. Fix all the occurrences where it's not
> done this way.
>
> Suggested-by: Max Reitz <mreitz@redhat.com>
> Signed-off-by: Sergio Lopez <slp@redhat.com>
> ---
> blockdev.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++--------
> 1 file changed, 58 insertions(+), 9 deletions(-)
I wonder whether we even need to set the target’s context, because I
suppose it should be done automatically when it is attached to the
backup job with bdrv_attach_child() in bdrv_backup_top_append(). *shrug*
> diff --git a/blockdev.c b/blockdev.c
> index 152a0f7454..b0647d8d33 100644
> --- a/blockdev.c
> +++ b/blockdev.c
[...]
> @@ -1868,6 +1880,20 @@ static void drive_backup_prepare(BlkActionState *common, Error **errp)
> goto out;
> }
>
> + /* Honor bdrv_try_set_aio_context() context acquisition requirements. */
> + old_context = bdrv_get_aio_context(target_bs);
> + aio_context_release(aio_context);
> + aio_context_acquire(old_context);
> +
> + ret = bdrv_try_set_aio_context(target_bs, aio_context, errp);
> + if (ret < 0) {
> + aio_context_release(old_context);
> + return;
> + }
> +
> + aio_context_release(old_context);
> + aio_context_acquire(aio_context);
Would it work to put the error block after these two calls so it can
just goto out again? (Which would help if someone were to e.g.
introduce a new resource that is to be freed behind the out label.)
> if (set_backing_hd) {
> bdrv_set_backing_hd(target_bs, source, &local_err);
> if (local_err) {
[...]
> @@ -4001,14 +4046,18 @@ void qmp_blockdev_mirror(bool has_job_id, const char *job_id,
>
> zero_target = (sync == MIRROR_SYNC_MODE_FULL);
>
> + /* Honor bdrv_try_set_aio_context() context acquisition requirements. */
> + old_context = bdrv_get_aio_context(target_bs);
> aio_context = bdrv_get_aio_context(bs);
> - aio_context_acquire(aio_context);
> + aio_context_acquire(old_context);
>
> ret = bdrv_try_set_aio_context(target_bs, aio_context, errp);
> if (ret < 0) {
> goto out;
> }
>
> + aio_context_acquire(aio_context);
> +
old_context is never released here.
Max
> blockdev_mirror_common(has_job_id ? job_id : NULL, bs, target_bs,
> has_replaces, replaces, sync, backing_mode,
> zero_target, has_speed, speed,
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-11-27 17:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-21 13:57 [PATCH v4 0/5] blockdev: avoid acquiring AioContext lock twice at do_drive_backup and do_blockdev_backup Sergio Lopez
2019-11-21 13:57 ` [PATCH v4 1/5] blockdev: fix coding style issues in drive_backup_prepare Sergio Lopez
2019-11-27 15:53 ` Max Reitz
2019-11-21 13:57 ` [PATCH v4 2/5] blockdev: unify qmp_drive_backup and drive-backup transaction paths Sergio Lopez
2019-11-27 16:37 ` Max Reitz
2019-11-21 13:57 ` [PATCH v4 3/5] blockdev: unify qmp_blockdev_backup and blockdev-backup " Sergio Lopez
2019-11-27 16:49 ` Max Reitz
2019-11-21 13:57 ` [PATCH v4 4/5] blockdev: honor bdrv_try_set_aio_context() context requirements Sergio Lopez
2019-11-27 17:10 ` Max Reitz [this message]
2019-11-21 13:57 ` [PATCH v4 5/5] iotests: fix 141 after qmp_drive_backup with transactions Sergio Lopez
2019-11-27 16:19 ` Max Reitz
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=7742b8ea-1e9e-7acc-6af2-3155b8d11af2@redhat.com \
--to=mreitz@redhat.com \
--cc=armbru@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=slp@redhat.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).