From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
Max Reitz <mreitz@redhat.com>
Subject: [Qemu-devel] [PATCH v2 5/9] block: Add @poll to bdrv_parent_drained_end_single()
Date: Wed, 19 Jun 2019 17:25:59 +0200 [thread overview]
Message-ID: <20190619152603.5937-6-mreitz@redhat.com> (raw)
In-Reply-To: <20190619152603.5937-1-mreitz@redhat.com>
This function has two callers; one wants it to poll, the other does not.
To implement this parameter, we also need a new BdrvChildRole method,
namely .drained_end_unquiesce(). This function differs from
.drained_end() in that it should poll and is thus allowed to modify the
block graph.
Note that currently every BDS child's .drained_end() implementation is
simply broken in exactly that regard; the current implementation is
actually fit for .drained_end_unquiesce(). However, at this point we
cannot implement .drained_end() correctly, so a later patch in this
series will address that issue.
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
include/block/block.h | 5 ++++-
include/block/block_int.h | 14 ++++++++++++++
block.c | 2 +-
block/io.c | 10 +++++++---
4 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/include/block/block.h b/include/block/block.h
index 3c084e8222..d98237f0f1 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -620,8 +620,11 @@ void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll);
* bdrv_parent_drained_end_single:
*
* End a quiesced section for the parent of @c.
+ *
+ * If @poll is true, poll until the parent is unquiesced. This may
+ * lead to changes in the block graph.
*/
-void bdrv_parent_drained_end_single(BdrvChild *c);
+void bdrv_parent_drained_end_single(BdrvChild *c, bool poll);
/**
* bdrv_parent_drained_end:
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 7f62907932..fce9a9e7ee 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -670,6 +670,20 @@ struct BdrvChildRole {
void (*drained_begin)(BdrvChild *child);
void (*drained_end)(BdrvChild *child);
+ /*
+ * Parents that require polling to actually become unquiesced
+ * should implement this function in addition to .drained_end().
+ * In it, the parent should end the drain and aio_poll() until it
+ * is no longer quiesced.
+ *
+ * Thus, in contrast to .drained_end(), this function is allowed
+ * to change the graph.
+ *
+ * (This pointer may be NULL, in which case .drained_end() is
+ * called instead.)
+ */
+ void (*drained_end_unquiesce)(BdrvChild *child);
+
/*
* Returns whether the parent has pending requests for the child. This
* callback is polled after .drained_begin() has been called until all
diff --git a/block.c b/block.c
index f7d7d8ccef..31b85df0f0 100644
--- a/block.c
+++ b/block.c
@@ -2252,7 +2252,7 @@ static void bdrv_replace_child_noperm(BdrvChild *child,
child->role->detach(child);
}
while (child->parent_quiesce_counter) {
- bdrv_parent_drained_end_single(child);
+ bdrv_parent_drained_end_single(child, true);
}
QLIST_REMOVE(child, next_parent);
} else {
diff --git a/block/io.c b/block/io.c
index 426ad5b4a1..5f30baa8e5 100644
--- a/block/io.c
+++ b/block/io.c
@@ -55,12 +55,16 @@ void bdrv_parent_drained_begin(BlockDriverState *bs, BdrvChild *ignore,
}
}
-void bdrv_parent_drained_end_single(BdrvChild *c)
+void bdrv_parent_drained_end_single(BdrvChild *c, bool poll)
{
assert(c->parent_quiesce_counter > 0);
c->parent_quiesce_counter--;
if (c->role->drained_end) {
- c->role->drained_end(c);
+ if (poll && c->role->drained_end_unquiesce) {
+ c->role->drained_end_unquiesce(c);
+ } else {
+ c->role->drained_end(c);
+ }
}
}
@@ -73,7 +77,7 @@ void bdrv_parent_drained_end(BlockDriverState *bs, BdrvChild *ignore,
if (c == ignore || (ignore_bds_parents && c->role->parent_is_bds)) {
continue;
}
- bdrv_parent_drained_end_single(c);
+ bdrv_parent_drained_end_single(c, false);
}
}
--
2.21.0
next prev parent reply other threads:[~2019-06-19 15:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-19 15:25 [Qemu-devel] [PATCH v2 0/9] block: Delay poll when ending drained sections Max Reitz
2019-06-19 15:25 ` [Qemu-devel] [PATCH v2 1/9] block: Introduce BdrvChild.parent_quiesce_counter Max Reitz
2019-06-19 15:25 ` [Qemu-devel] [PATCH v2 2/9] block: Add @data_objs to bdrv_drain_invoke() Max Reitz
2019-06-19 15:25 ` [Qemu-devel] [PATCH v2 3/9] block: Add bdrv_poll_drain_data_objs() Max Reitz
2019-06-19 15:25 ` [Qemu-devel] [PATCH v2 4/9] block: Move polling out of bdrv_drain_invoke() Max Reitz
2019-06-19 15:25 ` Max Reitz [this message]
2019-06-19 15:26 ` [Qemu-devel] [PATCH v2 6/9] block: Add bdrv_drained_end_no_poll() Max Reitz
2019-06-19 15:26 ` [Qemu-devel] [PATCH v2 7/9] block: Fix BDS children's .drained_end() Max Reitz
2019-06-19 15:26 ` [Qemu-devel] [PATCH v2 8/9] iotests: Add @has_quit to vm.shutdown() Max Reitz
2019-06-19 15:26 ` [Qemu-devel] [PATCH v2 9/9] iotests: Test commit with a filter on the chain Max Reitz
2019-07-15 13:24 ` [Qemu-devel] [PATCH v2 0/9] block: Delay poll when ending drained sections Max Reitz
2019-07-16 14:40 ` Kevin Wolf
2019-07-16 16:24 ` Max Reitz
2019-07-16 16:37 ` Kevin Wolf
2019-07-17 13:20 ` Max Reitz
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=20190619152603.5937-6-mreitz@redhat.com \
--to=mreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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).