From: Paolo Bonzini <pbonzini@redhat.com>
To: Alberto Garcia <berto@igalia.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
qemu-block@nongnu.org, Markus Armbruster <armbru@redhat.com>,
Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v11 01/19] block: Add bdrv_drain_all_{begin, end}()
Date: Sat, 15 Oct 2016 09:28:18 +0200 [thread overview]
Message-ID: <a6f565b5-c031-bb08-ec90-174ef468f517@redhat.com> (raw)
In-Reply-To: <99a0ff7379a345ed60a6092866c9a42f667b37b5.1476450059.git.berto@igalia.com>
On 14/10/2016 15:08, Alberto Garcia wrote:
> bdrv_drain_all() doesn't allow the caller to do anything after all
> pending requests have been completed but before block jobs are
> resumed.
>
> This patch splits bdrv_drain_all() into _begin() and _end() for that
> purpose. It also adds aio_{disable,enable}_external() calls to disable
> external clients in the meantime.
>
> Signed-off-by: Alberto Garcia <berto@igalia.com>
> ---
> block/io.c | 24 +++++++++++++++++++++---
> include/block/block.h | 2 ++
> 2 files changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/block/io.c b/block/io.c
> index b136c89..9418f8b 100644
> --- a/block/io.c
> +++ b/block/io.c
> @@ -275,8 +275,11 @@ void bdrv_drain(BlockDriverState *bs)
> *
> * This function does not flush data to disk, use bdrv_flush_all() for that
> * after calling this function.
> + *
> + * This pauses all block jobs and disables external clients. It must
> + * be paired with bdrv_drain_all_end().
> */
> -void bdrv_drain_all(void)
> +void bdrv_drain_all_begin(void)
> {
> /* Always run first iteration so any pending completion BHs run */
> bool busy = true;
> @@ -300,6 +303,7 @@ void bdrv_drain_all(void)
> bdrv_parent_drained_begin(bs);
> bdrv_io_unplugged_begin(bs);
> bdrv_drain_recurse(bs);
> + aio_disable_external(aio_context);
> aio_context_release(aio_context);
>
> if (!g_slist_find(aio_ctxs, aio_context)) {
> @@ -333,17 +337,25 @@ void bdrv_drain_all(void)
> }
> }
>
> + g_slist_free(aio_ctxs);
> +}
> +
> +void bdrv_drain_all_end(void)
> +{
> + BlockDriverState *bs;
> + BdrvNextIterator it;
> + BlockJob *job = NULL;
> +
> for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
> AioContext *aio_context = bdrv_get_aio_context(bs);
>
> aio_context_acquire(aio_context);
> + aio_enable_external(aio_context);
> bdrv_io_unplugged_end(bs);
> bdrv_parent_drained_end(bs);
> aio_context_release(aio_context);
> }
> - g_slist_free(aio_ctxs);
>
> - job = NULL;
> while ((job = block_job_next(job))) {
> AioContext *aio_context = blk_get_aio_context(job->blk);
>
> @@ -353,6 +365,12 @@ void bdrv_drain_all(void)
> }
> }
>
> +void bdrv_drain_all(void)
> +{
> + bdrv_drain_all_begin();
> + bdrv_drain_all_end();
> +}
> +
> /**
> * Remove an active request from the tracked requests list
> *
> diff --git a/include/block/block.h b/include/block/block.h
> index 107c603..301d713 100644
> --- a/include/block/block.h
> +++ b/include/block/block.h
> @@ -338,6 +338,8 @@ int bdrv_flush_all(void);
> void bdrv_close_all(void);
> void bdrv_drain(BlockDriverState *bs);
> void coroutine_fn bdrv_co_drain(BlockDriverState *bs);
> +void bdrv_drain_all_begin(void);
> +void bdrv_drain_all_end(void);
> void bdrv_drain_all(void);
>
> int bdrv_pdiscard(BlockDriverState *bs, int64_t offset, int count);
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
next prev parent reply other threads:[~2016-10-15 7:28 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-14 13:08 [Qemu-devel] [PATCH v11 00/19] Support streaming to an intermediate layer Alberto Garcia
2016-10-14 13:08 ` [Qemu-devel] [PATCH v11 01/19] block: Add bdrv_drain_all_{begin, end}() Alberto Garcia
2016-10-15 7:28 ` Paolo Bonzini [this message]
2016-10-19 17:11 ` Kevin Wolf
2016-10-20 8:25 ` Alberto Garcia
2016-10-20 9:11 ` Kevin Wolf
2016-10-21 18:55 ` John Snow
2016-10-21 19:03 ` Alberto Garcia
2016-10-21 19:34 ` John Snow
2016-10-24 10:53 ` Paolo Bonzini
2016-10-25 13:39 ` Alberto Garcia
2016-10-25 13:53 ` Paolo Bonzini
2016-10-25 14:38 ` Kevin Wolf
2016-10-25 14:41 ` Paolo Bonzini
2016-10-25 15:03 ` Kevin Wolf
2016-10-25 14:48 ` Alberto Garcia
2016-10-25 14:52 ` Paolo Bonzini
2016-10-14 13:08 ` [Qemu-devel] [PATCH v11 02/19] block: Pause all jobs during bdrv_reopen_multiple() Alberto Garcia
2016-10-15 7:28 ` Paolo Bonzini
2016-10-14 13:08 ` [Qemu-devel] [PATCH v11 03/19] block: Add block_job_add_bdrv() Alberto Garcia
2016-10-14 13:08 ` [Qemu-devel] [PATCH v11 04/19] block: Use block_job_add_bdrv() in mirror_start_job() Alberto Garcia
2016-10-14 13:08 ` [Qemu-devel] [PATCH v11 05/19] block: Use block_job_add_bdrv() in backup_start() Alberto Garcia
2016-10-14 13:08 ` [Qemu-devel] [PATCH v11 06/19] block: Check blockers in all nodes involved in a block-commit job Alberto Garcia
2016-10-14 13:08 ` [Qemu-devel] [PATCH v11 07/19] block: Block all nodes involved in the block-commit operation Alberto Garcia
2016-10-14 13:08 ` [Qemu-devel] [PATCH v11 08/19] block: Block all intermediate nodes in commit_active_start() Alberto Garcia
2016-10-14 13:08 ` [Qemu-devel] [PATCH v11 09/19] block: Support streaming to an intermediate layer Alberto Garcia
2016-10-14 13:08 ` [Qemu-devel] [PATCH v11 10/19] block: Add QMP support for " Alberto Garcia
2016-10-14 13:08 ` [Qemu-devel] [PATCH v11 11/19] docs: Document how to stream " Alberto Garcia
2016-10-14 13:08 ` [Qemu-devel] [PATCH v11 12/19] qemu-iotests: Test streaming " Alberto Garcia
2016-10-14 13:08 ` [Qemu-devel] [PATCH v11 13/19] qemu-iotests: Test block-stream operations in parallel Alberto Garcia
2016-10-14 13:08 ` [Qemu-devel] [PATCH v11 14/19] qemu-iotests: Test overlapping stream and commit operations Alberto Garcia
2016-10-14 13:08 ` [Qemu-devel] [PATCH v11 15/19] qemu-iotests: Test block-stream and block-commit in parallel Alberto Garcia
2016-10-14 13:08 ` [Qemu-devel] [PATCH v11 16/19] qemu-iotests: Add iotests.supports_quorum() Alberto Garcia
2016-10-14 13:08 ` [Qemu-devel] [PATCH v11 17/19] qemu-iotests: Test streaming to a Quorum child Alberto Garcia
2016-10-14 13:08 ` [Qemu-devel] [PATCH v11 18/19] block: Add 'base-node' parameter to the 'block-stream' command Alberto Garcia
2016-10-14 13:08 ` [Qemu-devel] [PATCH v11 19/19] qemu-iotests: Test the 'base-node' parameter of 'block-stream' Alberto Garcia
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=a6f565b5-c031-bb08-ec90-174ef468f517@redhat.com \
--to=pbonzini@redhat.com \
--cc=armbru@redhat.com \
--cc=berto@igalia.com \
--cc=kwolf@redhat.com \
--cc=mreitz@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).