[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/3] block: add BlockBackend->in_flight counter
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 1/3] block: add BlockBackend->in_flight counter |
Date: |
Fri, 9 Feb 2018 17:28:31 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 |
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.
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.
Paolo
Re: [Qemu-devel] [PATCH 0/3] block: fix blk_aio_*() segfault when blk->root == NULL, Eric Blake, 2018/02/09