All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: "תומר בן אור" <tomer@zertodata.com>,
	"Stefan Hajnoczi" <stefanha@gmail.com>,
	"Jeff Cody" <jcody@redhat.com>,
	dlaor@redhat.com, qemu-devel@nongnu.org,
	"Markus Armbruster" <armbru@redhat.com>,
	"Zhi Yong Wu" <zwu.kernel@gmail.com>,
	"Federico Simoncelli" <fsimonce@redhat.com>,
	"Ori Mamluk" <omamluk@zerto.com>, "עודד קדם" <oded@zerto.com>,
	"Yair Kuszpet" <yairk@zerto.com>
Subject: Re: [Qemu-devel] BlockDriverState stack and BlockListeners
Date: Tue, 21 Feb 2012 11:51:39 +0100	[thread overview]
Message-ID: <4F43773B.6060109@redhat.com> (raw)
In-Reply-To: <4F436D76.6090206@redhat.com>

Am 21.02.2012 11:09, schrieb Paolo Bonzini:
>>> 2) BlockListener would be entirely an implementation detail, used in the
>>> implementation of other commands.
>>
>> Depending on what you mean by command (presumably QMP commands?),
> 
> QMP commands, command-line (-drive), whatever.
> 
>> And on the other hand, protocols like file are entirely implementation
>> details as well, and still they are BlockDrivers.
> 
> True.  Formats and protocols also do not have perfectly overlapping
> functionality (backing images are only a format thing, for example).

And even protocols and protocols don't. Compare file to blkdebug, for
example. In fact, blkdebug and blkverify are already very close to what
BlockListeners would be.

>>>> The main difference that I see is that the listeners stay always on top.
>>>> For example, let's assume that if implemented a blkmirror driver in
>>>> today's infrastructure, you would get a BlockDriverState stack like
>>>> blkmirror -> qcow2 -> file. If you take a live snapshot now, you don't
>>>> want to have the blkmirror applied to the old top-level image, which is
>>>> now a read-only backing file. Instead, it should move to the new
>>>> top-level image.
>>>
>>> Yes, that's because a BlockListener always applies to a
>>> BlockDriverState, and live snapshots close+reopen the BDS but do not
>>> delete/recreate it.
>>
>> Hm, that's an interesting angle to look at it. The reasoning makes sense
>> to me (though I would reword it as a BlockListener belongs to a
>> drive/block device rather than a BDS, which is an implementation detail).
> 
> Yes.
> 
>> However, live snapshots can't close and reopen the BDS in the future,
>> because the reopen could fail and you must not have closed the old image
>> yet in this case. So what Jeff and I were looking into recently is to
>> change this so that new top-level images are opened first without
>> backing file and then the backing file relationship is created with the
>> existing BDS.
>>
>> Of course, we stumbled across the thing that you're telling me here,
>> that devices refer to the same BDS as before. So their content must be
>> swapped, but some data like the device name (and now BlockListeners)
>> stay with the top-level image instead.
>>
>> Which in turn reminds me of a discussion I had with Stefan a while ago,
>> where we came to the conclusion that we need to separate the
>> representation of an image file and a "view" of it which represents a
>> block device (as a whole). [...]
>>
>> Isn't it cool how everything is connected with everything? :-)
> 
> :)
> 
> So we'd have:
> 
> - Protocols -- Protocols tell you where to get the raw bits.
> - Formats -- Formats transform those raw bits into a block device.
> - Views -- Views can move from a format to another.  A format can use a
> default view implementation, or provide its own (e.g. to access
> different snapshots).
> - Listeners -- I think a view can have-a listener?

Where protocols, formats and listeners are-a image (Not the best name,
I'm open for suggestions. Something like "BDS stack building block"
would be most accurate...). Or actually not is-a in terms of
inheritance, but I think it would be the very same thing without any
subclassing, implemented by a BlockDriver.

> with the following relationship:
> 
> - A format has-a protocol for the raw bits and has-a view for the
> backing file.

An image has-a image from which it takes its data (bs->file). And it
has-a view for the backing file, yes. Both could be a listener.

> - A view has-a format, a device has-a view.
> - A view can have-a listener?  Or is it formats?

A view has-a image. This may happen to be a listener, which in turn
has-a image (could be another listener, a format or a protocol).

The question is what the semantics is with live snapshots (there are
probably similar problems, but this is the obvious one). For example we
could now have:

mirror -> qcow2 -> blkdebug -> file

