All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org
Subject: [PULL 24/51] block: Unify bdrv_child_cb_attach()
Date: Fri, 15 May 2020 14:44:54 +0200	[thread overview]
Message-ID: <20200515124521.335403-25-kwolf@redhat.com> (raw)
In-Reply-To: <20200515124521.335403-1-kwolf@redhat.com>

From: Max Reitz <mreitz@redhat.com>

Make bdrv_child_cb_attach() call bdrv_backing_attach() for children with
a COW role (and drop the reverse call from bdrv_backing_attach()), so it
can be used for any child (with a proper role set).

Because so far no child has a proper role set, we need a temporary new
callback for child_backing.attach that ensures bdrv_backing_attach() is
called for all COW children that do not have their role set yet.

(Also, move bdrv_child_cb_attach() down to group it with
bdrv_inherited_options().)

Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200513110544.176672-13-mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/block.c b/block.c
index b3b978a092..755704a54c 100644
--- a/block.c
+++ b/block.c
@@ -84,6 +84,7 @@ static BlockDriverState *bdrv_open_inherit(const char *filename,
 static void bdrv_inherited_options(BdrvChildRole role, bool parent_is_format,
                                    int *child_flags, QDict *child_options,
                                    int parent_flags, QDict *parent_options);
+static void bdrv_child_cb_attach(BdrvChild *child);
 
 /* If non-zero, use only whitelisted block drivers */
 static int use_bdrv_whitelist;
@@ -1099,12 +1100,6 @@ static void bdrv_child_cb_drained_end(BdrvChild *child,
     bdrv_drained_end_no_poll(bs, drained_end_counter);
 }
 
-static void bdrv_child_cb_attach(BdrvChild *child)
-{
-    BlockDriverState *bs = child->opaque;
-    bdrv_apply_subtree_drain(child, bs);
-}
-
 static void bdrv_child_cb_detach(BdrvChild *child)
 {
     BlockDriverState *bs = child->opaque;
@@ -1252,7 +1247,14 @@ static void bdrv_backing_attach(BdrvChild *c)
                     parent->backing_blocker);
     bdrv_op_unblock(backing_hd, BLOCK_OP_TYPE_BACKUP_TARGET,
                     parent->backing_blocker);
+}
 
+/* XXX: Will be removed along with child_backing */
+static void bdrv_child_cb_attach_backing(BdrvChild *c)
+{
+    if (!(c->role & BDRV_CHILD_COW)) {
+        bdrv_backing_attach(c);
+    }
     bdrv_child_cb_attach(c);
 }
 
