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: qemu-block@nongnu.org, s.reiter@proxmox.com,
	qemu-devel@nongnu.org, dietmar@proxmox.com, stefanha@redhat.com,
	mreitz@redhat.com, t.lamprecht@proxmox.com
Subject: Re: [PATCH for-5.0 v3 2/3] block: Increase BB.in_flight for coroutine and sync interfaces
Date: Tue, 7 Apr 2020 18:27:59 +0200	[thread overview]
Message-ID: <20200407162759.GH7695@linux.fritz.box> (raw)
In-Reply-To: <399cb66a-528e-b92b-546f-a712608bcc14@virtuozzo.com>

Am 07.04.2020 um 16:56 hat Vladimir Sementsov-Ogievskiy geschrieben:
> 07.04.2020 17:42, Kevin Wolf wrote:
> > Am 07.04.2020 um 16:22 hat Vladimir Sementsov-Ogievskiy geschrieben:
> > > 07.04.2020 15:12, Kevin Wolf wrote:
> > > > External callers of blk_co_*() and of the synchronous blk_*() functions
> > > > don't currently increase the BlockBackend.in_flight counter, but calls
> > > > from blk_aio_*() do, so there is an inconsistency whether the counter
> > > > has been increased or not.
> > > > 
> > > > This patch moves the actual operations to static functions that can
> > > > later know they will always be called with in_flight increased exactly
> > > > once, even for external callers using the blk_co_*() coroutine
> > > > interfaces.
> > > > 
> > > > If the public blk_co_*() interface is unused, remove it.
> > > > 
> > > > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > > 
> > > Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> > > 
> > > side question:
> > > 
> > > Should we inc/dec in blk_make_zero, blk_truncate?
> > 
> > I don't think it's necessary. They call into their bdrv_* counterpart
> > immediately, so the node-level counter should be enough.
> > 
> 
> bdrv_make_zero is not one request, it does block_status/pwrite_zeroes
> in a loop. So drained section may occur during bdrv_make_zero.
> Possibly, nothing bad in it?

It would potentially be a problem if it were called in coroutine
context. But it's a synchronous function that must be called in the main
thread (and also only used in qemu-img), so I don't see how drain could
happen while it runs.

If we did want to make it safe for use in coroutine context, it would be
by using bdrv_inc/dec_in_flight() in bdrv_make_zero().

> blk_truncate may do coroutine_enter before incrementing node-level
> counter, which may only schedule it..

This is bdrv_truncate(), not blk_truncate(). If you address it in
blk_truncate(), you miss the direct callers of bdrv_truncate().

But you're right that it could potentially be a problem. Not sure if it
really is, but maybe better safe than sorry, so if you want to send a
patch, go ahead.

Kevin



  reply	other threads:[~2020-04-07 16:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-07 12:12 [PATCH for-5.0 v3 0/3] block: Fix blk->in_flight during blk_wait_while_drained() Kevin Wolf
2020-04-07 12:12 ` [PATCH for-5.0 v3 1/3] block-backend: Reorder flush/pdiscard function definitions Kevin Wolf
2020-04-07 12:12 ` [PATCH for-5.0 v3 2/3] block: Increase BB.in_flight for coroutine and sync interfaces Kevin Wolf
2020-04-07 12:54   ` Max Reitz
2020-04-07 14:22   ` Vladimir Sementsov-Ogievskiy
2020-04-07 14:42     ` Kevin Wolf
2020-04-07 14:56       ` Vladimir Sementsov-Ogievskiy
2020-04-07 16:27         ` Kevin Wolf [this message]
2020-04-07 17:36           ` Vladimir Sementsov-Ogievskiy
2020-04-07 12:12 ` [PATCH for-5.0 v3 3/3] block: Fix blk->in_flight during blk_wait_while_drained() 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=20200407162759.GH7695@linux.fritz.box \
    --to=kwolf@redhat.com \
    --cc=dietmar@proxmox.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=s.reiter@proxmox.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 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).