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 B11C18D2B for ; Tue, 7 Mar 2023 10:17:46 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 95BDF9D84 for ; Tue, 7 Mar 2023 10:17:16 +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 10:17:15 +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 3F0164578B for ; Tue, 7 Mar 2023 10:17:15 +0100 (CET) Date: Tue, 7 Mar 2023 10:17:14 +0100 (CET) From: Christian Ebner To: =?UTF-8?Q?Fabian_Gr=C3=BCnbichler?= , Proxmox VE development discussion Message-ID: <349046786.3570.1678180634056@192.168.2.153> In-Reply-To: <1678178711.44w60pfavx.astroid@yuna.none> References: <20230306130752.1112199-1-c.ebner@proxmox.com> <638f7412-b51b-6580-5f9d-3b3259bd404b@proxmox.com> <1678178711.44w60pfavx.astroid@yuna.none> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer v7.10.6-Rev32 X-Originating-Client: open-xchange-appsuite X-SPAM-LEVEL: Spam detection results: 0 AWL -0.124 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 09:17:46 -0000 > On 07.03.2023 09:51 CET Fabian Gr=C3=BCnbichler wrote: >=20 > =20 > 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 fo= r > >> several storage types, because the respective storage plugins returned > >> only the volumes `size` on `volume_size_info` calls, while also the fo= rmat > >> is required. > >>=20 > >> This patch fixes the issue by returning also `format` and where possib= le `used`. > >>=20 > >> The issue was reported in the forum: > >> https://forum.proxmox.com/threads/pvesh-get-nodes-node-storage-storage= -content-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 u= ndef > >> * Return `parent` for RBD and ZFS > >> * Return `used` for ZFS > >>=20 >=20 > [..] >=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->{p= ool}/$vname"); > >> + my $used =3D $class->zfs_get_properties($scfg, 'used', "$scfg->{p= ool}/$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. >=20 > unfortunately not the case - a zvol can take up (significantly) more spac= e than > volsize: >=20 > $ 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 - >=20 > this is the common "ashift=3D12 / volblocksize=3D8 / raidz2" pitfall.. Okay, but nevertheless it should make sense to use `usedbydataset` rather t= han `used`. The fact, that used > size is possible here is then an exercise= in correct interpretation of the output anyway. Could this be documented i= n the API viewer?