From nobody Fri Apr 19 23:49:49 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 155231906985055.94640413194327; Mon, 11 Mar 2019 08:44:29 -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 329628666A; Mon, 11 Mar 2019 15:44:28 +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 05CAE5DD6B; Mon, 11 Mar 2019 15:44:28 +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 AD4D0181A13D; Mon, 11 Mar 2019 15:44:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2BFe1iT002323 for ; Mon, 11 Mar 2019 11:40:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id C674119724; Mon, 11 Mar 2019 15:40:01 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BCEF119736 for ; Mon, 11 Mar 2019 15:39:59 +0000 (UTC) Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6F7B4A85F for ; Mon, 11 Mar 2019 15:39:59 +0000 (UTC) Received: by mail-qt1-f200.google.com with SMTP id p40so5579196qtb.10 for ; Mon, 11 Mar 2019 08:39:59 -0700 (PDT) Received: from cube-1.lan (pool-173-73-12-108.washdc.fios.verizon.net. [173.73.12.108]) by smtp.gmail.com with ESMTPSA id l129sm3381742qkb.44.2019.03.11.08.39.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Mar 2019 08:39:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wKi7WJpV1OZQo3TXrWSPh7OtZedcsrNBkcgtuYkWBak=; b=e9bEcXh7e2IGwcRB4zf2cnUeK6qCvKKQLD+O2p5AnNPmcjCgh/10/M/nuvM6jAa9ws NCfo7f32nuB7cWL0Qi4cwkuU9BjMfoKoC1W+UNeuVW3p4VcfdYfF2feRd98q162VdvOH 5UwUz30D9EkeEI64VGmPYxVHNrX1JgRPx+CrEws4gFpFv27sR1oeZaLFEjf1iMJKLD+R 9vyu5kBtx08ETVIjv+6Gmmm2yYW0XLC2ijHiQVn9yvtWsxnhKymMiRIqTERmRw/GZ2yX VeIKKKsq3kMQIzsV76+P1pPkgV2mSNdD+SYFDdTa/zd5s9OBoC1FsALr2s12kLEu3aRg yj9g== X-Gm-Message-State: APjAAAV6ZKQ7EWcnGuVscD0Jw1PgP9DpLXwflWZs2+BQCjMXyfp527dK IF6rycNy6LBIvmt5+fQXOlg/yzrUiH8Tgu7xmBTXuKYiiJNqSj2dlGtmSdKpbl8Lte4Qih8d2fJ xEfOk7rP/C4ZElgqLX/w= X-Received: by 2002:aed:3571:: with SMTP id b46mr211268qte.214.1552318798459; Mon, 11 Mar 2019 08:39:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwbxvtihaOO/b0CBFIJJ9XGnG+mTRSMGOdsz1rDZIY0W6mmc+mz+IXX5cX3+fzltGoWApQiA== X-Received: by 2002:aed:3571:: with SMTP id b46mr211255qte.214.1552318798251; Mon, 11 Mar 2019 08:39:58 -0700 (PDT) From: jdillama@redhat.com X-Google-Original-From: dillaman@redhat.com To: libvir-list@redhat.com Date: Mon, 11 Mar 2019 11:39:54 -0400 Message-Id: <20190311153955.4131-2-dillaman@redhat.com> In-Reply-To: <20190311153955.4131-1-dillaman@redhat.com> References: <20190311153955.4131-1-dillaman@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Mon, 11 Mar 2019 11:44:16 -0400 Cc: Jason Dillaman Subject: [libvirt] [PATCH 1/2] rbd: do not attempt to use fast-diff if it's marked invalid 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: , 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.26]); Mon, 11 Mar 2019 15:44:28 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: Jason Dillaman The librbd API will transparently revert to a slow disk usage calculation method if the fast-diff map is marked as invalid. Signed-off-by: Jason Dillaman --- src/storage/storage_backend_rbd.c | 41 ++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index 2b7af1db23..e67911f928 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -437,10 +437,29 @@ volStorageBackendRBDGetFeatures(rbd_image_t image, } =20 #if LIBRBD_VERSION_CODE > 265 +static int +volStorageBackendRBDGetFlags(rbd_image_t image, + const char *volname, + uint64_t *flags) +{ + int r, ret =3D -1; + + if ((r =3D rbd_get_flags(image, flags)) < 0) { + virReportSystemError(-r, _("failed to get the flags of RBD image " + "%s"), volname); + goto cleanup; + } + ret =3D 0; + + cleanup: + return ret; +} + static bool -volStorageBackendRBDUseFastDiff(uint64_t features) +volStorageBackendRBDUseFastDiff(uint64_t features, uint64_t flags) { - return features & RBD_FEATURE_FAST_DIFF; + return (((features & RBD_FEATURE_FAST_DIFF) !=3D 0ULL) && + ((flags & RBD_FLAG_FAST_DIFF_INVALID) =3D=3D 0ULL)); } =20 static int @@ -484,7 +503,17 @@ virStorageBackendRBDSetAllocation(virStorageVolDefPtr = vol, =20 #else static int -volStorageBackendRBDUseFastDiff(uint64_t features ATTRIBUTE_UNUSED) +volStorageBackendRBDGetFlags(rbd_image_t image, + const char *volname, + uint64_t *flags) +{ + *flags =3D 0; + return 0; +} + +static int +volStorageBackendRBDUseFastDiff(uint64_t features ATTRIBUTE_UNUSED, + uint64_t feature_flags ATTRIBUTE_UNUSED) { return false; } @@ -509,6 +538,7 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr = vol, rbd_image_t image =3D NULL; rbd_image_info_t info; uint64_t features; + uint64_t flags; =20 if ((r =3D rbd_open_read_only(ptr->ioctx, vol->name, &image, NULL)) < = 0) { ret =3D -r; @@ -527,11 +557,14 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPt= r vol, if (volStorageBackendRBDGetFeatures(image, vol->name, &features) < 0) goto cleanup; =20 + if (volStorageBackendRBDGetFlags(image, vol->name, &flags) < 0) + goto cleanup; + vol->target.capacity =3D info.size; vol->type =3D VIR_STORAGE_VOL_NETWORK; vol->target.format =3D VIR_STORAGE_FILE_RAW; =20 - if (volStorageBackendRBDUseFastDiff(features)) { + if (volStorageBackendRBDUseFastDiff(features, flags)) { VIR_DEBUG("RBD image %s/%s has fast-diff feature enabled. " "Querying for actual allocation", def->source.name, vol->name); --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Fri Apr 19 23:49:49 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1552319059880227.17747806768637; Mon, 11 Mar 2019 08:44:19 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 10AC45AFF4; Mon, 11 Mar 2019 15:44:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DB9AD60BF1; Mon, 11 Mar 2019 15:44:17 +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 98199247E1; Mon, 11 Mar 2019 15:44:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x2BFe58P002328 for ; Mon, 11 Mar 2019 11:40:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 56AC060C60; Mon, 11 Mar 2019 15:40:05 +0000 (UTC) Received: from mx1.redhat.com (ext-mx04.extmail.prod.ext.phx2.redhat.com [10.5.110.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5008060BF1 for ; Mon, 11 Mar 2019 15:40:00 +0000 (UTC) Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 73E7D88306 for ; Mon, 11 Mar 2019 15:40:00 +0000 (UTC) Received: by mail-qt1-f197.google.com with SMTP id 35so5629986qtq.5 for ; Mon, 11 Mar 2019 08:40:00 -0700 (PDT) Received: from cube-1.lan (pool-173-73-12-108.washdc.fios.verizon.net. [173.73.12.108]) by smtp.gmail.com with ESMTPSA id l129sm3381742qkb.44.2019.03.11.08.39.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Mar 2019 08:39:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=h3kSry78a01jssNQuKLc0kxevahYtUuD7nG1yYHRccs=; b=QYk6Kxd3b7ELh6wPe+n0PTgUf10IVEwUMYU/BTV6lkG+jODvVo/6XHkvdYaL5EO6d3 o15PqqBfymtNLHp/Lnn0iBE3UweClMO42Eo/zA8HIox0nZDVSRdQl9okUWZPNvSjCDVT zUSMLt2r7VNdVrhUbpztlfUHGP7Mk9Y65Bve055L5IieaQ9j4UC0jqsx3OBT1n85NSsA 8KKgPiIiqZy12zJp5CXHdEcEB/5w9A7fzmaTvVeW4TXU0+1qsX+LHzU2iQvS7JLBmTwQ mU+r1XVun1MZIuSCAhE9E7sQD4CmZbuD4slptcb2NtSTntH/jIxr+wNju77EK+Kb+2/0 CfUA== X-Gm-Message-State: APjAAAUJvqUPqJ8UHgNYS5AO/TgNBtORznQZPwMHWDd9eIX3sOK0VXOl AN+3D1vo0gic9ba2JyM3xwROecL51ezAMX+631O7cQwxbPYNyzsl66MTFEO3vikLdxJ41jYlciL A5d7Br1z6vYvzEXED7VU= X-Received: by 2002:ac8:7545:: with SMTP id b5mr8855954qtr.239.1552318799566; Mon, 11 Mar 2019 08:39:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxrbUHhJcGH+NA4T4oHevCeotRttb7ujPWfoJQK06Re5YYvWk/ye7EgQLNhFFCWVjwG53LpZA== X-Received: by 2002:ac8:7545:: with SMTP id b5mr8855938qtr.239.1552318799332; Mon, 11 Mar 2019 08:39:59 -0700 (PDT) From: jdillama@redhat.com X-Google-Original-From: dillaman@redhat.com To: libvir-list@redhat.com Date: Mon, 11 Mar 2019 11:39:55 -0400 Message-Id: <20190311153955.4131-3-dillaman@redhat.com> In-Reply-To: <20190311153955.4131-1-dillaman@redhat.com> References: <20190311153955.4131-1-dillaman@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Mon, 11 Mar 2019 11:44:16 -0400 Cc: Jason Dillaman Subject: [libvirt] [PATCH 2/2] rbd: optionally disable actual disk-usage during pool/volume refresh 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: , 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 11 Mar 2019 15:44:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: Jason Dillaman For pools with numerous volumes or very large volumes, the disk-usage calculation can take a non-trivial amount of time even with the fast-diff feature enabled (especially since the the usage is calculated serially for each image in the pool). The "rbd:config_opts" node now supports a new libvirt-internal "libvirt_calculate_disk_usage" option which can be set to false to disable this calculation as needed. Signed-off-by: Jason Dillaman --- docs/formatstorage.html.in | 13 ++++++++-- src/storage/storage_backend_rbd.c | 41 ++++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in index 968651330f..eb65edc4d4 100644 --- a/docs/formatstorage.html.in +++ b/docs/formatstorage.html.in @@ -613,12 +613,21 @@ <rbd:option name=3D'client_mount_timeout' value=3D'45'/> <rbd:option name=3D'rados_mon_op_timeout' value=3D'20'/> <rbd:option name=3D'rados_osd_op_timeout' value=3D'10'/> + <rbd:option name=3D'libvirt_calculate_disk_usage' value=3D'false'/&= gt; </rbd:config_opts> </pool> =20 - Since 5.1.0. - + Since 5.1.0. +
+
libvirt_calculate_disk_usage
+
Disable calculating the actual disk usage of RBD volumes when + set to false. This will speed up pool and volume + refresh operations for pools with many volumes or pools with + large images. +
+
+ =20