There are two listeners here, mirror and blkdebug. (Things like blkdebug
are why view has-a listener isn't enough). After creating an external
snapshot, we expect the graph to look like this (the arrow down is the
backing file):

mirror -> qcow2 -> file
            |
            +-> qcow2 -> blkdebug -> file

The question is: Can we assume that any listeners that are on top of the
first format or protocol (i.e. those that would fit your model) should
move to the new top-level view? Or would it sometimes make sense to keep
it at the old one?

> But I think we're digressing...

No, in fact I think we need to get an idea of what we want to have in
the end. And we need to do it soon, almost any new topic that's coming
up ends up in a discussion about the same shortcomings of the block layer.

It doesn't make sense to hack in more and more stuff without having
proper infrastructure for it.

>>>> So maybe we just need to extend the current BlockDriverState stack to
>>>> distinguish "normal" and "always on top" BlockDrivers, where the latter
>>>> would roughly correspond to BlockListeners?
>>>
>>> I would prefer having separate objects.  Even if you do not count fields
>>> related to throttling or copy-on-read or other tasks in the list above,
>>> there are many fields in BDS that do not really apply to BlockListeners.
>>>  Backing files, device ops, encryption, even size.  Having extra methods
>>> is not a big problem, but unwanted data items smell...
>>
>> Most other block drivers use only little of them. We can try to clean up
>> some of them (and making the separation described above would probably
>> help with it), but BlockListeners aren't really different here from
>> existing drivers.
> 
> True, the question only matters insofar as having a separate data
> structure simplifies the design.  ("Simplify" means "we can actually
> understand it and be reasonably sure that it's correct and implementable").

Having only one kind of building block for the block driver graph is a
simplification, too. Or at least one common base class.

Kevin

  reply	other threads:[~2012-02-21 10:48 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-07 10:29 [Qemu-devel] [RFC PATCH] replication agent module Ori Mamluk
2012-02-07 12:12 ` Anthony Liguori
2012-02-07 12:25   ` Dor Laor
2012-02-07 12:30     ` Ori Mamluk
2012-02-07 12:40       ` Anthony Liguori
2012-02-07 14:06         ` Ori Mamluk
2012-02-07 14:40           ` Paolo Bonzini
2012-02-07 14:48             ` Ori Mamluk
2012-02-07 15:47               ` Paolo Bonzini
2012-02-08  6:10                 ` Ori Mamluk
2012-02-08  8:49                   ` Dor Laor
2012-02-08 11:59                     ` Stefan Hajnoczi
2012-02-08  8:55                   ` Kevin Wolf
2012-02-08  9:47                     ` Ori Mamluk
2012-02-08 10:04                       ` Kevin Wolf
2012-02-08 13:28                         ` [Qemu-devel] [RFC] Replication agent design (was [RFC PATCH] replication agent module) Ori Mamluk
2012-02-08 14:59                           ` Stefan Hajnoczi
2012-02-08 14:59                             ` Stefan Hajnoczi
2012-02-19 13:40                             ` Ori Mamluk
2012-02-20 14:32                               ` Paolo Bonzini
2012-02-21  9:03                                 ` [Qemu-devel] BlockDriverState stack and BlockListeners (was: [RFC] Replication agent design) Kevin Wolf
2012-02-21  9:15                                   ` [Qemu-devel] BlockDriverState stack and BlockListeners Paolo Bonzini
2012-02-21  9:49                                     ` Kevin Wolf
2012-02-21 10:09                                       ` Paolo Bonzini
2012-02-21 10:51                                         ` Kevin Wolf [this message]
2012-02-21 11:36                                           ` Paolo Bonzini
2012-02-21 12:22                                             ` Stefan Hajnoczi
2012-02-21 12:57                                               ` Paolo Bonzini
2012-02-21 15:49                                               ` Markus Armbruster
2012-02-21 13:10                                             ` Kevin Wolf
2012-02-21 13:21                                               ` Paolo Bonzini
2012-02-21 15:56                                               ` Markus Armbruster
2012-02-21 16:04                                                 ` Kevin Wolf
2012-02-21 16:19                                                   ` Markus Armbruster
2012-02-21 16:39                                                     ` Kevin Wolf
2012-02-21 17:16                                               ` Stefan Hajnoczi
2012-02-21 10:20                                       ` Ori Mamluk
2012-02-29  8:38                                   ` Ori Mamluk
2012-03-03 11:46                                     ` Stefan Hajnoczi
2012-03-04  5:14                                       ` Ori Mamluk
2012-03-04  8:56                                         ` Paolo Bonzini
2012-03-05 12:04                                         ` Stefan Hajnoczi
2012-02-08 11:02                   ` [Qemu-devel] [RFC PATCH] replication agent module Stefan Hajnoczi
2012-02-08 13:00                     ` [Qemu-devel] [RFC] Replication agent requirements (was [RFC PATCH] replication agent module) Ori Mamluk
2012-02-08 13:30                       ` Anthony Liguori
2012-02-08 12:03                   ` [Qemu-devel] [RFC PATCH] replication agent module Stefan Hajnoczi
2012-02-08 12:46                     ` Paolo Bonzini
2012-02-08 14:39                       ` Stefan Hajnoczi
2012-02-08 14:55                         ` Paolo Bonzini
2012-02-08 15:07                           ` Stefan Hajnoczi
2012-02-07 14:53             ` Kevin Wolf
2012-02-07 15:00             ` Anthony Liguori
2012-02-07 13:34 ` Kevin Wolf
2012-02-07 13:50   ` Stefan Hajnoczi
2012-02-07 13:58     ` Paolo Bonzini
2012-02-07 14:05     ` Paolo Bonzini
2012-02-08 12:17       ` Orit Wasserman
2012-02-07 14:18     ` Ori Mamluk
2012-02-07 14:59     ` Anthony Liguori
2012-02-07 15:20       ` Stefan Hajnoczi
2012-02-07 16:25         ` Anthony Liguori
2012-02-21 16:01       ` Markus Armbruster
2012-02-21 17:31         ` Stefan Hajnoczi
2012-02-07 14:45   ` Ori Mamluk
2012-02-08 12:29     ` Orit Wasserman
2012-02-08 11:45   ` Luiz Capitulino

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=4F43773B.6060109@redhat.com \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dlaor@redhat.com \
    --cc=fsimonce@redhat.com \
    --cc=jcody@redhat.com \
    --cc=oded@zerto.com \
    --cc=omamluk@zerto.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=tomer@zertodata.com \
    --cc=yairk@zerto.com \
    --cc=zwu.kernel@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.