scstadmin: Improve copy manager support further

Also restore pass-through LUNs


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@6712 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2015-11-23 23:04:57 +00:00
parent 3047ca75fd
commit 949aa31053
3 changed files with 40 additions and 11 deletions

View File

@@ -3930,7 +3930,11 @@ sub handlerAttributes {
}
}
next if ($attribute eq SCST_MGMT_IO);
if ($attribute eq SCST_MGMT_IO) {
$attributes{$attribute}->{'static'} = TRUE;
$attributes{$attribute}->{'value'} = $value;
next;
}
if (!(($mode & S_IRUSR) >> 6)) {
$attributes{$attribute}->{'static'} = FALSE;

View File

@@ -9,6 +9,8 @@ BEGIN {
if ($> == 0) {
ok(system("killall iscsi-scstd >/dev/null 2>&1; " .
"modprobe -r scst_cdrom; " .
"modprobe -r scst_disk; " .
"modprobe -r scst_local; " .
"modprobe -r isert-scst; " .
"modprobe -r iscsi-scst; " .

View File

@@ -1334,6 +1334,25 @@ sub serializeNkAttr {
return $result;
}
# Return TRUE if and only if $1 is an SCST pass-through device.
sub isPassthroughDev {
my $dev = shift;
my $pt = FALSE;
foreach my $handler (keys %{$CURRENT{'handler'}}) {
my ($ha, $errorString) = $SCST->handlerAttributes($handler);
next if ($ha->{'mgmt'} !~ 'echo "add_device H:C:I:L"');
my @devs = @{$CURRENT{'handler'}->{$handler}};
for my $i (0 .. $#devs) {
if ($dev eq @devs[$i]) {
$pt = TRUE;
last;
}
}
last if $pt;
}
}
# Returns 0 upon success and 1 upon error.
sub writeConfiguration {
my $nonkey = shift;
@@ -1462,11 +1481,14 @@ sub writeConfiguration {
my $t_lun_buff;
foreach my $lun (sort numerically keys %{$luns}) {
# Do not save copy_manager LUN definitions.
next if ($driver eq 'copy_manager');
my $lun_dev = $$luns{$lun};
# Do not save copy_manager LUN definitions
# for LUNs associated with an SCST device
# handler.
next if ($driver eq 'copy_manager' &&
isPassthroughDev($lun_dev));
$t_lun_buff .= "\t\tLUN $lun $lun_dev";
my ($attributes, $errorString) = $SCST->lunAttributes($driver, $target, $lun);
@@ -1895,7 +1917,7 @@ sub checkConfiguration {
}
}
if (!defined($$tgt{'LUN'}->{'0'})) {
if ($driver ne 'copy_manager' && !defined($$tgt{'LUN'}->{'0'})) {
print "\t-> WARNING: No LUN 0 defined for driver/target '$driver/$target'. ".
"Many initiators require a LUN 0 to be defined.\n\n";
$warnings++;
@@ -2107,7 +2129,7 @@ sub applyConfigAssignments {
if ($deletions) {
removeLun($driver, $target, $lun);
$changes++;
} else {
} elsif ($driver ne 'copy_manager') {
print "\t-> Device '$device' at LUN '$lun' is not in configuration ".
"for driver/target '$driver/$target'. ".
"Use -force to remove it.\n";
@@ -2617,11 +2639,6 @@ sub applyLunAssignments {
my $c_luns;
my $changes = 0;
# Do not restore copy_manager LUN definitions.
if ($driver eq 'copy_manager') {
return 0;
}
if (defined($group)) {
$c_luns = $CURRENT{'assign'}->{$driver}->{$target}->{'GROUP'}->{$group}->{'LUN'};
} else {
@@ -4888,6 +4905,12 @@ sub addLun {
my $attributes = shift;
my $group = shift;
# Do not complain about existing copy manager LUNs.
if ($driver eq 'copy_manager' &&
$SCST->lunExists($driver, $target, $lun, $group)) {
return FALSE;
}
if (defined($group)) {
print "\t-> Adding device '$device' at LUN $lun to driver/target/group ".
"'$driver/$target/$group': ";