From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 202178D0E for ; Tue, 7 Mar 2023 09:51:38 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id EDFE498DD for ; Tue, 7 Mar 2023 09:51:37 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Tue, 7 Mar 2023 09:51:36 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 4E45C42588 for ; Tue, 7 Mar 2023 09:51:36 +0100 (CET) Date: Tue, 07 Mar 2023 09:51:24 +0100 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Christian Ebner , Proxmox VE development discussion References: <20230306130752.1112199-1-c.ebner@proxmox.com> <638f7412-b51b-6580-5f9d-3b3259bd404b@proxmox.com> In-Reply-To: <638f7412-b51b-6580-5f9d-3b3259bd404b@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.16.0 (https://github.com/astroidmail/astroid) Message-Id: <1678178711.44w60pfavx.astroid@yuna.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL -0.027 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com, zfspoolplugin.pm] Subject: Re: [pve-devel] [PATCH v2 storage] api: fix get content call for volumes X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 07 Mar 2023 08:51:38 -0000 On March 7, 2023 9:31 am, Fiona Ebner wrote: > Am 06.03.23 um 14:07 schrieb Christian Ebner: >> `pvesh get /nodes/{node}/storage/{storage}/content/{volume}` failed for >> several storage types, because the respective storage plugins returned >> only the volumes `size` on `volume_size_info` calls, while also the form= at >> is required. >>=20 >> This patch fixes the issue by returning also `format` and where possible= `used`. >>=20 >> The issue was reported in the forum: >> https://forum.proxmox.com/threads/pvesh-get-nodes-node-storage-storage-c= ontent-volume-returns-error.123747/ >>=20 >> Signed-off-by: Christian Ebner >> --- >>=20 >> Changes since v1: >> * Remove errous check for $used being set, rely on fallback to 0 if und= ef >> * Return `parent` for RBD and ZFS >> * Return `used` for ZFS >>=20 [..] >> diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm >> index 9fbd149..acc50d9 100644 >> --- a/PVE/Storage/ZFSPoolPlugin.pm >> +++ b/PVE/Storage/ZFSPoolPlugin.pm >> @@ -446,13 +446,17 @@ sub status { >> sub volume_size_info { >> my ($class, $scfg, $storeid, $volname, $timeout) =3D @_; >> =20 >> - my (undef, $vname, undef, undef, undef, undef, $format) =3D >> + my (undef, $vname, undef, $parent, undef, undef, $format) =3D >> $class->parse_volname($volname); >> =20 >> my $attr =3D $format eq 'subvol' ? 'refquota' : 'volsize'; >> my $value =3D $class->zfs_get_properties($scfg, $attr, "$scfg->{poo= l}/$vname"); >> + my $used =3D $class->zfs_get_properties($scfg, 'used', "$scfg->{poo= l}/$vname"); >=20 > used also includes usage of snapshots and children. I think > usedbydataset is better. Like that used <=3D size should be guaranteed. > See man zfsprops for more information. >=20 > Also, one call to zfs_get_properties should be enough by passing both > "$attr,used". >=20 > While you're at it, I'd also rename $value to $size then. unfortunately not the case - a zvol can take up (significantly) more space = than volsize: $ zpool get ashift testpool NAME PROPERTY VALUE SOURCE testpool ashift 12 local $ zfs get volsize,volblocksize,space testpool/test NAME PROPERTY VALUE SOURCE testpool/test volsize 5G local testpool/test volblocksize 8K default testpool/test name testpool/test - testpool/test available 11.2G - testpool/test used 7.43G - testpool/test usedbysnapshots 0B - testpool/test usedbydataset 7.32G - testpool/test usedbyrefreservation 111M - testpool/test usedbychildren 0B - this is the common "ashift=3D12 / volblocksize=3D8 / raidz2" pitfall..