From: Stefan Hrdlicka <s.hrdlicka@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH V4 storage 1/3] fix #3967: enable ZFS dRAID creation via API
Date: Thu, 10 Nov 2022 14:24:48 +0100 [thread overview]
Message-ID: <20221110132450.567121-2-s.hrdlicka@proxmox.com> (raw)
In-Reply-To: <20221110132450.567121-1-s.hrdlicka@proxmox.com>
It is possible to set the number of spares and the size of
data stripes via draidspares & dreaddata parameters.
Signed-off-by: Stefan Hrdlicka <s.hrdlicka@proxmox.com>
---
PVE/API2/Disks/ZFS.pm | 55 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 54 insertions(+), 1 deletion(-)
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)',
+ },
+};
+
__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'}) {
+ $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};
for my $dev (@$devs) {
$dev = PVE::Diskmanage::verify_blockdev_path($dev);
@@ -381,6 +410,9 @@ __PACKAGE__->register_method ({
raidz => 3,
raidz2 => 4,
raidz3 => 5,
+ draid => 3,
+ draid2 => 4,
+ draid3 => 5,
};
# sanity checks
@@ -393,6 +425,22 @@ __PACKAGE__->register_method ({
die "$raidlevel needs at least $mindisks->{$raidlevel} disks\n"
if $numdisks < $mindisks->{$raidlevel};
+ # draid checks
+ if ($raidlevel =~ m/^draid/) {
+ # bare minimum would be two drives:
+ # one parity & one data drive this code doesn't allow that because
+ # it makes no sense, at least one spare disk should be used
+ my $draidmin = $mindisks->{$raidlevel} - 2;
+ $draidmin += $draid_data if $draid_data;
+ $draidmin += $draid_spares if $draid_spares;
+
+ 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 {
for my $dev (@$devs) {
PVE::Diskmanage::assert_disk_unused($dev);
@@ -429,6 +477,11 @@ __PACKAGE__->register_method ({
}
} elsif ($raidlevel eq 'single') {
push @$cmd, $devs->[0];
+ } elsif ($raidlevel =~ m/^draid/) {
+ my $draid_cmd = $raidlevel;
+ $draid_cmd .= ":${draid_data}d" if $draid_data;
+ $draid_cmd .= ":${draid_spares}s" if $draid_spares;
+ push @$cmd, $draid_cmd, @$devs;
} else {
push @$cmd, $raidlevel, @$devs;
}
--
2.30.2
next prev parent reply other threads:[~2022-11-10 13:25 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-10 13:24 [pve-devel] [PATCH V4 SERIES storage/manager/docs 0/3] fix #3967: add ZFS dRAID creation Stefan Hrdlicka
2022-11-10 13:24 ` Stefan Hrdlicka [this message]
2022-11-11 8:40 ` [pve-devel] applied: [PATCH V4 storage 1/3] fix #3967: enable ZFS dRAID creation via API Thomas Lamprecht
2022-11-10 13:24 ` [pve-devel] [PATCH V4 manager 2/3] fix #3967: enable ZFS dRAID creation in WebGUI Stefan Hrdlicka
2022-11-17 18:34 ` [pve-devel] applied: " Thomas Lamprecht
2022-11-10 13:24 ` [pve-devel] [PATCH V4 docs 3/3] fix #3967: add ZFS dRAID documentation Stefan Hrdlicka
2022-11-17 18:35 ` [pve-devel] applied: " Thomas Lamprecht
2022-11-10 13:43 ` [pve-devel] [PATCH V4 SERIES storage/manager/docs 0/3] fix #3967: add ZFS dRAID creation Lukas Wagner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221110132450.567121-2-s.hrdlicka@proxmox.com \
--to=s.hrdlicka@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox