qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Max Reitz <mreitz@redhat.com>
Cc: Alberto Garcia <berto@igalia.com>,
	qemu-block@nongnu.org, qemu-devel@nongnu.org,
	Markus Armbruster <armbru@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v6 07/15] block: Move BDS close notifiers into BB
Date: Mon, 9 Nov 2015 17:04:43 +0100	[thread overview]
Message-ID: <20151109160443.GG3621@noname.redhat.com> (raw)
In-Reply-To: <1446663467-22485-8-git-send-email-mreitz@redhat.com>

Am 04.11.2015 um 19:57 hat Max Reitz geschrieben:
> The only remaining user of the BDS close notifiers is NBD which uses
> them to determine when a BDS tree is being ejected. This patch removes
> the BDS-level close notifiers and adds a notifier list to the
> BlockBackend structure that is invoked whenever a BDS is removed.
> 
> Symmetrically to that, another notifier list is added that is invoked
> whenever a BDS is inserted. The dataplane implementations for virtio-blk
> and virtio-scsi use both notifier types for setting up and removing op
> blockers. This is not only important for setting up the op blockers on
> insertion, but also for removing them on ejection since bdrv_delete()
> asserts that there are no op blockers set up.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>

I think this needs to be split into smaller patches:

1. Add the new BlockBackend notifiers
2. Use them in virtio-blk in order to fix... removable virtio-blk
   devices, or what is it?
3. Convert NBD
4. Remove old close notifiers

>  block.c                         |  7 ----
>  block/block-backend.c           | 19 +++++++---
>  blockdev-nbd.c                  | 37 +-------------------
>  hw/block/dataplane/virtio-blk.c | 77 +++++++++++++++++++++++++++++++----------
>  hw/scsi/virtio-scsi.c           | 59 +++++++++++++++++++++++++++++++
>  include/block/block.h           |  1 -
>  include/block/block_int.h       |  2 --
>  include/hw/virtio/virtio-scsi.h | 10 ++++++
>  include/sysemu/block-backend.h  |  3 +-
>  nbd.c                           | 13 +++++++
>  10 files changed, 159 insertions(+), 69 deletions(-)

> diff --git a/block/block-backend.c b/block/block-backend.c
> index 6f9309f..38580f7 100644
> --- a/block/block-backend.c
> +++ b/block/block-backend.c
> @@ -48,6 +48,8 @@ struct BlockBackend {
>      BlockdevOnError on_read_error, on_write_error;
>      bool iostatus_enabled;
>      BlockDeviceIoStatus iostatus;
> +
> +    NotifierList remove_bs_notifiers, insert_bs_notifiers;
>  };
>  
>  typedef struct BlockBackendAIOCB {
> @@ -98,6 +100,8 @@ BlockBackend *blk_new(const char *name, Error **errp)
>      blk = g_new0(BlockBackend, 1);
>      blk->name = g_strdup(name);
>      blk->refcnt = 1;
> +    notifier_list_init(&blk->remove_bs_notifiers);
> +    notifier_list_init(&blk->insert_bs_notifiers);
>      QTAILQ_INSERT_TAIL(&blk_backends, blk, link);
>      return blk;
>  }
> @@ -343,6 +347,8 @@ void blk_hide_on_behalf_of_hmp_drive_del(BlockBackend *blk)
>   */
>  void blk_remove_bs(BlockBackend *blk)
>  {
> +    notifier_list_notify(&blk->remove_bs_notifiers, blk);
> +
>      blk_update_root_state(blk);
>  
>      blk->bs->blk = NULL;
> @@ -359,6 +365,8 @@ void blk_insert_bs(BlockBackend *blk, BlockDriverState *bs)
>      bdrv_ref(bs);
>      blk->bs = bs;
>      bs->blk = blk;
> +
> +    notifier_list_notify(&blk->insert_bs_notifiers, blk);
>  }

Do we want to notify on BB deletion, too? It's also some kind of removal
of a connection between BB and BDS.  In other words, should blk_delete()
call blk_remove_bs() rather than bdrv_unref()?

