From: Kevin Wolf <kwolf@redhat.com>
To: Max Reitz <mreitz@redhat.com>
Cc: Alberto Garcia <berto@igalia.com>,
qemu-block@nongnu.org, John Snow <jsnow@redhat.com>,
qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v5 17/38] block: Add BlockBackendRootState
Date: Tue, 22 Sep 2015 16:17:01 +0200 [thread overview]
Message-ID: <20150922141701.GD3999@noname.str.redhat.com> (raw)
In-Reply-To: <1442589793-7105-18-git-send-email-mreitz@redhat.com>
Am 18.09.2015 um 17:22 hat Max Reitz geschrieben:
> This structure will store some of the state of the root BDS if the BDS
> tree is removed, so that state can be restored once a new BDS tree is
> inserted.
This is magic that is bound to bite us sooner or later. I see that we
have to do this in order to maintain compatibility, but imagine we'll
have multiple BlockBackends sitting on top of the same BDS. They'll be
fighting for whose throttling settings are applied. With this approach,
the winner is the BlockBackend that most recently went from no medium to
medium, which might just be the most surprising way to solve the
problem.
I'll detail one aspect of the problem below.
The correct way to solve this seems to be that each BB has its own I/O
throttling filter. Actually, if we could lift the throttling code to
BlockBackend, that might solve the problem.
I guess the same applies for the other fields in BlockBackendRootState.
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> ---
> block/block-backend.c | 37 +++++++++++++++++++++++++++++++++++++
> include/block/block_int.h | 10 ++++++++++
> include/qemu/typedefs.h | 1 +
> include/sysemu/block-backend.h | 2 ++
> 4 files changed, 50 insertions(+)
>
> diff --git a/block/block-backend.c b/block/block-backend.c
> index 1f2cd9b..9590be5 100644
> --- a/block/block-backend.c
> +++ b/block/block-backend.c
> @@ -13,6 +13,7 @@
> #include "sysemu/block-backend.h"
> #include "block/block_int.h"
> #include "block/blockjob.h"
> +#include "block/throttle-groups.h"
> #include "sysemu/blockdev.h"
> #include "sysemu/sysemu.h"
> #include "qapi-event.h"
> @@ -37,6 +38,10 @@ struct BlockBackend {
> /* the block size for which the guest device expects atomicity */
> int guest_block_size;
>
> + /* If the BDS tree is removed, some of its options are stored here (which
> + * can be used to restore those options in the new BDS on insert) */
> + BlockBackendRootState root_state;
> +
> /* I/O stats (display with "info blockstats"). */
> BlockAcctStats stats;
>
> @@ -161,6 +166,7 @@ static void blk_delete(BlockBackend *blk)
> bdrv_unref(blk->bs);
> blk->bs = NULL;
> }
> + g_free(blk->root_state.throttle_group_name);
> /* Avoid double-remove after blk_hide_on_behalf_of_hmp_drive_del() */
> if (blk->name[0]) {
> QTAILQ_REMOVE(&blk_backends, blk, link);
> @@ -1050,3 +1056,34 @@ int blk_probe_geometry(BlockBackend *blk, HDGeometry *geo)
> {
> return bdrv_probe_geometry(blk->bs, geo);
> }
> +
> +/*
> + * Updates the BlockBackendRootState object with data from the currently
> + * attached BlockDriverState.
> + */
> +void blk_update_root_state(BlockBackend *blk)
> +{
> + assert(blk->bs);
> +
> + blk->root_state.open_flags = blk->bs->open_flags;
> + blk->root_state.read_only = blk->bs->read_only;
> + blk->root_state.detect_zeroes = blk->bs->detect_zeroes;
> +
> + blk->root_state.io_limits_enabled = blk->bs->io_limits_enabled;
> +
> + g_free(blk->root_state.throttle_group_name);
> + if (blk->bs->throttle_state) {
> + throttle_get_config(blk->bs->throttle_state,
> + &blk->root_state.throttle_config);
> + blk->root_state.throttle_group_name =
> + g_strdup(throttle_group_get_name(blk->bs));
The throttling group name is essentially a weak reference. I think
making it strong is worth considering.
If you attach a new BDS, if the old throttling group still exists, the
new BDS is re-added there, as expected. If the throttling group has got
changed limits meanwhile, you need to choose whether to apply the limits
saved here or use the new limits for the BDS. I guess the latter will be
the correct choice.
If the old throttling group doesn't exist any more, a new one is created
with the old name and limits. If two BlockBackends eject their media at
separate times and the throttle group goes away, reinstantiating the
throttle group by attaching a BDS to both BBs will use the config of the
BB that got a new medium first (as opposed to: the latest setting the
throttling group had before it was freed).
If the old throttling group was freed, but then a new throttling group
was created with the same name, we get attached to that new group with
its new limits. This could be slightly surprising as well.
Kevin
next prev parent reply other threads:[~2015-09-22 14:17 UTC|newest]
Thread overview: 74+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-18 15:22 [Qemu-devel] [PATCH v5 00/38] blockdev: BlockBackend and media Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 01/38] block: Remove host floppy support Max Reitz
2015-09-18 15:31 ` Eric Blake
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 02/38] block: Set BDRV_O_INCOMING in bdrv_fill_options() Max Reitz
2015-09-18 15:32 ` Eric Blake
2015-09-29 8:53 ` Alberto Garcia
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 03/38] blockdev: Allow creation of BDS trees without BB Max Reitz
2015-09-18 15:34 ` Eric Blake
2015-09-29 8:45 ` Alberto Garcia
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 04/38] iotests: Only create BB if necessary Max Reitz
2015-09-18 16:00 ` Eric Blake
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 05/38] block: Make bdrv_is_inserted() return a bool Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 06/38] block: Add blk_is_available() Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 07/38] block: Make bdrv_is_inserted() recursive Max Reitz
2015-09-18 16:20 ` Eric Blake
2015-09-29 9:15 ` Alberto Garcia
2015-09-30 14:32 ` Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 08/38] block/raw_bsd: Drop raw_is_inserted() Max Reitz
2015-09-18 16:20 ` Eric Blake
2015-09-29 10:47 ` Alberto Garcia
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 09/38] block: Invoke change media CB before NULLing drv Max Reitz
2015-09-18 16:22 ` Eric Blake
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 10/38] hw/block/fdc: Implement tray status Max Reitz
2015-09-18 16:24 ` Eric Blake
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 11/38] hw/usb-storage: Check whether BB is inserted Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 12/38] block: Fix BB AIOCB AioContext without BDS Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 13/38] block: Move guest_block_size into BlockBackend Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 14/38] block: Remove wr_highest_sector from BlockAcctStats Max Reitz
2015-09-18 16:59 ` Eric Blake
2015-09-21 7:57 ` Kevin Wolf
2015-09-21 15:53 ` Eric Blake
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 15/38] block: Move BlockAcctStats into BlockBackend Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 16/38] block: Move I/O status and error actions into BB Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 17/38] block: Add BlockBackendRootState Max Reitz
2015-09-22 14:17 ` Kevin Wolf [this message]
2015-09-22 15:00 ` Max Reitz
2015-09-29 11:17 ` Alberto Garcia
2015-09-29 12:30 ` Eric Blake
2015-09-29 13:12 ` Kevin Wolf
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 18/38] block: Make some BB functions fall back to BBRS Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 19/38] block: Fail requests to empty BlockBackend Max Reitz
2015-09-22 14:30 ` Kevin Wolf
2015-09-22 15:05 ` Max Reitz
2015-09-22 15:13 ` Kevin Wolf
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 20/38] block: Prepare remaining BB functions for NULL BDS Max Reitz
2015-09-22 14:35 ` Kevin Wolf
2015-09-22 15:07 ` Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 21/38] block: Add blk_insert_bs() Max Reitz
2015-09-22 14:42 ` Kevin Wolf
2015-09-22 15:20 ` Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 22/38] block: Prepare for NULL BDS Max Reitz
2015-09-18 19:42 ` Eric Blake
2015-10-07 10:43 ` Kevin Wolf
2015-10-07 15:08 ` Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 23/38] blockdev: Do not create BDS for empty drive Max Reitz
2015-09-18 15:22 ` [Qemu-devel] [PATCH v5 24/38] blockdev: Pull out blockdev option extraction Max Reitz
2015-09-30 11:16 ` Alberto Garcia
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 25/38] blockdev: Allow more options for BB-less BDS tree Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 26/38] block: Add blk_remove_bs() Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 27/38] blockdev: Add blockdev-open-tray Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 28/38] blockdev: Add blockdev-close-tray Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 29/38] blockdev: Add blockdev-remove-medium Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 30/38] blockdev: Add blockdev-insert-medium Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 31/38] blockdev: Implement eject with basic operations Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 32/38] blockdev: Implement change " Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 33/38] block: Inquire tray state before tray-moved events Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 34/38] qmp: Introduce blockdev-change-medium Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 35/38] hmp: Use blockdev-change-medium for change command Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 36/38] blockdev: read-only-mode for blockdev-change-medium Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 37/38] hmp: Add read-only-mode option to change command Max Reitz
2015-09-18 15:23 ` [Qemu-devel] [PATCH v5 38/38] iotests: Add test for change-related QMP commands Max Reitz
2015-09-22 14:45 ` [Qemu-devel] [PATCH v5 00/38] blockdev: BlockBackend and media Kevin Wolf
2015-09-22 15:09 ` Max Reitz
2015-09-23 6:20 ` Wen Congyang
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=20150922141701.GD3999@noname.str.redhat.com \
--to=kwolf@redhat.com \
--cc=armbru@redhat.com \
--cc=berto@igalia.com \
--cc=jsnow@redhat.com \
--cc=mreitz@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).