]> git.proxmox.com Git - pve-storage.git/commitdiff
disk manage: move "draid-config set only on draid level" assertion
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 11 Nov 2022 08:22:19 +0000 (09:22 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 11 Nov 2022 08:36:03 +0000 (09:36 +0100)
so that there is a better code locality and also we avoid forgetting
to adapt the check for each specific draid-config parameter if a new
one gets added or an existing one changed.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/API2/Disks/ZFS.pm

index 9651ba15cff8794e47c3e859365bab3b4ec96ae7..ca3169de49d4f4fdac095c99e82385f89b74123a 100644 (file)
@@ -363,6 +363,7 @@ __PACKAGE__->register_method ({
        my $compression = $param->{compression} // 'on';
        my $draid_config = {};
        if (exists $param->{'draid-config'}) {
+           die "draid-config set without using dRAID level\n" if $raidlevel !~ m/^draid/;
            $draid_config = PVE::JSONSchema::parse_property_string(
                $draid_config_format, $param->{'draid-config'});
        }
@@ -431,9 +432,6 @@ __PACKAGE__->register_method ({
 
            die "At least $draidmin disks needed for current dRAID config\n"
                if $numdisks < $draidmin;
-       } else {
-           die "draidspares and/or draiddata set without using dRAID"
-               if ($draid_spares or $draid_data);
        }
 
        my $code = sub {