My submission was rejected previously because I was not a member of
pve-devel mailing list. I added myself to this list and I'm now
re-submitting my patches.
From 753d826597851ef8bd55b7359ff7ee1c5b579920 Mon Sep 17 00:00:00 2001
From: Chris Allen <[email protected]>
Date: Fri, 28 Feb 2014 23:56:02 -0800
Subject: [PATCH 1/6] Added sparse zvol support to ZFS.
To enable, add "sparse" to the ZFS storage section, you wish to use it on, in "/etc/pve/storage.pm"
Signed-off-by: Chris Allen <Chris Allen>
---
PVE/Storage/ZFSPlugin.pm | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/PVE/Storage/ZFSPlugin.pm b/PVE/Storage/ZFSPlugin.pm
index 4a8e9e4..2d422d7 100644
--- a/PVE/Storage/ZFSPlugin.pm
+++ b/PVE/Storage/ZFSPlugin.pm
@@ -249,8 +249,13 @@ sub zfs_resize_lu {
sub zfs_create_zvol {
my ($scfg, $zvol, $size) = @_;
+
+ my $sparse = '';
+ if ($scfg->{sparse}) {
+ $sparse = '-s';
+ }
- zfs_request($scfg, undef, 'create', '-b', $scfg->{blocksize}, '-V', "${size}k", "$scfg->{pool}/$zvol");
+ zfs_request($scfg, undef, 'create', $sparse, '-b', $scfg->{blocksize}, '-V', "${size}k", "$scfg->{pool}/$zvol");
}
sub zfs_delete_zvol {
@@ -319,10 +324,15 @@ sub properties {
description => "iscsi provider",
type => 'string',
},
- blocksize => {
- description => "block size",
- type => 'string',
- }
+ blocksize => {
+ description => "block size",
+ type => 'string',
+ },
+ sparse => {
+ description => "use sparse volumes",
+ type => 'boolean',
+ optional => 1,
+ }
};
}
@@ -335,6 +345,7 @@ sub options {
pool => { fixed => 1 },
blocksize => { fixed => 1 },
iscsiprovider => { fixed => 1 },
+ sparse => { optional => 1 },
content => { optional => 1 },
};
}
--
1.7.10.4
From 8551dfb1a5aa7447480b7abf9e5b581eba567092 Mon Sep 17 00:00:00 2001
From: Chris Allen <Chris Allen>
Date: Mon, 10 Mar 2014 12:07:35 -0700
Subject: [PATCH 2/6] Added "nowritecache" option to ZFS storage plugin. Turns
off write caching on Comstar and Istgt LUNs created by
the plugin. Has no effect on IET, as IET always uses
write-through caching for blockio volumes not in
read-only mode.
Signed-off-by: Chris Allen <Chris Allen>
---
PVE/Storage/LunCmd/Comstar.pm | 6 +++++-
PVE/Storage/LunCmd/Istgt.pm | 16 +++++++++++++---
PVE/Storage/ZFSPlugin.pm | 9 ++++++++-
3 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/PVE/Storage/LunCmd/Comstar.pm b/PVE/Storage/LunCmd/Comstar.pm
index 45ad6a5..aa1c614 100644
--- a/PVE/Storage/LunCmd/Comstar.pm
+++ b/PVE/Storage/LunCmd/Comstar.pm
@@ -50,11 +50,15 @@ sub run_lun_command {
};
if ($method eq 'create_lu') {
+ my $wcd = 'false';
+ if ($scfg->{nowritecache}) {
+ $wcd = 'true';
+ }
my $prefix = '600144f';
my $digest = md5_hex($params[0]);
$digest =~ /(\w{7}(.*))/;
$guid = "$prefix$2";
- @params = ('-p', 'wcd=false', '-p', "guid=$guid", @params);
+ @params = ('-p', "wcd=$wcd", '-p', "guid=$guid", @params);
} elsif ($method eq 'modify_lu') {
@params = ('-s', @params);
} elsif ($method eq 'list_view') {
diff --git a/PVE/Storage/LunCmd/Istgt.pm b/PVE/Storage/LunCmd/Istgt.pm
index 9bbdfa0..b386b5d 100644
--- a/PVE/Storage/LunCmd/Istgt.pm
+++ b/PVE/Storage/LunCmd/Istgt.pm
@@ -173,6 +173,11 @@ my $lun_dumper = sub {
foreach my $conf (@{$SETTINGS->{$lun}->{luns}}) {
$config .= "$conf->{lun} Storage " . $conf->{Storage};
$config .= ' ' . $size_with_unit->($conf->{Size}) . "\n";
+ foreach ($conf->{options}) {
+ if ($_) {
+ $config .= "$conf->{lun} Option " . $_ . "\n";
+ }
+ }
}
$config .= "\n";
@@ -228,16 +233,21 @@ my $free_lu_name = sub {
};
my $make_lun = sub {
- my ($path) = @_;
+ my ($scfg, $path) = @_;
my $target = $SETTINGS->{current};
die 'Maximum number of LUNs per target is 63' if scalar @{$SETTINGS->{$target}->{luns}} >= $MAX_LUNS;
+ my @options = ();
my $lun = $get_lu_name->($target);
+ if ($scfg->{nowritecache}) {
+ push @options, "WriteCache Disable";
+ }
my $conf = {
lun => $lun,
Storage => $path,
Size => 'AUTO',
+ options => @options,
};
push @{$SETTINGS->{$target}->{luns}}, $conf;
@@ -274,7 +284,7 @@ my $parser = sub {
} elsif ($lun) {
next if (($_ =~ /^\s*#/) || ($_ =~ /^\s*$/));
if ($_ =~ /^\s*(\w+)\s+(.+)\s*/) {
- #next if $2 =~ /^Option.*/;
+ next if $2 =~ /^Option.*/;
$SETTINGS->{$lun}->{$1} = $2;
$SETTINGS->{$lun}->{$1} =~ s/^\s+|\s+$|"\s*//g;
} else {
@@ -349,7 +359,7 @@ my $create_lun = sub {
die "$params[0]: LUN exists";
}
my $lun = $params[0];
- $lun = $make_lun->($lun);
+ $lun = $make_lun->($scfg, $lun);
my $config = $lun_dumper->($SETTINGS->{current});
open(my $fh, '>', $file) or die "Could not open file '$file' $!";
diff --git a/PVE/Storage/ZFSPlugin.pm b/PVE/Storage/ZFSPlugin.pm
index 2d422d7..302d2d6 100644
--- a/PVE/Storage/ZFSPlugin.pm
+++ b/PVE/Storage/ZFSPlugin.pm
@@ -328,10 +328,16 @@ sub properties {
description => "block size",
type => 'string',
},
+ # this will disable write caching on comstar and istgt.
+ # it is not implemented for iet. iet blockio always operates with
+ # writethrough caching when not in readonly mode
+ nowritecache => {
+ description => "disable write caching on the target",
+ type => 'boolean',
+ },
sparse => {
description => "use sparse volumes",
type => 'boolean',
- optional => 1,
}
};
}
@@ -345,6 +351,7 @@ sub options {
pool => { fixed => 1 },
blocksize => { fixed => 1 },
iscsiprovider => { fixed => 1 },
+ nowritecache => { optional => 1 },
sparse => { optional => 1 },
content => { optional => 1 },
};
--
1.7.10.4
From d363050104e0ba0767cef34d8ad140cd4c953707 Mon Sep 17 00:00:00 2001
From: Chris Allen <Chris Allen>
Date: Mon, 10 Mar 2014 13:06:09 -0700
Subject: [PATCH 3/6] Fixed command substitution and output redirection in
Istgt module to work in csh - the default shell in
FreeBSD. Changed Istgt "restart" to "onerestart". This
way a running istgt daemon will always restart whether
or not it is enabled in rc.conf.
Signed-off-by: Chris Allen <Chris Allen>
---
PVE/Storage/LunCmd/Istgt.pm | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/PVE/Storage/LunCmd/Istgt.pm b/PVE/Storage/LunCmd/Istgt.pm
index b386b5d..2d59ef3 100644
--- a/PVE/Storage/LunCmd/Istgt.pm
+++ b/PVE/Storage/LunCmd/Istgt.pm
@@ -430,14 +430,14 @@ my $add_view = sub {
my $cmdmap;
if (@params && $params[0] eq 'restart') {
- @params = ('restart', '1>&2', '>', '/dev/null');
+ @params = ('onerestart', '>&', '/dev/null');
$cmdmap = {
cmd => 'ssh',
method => $DAEMON,
params => \@params,
};
} else {
- @params = ('-HUP', '$(cat '. "$SETTINGS->{pidfile})");
+ @params = ('-HUP', '`cat '. "$SETTINGS->{pidfile}`");
$cmdmap = {
cmd => 'ssh',
method => 'kill',
--
1.7.10.4
From b3a474daeb456029f6c970b949d88ee8a7f283c3 Mon Sep 17 00:00:00 2001
From: Chris Allen <Chris Allen>
Date: Tue, 11 Mar 2014 10:46:24 -0700
Subject: [PATCH 4/6] Fixed Istgt LUN Options handling.
Signed-off-by: Chris Allen <Chris Allen>
---
PVE/Storage/LunCmd/Istgt.pm | 38 ++++++++++++++++++++++++--------------
1 file changed, 24 insertions(+), 14 deletions(-)
diff --git a/PVE/Storage/LunCmd/Istgt.pm b/PVE/Storage/LunCmd/Istgt.pm
index 2d59ef3..c17d1c8 100644
--- a/PVE/Storage/LunCmd/Istgt.pm
+++ b/PVE/Storage/LunCmd/Istgt.pm
@@ -284,9 +284,15 @@ my $parser = sub {
} elsif ($lun) {
next if (($_ =~ /^\s*#/) || ($_ =~ /^\s*$/));
if ($_ =~ /^\s*(\w+)\s+(.+)\s*/) {
- next if $2 =~ /^Option.*/;
- $SETTINGS->{$lun}->{$1} = $2;
- $SETTINGS->{$lun}->{$1} =~ s/^\s+|\s+$|"\s*//g;
+ my $arg1 = $1;
+ $2 =~ s/^\s+|\s+$|"\s*//g;
+ if ($2 =~ /^Storage\s*(.+)/i) {
+ $SETTINGS->{$lun}->{$arg1}->{storage} = $1;
+ } elsif ($2 =~ /^Option\s*(.+)/i) {
+ push @{$SETTINGS->{$lun}->{$arg1}->{options}}, $1;
+ } else {
+ $SETTINGS->{$lun}->{$arg1} = $2;
+ }
} else {
die "$line: parse error [$_]";
}
@@ -305,19 +311,23 @@ my $parser = sub {
my $lu = ();
while ((my $key, my $val) = each(%{$SETTINGS->{"LogicalUnit$i"}})) {
if ($key =~ /^LUN\d+/) {
- if ($val =~ /^Storage\s+([\w\/\-]+)\s+(\w+)/) {
- my $storage = $1;
- my $size = $parse_size->($2);
- my $conf = undef;
- if ($storage =~ /^$base\/$scfg->{pool}\/([\w\-]+)$/) {
- $conf = {
- lun => $key,
- Storage => $storage,
- Size => $size,
- };
+ $val->{storage} =~ /^([\w\/\-]+)\s+(\w+)/;
+ my $storage = $1;
+ my $size = $parse_size->($2);
+ my $conf = undef;
+ my @options = ();
+ if ($val->{options}) {
+ @options = @{$val->{options}};
+ }
+ if ($storage =~ /^$base\/$scfg->{pool}\/([\w\-]+)$/) {
+ $conf = {
+ lun => $key,
+ Storage => $storage,
+ Size => $size,
+ options => @options,
}
- push @$lu, $conf if $conf;
}
+ push @$lu, $conf if $conf;
delete $SETTINGS->{"LogicalUnit$i"}->{$key};
}
}
--
1.7.10.4
From afdb500927b634d962dd131208be2a239519c6c4 Mon Sep 17 00:00:00 2001
From: Chris Allen <Chris Allen>
Date: Tue, 11 Mar 2014 15:07:53 -0700
Subject: [PATCH 5/6] Added target-group and host-group options for ZFS
comstar views. Use "comstar_tg" and "comstar_hg" in
"/etc/pve/storage.pm".
Signed-off-by: Chris Allen <Chris Allen>
---
PVE/Storage/LunCmd/Comstar.pm | 9 +++++++++
PVE/Storage/ZFSPlugin.pm | 12 +++++++++++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/PVE/Storage/LunCmd/Comstar.pm b/PVE/Storage/LunCmd/Comstar.pm
index aa1c614..1b079f0 100644
--- a/PVE/Storage/LunCmd/Comstar.pm
+++ b/PVE/Storage/LunCmd/Comstar.pm
@@ -66,6 +66,15 @@ sub run_lun_command {
} elsif ($method eq 'list_lu') {
$guid = $params[0];
@params = undef;
+ } elsif ($method eq 'add_view') {
+ if ($scfg->{comstar_tg}) {
+ unshift @params, $scfg->{comstar_tg};
+ unshift @params, '--target-group';
+ }
+ if ($scfg->{comstar_hg}) {
+ unshift @params, $scfg->{comstar_hg};
+ unshift @params, '--host-group';
+ }
}
my $cmdmap = $get_lun_cmd_map->($method);
diff --git a/PVE/Storage/ZFSPlugin.pm b/PVE/Storage/ZFSPlugin.pm
index 302d2d6..208e718 100644
--- a/PVE/Storage/ZFSPlugin.pm
+++ b/PVE/Storage/ZFSPlugin.pm
@@ -338,7 +338,15 @@ sub properties {
sparse => {
description => "use sparse volumes",
type => 'boolean',
- }
+ },
+ comstar_tg => {
+ description => "target group for comstar views",
+ type => 'string',
+ },
+ comstar_hg => {
+ description => "host group for comstar views",
+ type => 'string',
+ },
};
}
@@ -353,6 +361,8 @@ sub options {
iscsiprovider => { fixed => 1 },
nowritecache => { optional => 1 },
sparse => { optional => 1 },
+ comstar_hg => { optional => 1 },
+ comstar_tg => { optional => 1 },
content => { optional => 1 },
};
}
--
1.7.10.4
From d749f409743f02c89d8aaa04b2726b3b10a8e41a Mon Sep 17 00:00:00 2001
From: Chris Allen <Chris Allen>
Date: Tue, 11 Mar 2014 17:32:17 -0700
Subject: [PATCH 6/6] Added code to abort a snapshot rollback in ZFS if the
snapshot selected is not the most recent. This is to
avoid lu deletion when trying to rollback to a snapshot
that isn't the newest.
Signed-off-by: Chris Allen <Chris Allen>
---
PVE/Storage/ZFSPlugin.pm | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/PVE/Storage/ZFSPlugin.pm b/PVE/Storage/ZFSPlugin.pm
index 208e718..cb733d1 100644
--- a/PVE/Storage/ZFSPlugin.pm
+++ b/PVE/Storage/ZFSPlugin.pm
@@ -607,6 +607,21 @@ sub volume_snapshot {
sub volume_snapshot_rollback {
my ($class, $scfg, $storeid, $volname, $snap) = @_;
+ # abort rollback if snapshot is not the latest
+ my @params = ('-t', 'snapshot', '-o', 'name', '-s', 'creation');
+ my $text = zfs_request($scfg, undef, 'list', @params);
+ my @snapshots = split(/\n/, $text);
+ my $recentsnap = undef;
+ foreach (@snapshots) {
+ if (/$scfg->{pool}\/$volname/) {
+ s/^.*@//;
+ $recentsnap = $_;
+ }
+ }
+ if ($snap ne $recentsnap) {
+ die "cannot rollback, more recent snapshots exist\n";
+ }
+
zfs_delete_lu($scfg, $volname);
zfs_request($scfg, undef, 'rollback', "$scfg->{pool}/$volname\@$snap");
--
1.7.10.4
_______________________________________________
pve-devel mailing list
[email protected]
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel