All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
To: Max Reitz <mreitz@redhat.com>, qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, armbru@redhat.com, eblake@redhat.com,
	ehabkost@redhat.com, berrange@redhat.com, pbonzini@redhat.com,
	jsnow@redhat.com, kwolf@redhat.com, den@openvz.org
Subject: Re: [PATCH 01/21] block: introduce bdrv_replace_child_bs()
Date: Wed, 19 May 2021 13:12:04 +0300	[thread overview]
Message-ID: <7291edd6-f5e2-63d3-0633-9d55fd14cfc6@virtuozzo.com> (raw)
In-Reply-To: <ee302de8-bd22-b43c-f30f-eedce438d825@redhat.com>

17.05.2021 15:09, Max Reitz wrote:
> On 17.05.21 08:44, Vladimir Sementsov-Ogievskiy wrote:
>> Add function to transactionally replace bs inside BdrvChild.
>>
>> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
>> ---
>>   include/block/block.h |  2 ++
>>   block.c               | 36 ++++++++++++++++++++++++++++++++++++
>>   2 files changed, 38 insertions(+)
> 
> As you may guess, I know little about the rewritten replacing functions, so this is kind of difficult to review for me.  However, nothing looks out of place, and the function looks sufficiently similar to bdrv_replace_node_common() to make me happy.
> 
>> diff --git a/include/block/block.h b/include/block/block.h
>> index 82185965ff..f9d5fcb108 100644
>> --- a/include/block/block.h
>> +++ b/include/block/block.h
>> @@ -361,6 +361,8 @@ int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top,
>>                   Error **errp);
>>   int bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
>>                         Error **errp);
>> +int bdrv_replace_child_bs(BdrvChild *child, BlockDriverState *new_bs,
>> +                          Error **errp);
>>   BlockDriverState *bdrv_insert_node(BlockDriverState *bs, QDict *node_options,
>>                                      int flags, Error **errp);
>>   int bdrv_drop_filter(BlockDriverState *bs, Error **errp);
>> diff --git a/block.c b/block.c
>> index 9ad725d205..755fa53d85 100644
>> --- a/block.c
>> +++ b/block.c
>> @@ -4961,6 +4961,42 @@ out:
>>       return ret;
>>   }
>> +int bdrv_replace_child_bs(BdrvChild *child, BlockDriverState *new_bs,
>> +                          Error **errp)
>> +{
>> +    int ret;
>> +    Transaction *tran = tran_new();
>> +    g_autoptr(GHashTable) found = NULL;
>> +    g_autoptr(GSList) refresh_list = NULL;
>> +    BlockDriverState *old_bs = child->bs;
>> +
>> +    if (old_bs) {
> 
> Hm.  Can child->bs be ever NULL?

Seems it can. For example we have hmp_drive_del command, that removes bs from blk :(

qmp eject and blockdev-remove-medium seems do it too.

> 
>> +        bdrv_ref(old_bs);
>> +        bdrv_drained_begin(old_bs);
>> +    }
>> +    bdrv_drained_begin(new_bs);
> 
> (I was wondering why we couldn’t handle the new_bs == NULL case here to replace bdrv_remove_filter_or_cow_child(), but then I realized it’s probably because that’s kind of difficult, precisely because child->bs at least should generally be non-NULL.  Which is why bdrv_remove_filter_or_cow_child() needs to add its own transaction entry to handle the BdrvChild object and the pointer to it.
> 
> Hence me wondering whether we could assume child->bs not to be NULL.)
> 
>> +
>> +    bdrv_replace_child(child, new_bs, tran);
>> +
>> +    found = g_hash_table_new(NULL, NULL);
>> +    if (old_bs) {
>> +        refresh_list = bdrv_topological_dfs(refresh_list, found, old_bs);
>> +    }
>> +    refresh_list = bdrv_topological_dfs(refresh_list, found, new_bs);
>> +
>> +    ret = bdrv_list_refresh_perms(refresh_list, NULL, tran, errp);
> 
> Speaking of bdrv_remove_filter_or_cow_child(): That function doesn’t refresh permissions.  I think it’s correct to do it here, so the following question doesn’t really concern this patch, but: Why don’t we do it there?
> 
> I guess it’s because we expect the node to go away anyway, so we don’t need to refresh the permissions.  And that assumption should hold true right now, given its callers.  But is that a safe assumption in general?  Would there be a problem if we refreshed permissions there?  Or is not refreshing permissions just part of the function’s interface?
> 
> Max
> 
>> +
>> +    tran_finalize(tran, ret);
>> +
>> +    if (old_bs) {
>> +        bdrv_drained_end(old_bs);
>> +        bdrv_unref(old_bs);
>> +    }
>> +    bdrv_drained_end(new_bs);
>> +
>> +    return ret;
>> +}
>> +
>>   static void bdrv_delete(BlockDriverState *bs)
>>   {
>>       assert(bdrv_op_blocker_is_empty(bs));
>>
> 


-- 
Best regards,
Vladimir


  parent reply	other threads:[~2021-05-19 10:22 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-17  6:44 [PATCH 00/21] block: publish backup-top filter Vladimir Sementsov-Ogievskiy
2021-05-17  6:44 ` [PATCH] block/copy-on-read: use bdrv_drop_filter() and drop s->active Vladimir Sementsov-Ogievskiy
2021-05-17  6:44 ` [PATCH 01/21] block: introduce bdrv_replace_child_bs() Vladimir Sementsov-Ogievskiy
2021-05-17 12:09   ` Max Reitz
2021-05-17 14:30     ` Vladimir Sementsov-Ogievskiy
2021-05-17 15:51       ` Max Reitz
2021-05-17 18:05         ` Vladimir Sementsov-Ogievskiy
2021-05-19 10:12     ` Vladimir Sementsov-Ogievskiy [this message]
2021-05-19 11:11       ` Max Reitz
2021-05-19 11:14         ` Vladimir Sementsov-Ogievskiy
2021-05-17  6:44 ` [PATCH 02/21] block: introduce blk_replace_bs Vladimir Sementsov-Ogievskiy
2021-05-17 12:32   ` Max Reitz
2021-05-17  6:44 ` [PATCH 03/21] qdev-properties: PropertyInfo: add realized_set_allowed field Vladimir Sementsov-Ogievskiy
2021-05-17 12:40   ` Max Reitz
2021-05-17 14:33     ` Vladimir Sementsov-Ogievskiy
2021-05-17  6:44 ` [PATCH 04/21] qdev: allow setting drive property for realized device Vladimir Sementsov-Ogievskiy
2021-05-17 15:48   ` Max Reitz
2021-05-17 18:09     ` Vladimir Sementsov-Ogievskiy
2021-05-18  9:09       ` Max Reitz
2021-05-18  9:20         ` Vladimir Sementsov-Ogievskiy
2021-05-17  6:44 ` [PATCH 05/21] block: rename backup-top to copy-before-write Vladimir Sementsov-Ogievskiy
2021-05-17 16:05   ` Max Reitz
2021-05-17 19:42     ` Vladimir Sementsov-Ogievskiy
2021-05-18  9:37       ` Max Reitz
2021-05-17  6:44 ` [PATCH 06/21] block/backup: drop support for copy_range Vladimir Sementsov-Ogievskiy
2021-05-17 16:20   ` Max Reitz
2021-05-17  6:44 ` [PATCH 07/21] block-copy: always set BDRV_REQ_SERIALISING flag Vladimir Sementsov-Ogievskiy
2021-05-17 16:46   ` Max Reitz
2021-05-17  6:44 ` [PATCH 08/21] block/backup: stricter backup_calculate_cluster_size() Vladimir Sementsov-Ogievskiy
2021-05-17 16:57   ` Max Reitz
2021-05-17 19:53     ` Vladimir Sementsov-Ogievskiy
2021-05-17  6:44 ` [PATCH 09/21] block/backup: move cluster size calculation to block-copy Vladimir Sementsov-Ogievskiy
2021-05-17 17:09   ` Max Reitz
2021-05-17  6:44 ` [PATCH 10/21] block/copy-before-write: relax permission requirements when no parents Vladimir Sementsov-Ogievskiy
2021-05-18 11:10   ` Max Reitz
2021-05-18 12:16     ` Vladimir Sementsov-Ogievskiy
2021-05-17  6:44 ` [PATCH 11/21] block/copy-before-write: use file child instead of backing Vladimir Sementsov-Ogievskiy
2021-05-18 11:47   ` Max Reitz
2021-05-18 12:21     ` Vladimir Sementsov-Ogievskiy
2021-05-17  6:44 ` [PATCH 12/21] block/copy-before-write: bdrv_cbw_append(): replace child at last Vladimir Sementsov-Ogievskiy
2021-05-18 12:35   ` Max Reitz
2021-05-17  6:44 ` [PATCH 13/21] block/copy-before-write: introduce cbw_init() Vladimir Sementsov-Ogievskiy
2021-05-18 12:53   ` Max Reitz
2021-05-17  6:44 ` [PATCH 14/21] block/copy-before-write: cbw_init(): rename variables Vladimir Sementsov-Ogievskiy
2021-05-18 13:01   ` Max Reitz
2021-05-17  6:44 ` [PATCH 15/21] block/copy-before-write: cbw_init(): use file child after attaching Vladimir Sementsov-Ogievskiy
2021-05-18 13:43   ` Max Reitz
2021-05-17  6:44 ` [PATCH 16/21] block/copy-before-write: cbw_init(): use options Vladimir Sementsov-Ogievskiy
2021-05-18 13:56   ` Max Reitz
2021-05-18 14:24     ` Vladimir Sementsov-Ogievskiy
2021-05-18 14:29       ` Max Reitz
2021-05-18 14:32         ` Vladimir Sementsov-Ogievskiy
2021-05-17  6:44 ` [PATCH 17/21] block/block-copy: switch to fully set bitmap by default Vladimir Sementsov-Ogievskiy
2021-05-18 14:22   ` Max Reitz
2021-05-18 14:31     ` Vladimir Sementsov-Ogievskiy
2021-05-17  6:44 ` [PATCH 18/21] block/block-copy: make setting progress optional Vladimir Sementsov-Ogievskiy
2021-05-18 14:26   ` Max Reitz
2021-05-18 14:35     ` Vladimir Sementsov-Ogievskiy
2021-05-17  6:44 ` [PATCH 19/21] block/copy-before-write: make public block driver Vladimir Sementsov-Ogievskiy
2021-05-18 14:46   ` Max Reitz
2021-05-17  6:44 ` [PATCH 20/21] qapi: publish copy-before-write filter Vladimir Sementsov-Ogievskiy
2021-05-18 14:48   ` Max Reitz
2021-05-18 14:56     ` Vladimir Sementsov-Ogievskiy
2021-05-17  6:44 ` [PATCH 21/21] itotests/222: add test-case for " Vladimir Sementsov-Ogievskiy
2021-05-18 15:24   ` Max Reitz
2021-05-18 15:41     ` Vladimir Sementsov-Ogievskiy

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=7291edd6-f5e2-63d3-0633-9d55fd14cfc6@virtuozzo.com \
    --to=vsementsov@virtuozzo.com \
    --cc=armbru@redhat.com \
    --cc=berrange@redhat.com \
    --cc=den@openvz.org \
    --cc=eblake@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@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 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.