From: Paolo Bonzini <pbonzini@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>,
Emanuele Giuseppe Esposito <eesposit@redhat.com>
Cc: Fam Zheng <fam@euphon.net>,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
qemu-block@nongnu.org, qemu-devel@nongnu.org,
Hanna Reitz <hreitz@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
John Snow <jsnow@redhat.com>
Subject: Re: [PATCH 5/6] test-bdrv-drain.c: remove test_detach_by_parent_cb()
Date: Mon, 14 Feb 2022 12:42:55 +0100 [thread overview]
Message-ID: <db25869b-fbf2-f5ca-b2f8-4fe4f3c0a040@redhat.com> (raw)
In-Reply-To: <YgaDBkblIA6wu82p@redhat.com>
On 2/11/22 16:38, Kevin Wolf wrote:
> The callback of an I/O function isn't I/O, though. It is code_after_
> the I/O has completed. If this doesn't work any more, it feels like this
> is a bug.
The issue is that the I/O has *not* completed yet. blk_aio_preadv(...,
cb, opaque) is not equivalent to
ret = blk_co_preadv(...);
cb(ret, opaque);
but rather to
blk_inc_in_flight(blk);
ret = blk_co_preadv(...);
cb(ret, opaque);
blk_dec_in_flight(blk);
Your own commit message (yeah I know we've all been through that :))
explains why, and notes that it is now invalid to drain in a callback:
commit 46aaf2a566e364a62315219255099cbf1c9b990d
Author: Kevin Wolf <kwolf@redhat.com>
Date: Thu Sep 6 17:47:22 2018 +0200
block-backend: Decrease in_flight only after callback
Request callbacks can do pretty much anything, including operations
that will yield from the coroutine (such as draining the backend).
In that case, a decreased in_flight would be visible to other code
and could lead to a drain completing while the callback hasn't
actually completed yet.
Note that reordering these operations forbids calling drain directly
inside an AIO callback.
So the questions are:
1) is the above commit wrong though well-intentioned?
2) is it unexpected that bdrv_replace_child_noperm() drains (thus
becoming invalid from the callback, albeit valid through a bottom half)?
My answer is respectively 1) it's correct, many coroutines do
inc_in_flight before creation and dec_in_flight at the end, we're just
saying that it's _always_ the case for callback-based operations; 2) no,
it's not unexpected and therefore the test is the incorrect one.
Paolo
next prev parent reply other threads:[~2022-02-14 11:46 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-08 15:36 [PATCH 0/6] block: bug fixes in preparation of AioContext removal Emanuele Giuseppe Esposito
2022-02-08 15:36 ` [PATCH 1/6] block/io.c: fix bdrv_child_cb_drained_begin invocations from a coroutine Emanuele Giuseppe Esposito
2022-02-10 14:14 ` Stefan Hajnoczi
2022-02-11 11:54 ` Kevin Wolf
2022-02-14 10:27 ` Emanuele Giuseppe Esposito
2022-02-14 11:57 ` Paolo Bonzini
2022-02-17 15:49 ` Emanuele Giuseppe Esposito
2022-02-14 12:03 ` Kevin Wolf
2022-02-08 15:36 ` [PATCH 2/6] block.c: bdrv_replace_child_noperm: first remove the child, and then call ->detach() Emanuele Giuseppe Esposito
2022-02-10 14:16 ` Stefan Hajnoczi
2022-02-11 12:28 ` Kevin Wolf
2022-02-08 15:36 ` [PATCH 3/6] block.c: bdrv_replace_child_noperm: first call ->attach(), and then add child Emanuele Giuseppe Esposito
2022-02-10 14:16 ` Stefan Hajnoczi
2022-02-11 12:34 ` Kevin Wolf
2022-02-14 10:37 ` Emanuele Giuseppe Esposito
2022-02-08 15:36 ` [PATCH 4/6] test-bdrv-drain.c: adapt test to the coming subtree drains Emanuele Giuseppe Esposito
2022-02-10 14:32 ` Stefan Hajnoczi
2022-02-10 16:02 ` Emanuele Giuseppe Esposito
2022-02-08 15:36 ` [PATCH 5/6] test-bdrv-drain.c: remove test_detach_by_parent_cb() Emanuele Giuseppe Esposito
2022-02-10 14:33 ` Stefan Hajnoczi
2022-02-11 15:38 ` Kevin Wolf
2022-02-14 11:11 ` Emanuele Giuseppe Esposito
2022-02-14 11:42 ` Paolo Bonzini [this message]
2022-02-14 15:28 ` Kevin Wolf
2022-02-14 17:39 ` Paolo Bonzini
2022-02-08 15:36 ` [PATCH 6/6] jobs: ensure sleep in job_sleep_ns is fully performed Emanuele Giuseppe Esposito
2022-02-10 14:43 ` Stefan Hajnoczi
2022-02-10 15:02 ` Vladimir Sementsov-Ogievskiy
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=db25869b-fbf2-f5ca-b2f8-4fe4f3c0a040@redhat.com \
--to=pbonzini@redhat.com \
--cc=eesposit@redhat.com \
--cc=fam@euphon.net \
--cc=hreitz@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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).