Storage volume XML

diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backen= d_rbd.c index e67911f928..07ab72f97c 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -61,6 +61,9 @@ struct _virStoragePoolRBDConfigOptionsDef { =20 #define STORAGE_POOL_RBD_NAMESPACE_HREF "http://libvirt.org/schemas/storag= epool/rbd/1.0" =20 +#define CONFIG_OPTION_INTERNAL_PREFIX "libvirt_" +#define CONFIG_OPTION_CALCULATE_DISK_USAGE CONFIG_OPTION_INTERNAL_PREFIX "= calculate_disk_usage" + static void virStoragePoolDefRBDNamespaceFree(void *nsdata) { @@ -321,6 +324,9 @@ virStorageBackendRBDOpenRADOSConn(virStorageBackendRBDS= tatePtr ptr, char uuidstr[VIR_UUID_STRING_BUFLEN]; =20 for (i =3D 0; i < cmdopts->noptions; i++) { + if (STRPREFIX(cmdopts->names[i], CONFIG_OPTION_INTERNAL_PREFIX= )) + continue; + if (virStorageBackendRBDRADOSConfSet(ptr->cluster, cmdopts->names[i], cmdopts->values[i]) < 0) @@ -527,10 +533,30 @@ virStorageBackendRBDSetAllocation(virStorageVolDefPtr= vol ATTRIBUTE_UNUSED, } #endif =20 +static bool +virStorageBackendRBDCalculateDiskUsage(virStoragePoolDefPtr def) +{ + size_t i; + bool calculate_disk_usage =3D true; + + if (def->namespaceData) { + virStoragePoolRBDConfigOptionsDefPtr cmdopts =3D def->namespaceDat= a; + + for (i =3D 0; i < cmdopts->noptions; i++) { + if (STREQ(cmdopts->names[i], CONFIG_OPTION_CALCULATE_DISK_USAG= E)) { + calculate_disk_usage =3D STRCASEEQ(cmdopts->values[i], "tr= ue"); + break; + } + } + } + return calculate_disk_usage; +} + static int volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr vol, virStoragePoolObjPtr pool, - virStorageBackendRBDStatePtr ptr) + virStorageBackendRBDStatePtr ptr, + bool calculate_disk_usage) { int ret =3D -1; virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); @@ -564,7 +590,8 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr = vol, vol->type =3D VIR_STORAGE_VOL_NETWORK; vol->target.format =3D VIR_STORAGE_FILE_RAW; =20 - if (volStorageBackendRBDUseFastDiff(features, flags)) { + if (calculate_disk_usage && + volStorageBackendRBDUseFastDiff(features, flags)) { VIR_DEBUG("RBD image %s/%s has fast-diff feature enabled. " "Querying for actual allocation", def->source.name, vol->name); @@ -610,8 +637,10 @@ virStorageBackendRBDRefreshPool(virStoragePoolObjPtr p= ool) virStorageBackendRBDStatePtr ptr =3D NULL; struct rados_cluster_stat_t clusterstat; struct rados_pool_stat_t poolstat; + bool calculate_disk_usage =3D virStorageBackendRBDCalculateDiskUsage(d= ef); VIR_AUTOFREE(char *) names =3D NULL; =20 + if (!(ptr =3D virStorageBackendRBDNewState(pool))) goto cleanup; =20 @@ -663,7 +692,8 @@ virStorageBackendRBDRefreshPool(virStoragePoolObjPtr po= ol) =20 name +=3D strlen(name) + 1; =20 - r =3D volStorageBackendRBDRefreshVolInfo(vol, pool, ptr); + r =3D volStorageBackendRBDRefreshVolInfo(vol, pool, ptr, + calculate_disk_usage); =20 /* It could be that a volume has been deleted through a different = route * then libvirt and that will cause a -ENOENT to be returned. @@ -1238,12 +1268,15 @@ virStorageBackendRBDRefreshVol(virStoragePoolObjPtr= pool, virStorageVolDefPtr vol) { virStorageBackendRBDStatePtr ptr =3D NULL; + virStoragePoolDefPtr def =3D virStoragePoolObjGetDef(pool); + bool calculate_disk_usage =3D virStorageBackendRBDCalculateDiskUsage(d= ef); int ret =3D -1; =20 if (!(ptr =3D virStorageBackendRBDNewState(pool))) goto cleanup; =20 - if (volStorageBackendRBDRefreshVolInfo(vol, pool, ptr) < 0) + if (volStorageBackendRBDRefreshVolInfo(vol, pool, ptr, + calculate_disk_usage) < 0) goto cleanup; =20 ret =3D 0; --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list