From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7AABC28D18 for ; Wed, 5 Jun 2019 12:34:32 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 94FA0206BA for ; Wed, 5 Jun 2019 12:34:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94FA0206BA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([127.0.0.1]:40672 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYV7f-0000XI-Q1 for qemu-devel@archiver.kernel.org; Wed, 05 Jun 2019 08:34:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYV5q-00081j-Dv for qemu-devel@nongnu.org; Wed, 05 Jun 2019 08:32:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYV5p-0006Ki-82 for qemu-devel@nongnu.org; Wed, 05 Jun 2019 08:32:38 -0400 Received: from relay.sw.ru ([185.231.240.75]:52306) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hYV5o-0006EG-Uf; Wed, 05 Jun 2019 08:32:37 -0400 Received: from [10.94.3.0] (helo=kvm.qa.sw.ru) by relay.sw.ru with esmtp (Exim 4.91) (envelope-from ) id 1hYV5i-0001rG-5k; Wed, 05 Jun 2019 15:32:30 +0300 From: Vladimir Sementsov-Ogievskiy To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Wed, 5 Jun 2019 15:32:28 +0300 Message-Id: <20190605123229.92848-2-vsementsov@virtuozzo.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20190605123229.92848-1-vsementsov@virtuozzo.com> References: <20190605123229.92848-1-vsementsov@virtuozzo.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 185.231.240.75 Subject: [Qemu-devel] [PATCH v2 1/2] block: introduce pinned blk X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, jsnow@redhat.com, mreitz@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add stay_at_node fields to BlockBackend and BdrvChild, for the same behavior as stay_at_node field of BdrvChildRole. It will be used for block-job blk. Signed-off-by: Vladimir Sementsov-Ogievskiy --- include/block/block_int.h | 6 ++++++ include/sysemu/block-backend.h | 2 ++ block.c | 2 +- block/block-backend.c | 25 ++++++++++++++++++++++++- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/include/block/block_int.h b/include/block/block_int.h index 06df2bda1b..1a2eebd904 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -729,6 +729,12 @@ struct BdrvChild { */ bool frozen; + /* + * This link should not be modified in bdrv_replace_node process. Used by + * should_update_child() + */ + bool stay_at_node; + QLIST_ENTRY(BdrvChild) next; QLIST_ENTRY(BdrvChild) next_parent; }; diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 733c4957eb..fb248be977 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -77,6 +77,8 @@ typedef struct BlockBackendPublic { } BlockBackendPublic; BlockBackend *blk_new(AioContext *ctx, uint64_t perm, uint64_t shared_perm); +BlockBackend *blk_new_pinned(AioContext *ctx, + uint64_t perm, uint64_t shared_perm); BlockBackend *blk_new_open(const char *filename, const char *reference, QDict *options, int flags, Error **errp); int blk_get_refcnt(BlockBackend *blk); diff --git a/block.c b/block.c index e3e77feee0..fda92c8629 100644 --- a/block.c +++ b/block.c @@ -3971,7 +3971,7 @@ static bool should_update_child(BdrvChild *c, BlockDriverState *to) GHashTable *found; bool ret; - if (c->role->stay_at_node) { + if (c->stay_at_node || c->role->stay_at_node) { return false; } diff --git a/block/block-backend.c b/block/block-backend.c index f5d9407d20..cd59f98e51 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -88,6 +88,11 @@ struct BlockBackend { * Accessed with atomic ops. */ unsigned int in_flight; + + /* + * On blk_insert_bs() new child will inherit @stay_at_node. + */ + bool stay_at_node; }; typedef struct BlockBackendAIOCB { @@ -321,9 +326,14 @@ static const BdrvChildRole child_root = { * to other users of the attached node. * Both sets of permissions can be changed later using blk_set_perm(). * + * @stay_at_node is used to set stay_at_node field of child, attached in + * blk_insert_bs(). If true, child bs will not be updated on bdrv_replace_node. + * * Return the new BlockBackend on success, null on failure. */ -BlockBackend *blk_new(AioContext *ctx, uint64_t perm, uint64_t shared_perm) +static BlockBackend *blk_new_common(AioContext *ctx, + uint64_t perm, uint64_t shared_perm, + bool stay_at_node) { BlockBackend *blk; @@ -332,6 +342,7 @@ BlockBackend *blk_new(AioContext *ctx, uint64_t perm, uint64_t shared_perm) blk->ctx = ctx; blk->perm = perm; blk->shared_perm = shared_perm; + blk->stay_at_node = stay_at_node; blk_set_enable_write_cache(blk, true); blk->on_read_error = BLOCKDEV_ON_ERROR_REPORT; @@ -347,6 +358,17 @@ BlockBackend *blk_new(AioContext *ctx, uint64_t perm, uint64_t shared_perm) return blk; } +BlockBackend *blk_new(AioContext *ctx, uint64_t perm, uint64_t shared_perm) +{ + return blk_new_common(ctx, perm, shared_perm, false); +} + +BlockBackend *blk_new_pinned(AioContext *ctx, + uint64_t perm, uint64_t shared_perm) +{ + return blk_new_common(ctx, perm, shared_perm, true); +} + /* * Creates a new BlockBackend, opens a new BlockDriverState, and connects both. * The new BlockBackend is in the main AioContext. @@ -808,6 +830,7 @@ int blk_insert_bs(BlockBackend *blk, BlockDriverState *bs, Error **errp) if (blk->root == NULL) { return -EPERM; } + blk->root->stay_at_node = blk->stay_at_node; notifier_list_notify(&blk->insert_bs_notifiers, blk); if (tgm->throttle_state) { -- 2.18.0