qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: den@openvz.org, hreitz@redhat.com, qemu-devel@nongnu.org,
	qemu-block@nongnu.org
Subject: Re: [PATCH] block: bdrv_set_backing_hd(): use drained section
Date: Thu, 27 Jan 2022 15:14:14 +0100	[thread overview]
Message-ID: <YfKotrIcGEbOKkaO@redhat.com> (raw)
In-Reply-To: <20220124173741.2984056-1-vsementsov@virtuozzo.com>

Am 24.01.2022 um 18:37 hat Vladimir Sementsov-Ogievskiy geschrieben:
> Graph modifications should be done in drained section. stream_prepare()
> handler of block stream job call bdrv_set_backing_hd() without using
> drained section and it's theoretically possible that some IO request
> will interleave with graph modification and will use outdated pointers
> to removed block nodes.
> 
> Some other callers use bdrv_set_backing_hd() not caring about drained
> sections too. So it seems good to make a drained section exactly in
> bdrv_set_backing_hd().
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

Thanks, applied to the block branch.

> Hi all!
> 
> We faced the following bug in our Rhel7-based downstream:
> read request crashes because backing bs is NULL unexpectedly (honestly,
> it crashes inside bdrv_is_allocated(), which is called during read and
> it's a downstream-only code, but that doesn't make real sense).
> 
> In gdb I also see block-stream job in state
> "refcnt = 0, status = JOB_STATUS_NULL", but it's still in jobs list.
> 
> So, I assume that backing file was disappeared exactly as final step of
> block-stream job. And the problem is that this step should be done in
> drained section, but seems that it isn't.
> 
> If we have a drained section, we'd wait for finish of read request
> before removing the backing node.
> 
> I don't have a reproducer. I spent some time to write a test, but there
> are problems that makes hard to use blkdebug's break-points: we have
> drained section at block-stream start, and we do have drained section at
> block-stream finish: bdrv_cor_filter_drop() called from stream_prepare()
> does drained section (unlike bdrv_set_backing_hd()).

Maybe a unit test would be easier to write for this kind of thing than
an iotest?

> So, the fix is intuitive. I think, it's correct)
> 
> Note also, that alternative would be to make a drained section in
> stream_prepare() and don't touch bdrv_set_backing_hd() function. But it
> seems good to make a public graph-modification function more safe.

Yes, makes sense to me.

Kevin



      parent reply	other threads:[~2022-01-27 14:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-24 17:37 [PATCH] block: bdrv_set_backing_hd(): use drained section Vladimir Sementsov-Ogievskiy
2022-01-25  9:24 ` Paolo Bonzini
2022-01-25 10:12   ` Vladimir Sementsov-Ogievskiy
2022-01-27 14:13     ` Kevin Wolf
2022-01-28 14:12       ` Emanuele Giuseppe Esposito
2022-02-01 11:00         ` Vladimir Sementsov-Ogievskiy
2022-01-27 14:14 ` Kevin Wolf [this message]

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=YfKotrIcGEbOKkaO@redhat.com \
    --to=kwolf@redhat.com \
    --cc=den@openvz.org \
    --cc=hreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --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 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).