mirror of
https://github.com/qemu/qemu.git
synced 2024-11-28 14:24:02 +08:00
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2 iQEtBAABCAAXBQJY9imYEBxmYW16QHJlZGhhdC5jb20ACgkQyjViTGqRccYulQf/ aMygBnFxgH/YJ9TkoSlXmss1M+nyjXsckJ4GD5hecSmDefEDvlbhzMANe4b/Rcma Q6ibxvgnxUEKGSsQx71UzDo64vLPZxsyLkPjbp03ojkiq+1I8rVdBKJmsH8W3RPv cFL8FmfGJh+PjhrPXZ50fwcQclCLzXkeP4Nlxi0PgyvJAzzpNFRP+DxLgFqOfJCf rB8ziO8XXdSbaLO3e5GwWqJiLvEZ9l91Gt+S5MW4yB7zjjjd/ODrFcslExL7fLEX skXjCBIGUNlRVhYKLdRoK8Q+zQhn+72wq1HTd5RRvJp7qXocqm8xNIiIBaUwobhd LeT97Cmr8gOGIwr5Q4HNVw== =6F+u -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/famz/tags/block-pull-request' into staging # gpg: Signature made Tue 18 Apr 2017 15:58:32 BST # gpg: using RSA key 0xCA35624C6A9171C6 # gpg: Good signature from "Fam Zheng <famz@redhat.com>" # gpg: WARNING: This key is not certified with sufficiently trusted signatures! # gpg: It is not certain that the signature belongs to the owner. # Primary key fingerprint: 5003 7CB7 9706 0F76 F021 AD56 CA35 624C 6A91 71C6 * remotes/famz/tags/block-pull-request: block: Drain BH in bdrv_drained_begin block: Walk bs->children carefully in bdrv_drain_recurse Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
d1263f8f18
23
block/io.c
23
block/io.c
@ -158,7 +158,7 @@ bool bdrv_requests_pending(BlockDriverState *bs)
|
||||
|
||||
static bool bdrv_drain_recurse(BlockDriverState *bs)
|
||||
{
|
||||
BdrvChild *child;
|
||||
BdrvChild *child, *tmp;
|
||||
bool waited;
|
||||
|
||||
waited = BDRV_POLL_WHILE(bs, atomic_read(&bs->in_flight) > 0);
|
||||
@ -167,8 +167,25 @@ static bool bdrv_drain_recurse(BlockDriverState *bs)
|
||||
bs->drv->bdrv_drain(bs);
|
||||
}
|
||||
|
||||
QLIST_FOREACH(child, &bs->children, next) {
|
||||
waited |= bdrv_drain_recurse(child->bs);
|
||||
QLIST_FOREACH_SAFE(child, &bs->children, next, tmp) {
|
||||
BlockDriverState *bs = child->bs;
|
||||
bool in_main_loop =
|
||||
qemu_get_current_aio_context() == qemu_get_aio_context();
|
||||
assert(bs->refcnt > 0);
|
||||
if (in_main_loop) {
|
||||
/* In case the recursive bdrv_drain_recurse processes a
|
||||
* block_job_defer_to_main_loop BH and modifies the graph,
|
||||
* let's hold a reference to bs until we are done.
|
||||
*
|
||||
* IOThread doesn't have such a BH, and it is not safe to call
|
||||
* bdrv_unref without BQL, so skip doing it there.
|
||||
*/
|
||||
bdrv_ref(bs);
|
||||
}
|
||||
waited |= bdrv_drain_recurse(bs);
|
||||
if (in_main_loop) {
|
||||
bdrv_unref(bs);
|
||||
}
|
||||
}
|
||||
|
||||
return waited;
|
||||
|
@ -381,12 +381,13 @@ void bdrv_drain_all(void);
|
||||
|
||||
#define BDRV_POLL_WHILE(bs, cond) ({ \
|
||||
bool waited_ = false; \
|
||||
bool busy_ = true; \
|
||||
BlockDriverState *bs_ = (bs); \
|
||||
AioContext *ctx_ = bdrv_get_aio_context(bs_); \
|
||||
if (aio_context_in_iothread(ctx_)) { \
|
||||
while ((cond)) { \
|
||||
aio_poll(ctx_, true); \
|
||||
waited_ = true; \
|
||||
while ((cond) || busy_) { \
|
||||
busy_ = aio_poll(ctx_, (cond)); \
|
||||
waited_ |= !!(cond) | busy_; \
|
||||
} \
|
||||
} else { \
|
||||
assert(qemu_get_current_aio_context() == \
|
||||
@ -398,11 +399,16 @@ void bdrv_drain_all(void);
|
||||
*/ \
|
||||
assert(!bs_->wakeup); \
|
||||
bs_->wakeup = true; \
|
||||
while ((cond)) { \
|
||||
aio_context_release(ctx_); \
|
||||
aio_poll(qemu_get_aio_context(), true); \
|
||||
aio_context_acquire(ctx_); \
|
||||
waited_ = true; \
|
||||
while (busy_) { \
|
||||
if ((cond)) { \
|
||||
waited_ = busy_ = true; \
|
||||
aio_context_release(ctx_); \
|
||||
aio_poll(qemu_get_aio_context(), true); \
|
||||
aio_context_acquire(ctx_); \
|
||||
} else { \
|
||||
busy_ = aio_poll(ctx_, false); \
|
||||
waited_ |= busy_; \
|
||||
} \
|
||||
} \
|
||||
bs_->wakeup = false; \
|
||||
} \
|
||||
|
Loading…
Reference in New Issue
Block a user