@@ -1311,7 +1313,7 @@ static int bdrv_backing_update_filename(BdrvChild *c, BlockDriverState *base,
 const BdrvChildClass child_backing = {
     .parent_is_bds   = true,
     .get_parent_desc = bdrv_child_get_parent_desc,
-    .attach          = bdrv_backing_attach,
+    .attach          = bdrv_child_cb_attach_backing,
     .detach          = bdrv_backing_detach,
     .inherit_options = bdrv_backing_options,
     .drained_begin   = bdrv_child_cb_drained_begin,
@@ -1403,6 +1405,17 @@ static void bdrv_inherited_options(BdrvChildRole role, bool parent_is_format,
     *child_flags = flags;
 }
 
+static void bdrv_child_cb_attach(BdrvChild *child)
+{
+    BlockDriverState *bs = child->opaque;
+
+    if (child->role & BDRV_CHILD_COW) {
+        bdrv_backing_attach(child);
+    }
+
+    bdrv_apply_subtree_drain(child, bs);
+}
+
 static int bdrv_open_flags(BlockDriverState *bs, int flags)
 {
     int open_flags = flags;
-- 
2.25.4



  parent reply	other threads:[~2020-05-15 13:06 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-15 12:44 [PULL 00/51] Block layer patches Kevin Wolf
2020-05-15 12:44 ` [PULL 01/51] iotests/109: Don't mirror with mismatched size Kevin Wolf
2020-05-15 12:44 ` [PULL 02/51] iotests/229: Use blkdebug to inject an error Kevin Wolf
2020-05-15 12:44 ` [PULL 03/51] mirror: Make sure that source and target size match Kevin Wolf
2020-05-15 12:44 ` [PULL 04/51] iotests: Mirror with different source/target size Kevin Wolf
2020-05-15 12:44 ` [PULL 05/51] block/replication.c: Avoid cancelling the job twice Kevin Wolf
2020-05-15 12:44 ` [PULL 06/51] iotests: Fix incomplete type declarations Kevin Wolf
2020-05-15 12:44 ` [PULL 07/51] iotests: Run pylint and mypy in a testcase Kevin Wolf
2020-05-15 12:44 ` [PULL 08/51] block: Add bdrv_make_empty() Kevin Wolf
2020-05-15 12:44 ` [PULL 09/51] block: Add blk_make_empty() Kevin Wolf
2020-05-15 12:44 ` [PULL 10/51] block: Use blk_make_empty() after commits Kevin Wolf
2020-05-15 12:44 ` [PULL 11/51] replication: Avoid blk_make_empty() on read-only child Kevin Wolf
2020-05-15 12:44 ` [PULL 12/51] block: Use bdrv_make_empty() where possible Kevin Wolf
2020-05-15 12:44 ` [PULL 13/51] block: Mark commit, mirror, blkreplay as filters Kevin Wolf
2020-05-15 12:44 ` [PULL 14/51] block: Add BlockDriver.is_format Kevin Wolf
2020-05-15 12:44 ` [PULL 15/51] block: Rename BdrvChildRole to BdrvChildClass Kevin Wolf
2020-05-15 12:44 ` [PULL 16/51] block: Add BdrvChildRole and BdrvChildRoleBits Kevin Wolf
2020-05-15 12:44 ` [PULL 17/51] block: Add BdrvChildRole to BdrvChild Kevin Wolf
2020-05-15 12:44 ` [PULL 18/51] block: Pass BdrvChildRole to bdrv_child_perm() Kevin Wolf
2020-05-15 12:44 ` [PULL 19/51] block: Pass BdrvChildRole to .inherit_options() Kevin Wolf
2020-05-15 12:44 ` [PULL 20/51] block: Pass parent_is_format " Kevin Wolf
2020-05-15 12:44 ` [PULL 21/51] block: Rename bdrv_inherited_options() Kevin Wolf
2020-05-15 12:44 ` [PULL 22/51] block: Add generic bdrv_inherited_options() Kevin Wolf
2020-05-15 12:44 ` [PULL 23/51] block: Use bdrv_inherited_options() Kevin Wolf
2020-05-15 12:44 ` Kevin Wolf [this message]
2020-05-15 12:44 ` [PULL 25/51] block: Unify bdrv_child_cb_detach() Kevin Wolf
2020-05-15 12:44 ` [PULL 26/51] block: Add child_of_bds Kevin Wolf
2020-05-15 12:44 ` [PULL 27/51] block: Distinguish paths in *_format_default_perms Kevin Wolf
2020-05-15 12:44 ` [PULL 28/51] block: Pull out bdrv_default_perms_for_cow() Kevin Wolf
2020-05-15 12:44 ` [PULL 29/51] block: Pull out bdrv_default_perms_for_storage() Kevin Wolf
2020-05-15 12:45 ` [PULL 30/51] block: Relax *perms_for_storage for data children Kevin Wolf
2020-05-15 12:45 ` [PULL 31/51] block: Add bdrv_default_perms() Kevin Wolf
2020-05-15 12:45 ` [PULL 32/51] raw-format: Split raw_read_options() Kevin Wolf
2020-05-15 12:45 ` [PULL 33/51] block: Switch child_format users to child_of_bds Kevin Wolf
2020-05-15 12:45 ` [PULL 34/51] block: Drop child_format Kevin Wolf
2020-05-15 12:45 ` [PULL 35/51] block: Make backing files child_of_bds children Kevin Wolf
2020-05-15 12:45 ` [PULL 36/51] block: Drop child_backing Kevin Wolf
2020-05-15 12:45 ` [PULL 37/51] block: Make format drivers use child_of_bds Kevin Wolf
2020-05-15 12:45 ` [PULL 38/51] block: Make filter " Kevin Wolf
2020-05-15 12:45 ` [PULL 39/51] block: Use child_of_bds in remaining places Kevin Wolf
2020-05-15 12:45 ` [PULL 40/51] tests: Use child_of_bds instead of child_file Kevin Wolf
2020-05-15 12:45 ` [PULL 41/51] block: Use bdrv_default_perms() Kevin Wolf
2020-05-15 12:45 ` [PULL 42/51] block: Make bdrv_filter_default_perms() static Kevin Wolf
2020-05-15 12:45 ` [PULL 43/51] block: Drop bdrv_format_default_perms() Kevin Wolf
2020-05-15 12:45 ` [PULL 44/51] block: Drop child_file Kevin Wolf
2020-05-15 12:45 ` [PULL 45/51] block: Pass BdrvChildRole in remaining cases Kevin Wolf
2020-05-15 12:45 ` [PULL 46/51] block: Drop @child_class from bdrv_child_perm() Kevin Wolf
2020-05-15 12:45 ` [PULL 47/51] block/block-copy: Fix uninitialized variable in block_copy_task_entry Kevin Wolf
2020-05-15 12:45 ` [PULL 48/51] block/block-copy: Simplify block_copy_do_copy() Kevin Wolf
2020-05-15 12:45 ` [PULL 49/51] iotests: log messages from notrun() Kevin Wolf
2020-05-15 12:45 ` [PULL 50/51] hw/ide/ahci: Log lost IRQs Kevin Wolf
2020-05-15 12:45 ` [PULL 51/51] iotests/030: Reduce run time by unthrottling job earlier Kevin Wolf
2020-05-15 14:28 ` [PULL 00/51] Block layer patches Peter Maydell
2020-05-15 20:30 ` no-reply

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=20200515124521.335403-25-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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 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.