[ Edit: I see that's what the next patch does. Good. ]

Should blk_unref() also assert that the notifier list is empty?
Otherwise we would be leaking notifiers.

Kevin

  reply	other threads:[~2015-11-09 16:05 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-04 18:57 [Qemu-devel] [PATCH v6 for-2.6 00/15] block: Rework bdrv_close_all() Max Reitz
2015-11-04 18:57 ` [Qemu-devel] [PATCH v6 01/15] blockdev: Add missing bdrv_unref() in drive-backup Max Reitz
2015-11-09 13:21   ` Alberto Garcia
2015-11-04 18:57 ` [Qemu-devel] [PATCH v6 02/15] blockjob: Call bdrv_unref() on creation error Max Reitz
2015-11-09 13:23   ` Alberto Garcia
2015-11-04 18:57 ` [Qemu-devel] [PATCH v6 03/15] block: Release dirty bitmaps in bdrv_close() Max Reitz
2015-11-06 18:59   ` [Qemu-devel] [Qemu-block] " John Snow
2015-11-09 16:21     ` Max Reitz
2015-11-09 21:00       ` Max Reitz
2015-11-09 16:04   ` [Qemu-devel] " Kevin Wolf
2015-11-09 16:47     ` Max Reitz
2015-11-04 18:57 ` [Qemu-devel] [PATCH v6 04/15] iotests: Move _filter_nbd into common.filter Max Reitz
2015-11-09 16:04   ` Kevin Wolf
2015-11-09 18:17     ` Max Reitz
2015-11-09 18:20       ` Max Reitz
2015-11-10 10:25       ` Kevin Wolf
2015-11-04 18:57 ` [Qemu-devel] [PATCH v6 05/15] iotests: Make redirecting qemu's stderr optional Max Reitz
2015-11-04 18:57 ` [Qemu-devel] [PATCH v6 06/15] iotests: Add test for eject under NBD server Max Reitz
2015-11-04 18:57 ` [Qemu-devel] [PATCH v6 07/15] block: Move BDS close notifiers into BB Max Reitz
2015-11-09 16:04   ` Kevin Wolf [this message]
2015-11-09 16:50     ` Max Reitz
2015-11-09 16:59       ` Kevin Wolf
2015-11-04 18:57 ` [Qemu-devel] [PATCH v6 08/15] block: Use blk_remove_bs() in blk_delete() Max Reitz
2015-11-04 18:57 ` [Qemu-devel] [PATCH v6 09/15] blockdev: Use blk_remove_bs() in do_drive_del() Max Reitz
2015-11-04 18:57 ` [Qemu-devel] [PATCH v6 10/15] block: Make bdrv_close() static Max Reitz
2015-11-09 13:25   ` Alberto Garcia
2015-11-04 18:57 ` [Qemu-devel] [PATCH v6 11/15] block: Add list of all BlockDriverStates Max Reitz
2015-11-04 18:57 ` [Qemu-devel] [PATCH v6 12/15] blockdev: Keep track of monitor-owned BDS Max Reitz
2015-11-09 15:05   ` Alberto Garcia
2015-11-09 16:26     ` Kevin Wolf
2015-11-09 16:38       ` Alberto Garcia
2015-11-09 16:28     ` Max Reitz
2015-11-04 18:57 ` [Qemu-devel] [PATCH v6 13/15] block: Add blk_remove_all_bs() Max Reitz
2015-11-04 18:57 ` [Qemu-devel] [PATCH v6 14/15] block: Rewrite bdrv_close_all() Max Reitz
2015-11-05 17:15   ` Paolo Bonzini
2015-11-05 17:37     ` Max Reitz
2015-11-05 17:40       ` Paolo Bonzini
2015-11-05 17:44         ` Eric Blake
2015-11-05 17:54           ` Paolo Bonzini
2015-11-04 18:57 ` [Qemu-devel] [PATCH v6 15/15] iotests: Add test for multiple BB on BDS tree Max Reitz
2015-11-09 16:03 ` [Qemu-devel] [PATCH v6 for-2.6 00/15] block: Rework bdrv_close_all() 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=20151109160443.GG3621@noname.redhat.com \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=berto@igalia.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --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 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).