All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Benoît Canet" <benoit.canet@irqsave.net>
To: Kevin Wolf <kwolf@redhat.com>
Cc: "Benoît Canet" <benoit.canet@irqsave.net>,
	famz@redhat.com, "Markus Armbruster" <armbru@redhat.com>,
	stefanha@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 02/23] block: New BlockBackend
Date: Wed, 10 Sep 2014 13:51:25 +0200	[thread overview]
Message-ID: <20140910115124.GA26939@irqsave.net> (raw)
In-Reply-To: <20140910114417.GB844@noname.str.redhat.com>

The Wednesday 10 Sep 2014 à 13:44:17 (+0200), Kevin Wolf wrote :
> Am 10.09.2014 um 13:34 hat Benoît Canet geschrieben:
> > The Wednesday 10 Sep 2014 à 10:13:31 (+0200), Markus Armbruster wrote :
> > > A block device consists of a frontend device model and a backend.
> > > 
> > > A block backend has a tree of block drivers doing the actual work.
> > > The tree is managed by the block layer.
> > > 
> > > We currently use a single abstraction BlockDriverState both for tree
> > > nodes and the backend as a whole.  Drawbacks:
> > > 
> > > * Its API includes both stuff that makes sense only at the block
> > >   backend level (root of the tree) and stuff that's only for use
> > >   within the block layer.  This makes the API bigger and more complex
> > >   than necessary.  Moreover, it's not obvious which interfaces are
> > >   meant for device models, and which really aren't.
> > > 
> > > * Since device models keep a reference to their backend, the backend
> > >   object can't just be destroyed.  But for media change, we need to
> > >   replace the tree.  Our solution is to make the BlockDriverState
> > >   generic, with actual driver state in a separate object, pointed to
> > >   by member opaque.  That lets us replace the tree by deinitializing
> > >   and reinitializing its root.  This special need of the root makes
> > >   the data structure awkward everywhere in the tree.
> > > 
> > > The general plan is to separate the APIs into "block backend", for use
> > > by device models, monitor and whatever other code dealing with block
> > > backends, and "block driver", for use by the block layer and whatever
> > > other code (if any) dealing with trees and tree nodes.
> > > 
> > > Code dealing with block backends, device models in particular, should
> > > become completely oblivious of BlockDriverState.  This should let us
> > > clean up both APIs, and the tree data structures.
> > > 
> > > This commit is a first step.  It creates a minimal "block backend"
> > > API: type BlockBackend and functions to create, destroy and find them.
> > > BlockBackend objects are created and destroyed, but not yet used for
> > > anything; that'll come shortly.
> > > 
> > > BlockBackend is reference-counted.  Its reference count never exceeds
> > > one so far, but that's going to change.
> > > 
> > > Signed-off-by: Markus Armbruster <armbru@redhat.com>
> 
> > > +/**
> > > + * blk_ref:
> > > + *
> > > + * Increment @blk's reference count.
> > > + */
> > > +void blk_ref(BlockBackend *blk)
> > > +{
> > 
> > if blk_unref you take care of doing
> > +    if (blk) {
> > to make sur the user does not pass a NULL pointer.
> > Transforming blk into a NULL pointer is not a side effect
> > of blk_unref so this test is designed to prevent a user
> > brain damage.
> 
> Not really, I'd rather consider it a convenience feature, just like
> you're allowed to call free(NULL) or bdrv_unref(NULL) without having a
> check for != NULL everywhere. This will be handy especially in error
> paths.

ok I see the spirit of it.

Benoit
> 
> > If the user can be brain damaged to pass a NULL to blk_unref he
> > could be equally stupid passing a NULL to blk_ref.
> > Why not adding the same test here ?
> 
> Whereas in blk_ref() it really wouldn't make any sense.
> 
> Kevin
> 

  reply	other threads:[~2014-09-10 11:52 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-10  8:13 [Qemu-devel] [PATCH 00/23] Split BlockBackend off BDS with an axe Markus Armbruster
2014-09-10  8:13 ` [Qemu-devel] [PATCH 01/23] block: Split bdrv_new_named() off bdrv_new() Markus Armbruster
2014-09-10 11:03   ` Benoît Canet
2014-09-10 15:05     ` Eric Blake
2014-09-11  8:20       ` Markus Armbruster
2014-09-11  8:29     ` Markus Armbruster
2014-09-10 15:07   ` Eric Blake
2014-09-10 15:27   ` Benoît Canet
2014-09-10 21:22   ` Benoît Canet
2014-09-11  6:33   ` Fam Zheng
2014-09-10  8:13 ` [Qemu-devel] [PATCH 02/23] block: New BlockBackend Markus Armbruster
2014-09-10  9:56   ` Kevin Wolf
2014-09-11 10:03     ` Markus Armbruster
2014-09-11 11:45       ` Markus Armbruster
2014-09-11 14:38       ` Markus Armbruster
2014-09-10 11:34   ` Benoît Canet
2014-09-10 11:44     ` Kevin Wolf
2014-09-10 11:51       ` Benoît Canet [this message]
2014-09-11 10:11     ` Markus Armbruster
2014-09-10 12:40   ` Benoît Canet
2014-09-10 12:46     ` Benoît Canet
2014-09-11 10:22       ` Markus Armbruster
2014-09-11 10:21     ` Markus Armbruster
2014-09-10  8:13 ` [Qemu-devel] [PATCH 03/23] block: Connect BlockBackend to BlockDriverState Markus Armbruster
2014-09-10 11:55   ` Benoît Canet
2014-09-11 10:52     ` Markus Armbruster
2014-09-10 12:24   ` Kevin Wolf
2014-09-11 15:27     ` Markus Armbruster
2014-09-10  8:13 ` [Qemu-devel] [PATCH 04/23] block: Connect BlockBackend and DriveInfo Markus Armbruster
2014-09-10 13:08   ` Benoît Canet
2014-09-11 18:03     ` Markus Armbruster
2014-09-11 20:43       ` Eric Blake
2014-09-10 13:30   ` Kevin Wolf
2014-09-11 17:41     ` Markus Armbruster
2014-09-10  8:13 ` [Qemu-devel] [PATCH 05/23] block: Make BlockBackend own its BlockDriverState Markus Armbruster
2014-09-10 10:14   ` Kevin Wolf
2014-09-11 18:38     ` Markus Armbruster
2014-09-10  8:13 ` [Qemu-devel] [PATCH 06/23] block: Eliminate bdrv_states, use block_next() instead Markus Armbruster
2014-09-11 10:25   ` Benoît Canet
2014-09-10  8:13 ` [Qemu-devel] [PATCH 07/23] block: Eliminate bdrv_iterate(), use bdrv_next() Markus Armbruster
2014-09-11 10:46   ` Benoît Canet
2014-09-11 18:44     ` Markus Armbruster
2014-09-10  8:13 ` [Qemu-devel] [PATCH 08/23] block: Eliminate BlockDriverState member device_name[] Markus Armbruster
2014-09-10 16:09   ` Eric Blake
2014-09-11 18:45     ` Markus Armbruster
2014-09-11 11:34   ` Benoît Canet
2014-09-11 11:43     ` Benoît Canet
2014-09-11 13:00     ` Eric Blake
2014-09-11 13:18       ` Benoît Canet
2014-09-11 19:11         ` Markus Armbruster
2014-09-11 19:01     ` Markus Armbruster
2014-09-10  8:13 ` [Qemu-devel] [PATCH 09/23] block: Merge BlockBackend and BlockDriverState name spaces Markus Armbruster
2014-09-10  8:13 ` [Qemu-devel] [PATCH 10/23] block: Eliminate DriveInfo member bdrv, use blk_by_legacy_dinfo() Markus Armbruster
2014-09-11 12:07   ` Benoît Canet
2014-09-11 19:20     ` Markus Armbruster
2014-09-11 17:06   ` Benoît Canet
2014-09-11 19:12     ` Markus Armbruster
2014-09-11 19:34       ` Benoît Canet
2014-09-11 19:40         ` Eric Blake
2014-09-12  6:38           ` Markus Armbruster
2014-09-10  8:13 ` [Qemu-devel] [PATCH 11/23] block: Rename BlockDriverAIOCB* to BlockAIOCB* Markus Armbruster
2014-09-11 12:15   ` Benoît Canet
2014-09-11 19:23     ` Markus Armbruster
2014-09-10  8:13 ` [Qemu-devel] [PATCH 12/23] virtio-blk: Drop redundant VirtIOBlock member conf Markus Armbruster
2014-09-10  8:13 ` [Qemu-devel] [PATCH 13/23] virtio-blk: Rename VirtIOBlkConf variables to conf Markus Armbruster
2014-09-10  8:13 ` [Qemu-devel] [PATCH 14/23] hw: Convert from BlockDriverState to BlockBackend, mostly Markus Armbruster
2014-09-10  8:13 ` [Qemu-devel] [PATCH 15/23] ide: Complete conversion from BlockDriverState to BlockBackend Markus Armbruster
2014-09-10  8:13 ` [Qemu-devel] [PATCH 16/23] pc87312: Drop unused members of PC87312State Markus Armbruster
2014-09-10  8:13 ` [Qemu-devel] [PATCH 17/23] blockdev: Drop superfluous DriveInfo member id Markus Armbruster
2014-09-10  8:13 ` [Qemu-devel] [PATCH 18/23] blockdev: Fix blockdev-add not to create IDE drive (0, 0) Markus Armbruster
2014-09-10  8:13 ` [Qemu-devel] [PATCH 19/23] blockdev: Drop DriveInfo member enable_auto_del Markus Armbruster
2014-09-10  8:13 ` [Qemu-devel] [PATCH 20/23] block/qapi: Convert qmp_query_block() to BlockBackend Markus Armbruster
2014-09-10  8:13 ` [Qemu-devel] [PATCH 21/23] blockdev: Convert qmp_eject(), qmp_change_blockdev() " Markus Armbruster
2014-09-10  8:13 ` [Qemu-devel] [PATCH 22/23] block: Lift device model API into BlockBackend Markus Armbruster
2014-09-10  8:13 ` [Qemu-devel] [PATCH 23/23] block: Make device model's references to BlockBackend strong Markus Armbruster
2014-09-11 19:24 ` [Qemu-devel] [PATCH 00/23] Split BlockBackend off BDS with an axe Markus Armbruster

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=20140910115124.GA26939@irqsave.net \
    --to=benoit.canet@irqsave.net \
    --cc=armbru@redhat.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --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 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.