From: John Snow <jsnow@redhat.com>
To: Peng Liang <liangpeng10@huawei.com>,
qemu-block@nongnu.org, kwolf@redhat.com
Cc: qemu-devel@nongnu.org, xiexiangyou@huawei.com,
zhang.zhanghailiang@huawei.com
Subject: Re: [PATCH] block/mirror: fix core when using iothreads
Date: Wed, 23 Sep 2020 10:50:48 -0400 [thread overview]
Message-ID: <11c14e57-e285-68c1-33cd-37f2121d302b@redhat.com> (raw)
In-Reply-To: <20200826131910.1879079-1-liangpeng10@huawei.com>
On 8/26/20 9:19 AM, Peng Liang wrote:
> We found an issue when doing block-commit with iothreads, which tries to
> dereference a NULL pointer.
>
I'm clearing out my patch backlog. I am a bit out of the loop on block
issues at the moment, did this issue get addressed in a later patch that
I am not seeing, or does it still need attention?
--js
> <main thread> |<IO thread>
> |
> mirror_start_job |
> 1. bdrv_ref(mirror_top_bs); |
> bdrv_drained_begin(bs); |
> bdrv_append(mirror_top_bs, |
> bs, &local_err); |
> bdrv_drained_end(bs); |
> |
> 2. s = block_job_create(...); |
> |bdrv_mirror_top_pwritev
> | MirrorBDSOpaque *s = bs->opaque;
> | bool copy_to_target;
> | copy_to_target = s->job->ret >= 0 &&
> | s->job->copy_mode ==
> | MIRROR_COPY_MODE_WRITE_BLOCKING;
> | (s->job is not NULL until 3!)
> 3. bs_opaque->job = s; |
>
> Just moving step 2 & 3 before 1 can avoid this.
>
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Peng Liang <liangpeng10@huawei.com>
> ---
> block/mirror.c | 21 ++++++++++-----------
> 1 file changed, 10 insertions(+), 11 deletions(-)
>
> diff --git a/block/mirror.c b/block/mirror.c
> index e8e8844afc40..7c872be71149 100644
> --- a/block/mirror.c
> +++ b/block/mirror.c
> @@ -1600,6 +1600,16 @@ static BlockJob *mirror_start_job(
> mirror_top_bs->supported_zero_flags = BDRV_REQ_WRITE_UNCHANGED |
> BDRV_REQ_NO_FALLBACK;
> bs_opaque = g_new0(MirrorBDSOpaque, 1);
> + /* Make sure that the source is not resized while the job is running */
> + s = block_job_create(job_id, driver, NULL, bs,
> + BLK_PERM_CONSISTENT_READ,
> + BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGED |
> + BLK_PERM_WRITE | BLK_PERM_GRAPH_MOD, speed,
> + creation_flags, cb, opaque, errp);
> + if (!s) {
> + goto fail;
> + }
> + bs_opaque->job = s;
> mirror_top_bs->opaque = bs_opaque;
>
> /* bdrv_append takes ownership of the mirror_top_bs reference, need to keep
> @@ -1612,19 +1622,8 @@ static BlockJob *mirror_start_job(
> if (local_err) {
> bdrv_unref(mirror_top_bs);
> error_propagate(errp, local_err);
> - return NULL;
> - }
> -
> - /* Make sure that the source is not resized while the job is running */
> - s = block_job_create(job_id, driver, NULL, mirror_top_bs,
> - BLK_PERM_CONSISTENT_READ,
> - BLK_PERM_CONSISTENT_READ | BLK_PERM_WRITE_UNCHANGED |
> - BLK_PERM_WRITE | BLK_PERM_GRAPH_MOD, speed,
> - creation_flags, cb, opaque, errp);
> - if (!s) {
> goto fail;
> }
> - bs_opaque->job = s;
>
> /* The block job now has a reference to this node */
> bdrv_unref(mirror_top_bs);
>
next prev parent reply other threads:[~2020-09-23 14:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-26 13:19 [PATCH] block/mirror: fix core when using iothreads Peng Liang
2020-09-23 14:50 ` John Snow [this message]
2021-02-01 12:17 ` Peng Liang
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=11c14e57-e285-68c1-33cd-37f2121d302b@redhat.com \
--to=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=liangpeng10@huawei.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=xiexiangyou@huawei.com \
--cc=zhang.zhanghailiang@huawei.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).