From: Stefan Hajnoczi <stefanha@redhat.com>
To: Fam Zheng <famz@redhat.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, jcody@redhat.com,
Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>,
pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH RFC 2/9] aio: Add drain begin/end API to AioContext
Date: Thu, 30 Nov 2017 16:07:10 +0000 [thread overview]
Message-ID: <20171130160710.GA17703@stefanha-x1.localdomain> (raw)
In-Reply-To: <20171129144956.11409-3-famz@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2161 bytes --]
On Wed, Nov 29, 2017 at 10:49:49PM +0800, Fam Zheng wrote:
> diff --git a/util/async.c b/util/async.c
> index 4dd9d95a9e..cca0efd263 100644
> --- a/util/async.c
> +++ b/util/async.c
> @@ -402,6 +402,7 @@ AioContext *aio_context_new(Error **errp)
> AioContext *ctx;
>
> ctx = (AioContext *) g_source_new(&aio_source_funcs, sizeof(AioContext));
> + QTAILQ_INIT(&ctx->drain_ops);
> aio_context_setup(ctx);
>
> ret = event_notifier_init(&ctx->notifier, false);
> @@ -506,3 +507,75 @@ void aio_context_release(AioContext *ctx)
> {
> qemu_rec_mutex_unlock(&ctx->lock);
> }
> +
> +/* Called with ctx->lock */
> +void aio_context_drained_begin(AioContext *ctx)
> +{
> + AioDrainOps *ops;
> +
> + /* TODO: When all external fds are handled in the following drain_ops
> + * callbacks, aio_disable_external can be dropped. */
> + aio_disable_external(ctx);
> +restart:
> + ctx->drain_ops_updated = false;
> + QTAILQ_FOREACH(ops, &ctx->drain_ops, next) {
> + ops->drained_begin(ops->opaque);
> + if (ctx->drain_ops_updated) {
> + goto restart;
drained_begin() can be called multiple times. This needs to be clearly
documented to avoid surprises.
> + }
> + }
> +}
> +
> +/* Called with ctx->lock */
> +void aio_context_drained_end(AioContext *ctx)
> +{
> + AioDrainOps *ops;
> +
> +restart:
> + ctx->drain_ops_updated = false;
> + QTAILQ_FOREACH(ops, &ctx->drain_ops, next) {
> + if (ops->is_new) {
> + continue;
> + }
> + ops->drained_end(ops->opaque);
drained_end() can be called multiple times. This needs to be clearly
documented to avoid surprises.
> + if (ctx->drain_ops_updated) {
> + goto restart;
> + }
> + }
> + if (aio_enable_external(ctx)) {
> + QTAILQ_FOREACH(ops, &ctx->drain_ops, next) {
> + ops->is_new = false;
> + }
> + }
This is weird, aio_context_drained_end() has nesting support for
->is_new but not for ->drained_end() calls. I'm not sure where you're
going with these semantics yet.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
next prev parent reply other threads:[~2017-12-01 16:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-29 14:49 [Qemu-devel] [PATCH RFC 0/9] block: Rewrite block drain begin/end Fam Zheng
2017-11-29 14:49 ` [Qemu-devel] [PATCH RFC 1/9] block: Remove unused bdrv_requests_pending Fam Zheng
2017-12-01 12:35 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2017-11-29 14:49 ` [Qemu-devel] [PATCH RFC 2/9] aio: Add drain begin/end API to AioContext Fam Zheng
2017-11-30 16:07 ` Stefan Hajnoczi [this message]
2017-11-29 14:49 ` [Qemu-devel] [PATCH RFC 3/9] blockjob: Implement AioContext drain ops Fam Zheng
2017-11-30 16:09 ` Stefan Hajnoczi
2017-11-29 14:49 ` [Qemu-devel] [PATCH RFC 4/9] throttle: " Fam Zheng
2017-11-29 14:49 ` [Qemu-devel] [PATCH RFC 5/9] qed: " Fam Zheng
2017-11-29 14:49 ` [Qemu-devel] [PATCH RFC 6/9] block: Use aio_context_drained_begin in bdrv_set_aio_context Fam Zheng
2017-11-29 14:49 ` [Qemu-devel] [PATCH RFC 7/9] block: Switch to use AIO drained begin/end API Fam Zheng
2017-11-29 14:49 ` [Qemu-devel] [PATCH RFC 8/9] block: Drop old drained_{begin, end} callbacks Fam Zheng
2017-11-29 14:49 ` [Qemu-devel] [PATCH RFC 9/9] blockjob: Drop unused functions Fam Zheng
2017-11-29 17:25 ` [Qemu-devel] [PATCH RFC 0/9] block: Rewrite block drain begin/end Kevin Wolf
2017-11-30 2:03 ` Fam Zheng
2017-11-30 10:31 ` Kevin Wolf
2017-11-30 14:34 ` Fam Zheng
2017-11-30 15:10 ` Kevin Wolf
2017-11-30 16:04 ` Paolo Bonzini
2017-12-01 9:51 ` Fam Zheng
2017-12-01 12:24 ` Kevin Wolf
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=20171130160710.GA17703@stefanha-x1.localdomain \
--to=stefanha@redhat.com \
--cc=famz@redhat.com \
--cc=jcody@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--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).