From: Kevin Wolf <kwolf@redhat.com>
To: Alberto Garcia <berto@igalia.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/7] block: Set BDRV_O_ALLOW_RDWR and snapshot_options before storing the flags
Date: Thu, 15 Sep 2016 14:50:53 +0200 [thread overview]
Message-ID: <20160915125053.GF4726@noname.redhat.com> (raw)
In-Reply-To: <w51bmzp1h0x.fsf@maestria.local.igalia.com>
Am 15.09.2016 um 14:31 hat Alberto Garcia geschrieben:
> On Thu 15 Sep 2016 02:19:36 PM CEST, Kevin Wolf wrote:
>
> >> >> + if (flags & BDRV_O_RDWR) {
> >> >> + flags |= BDRV_O_ALLOW_RDWR;
> >> >> + }
> >> >> +
> >> >> + if (flags & BDRV_O_SNAPSHOT) {
> >> >> + snapshot_options = qdict_new();
> >> >> + bdrv_temp_snapshot_options(&snapshot_flags, snapshot_options,
> >> >> + flags, options);
> >> >> + bdrv_backing_options(&flags, options, flags, options);
> >> >> + }
> >> >> +
> >> >> bs->open_flags = flags;
> >> >> bs->options = options;
> >> >> options = qdict_clone_shallow(options);
> >> >
> >> > Here I think we get different semantics now: bdrv_backing_options()
> >> > only affected the cloned QDict before, and now it affects bs->options,
> >> > too.
> >>
> >> The thing is that bdrv_backing_options() doesn't change the options in
> >> general, and in the case where it does (BDRV_OPT_READ_ONLY after the
> >> next patch) I think it makes sense that the options are changed.
> >> "snapshot=on" is a bit of a special case after all.
> >
> > Fair enough, it is correct (as I suspected), but it's not a bug fix
> > because so far the options weren't changed, so there's no observable
> > difference.
>
> The idea of this change is to remove the ' bs->open_flags = flags ' line
> in the original code, as explained in the commit message.
>
> That's one thing. The other (and most important one) is to prepare for
> the introduction of BDRV_OPT_READ_ONLY.
>
> Without this patch we'd need to need to update not just bs->open_flags
> but bs->options as well, and it would be something like this:
>
> bs->open_flags = flags;
> bs->options = options;
>
> /* ... */
>
> if ((flags & BDRV_O_PROTOCOL) == 0) {
>
> /* ... */
>
> if (flags & BDRV_O_SNAPSHOT) {
> snapshot_options = qdict_new();
> bdrv_temp_snapshot_options(&snapshot_flags, snapshot_options,
> flags, options);
> + qdict_del(bs->options, BDRV_OPT_READ_ONLY);
> + qdict_del(options, BDRV_OPT_READ_ONLY);
> bdrv_backing_options(&flags, options, flags, options);
> }
>
> bs->open_flags = flags;
> + qdict_copy_default(bs->options, options, BDRV_OPT_READ_ONLY);
>
> /* ... */
> }
>
> Moving this chunk of code saves us from having to update bs->open_flags
> and bs->options and makes things more readable.
I fully understand understand what the patch is for, and I don't want
you to change any code. I was asking whether there was a hidden bug fix
in here (which should have been moved into a separate patch then), but
you explained to me why there isn't, so we're good. The only thing I'm
looking for now is putting this explanation into the commit message.
So just include in the commit message that moving across the clone of
bs->options doesn't make an observable difference (at the point of this
patch) because the bdrv_backing_options() call doesn't actually change
options yet, and that applying any changes made by it in the future
to bs->options makes more sense anyway.
Kevin
next prev parent reply other threads:[~2016-09-15 12:51 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-14 15:52 [Qemu-devel] [PATCH 0/7] Add "read-only" to the options QDict Alberto Garcia
2016-09-14 15:52 ` [Qemu-devel] [PATCH 1/7] block: Remove bdrv_is_snapshot Alberto Garcia
2016-09-14 16:43 ` Kevin Wolf
2016-09-14 17:07 ` Eric Blake
2016-09-14 15:52 ` [Qemu-devel] [PATCH 2/7] block: Set BDRV_O_ALLOW_RDWR and snapshot_options before storing the flags Alberto Garcia
2016-09-14 16:40 ` Kevin Wolf
2016-09-15 11:24 ` Alberto Garcia
2016-09-15 12:19 ` Kevin Wolf
2016-09-15 12:31 ` Alberto Garcia
2016-09-15 12:50 ` Kevin Wolf [this message]
2016-09-15 12:55 ` Alberto Garcia
2016-09-14 18:54 ` [Qemu-devel] [Qemu-block] " Jeff Cody
2016-09-15 9:10 ` Alberto Garcia
2016-09-14 15:52 ` [Qemu-devel] [PATCH 3/7] block: Update bs->open_flags earlier in bdrv_open_common() Alberto Garcia
2016-09-14 16:42 ` Kevin Wolf
2016-09-14 15:52 ` [Qemu-devel] [PATCH 4/7] block: Add "read-only" to the options QDict Alberto Garcia
2016-09-15 10:51 ` Kevin Wolf
2016-09-15 11:42 ` Alberto Garcia
2016-09-14 15:52 ` [Qemu-devel] [PATCH 5/7] block: Don't queue the same BDS twice in bdrv_reopen_queue_child() Alberto Garcia
2016-09-15 13:04 ` Kevin Wolf
2016-09-14 15:52 ` [Qemu-devel] [PATCH 6/7] commit: Add 'base' to the reopen queue before 'overlay_bs' Alberto Garcia
2016-09-15 13:06 ` Kevin Wolf
2016-09-14 15:52 ` [Qemu-devel] [PATCH 7/7] block: rename "read-only" to BDRV_OPT_READ_ONLY Alberto Garcia
2016-09-15 13:09 ` 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=20160915125053.GF4726@noname.redhat.com \
--to=kwolf@redhat.com \
--cc=berto@igalia.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).