Add functionality for iSCSI multipathing
- Added patch from @tl8roy to add multipathing to the ZFSPluging.pm for FreeNAS. I believe this was only patched and tested for FreeNAS. I tested WITHOUT using multipathing and I have had no issues. Closes enhancement request #15 and reference #11.
This commit is contained in:
parent
94d897f7d1
commit
0e58a78e4a
|
|
@ -1,5 +1,5 @@
|
||||||
--- ZFSPlugin.pm.orig 2018-05-16 04:06:14.000000000 -0400
|
--- ZFSPlugin.pm.orig 2018-05-16 04:06:14.000000000 -0400
|
||||||
+++ ZFSPlugin.pm 2018-08-19 09:34:25.169349056 -0400
|
+++ ZFSPlugin.pm 2018-08-19 15:44:12.472851999 -0400
|
||||||
@@ -10,6 +10,7 @@
|
@@ -10,6 +10,7 @@
|
||||||
|
|
||||||
use base qw(PVE::Storage::ZFSPoolPlugin);
|
use base qw(PVE::Storage::ZFSPoolPlugin);
|
||||||
|
|
@ -8,7 +8,14 @@
|
||||||
use PVE::Storage::LunCmd::Istgt;
|
use PVE::Storage::LunCmd::Istgt;
|
||||||
use PVE::Storage::LunCmd::Iet;
|
use PVE::Storage::LunCmd::Iet;
|
||||||
|
|
||||||
@@ -31,7 +32,7 @@
|
@@ -25,13 +26,14 @@
|
||||||
|
modify_lu => 1,
|
||||||
|
add_view => 1,
|
||||||
|
list_view => 1,
|
||||||
|
+ list_extent => 1,
|
||||||
|
list_lu => 1,
|
||||||
|
};
|
||||||
|
|
||||||
my $zfs_unknown_scsi_provider = sub {
|
my $zfs_unknown_scsi_provider = sub {
|
||||||
my ($provider) = @_;
|
my ($provider) = @_;
|
||||||
|
|
||||||
|
|
@ -17,7 +24,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
my $zfs_get_base = sub {
|
my $zfs_get_base = sub {
|
||||||
@@ -39,6 +40,8 @@
|
@@ -39,6 +41,8 @@
|
||||||
|
|
||||||
if ($scfg->{iscsiprovider} eq 'comstar') {
|
if ($scfg->{iscsiprovider} eq 'comstar') {
|
||||||
return PVE::Storage::LunCmd::Comstar::get_base;
|
return PVE::Storage::LunCmd::Comstar::get_base;
|
||||||
|
|
@ -26,7 +33,7 @@
|
||||||
} elsif ($scfg->{iscsiprovider} eq 'istgt') {
|
} elsif ($scfg->{iscsiprovider} eq 'istgt') {
|
||||||
return PVE::Storage::LunCmd::Istgt::get_base;
|
return PVE::Storage::LunCmd::Istgt::get_base;
|
||||||
} elsif ($scfg->{iscsiprovider} eq 'iet') {
|
} elsif ($scfg->{iscsiprovider} eq 'iet') {
|
||||||
@@ -59,6 +62,8 @@
|
@@ -59,6 +63,8 @@
|
||||||
if ($lun_cmds->{$method}) {
|
if ($lun_cmds->{$method}) {
|
||||||
if ($scfg->{iscsiprovider} eq 'comstar') {
|
if ($scfg->{iscsiprovider} eq 'comstar') {
|
||||||
$msg = PVE::Storage::LunCmd::Comstar::run_lun_command($scfg, $timeout, $method, @params);
|
$msg = PVE::Storage::LunCmd::Comstar::run_lun_command($scfg, $timeout, $method, @params);
|
||||||
|
|
@ -35,7 +42,22 @@
|
||||||
} elsif ($scfg->{iscsiprovider} eq 'istgt') {
|
} elsif ($scfg->{iscsiprovider} eq 'istgt') {
|
||||||
$msg = PVE::Storage::LunCmd::Istgt::run_lun_command($scfg, $timeout, $method, @params);
|
$msg = PVE::Storage::LunCmd::Istgt::run_lun_command($scfg, $timeout, $method, @params);
|
||||||
} elsif ($scfg->{iscsiprovider} eq 'iet') {
|
} elsif ($scfg->{iscsiprovider} eq 'iet') {
|
||||||
@@ -173,6 +178,22 @@
|
@@ -155,6 +161,14 @@
|
||||||
|
return $class->zfs_request($scfg, undef, 'list_view', $guid);
|
||||||
|
}
|
||||||
|
|
||||||
|
+sub zfs_get_wwid_number {
|
||||||
|
+ my ($class, $scfg, $guid) = @_;
|
||||||
|
+
|
||||||
|
+ die "could not find lun_number for guid $guid" if !$guid;
|
||||||
|
+
|
||||||
|
+ return $class->zfs_request($scfg, undef, 'list_extent', $guid);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
# Configuration
|
||||||
|
|
||||||
|
sub type {
|
||||||
|
@@ -173,6 +187,22 @@
|
||||||
description => "iscsi provider",
|
description => "iscsi provider",
|
||||||
type => 'string',
|
type => 'string',
|
||||||
},
|
},
|
||||||
|
|
@ -58,7 +80,7 @@
|
||||||
# this will disable write caching on comstar and istgt.
|
# this will disable write caching on comstar and istgt.
|
||||||
# it is not implemented for iet. iet blockio always operates with
|
# it is not implemented for iet. iet blockio always operates with
|
||||||
# writethrough caching when not in readonly mode
|
# writethrough caching when not in readonly mode
|
||||||
@@ -204,6 +225,10 @@
|
@@ -204,6 +234,10 @@
|
||||||
sparse => { optional => 1 },
|
sparse => { optional => 1 },
|
||||||
comstar_hg => { optional => 1 },
|
comstar_hg => { optional => 1 },
|
||||||
comstar_tg => { optional => 1 },
|
comstar_tg => { optional => 1 },
|
||||||
|
|
@ -69,3 +91,46 @@
|
||||||
content => { optional => 1 },
|
content => { optional => 1 },
|
||||||
bwlimit => { optional => 1 },
|
bwlimit => { optional => 1 },
|
||||||
};
|
};
|
||||||
|
@@ -225,7 +259,41 @@
|
||||||
|
my $guid = $class->zfs_get_lu_name($scfg, $name);
|
||||||
|
my $lun = $class->zfs_get_lun_number($scfg, $guid);
|
||||||
|
|
||||||
|
- my $path = "iscsi://$portal/$target/$lun";
|
||||||
|
+ my $wwid = $class->zfs_get_wwid_number($scfg, $guid);
|
||||||
|
+# syslog(info,"JD: path get_lun_number guid $uid");
|
||||||
|
+
|
||||||
|
+ if ($wwid =~ /^([-\@\w.]+)$/) {
|
||||||
|
+ $wwid = $1; # $data now untainted
|
||||||
|
+ } else {
|
||||||
|
+ die "Bad data in '$wwid'"; # log this somewhere
|
||||||
|
+ }
|
||||||
|
+ my $wwid_end = substr $wwid, 16;
|
||||||
|
+
|
||||||
|
+ my $mapper = '';
|
||||||
|
+ sleep 3;
|
||||||
|
+ run_command("iscsiadm -m session --rescan");
|
||||||
|
+ sleep 3;
|
||||||
|
+ my $line = `multipath -ll | grep \"$wwid_end\"`;
|
||||||
|
+ my ($mapper_device) = split(' ', $line);
|
||||||
|
+ $mapper_device = "" unless $mapper_device;
|
||||||
|
+ $mapper .= $mapper_device;
|
||||||
|
+
|
||||||
|
+ my $path = "";
|
||||||
|
+
|
||||||
|
+ if ($mapper =~ /^([-\@\w.]+)$/) {
|
||||||
|
+ $mapper = $1; # $data now untainted
|
||||||
|
+ } else {
|
||||||
|
+ $mapper = '';
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+# syslog(info,"Mapper: $mapper\n");
|
||||||
|
+ if ($mapper eq "")
|
||||||
|
+ {
|
||||||
|
+ $path = "iscsi://$portal/$target/$lun";
|
||||||
|
+ } else {
|
||||||
|
+ $path = "/dev/mapper/$mapper";
|
||||||
|
+ sleep 5;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
return ($path, $vmid, $vtype);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue