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 5E7B68E424 for ; Fri, 11 Nov 2022 09:40:57 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 36FB82FBF9 for ; Fri, 11 Nov 2022 09:40:27 +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 ; Fri, 11 Nov 2022 09:40:26 +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 5263A4075A for ; Fri, 11 Nov 2022 09:40:26 +0100 (CET) Message-ID: Date: Fri, 11 Nov 2022 09:40:25 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:107.0) Gecko/20100101 Thunderbird/107.0 Content-Language: en-GB To: Proxmox VE development discussion , Stefan Hrdlicka References: <20221110132450.567121-1-s.hrdlicka@proxmox.com> <20221110132450.567121-2-s.hrdlicka@proxmox.com> From: Thomas Lamprecht In-Reply-To: <20221110132450.567121-2-s.hrdlicka@proxmox.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.033 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 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. [zfs.pm] Subject: [pve-devel] applied: [PATCH V4 storage 1/3] fix #3967: enable ZFS dRAID creation via API 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: Fri, 11 Nov 2022 08:40:57 -0000 Am 10/11/2022 um 14:24 schrieb Stefan Hrdlicka: > It is possible to set the number of spares and the size of > data stripes via draidspares & dreaddata parameters. > > Signed-off-by: Stefan Hrdlicka > --- > PVE/API2/Disks/ZFS.pm | 55 ++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 54 insertions(+), 1 deletion(-) > applied with Lukas' T-b tag and some stylistic follow ups (see below), thanks! > diff --git a/PVE/API2/Disks/ZFS.pm b/PVE/API2/Disks/ZFS.pm > index a4d4aa2..d1bcbcb 100644 > --- a/PVE/API2/Disks/ZFS.pm > +++ b/PVE/API2/Disks/ZFS.pm > @@ -285,6 +285,19 @@ __PACKAGE__->register_method ({ > return $pool; > }}); > > +my $draid_config_format = { > + spares => { > + type => 'integer', > + minimum => 0, > + description => 'Number of dRAID spares.', > + }, > + data => { > + type => 'integer', > + minimum => 1, > + description => 'The number of data devices per redundancy group. (dRAID)', the code handles either as optional but this isn't encoded in the schema, I added it, please re-check if that was OK. > + }, > +}; > + > __PACKAGE__->register_method ({ > name => 'create', > path => '', > @@ -303,12 +316,21 @@ __PACKAGE__->register_method ({ > raidlevel => { > type => 'string', > description => 'The RAID level to use.', > - enum => ['single', 'mirror', 'raid10', 'raidz', 'raidz2', 'raidz3'], > + enum => [ > + 'single', 'mirror', > + 'raid10', 'raidz', 'raidz2', 'raidz3', > + 'draid', 'draid2', 'draid3', > + ], > }, > devices => { > type => 'string', format => 'string-list', > description => 'The block devices you want to create the zpool on.', > }, > + 'draid-config' => { > + type => 'string', > + format => $draid_config_format, > + optional => 1, > + }, > ashift => { > type => 'integer', > minimum => 9, > @@ -344,6 +366,13 @@ __PACKAGE__->register_method ({ > my $devs = [PVE::Tools::split_list($param->{devices})]; > my $raidlevel = $param->{raidlevel}; > my $compression = $param->{compression} // 'on'; > + my $draid_config = {}; > + if (exists $param->{'draid-config'}) { I moved the "draid-config but no draid level" assertion here, we don't need to check spare/raid settings then explicitly, which would have been prone to forget to updating the check below if draid-config ever got more parameters. > + $draid_config = PVE::JSONSchema::parse_property_string( > + $draid_config_format, $param->{'draid-config'}); > + } > + my $draid_data = $draid_config->{data}; > + my $draid_spares = $draid_config->{spares}; I dropped those intermediate variables, location of declaration and usage was pretty split and it didn't felt like we'd gain much over just using the hash directly here in their current usage.