qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-devel@nongnu.org, John Snow <jsnow@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/3] block: add BlockBackend->in_flight counter
Date: Mon, 12 Feb 2018 14:08:25 +0000	[thread overview]
Message-ID: <20180212140825.GF4913@stefanha-x1.localdomain> (raw)
In-Reply-To: <94eef553-a2d6-cfac-9e5a-006ceee74519@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1566 bytes --]

On Fri, Feb 09, 2018 at 06:26:41PM +0100, Paolo Bonzini wrote:
> On 09/02/2018 18:23, Kevin Wolf wrote:
> > Am 09.02.2018 um 17:28 hat Paolo Bonzini geschrieben:
> >> On 08/02/2018 18:18, Stefan Hajnoczi wrote:
> >>> +    BlockDriverState *bs = blk_bs(blk);
> >>> +
> >>> +    if (bs) {
> >>> +        bdrv_drained_begin(bs);
> >>> +    }
> >>> +
> >>> +    /* We may have aio requests like -ENOMEDIUM in flight */
> >>> +    while (atomic_mb_read(&blk->in_flight) > 0) {
> >>> +        aio_poll(blk_get_aio_context(blk), true);
> >>> +    }
> >>> +
> >>> +    if (bs) {
> >>> +        bdrv_drained_end(bs);
> >>
> >> This only works if you are in the default AioContext, otherwise you can
> >> run handlers for one AioContexts in two threads.
> > 
> > Should aio_poll() assert that it's called in the right thread to make
> > sure we obey the rules?
> > 
> >> bdrv_dec_in_flight uses bdrv_wakeup and BDRV_POLL_WHILE to ensure that
> >> this doesn't happen, so there would be more code that you have to copy
> >> into block-backend.c.
> > 
> > Instead of copying, can't we generalise it into a POLL_WHILE(ctx,
> > wakeup, cond) and make BDRV_POLL_WHILE() a wrapper for that?
> 
> Yes, or even move bdrv_wakeup to AioContext would do.  We already have
> block layer-specific fields such as the linux-aio state(*).
> 
> 	(*) though now that linux-aio has been improved to do something
> 	    like epoll, there may be a better reason to place linux-aio
> 	    state in AioContext.

Thanks for the ideas, will fix in v2.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

  reply	other threads:[~2018-02-12 14:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-08 17:18 [Qemu-devel] [PATCH 0/3] block: fix blk_aio_*() segfault when blk->root == NULL Stefan Hajnoczi
2018-02-08 17:18 ` [Qemu-devel] [PATCH 1/3] block: add BlockBackend->in_flight counter Stefan Hajnoczi
2018-02-09 15:20   ` Eric Blake
2018-02-09 16:28   ` Paolo Bonzini
2018-02-09 17:23     ` Kevin Wolf
2018-02-09 17:26       ` Paolo Bonzini
2018-02-12 14:08         ` Stefan Hajnoczi [this message]
2018-02-08 17:18 ` [Qemu-devel] [PATCH 2/3] block: test blk_aio_flush() with blk->root == NULL Stefan Hajnoczi
2018-02-09 15:23   ` Eric Blake
2018-02-12 14:10     ` Stefan Hajnoczi
2018-02-08 17:18 ` [Qemu-devel] [PATCH 3/3] Revert "IDE: Do not flush empty CDROM drives" Stefan Hajnoczi
2018-02-09 15:27   ` Eric Blake
2018-02-09 15:34 ` [Qemu-devel] [PATCH 0/3] block: fix blk_aio_*() segfault when blk->root == NULL Eric Blake

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=20180212140825.GF4913@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).