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=-10.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 3281DC48BD1 for ; Fri, 11 Jun 2021 15:00:36 +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 9475161278 for ; Fri, 11 Jun 2021 15:00:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9475161278 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]:42660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lrieA-0001Cq-7H for qemu-devel@archiver.kernel.org; Fri, 11 Jun 2021 11:00:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41684) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrid8-0008Cv-7C for qemu-devel@nongnu.org; Fri, 11 Jun 2021 10:59:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24379) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lrid4-0008GP-Bs for qemu-devel@nongnu.org; Fri, 11 Jun 2021 10:59:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623423565; 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=8gnUv4t0d7qL3H93JKYlHNSYK7N9iPuFUdSFLwpAQhs=; b=ReQsBf5KaqYADibDsmUeAKaDTf4hRxUenW7w7gozcTCh9SQWhNhyiZ7xei9K9VCjcnstr2 rm5DTHQSHMKY/l/3heWX9FcQD56mj1Y662y6Tn4kHF+PhpbUCiQF0Px2YAtiibeozSl5sv taPiiWoegkqhg+7lqkyk5VMTtASlscI= 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-182-csQa-RjCO0ir9z7N85a8tg-1; Fri, 11 Jun 2021 10:59:21 -0400 X-MC-Unique: csQa-RjCO0ir9z7N85a8tg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F094C193F562; Fri, 11 Jun 2021 14:59:20 +0000 (UTC) Received: from redhat.com (ovpn-113-53.phx2.redhat.com [10.3.113.53]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 56C7619C59; Fri, 11 Jun 2021 14:59:20 +0000 (UTC) Date: Fri, 11 Jun 2021 09:59:18 -0500 From: Eric Blake To: Vladimir Sementsov-Ogievskiy Subject: Re: [PATCH v2] qemu-img: Make unallocated part of backing chain obvious in map Message-ID: <20210611145918.pslzaqiuxyjttcmj@redhat.com> References: <20210611140157.1366738-1-eblake@redhat.com> <6a0aabb6-441c-8671-fc07-a7113043ccc8@virtuozzo.com> MIME-Version: 1.0 In-Reply-To: <6a0aabb6-441c-8671-fc07-a7113043ccc8@virtuozzo.com> User-Agent: NeoMutt/20210205 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eblake@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=170.10.133.124; envelope-from=eblake@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.199, 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_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: nsoffer@redhat.com, Kevin Wolf , qemu-devel@nongnu.org, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Fri, Jun 11, 2021 at 05:35:12PM +0300, Vladimir Sementsov-Ogievskiy wrote: > > An obvious solution is to make 'qemu-img map --output=json' > > distinguish between clusters that have a local allocation from those > > that are found nowhere in the chain. We already have a one-off > > mismatch between qemu-img map and NBD qemu:allocation-depth (the > > former chose 0, and the latter 1 for the local layer), so exposing the > > latter's choice of 0 for unallocated in the entire chain would mean > > using using "depth":-1 in the former, but a negative depth may confuse > > existing tools. But there is an easy out: for any chain of length N, > > we can simply represent an unallocated cluster as "depth":N+1. This > > does have a slight risk of confusing any tool that might try to > > dereference NULL when finding the backing image for the last file in > > the backing chain, but that risk sseems worth the more precise output. > > The iotests have several examples where this distinction demonstrates > > the additional accuracy. > > > > Signed-off-by: Eric Blake > > --- > > > > Replaces v1: 20210610213906.1313440-1-eblake@redhat.com > > (qemu-img: Use "depth":-1 to make backing probes obvious) > > > > Use N+1 instead of -1 for unallocated [Kevin] > > > > Bit in contrast with -1, or with separate boolean flag, you lose the possibility to distinguish case when we have 3 layers and the cluster is absent in all of them, and the case when we have 4 layers and the cluster is absent in top 3 but in 4 it is qcow2 UNALLOCATED_ZERO cluster. Using just 'qemu-img map --output-json', you only see depth numbers. You also have to use 'qemu-img info --backing-chain' to see what file those depth numbers correspond to, at which point it becomes obvious whether "depth":4 meant unallocated (because the chain was length 3) or allocated at depth 4 (because the chain was length 4 or longer). But that's no worse than pre-patch, where you had to use qemu-img info --backing-chain to learn which file a particular "depth" maps to. > > So, if someone use this API to reconstruct the chain, then for original 3 empty layers he will create 3 empty layers and 4rd additional ZERO layer. And such reconstructed chain would not be equal to original chain (as if we take these two chains and add additional backing file as a new bottom layer, effect would be different).. I'm not sure is it a problem in the task you are solving :\ It should be fairly easy to optimize the case of a backing chain where EVERY listed cluster at the final depth was "data":false,"zero":true to omit that file after all. And in oVirt's case, Nir pointed out that we have one more tool at our disposal in recreating a backing chain: if you use json:{"driver":"qcow2", "backing":null, ...} as your image file, you don't have to worry about arbitrary files in the backing chain, only about recreating the top-most layer of a chain. And in that case, it becomes very obvious that "depth":0 is something you must recreate, and "depth":1 would be a non-existent backing file because you just passed "backing":null. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org