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=-13.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 5611AC433E0 for ; Thu, 4 Feb 2021 14:33:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E205C64EE2 for ; Thu, 4 Feb 2021 14:33:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E205C64EE2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7fhN-000602-Qa for qemu-devel@archiver.kernel.org; Thu, 04 Feb 2021 09:33:33 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7fg4-0004qY-Px for qemu-devel@nongnu.org; Thu, 04 Feb 2021 09:32:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21714) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7ffx-0005TI-4t for qemu-devel@nongnu.org; Thu, 04 Feb 2021 09:32:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612449123; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2reUQzzarqgssbUcyDxWpMwQ8uXrhWFbgIP0XLEN3Lk=; b=UxadbC2U2qiTatVZSpDVw4ENjZqvadrYiGAaQhyr1nuLBvN4o2YjRTh56u8LzOd/rPjm2N gAmNXAxZHn8/UxVOGPnY6ktxFbDq8hHkKrXcMggz7fm15dnvbfcog/Rhf9qNrU1JnaeXh3 NFE/up0WZi1hvuPs2TL8sFERGyiyACE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-279-GkKLHvmXP0qODAnubpiRQw-1; Thu, 04 Feb 2021 09:32:02 -0500 X-MC-Unique: GkKLHvmXP0qODAnubpiRQw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 98BBE801960; Thu, 4 Feb 2021 14:32:00 +0000 (UTC) Received: from merkur.fritz.box (ovpn-112-162.ams2.redhat.com [10.36.112.162]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0C6485C3DF; Thu, 4 Feb 2021 14:31:58 +0000 (UTC) Date: Thu, 4 Feb 2021 15:31:57 +0100 From: Kevin Wolf To: Vladimir Sementsov-Ogievskiy Subject: Re: [PATCH v2 26/36] block/backup-top: drop .active Message-ID: <20210204143157.GH6496@merkur.fritz.box> References: <20201127144522.29991-1-vsementsov@virtuozzo.com> <20201127144522.29991-27-vsementsov@virtuozzo.com> <20210204122651.GE6496@merkur.fritz.box> <20210204132529.GF6496@merkur.fritz.box> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Received-SPF: pass client-ip=216.205.24.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.351, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-block@nongnu.org, armbru@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, den@openvz.org, jsnow@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Am 04.02.2021 um 14:46 hat Vladimir Sementsov-Ogievskiy geschrieben: > 04.02.2021 16:25, Kevin Wolf wrote: > > Am 04.02.2021 um 13:33 hat Vladimir Sementsov-Ogievskiy geschrieben: > > > 04.02.2021 15:26, Kevin Wolf wrote: > > > > Am 27.11.2020 um 15:45 hat Vladimir Sementsov-Ogievskiy geschrieben: > > > > > We don't need this workaround anymore: bdrv_append is already smart > > > > > enough and we can use new bdrv_drop_filter(). > > > > > > > > > > Signed-off-by: Vladimir Sementsov-Ogievskiy > > > > > --- > > > > > block/backup-top.c | 38 +------------------------------------- > > > > > tests/qemu-iotests/283.out | 2 +- > > > > > 2 files changed, 2 insertions(+), 38 deletions(-) > > > > > > > > > > diff --git a/block/backup-top.c b/block/backup-top.c > > > > > index 650ed6195c..84eb73aeb7 100644 > > > > > --- a/block/backup-top.c > > > > > +++ b/block/backup-top.c > > > > > @@ -37,7 +37,6 @@ > > > > > typedef struct BDRVBackupTopState { > > > > > BlockCopyState *bcs; > > > > > BdrvChild *target; > > > > > - bool active; > > > > > int64_t cluster_size; > > > > > } BDRVBackupTopState; > > > > > @@ -127,21 +126,6 @@ static void backup_top_child_perm(BlockDriverState *bs, BdrvChild *c, > > > > > uint64_t perm, uint64_t shared, > > > > > uint64_t *nperm, uint64_t *nshared) > > > > > { > > > > > - BDRVBackupTopState *s = bs->opaque; > > > > > - > > > > > - if (!s->active) { > > > > > - /* > > > > > - * The filter node may be in process of bdrv_append(), which firstly do > > > > > - * bdrv_set_backing_hd() and then bdrv_replace_node(). This means that > > > > > - * we can't unshare BLK_PERM_WRITE during bdrv_append() operation. So, > > > > > - * let's require nothing during bdrv_append() and refresh permissions > > > > > - * after it (see bdrv_backup_top_append()). > > > > > - */ > > > > > - *nperm = 0; > > > > > - *nshared = BLK_PERM_ALL; > > > > > - return; > > > > > - } > > > > > - > > > > > if (!(role & BDRV_CHILD_FILTERED)) { > > > > > /* > > > > > * Target child > > > > > @@ -229,18 +213,6 @@ BlockDriverState *bdrv_backup_top_append(BlockDriverState *source, > > > > > } > > > > > appended = true; > > > > > - /* > > > > > - * bdrv_append() finished successfully, now we can require permissions > > > > > - * we want. > > > > > - */ > > > > > - state->active = true; > > > > > - bdrv_child_refresh_perms(top, top->backing, &local_err); > > > > > > > > bdrv_append() uses bdrv_refresh_perms() for the whole node. Is it doing > > > > unnecessary extra work there and should really do the same as backup-top > > > > did here, i.e. bdrv_child_refresh_perms(bs_new->backing)? > > > > > > > > (Really a comment for an earlier patch. This patch itself looks fine.) > > > > > > > > > > You mean how backup-top code works at the point when we modified > > > bdrv_append()? Actually all works, as we use state->active. We set it > > > to true and should call refresh_perms. Now we drop _refresh_perms > > > _together_ with state->active variable, so filter is always "active", > > > but new bdrv_append can handle it now. I.e., before this patch > > > backup-top.c code is correct but over-complicated with logic which is > > > not necessary after bdrv_append() improvement (and of-course we need > > > also bdrv_drop_filter() to drop the whole state->active related > > > logic). > > > > No, I just mean that bdrv_child_refresh_perms(bs, bs->backing) is enough > > when adding a new image to the chain. A full bdrv_child_refresh_perms() > > like we now have in bdrv_append() is doing more work than is necessary. > > > > It doesn't make a difference for backup-top (because the filter has only > > a single child), but if you append a new qcow2 snapshot, you would also > > recalculate permissions for the bs->file subtree even though nothing has > > changed there. > > > > It's only a small detail anyway, not very important in a slow path. > > Understand now. I think bdrv_append() do correct things: bs_new gets > new parents, so we refresh the whole subtree.. So for appending qcow2 > we should refresh its file child as well. Probably new permissions of > new bs_new parents will influence what qcow2 wants to do with it file > node.. You mean the parents that move from bs_top to bs_new and that they could change the permissions that bs_new needs? Good point, yes. Kevin