From: Max Reitz <mreitz@redhat.com>
To: Alberto Garcia <berto@igalia.com>, qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, Kevin Wolf <kwolf@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 14/14] block: Stop passing flags to bdrv_reopen_queue_child()
Date: Mon, 8 Oct 2018 04:48:50 +0200 [thread overview]
Message-ID: <204d1911-765b-bd4b-27b8-3f1a35a6b9d6@redhat.com> (raw)
In-Reply-To: <ba0e2f728d7b2a0bbf5c0f44d907a4c7e3723501.1537367701.git.berto@igalia.com>
[-- Attachment #1: Type: text/plain, Size: 6302 bytes --]
On 19.09.18 16:47, Alberto Garcia wrote:
> Now that all callers are passing the new options using the QDict we no
> longer need the 'flags' parameter.
>
> This patch makes the following changes:
>
> 1) The update_options_from_flags() call is no longer necessary
> so it can be removed.
>
> 2) The update_flags_from_options() call is now used in all cases,
> and is moved down a few lines so it happens after the options
> QDict contains the final set of values.
>
> 3) The flags parameter is removed. Now the flags are initialized
> using the current value (for the top-level node) or the parent
> flags (after inherit_options()). In both cases the initial
> values are updated to reflect the new options in the QDict. This
> happens in bdrv_reopen_queue_child() (as explained above) and in
> bdrv_reopen_prepare().
>
> Signed-off-by: Alberto Garcia <berto@igalia.com>
> ---
> block.c | 50 +++++++++++++++++++++-----------------------------
> 1 file changed, 21 insertions(+), 29 deletions(-)
>
> diff --git a/block.c b/block.c
> index fd27b204d9..26c6a4e58a 100644
> --- a/block.c
> +++ b/block.c
> @@ -2884,7 +2884,6 @@ BlockDriverState *bdrv_open(const char *filename, const char *reference,
> static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
> BlockDriverState *bs,
> QDict *options,
> - int flags,
> const BdrvChildRole *role,
> QDict *parent_options,
> int parent_flags)
> @@ -2894,6 +2893,7 @@ static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
> BlockReopenQueueEntry *bs_entry;
> BdrvChild *child;
> QDict *old_options, *explicit_options;
> + int flags;
>
> /* Make sure that the caller remembered to use a drained section. This is
> * important to avoid graph changes between the recursive queuing here and
> @@ -2919,22 +2919,11 @@ static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
> /*
> * Precedence of options:
> * 1. Explicitly passed in options (highest)
> - * 2. Set in flags (only for top level)
> - * 3. Retained from explicitly set options of bs
> - * 4. Inherited from parent node
> - * 5. Retained from effective options of bs
> + * 2. Retained from explicitly set options of bs
> + * 3. Inherited from parent node
> + * 4. Retained from effective options of bs
> */
>
> - if (!parent_options) {
> - /*
> - * Any setting represented by flags is always updated. If the
> - * corresponding QDict option is set, it takes precedence. Otherwise
> - * the flag is translated into a QDict option. The old setting of bs is
> - * not considered.
> - */
> - update_options_from_flags(options, flags);
> - }
> -
> /* Old explicitly set values (don't overwrite by inherited value) */
> if (bs_entry) {
> old_options = qdict_clone_shallow(bs_entry->state.explicit_options);
> @@ -2948,12 +2937,22 @@ static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
>
> /* Inherit from parent node */
> if (parent_options) {
> - QemuOpts *opts;
> - QDict *options_copy;
> - Error *local_err = NULL;
> - assert(!flags);
> + flags = 0;
> role->inherit_options(&flags, options, parent_flags, parent_options);
> - options_copy = qdict_clone_shallow(options);
> + } else {
> + flags = bdrv_get_flags(bs);
> + }
> +
> + /* Old values are used for options that aren't set yet */
> + old_options = qdict_clone_shallow(bs->options);
> + bdrv_join_options(bs, options, old_options);
> + qobject_unref(old_options);
> +
> + /* We have the final set of options so let's update the flags */
> + {
> + Error *local_err = NULL;
> + QemuOpts *opts;
> + QDict *options_copy = qdict_clone_shallow(options);
I-I'm not sure this conforms to our coding style.
While I applaud your effort to keep the patch size small, I know for
sure I don't want to read code like this. (Unless it's necessary
because of some variables' lifetimes.)
I agree with the changes, however.
Max
> opts = qemu_opts_create(&bdrv_runtime_opts, NULL, 0, &error_abort);
> qemu_opts_absorb_qdict(opts, options_copy, &local_err);
> /* Don't call update_flags_from_options() if the options are wrong.
> @@ -2967,11 +2966,6 @@ static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
> qobject_unref(options_copy);
> }
>
> - /* Old values are used for options that aren't set yet */
> - old_options = qdict_clone_shallow(bs->options);
> - bdrv_join_options(bs, options, old_options);
> - qobject_unref(old_options);
> -
> /* bdrv_open_inherit() sets and clears some additional flags internally */
> flags &= ~BDRV_O_PROTOCOL;
> if (flags & BDRV_O_RDWR) {
> @@ -3011,7 +3005,7 @@ static BlockReopenQueue *bdrv_reopen_queue_child(BlockReopenQueue *bs_queue,
> qdict_extract_subqdict(options, &new_child_options, child_key_dot);
> g_free(child_key_dot);
>
> - bdrv_reopen_queue_child(bs_queue, child->bs, new_child_options, 0,
> + bdrv_reopen_queue_child(bs_queue, child->bs, new_child_options,
> child->role, options, flags);
> }
>
> @@ -3022,9 +3016,7 @@ BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue,
> BlockDriverState *bs,
> QDict *options)
> {
> - int flags = bdrv_get_flags(bs);
> - return bdrv_reopen_queue_child(bs_queue, bs, options, flags,
> - NULL, NULL, 0);
> + return bdrv_reopen_queue_child(bs_queue, bs, options, NULL, NULL, 0);
> }
>
> /*
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2018-10-08 2:49 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1537367701.git.berto@igalia.com>
[not found] ` <16ec059666d4e2177ad59b9a85978979a0d45917.1537367701.git.berto@igalia.com>
2018-10-08 0:43 ` [Qemu-devel] [PATCH 01/14] block: Don't call update_flags_from_options() if the options are wrong Max Reitz
[not found] ` <23f88429b3135b18abdc8643fb5cc35a6dd5d912.1537367701.git.berto@igalia.com>
2018-10-08 0:55 ` [Qemu-devel] [PATCH 02/14] block: Add bdrv_reopen_set_read_only() Max Reitz
[not found] ` <fd17cf9069d624e3a0b55ee3ba037830c23c60be.1537367701.git.berto@igalia.com>
2018-10-08 0:58 ` [Qemu-devel] [PATCH 03/14] block: Use bdrv_reopen_set_read_only() in bdrv_backing_update_filename() Max Reitz
[not found] ` <57d02fc28b31eebda8ee6d751587c5f25ebf5af0.1537367701.git.berto@igalia.com>
2018-10-08 1:11 ` [Qemu-devel] [PATCH 04/14] block: Use bdrv_reopen_set_read_only() in commit_start/complete() Max Reitz
[not found] ` <27ece91df0fbe7528e01425e94992e46b71ff042.1537367701.git.berto@igalia.com>
2018-10-08 1:16 ` [Qemu-devel] [PATCH 05/14] block: Use bdrv_reopen_set_read_only() in bdrv_commit() Max Reitz
[not found] ` <5f1c063ccfaf20fde5d1334652648f054b0f9d8a.1537367701.git.berto@igalia.com>
2018-10-08 1:21 ` [Qemu-devel] [PATCH 06/14] block: Use bdrv_reopen_set_read_only() in stream_start/complete() Max Reitz
[not found] ` <f68a21f152eef2c51361539bdc6c8f5eefe6af61.1537367701.git.berto@igalia.com>
2018-10-08 1:26 ` [Qemu-devel] [PATCH 07/14] block: Use bdrv_reopen_set_read_only() in qmp_change_backing_file() Max Reitz
[not found] ` <8f8a151dae565027208268ed8d120e4612ef5f9f.1537367701.git.berto@igalia.com>
2018-10-08 1:31 ` [Qemu-devel] [PATCH 08/14] block: Use bdrv_reopen_set_read_only() in external_snapshot_commit() Max Reitz
2018-10-08 18:04 ` Alberto Garcia
[not found] ` <32c99e47940fcee5e83c780147e34a8f3840f7e4.1537367701.git.berto@igalia.com>
2018-10-08 1:46 ` [Qemu-devel] [PATCH 09/14] block: Use bdrv_reopen_set_read_only() in the mirror driver Max Reitz
[not found] ` <570b9109b10c519aceb6c333a6e0d0a59795defb.1537367701.git.berto@igalia.com>
2018-10-08 1:48 ` [Qemu-devel] [PATCH 10/14] block: Drop bdrv_reopen() Max Reitz
[not found] ` <298f85a0b53dc90b1d6bea272c26983ab684619e.1537367701.git.berto@igalia.com>
2018-10-08 2:05 ` [Qemu-devel] [PATCH 11/14] qemu-io: Put flag changes in the options QDict in reopen_f() Max Reitz
[not found] ` <95addb261af316f49517069e1cce4d9c601d274b.1537367701.git.berto@igalia.com>
2018-10-08 2:34 ` [Qemu-devel] [PATCH 12/14] block: Clean up reopen_backing_file() in block/replication.c Max Reitz
2018-10-10 11:23 ` Alberto Garcia
[not found] ` <8e3622ca8e46a8f450dd94f6f2a485bfbe4a72ab.1537367701.git.berto@igalia.com>
2018-10-08 2:41 ` [Qemu-devel] [PATCH 13/14] block: Remove flags parameter from bdrv_reopen_queue() Max Reitz
[not found] ` <ba0e2f728d7b2a0bbf5c0f44d907a4c7e3723501.1537367701.git.berto@igalia.com>
2018-10-08 2:48 ` Max Reitz [this message]
2018-10-08 18:13 ` [Qemu-devel] [PATCH 14/14] block: Stop passing flags to bdrv_reopen_queue_child() Alberto Garcia
2018-10-08 18:46 ` Max Reitz
2018-10-09 8:44 ` 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=204d1911-765b-bd4b-27b8-3f1a35a6b9d6@redhat.com \
--to=mreitz@redhat.com \
--cc=berto@igalia.com \
--cc=kwolf@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).