From nobody Sat May 4 12:02:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=canonical.com ARC-Seal: i=1; a=rsa-sha256; t=1599055113; cv=none; d=zohomail.com; s=zohoarc; b=WG9mFitpNsG2dJaj0mlpbYPpQxnziwbR5FHjKdm1WU+C7C1xtaanPwYTpQfP2KbChpoTl6n2BCh4e/aBYhhlRdp56ya2GwQ6AgJHM+1op6Z4s03G2pkpjibwkfMW61P5EpqBb1mH1lnFpU79VTyhymuYpY8nEKFTI2RUrfdt1v0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599055113; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=+EgktUQ3EONp42XYwmHANk5punQzGhzS8BOjyTQVDgc=; b=bMoXUa3Ow9supxOICOjKV+AcFVwtdtcNClMT+t9eL/8iGhvi5H5Tz+6n+lkQ1Oqm0MzJ2kc6mEaMgjLDoclEAx5sy6iSF9fr7ELQebdr1qGpicE9SXqzDYfcNg73+wvfkIv1jOpx5uzZwTo5JVjMy030DGLXcAYjo6RTP0G6Xo4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1599055113929312.5123948599389; Wed, 2 Sep 2020 06:58:33 -0700 (PDT) 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-134-7yfGt_F1OwiGj0N8eTqbzQ-1; Wed, 02 Sep 2020 09:58:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 023EC1902EB8; Wed, 2 Sep 2020 13:58:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C88DC5D9CC; Wed, 2 Sep 2020 13:58:23 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 896C9183D020; Wed, 2 Sep 2020 13:58:23 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 082DwM7V018506 for ; Wed, 2 Sep 2020 09:58:22 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3884CD1BD8; Wed, 2 Sep 2020 13:58:22 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 344C4CF635 for ; Wed, 2 Sep 2020 13:58:19 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B38A618AE949 for ; Wed, 2 Sep 2020 13:58:19 +0000 (UTC) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-317-Z4bt1gagPuqVx2u4xGiDuQ-1; Wed, 02 Sep 2020 09:58:17 -0400 Received: from 2.general.paelzer.uk.vpn ([10.172.196.173] helo=Keschdeichel.fritz.box) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1kDTHD-0003qD-Q5; Wed, 02 Sep 2020 13:58:15 +0000 X-MC-Unique: 7yfGt_F1OwiGj0N8eTqbzQ-1 X-MC-Unique: Z4bt1gagPuqVx2u4xGiDuQ-1 From: Christian Ehrhardt To: libvir-list@redhat.com Subject: [PATCH] storage: only fallocate when allocation matches capacity Date: Wed, 2 Sep 2020 15:58:14 +0200 Message-Id: <20200902135814.869486-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false; X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Pavel Hrdina , Christian Ehrhardt , Wim ten Have , Cole Robinson X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.004 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In c9ec7088 "storage: extend preallocation flags support for qemu-img" the option to fallocate was added and meant to be active when (quote): "the XML described storage matches its " Up until recently 81a3042a12 "storage_util: fix qemu-img sparse allocation" the compared allocation size was an order of magnitude too small, but still it does use fallocate too often unless capacity>allocation. This change fixes the comparison to match the intended description of the feature. Fixes: c9ec7088c7a3f4cd26bb471f1f243931fff6f4f9 Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D1759454 Fixes: https://bugs.launchpad.net/ubuntu/focal/+source/libvirt/+bug/1847105 Signed-off-by: Christian Ehrhardt Reviewed-by: Michal Privoznik --- src/storage/storage_util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index cf82ea0a87..85bed76863 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -710,10 +710,10 @@ storageBackendCreateQemuImgOpts(virStorageEncryptionI= nfoDefPtr encinfo, virQEMUBuildQemuImgKeySecretOpts(&buf, encinfo, info->secretAlias); =20 if (info->preallocate) { - if (info->size_arg > info->allocation) - virBufferAddLit(&buf, "preallocation=3Dmetadata,"); - else + if (info->size_arg =3D=3D info->allocation) virBufferAddLit(&buf, "preallocation=3Dfalloc,"); + else + virBufferAddLit(&buf, "preallocation=3Dmetadata,"); } =20 if (info->nocow) --=20 2.28.0