From: Eric Blake <eblake@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, Adam Wolfe Gordon <awg@digitalocean.com>
Cc: "open list:All patches CC here" <qemu-devel@nongnu.org>,
Josh Durgin <jdurgin@redhat.com>, Jeff Cody <jcody@redhat.com>,
qemu-block@nongnu.org, Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] rbd: Detect rbd image resizes and propagate them
Date: Fri, 15 Sep 2017 17:08:32 -0500 [thread overview]
Message-ID: <7d812c2f-8352-dc1a-866a-c482755f0827@redhat.com> (raw)
In-Reply-To: <20170915123327.GD4077@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 2758 bytes --]
On 09/15/2017 07:33 AM, Kevin Wolf wrote:
> Am 13.09.2017 um 18:44 hat Adam Wolfe Gordon geschrieben:
>> Register a watcher with rbd so that we get notified when an image is
>> resized. Propagate resizes to parent block devices so that guest devices
>> get resized without user intervention.
>>
>> Signed-off-by: Adam Wolfe Gordon <awg@digitalocean.com>
>> ---
>
> There's more wrong about this than just making assumptions about the
> graph layout above our own node (which would be wrong enough already).
>
> Other assumptions that you are making here and that don't hold true
> generally are that there is only one parent node (no reason why the
> image couldn't be used by two different users) and that we always
> inherit from a parent. If this node was created explicitly by the user
> with its own -blockdev (or -drive) option, it doesn't inherit options
> from any of its parents.
>
> Basically, a block driver shouldn't care about its users and it can't
> access them in a clean way. This is intentional.
>
>> + if (parent == NULL) {
>> + error_report("bs %s does not have parent", bdrv_get_device_or_node_name(bs));
>> + return;
>> + }
>> +
>> + /* Force parents to re-read our size. */
>> + was_variable_length = bs->drv->has_variable_length;
>> + bs->drv->has_variable_length = true;
>> + new_parent_len = bdrv_getlength(parent);
>> + if (new_parent_len < 0) {
>> + error_report("getlength failed on parent %s", bdrv_get_device_or_node_name(parent));
>> + bs->drv->has_variable_length = was_variable_length;
>> + return;
>> + }
>> + bs->drv->has_variable_length = was_variable_length;
>> +
>> + /* Notify block backends that that we have resized.
>> + Copied from bdrv_parent_cb_resize. */
>> + QLIST_FOREACH(c, &parent->parents, next_parent) {
>> + if (c->role->resize) {
>> + c->role->resize(c);
>> + }
>> + }
>
> This is the right approach that you should use consistently instead.
Also, we need to fix existing bugs in block.c first; right now,
bdrv_truncate() forgets that refresh_total_sectors() can fail, and then
calls bdrv_dirty_bitmap_truncate() even though that will act on the
wrong length. If we are going to allow devices to recognize that they
have been externally resized outside of qemu's control, then we need to
make sure that we react to size updates consistently.
I'm trying to fix that [1], but it may interact with what you are trying
to do here.
[1] https://lists.gnu.org/archive/html/qemu-devel/2017-09/msg03776.html
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 619 bytes --]
prev parent reply other threads:[~2017-09-15 22:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-13 16:44 [Qemu-devel] [PATCH] rbd: Detect rbd image resizes and propagate them Adam Wolfe Gordon
2017-09-13 20:22 ` no-reply
2017-09-13 20:22 ` no-reply
2017-09-13 20:53 ` [Qemu-devel] [Qemu-block] " John Snow
2017-09-13 21:36 ` Adam Wolfe Gordon
2017-09-14 0:47 ` John Snow
2017-09-14 22:27 ` Adam Wolfe Gordon
2017-09-13 21:21 ` Jason Dillaman
2017-09-13 21:56 ` Adam Wolfe Gordon
2017-09-15 12:33 ` [Qemu-devel] " Kevin Wolf
2017-09-15 22:08 ` Eric Blake [this message]
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=7d812c2f-8352-dc1a-866a-c482755f0827@redhat.com \
--to=eblake@redhat.com \
--cc=awg@digitalocean.com \
--cc=jcody@redhat.com \
--cc=jdurgin@redhat.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).