From nobody Sun Feb 8 15:46:14 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1506354577263680.4610571319857; Mon, 25 Sep 2017 08:49:37 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 13F11267FB; Mon, 25 Sep 2017 15:49:36 +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 E86355D9C9; Mon, 25 Sep 2017 15:49:35 +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 B126C180884A; Mon, 25 Sep 2017 15:49:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v8PFkZMa021185 for ; Mon, 25 Sep 2017 11:46:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 059AC6F443; Mon, 25 Sep 2017 15:46:35 +0000 (UTC) Received: from dnr.brq.redhat.com (unknown [10.43.2.37]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8193A6F7EA for ; Mon, 25 Sep 2017 15:46:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 13F11267FB Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Mon, 25 Sep 2017 17:46:09 +0200 Message-Id: <3142aaf19f71a37f84fa09020526331aa0299244.1506354254.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/3] virStorageFileResize: fallocate the whole capacity 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 25 Sep 2017 15:49:36 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We have been trying to implement the ALLOCATE flag to mean "the volume should be fully allocated after the resize". Since commit b0579ed9 we do not allocate from the existing capacity, but from the existing allocation value. However this value is a total of all the allocated bytes, not an offset. For a sparsely allocated file: $ perl -e 'print "x"x8192;' > vol1 $ fallocate -p -o 0 -l 4096 vol1 Treating allocation as an offset would result in an incompletely allocated file: $ virsh vol-resize vol1 --pool default 16384 --allocate Capacity: 16.00 KiB Allocation: 12.00 KiB Call fallocate from zero on the whole requested capacity to fully allocate the file. Reviewed-by: John Ferlan --- src/storage/storage_util.c | 3 +-- src/util/virstoragefile.c | 8 +------- src/util/virstoragefile.h | 1 - 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c index 07dba2222..b94b3f397 100644 --- a/src/storage/storage_util.c +++ b/src/storage/storage_util.c @@ -2329,8 +2329,7 @@ virStorageBackendVolResizeLocal(virConnectPtr conn AT= TRIBUTE_UNUSED, bool pre_allocate =3D flags & VIR_STORAGE_VOL_RESIZE_ALLOCATE; =20 if (vol->target.format =3D=3D VIR_STORAGE_FILE_RAW) { - return virStorageFileResize(vol->target.path, capacity, - vol->target.allocation, pre_allocate); + return virStorageFileResize(vol->target.path, capacity, pre_alloca= te); } else if (vol->target.format =3D=3D VIR_STORAGE_FILE_PLOOP) { return storagePloopResize(vol, capacity); } else { diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index b3da0a452..5df1ea0b8 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -1315,17 +1315,11 @@ virStorageFileChainGetBroken(virStorageSourcePtr ch= ain, int virStorageFileResize(const char *path, unsigned long long capacity, - unsigned long long orig_capacity, bool pre_allocate) { int fd =3D -1; int ret =3D -1; int rc; - off_t offset ATTRIBUTE_UNUSED; - off_t len ATTRIBUTE_UNUSED; - - offset =3D orig_capacity; - len =3D capacity - orig_capacity; =20 if ((fd =3D open(path, O_RDWR)) < 0) { virReportSystemError(errno, _("Unable to open '%s'"), path); @@ -1333,7 +1327,7 @@ virStorageFileResize(const char *path, } =20 if (pre_allocate) { - if ((rc =3D virFileAllocate(fd, offset, len)) !=3D 0) { + if ((rc =3D virFileAllocate(fd, 0, capacity)) !=3D 0) { if (rc =3D=3D -2) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("preallocate is not supported on this pla= tform")); diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index f7e897f25..1eb1c6471 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -328,7 +328,6 @@ virStorageSourcePtr virStorageFileChainLookup(virStorag= eSourcePtr chain, =20 int virStorageFileResize(const char *path, unsigned long long capacity, - unsigned long long orig_capacity, bool pre_allocate); =20 int virStorageFileIsClusterFS(const char *path); --=20 2.13.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list