Mitch,
Your hints were right on target. I converted your Perl to Bourne Shell and
finished converting the script to work with the Qualstar. It is now working
very well. Thank you! My box only has one drive, can anybody give me any
hints on how to make this work with two? Would I just define a second backup
set with a different set of drive parameters? Can somebody send me a mtx
status result from a Qualstar that has 2 tape drives?
I have attached the script as it stands for anybody else who has a Qualstar
with one drive.
markh
-----Original Message-----
From: Mitch Collinsworth [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 22, 2001 8:59 PM
To: Mark Holm
Cc: '[EMAIL PROTECTED]'
Subject: Re: Qualstar TLS-4220 problems
On Wed, 22 Aug 2001, Mark Holm wrote:
> Qualstar TLS-4220 Tape Jukebox with 20 slots and 1 AIT-1 tape drive
>
> It appears as if the changer mechanism and the tape drive are not
> releasing the SCSI bus in a timely manner to allow the commands to
complete
> when you switch devices.
>
> Has anybody else seen this behavior? How do I fix it? Does anybody else
have
> a Qualstar working with Amanda on RedHat 7.1?
I have a Qualstar TLS-4212 that I have not yet started interfacing
to Amanda, but will be doing so soon. What I have found with this
library, as well as with an Overland library I used in a previous
job, is that there is a delay between when a tape is loaded by the
library into the tape drive and when the tape drive becomes ready to
accept tape commands. Commands issued to the tape drive during this
period receive errors.
The Overland I used with a system that didn't at that time have a
supported changer script, so I wrote my own. I found I had to insert
a delay after loading a tape until the drive became ready before
returning to the calling program. Amanda tape changing worked
flawlessly in this manner.
I haven't yet begun setting up my Qualstar with Amanda but from
initial testing with a perl script it appears the same trick will be
necessary. Below is a copy of my test script, which illustrates how
I was able to get the Qualstar to behave itself under program control.
Note in particular the wait_for_drive_ready subroutine. This is stolen
more or less directly from my changer script for the Overland, except
for the open() test that worked the Overland's DLT drive but failed
to work with the Qualstar's AIT2 drive. This is replaced with a
rather kludgy (but working) routine called tape_online. I'd like to
think there's a better way to do this bit but in the short time I've
spent on it so far it hasn't come to me.
-Mitch
---------
#!/usr/local/bin/perl
# qtest: some preliminary testing of qualstar tape library
# configuration data
$CHANGER = '/dev/sg4'; # device file for changer mechanism
$TAPE = '/dev/nst0'; # device file for tape drive
$MT = "/bin/mt -t $TAPE"; # path to mt
$MTX = "/sbin/mtx -f $CHANGER"; # path to mtx
$MAXDELAY = 200; # max delay to insert after tape load
# to allow tape drive to become ready.
$FIRST_SLOT = 1;
$LAST_SLOT = 10;
#$slot = 10;
#while (1) {
# &load_tape($slot++);
# if ($slot > $LAST_SLOT) { $slot = $FIRST_SLOT; }
#}
while (1) {
$loaded_tape = &tape_loaded;
print "Current loaded tape: $loaded_tape\n";
&next_tape;
}
exit 0;
#
# load_tape: load tape from specified slot
#
sub load_tape {
local($new_slot) = @_;
local($response,$result);
# first see if a tape is already loaded that needs to be put away
$loaded_slot = &tape_loaded;
# put away loaded tape
if ($loaded_slot > 0) {
if (&tape_online) {
print "ejecting tape from drive...\n";
system "$MT offl";
}
print "returning tape to slot $loaded_slot...\n";
system "$MTX unload >/dev/null 2>&1";
}
# load requested tape
print "loading tape from slot $new_slot...\n";
system "$MTX load $new_slot";
# wait for tape loading to complete and drive to become ready
&wait_for_drive_ready;
}
#
# next_tape: load next tape in sequence
#
sub next_tape {
local $loaded_slot = &tape_loaded;
# if tape is in drive, eject first
if (&tape_online) {
print "ejecting tape from drive...\n";
system "$MT offl";
}
# if current tape is from last slot, load tape from first slot
if ($loaded_slot == $LAST_SLOT) {
&load_tape( $FIRST_SLOT );
} else {
# load next tape
print "loading next tape\n";
system "$MTX next >/dev/null 2>&1";
}
# wait for tape loading to complete and drive to become ready
&wait_for_drive_ready;
}
#
# tape_loaded: returns slot currently loaded tape came from, -1 if none
#
sub tape_loaded {
local ($loaded_slot);
open(MTX, "$MTX status|");
while (<MTX>) {
if ( /Data Transfer Element 0:Full/ ) {
($loaded_slot) = /Storage Element (\d+) Loaded/;
last;
} elsif ( /Data Transfer Element 0:Empty/ ) {
$loaded_slot = -1;
last;
}
}
close MTX;
return $loaded_slot;
}
#
# wait_for_drive_ready: test/sleep loop to wait till tape drive
# becomes ready
#
sub wait_for_drive_ready {
local $remaining;
# see if tape drive is ready. if not, sleep a while and check again
$remaining = $MAXDELAY;
# this test works for DLT4000 but not for AIT2
# while (!open(TAPE,$TAPE) && $remaining > 0) {
# this test works for AIT2
while (!&tape_online && $remaining > 0) {
$remaining -= sleep 5;
}
if ($remaining <= 0) {
print "$0 drive $TAPE timed out, not responding\n";
exit 2;
}
# close TAPE;
}
#
# tape_online: test a AIT2 tape drive to see if it's ready for some work
#
sub tape_online {
# do an 'mt status' command and throw away all but the last line
# of output. See if last line contains "ONLINE".
open(MT,"$MT status|");
while (<MT>) {
last if (/General status bits on/);
}
$_ = <MT>;
if (/ONLINE/) {
return 1;
} else {
return 0;
}
}
begin 600 chg-mtx
M(R$O8FEN+W-H("UX=@T*(PT*(R!%>&ET(%-T871U<SH-"B,@,"!!;&QE<R!/
M:PT*(R`Q($EL;&5G86P@4F5Q=65S=`T*(R`R($9A=&%L($5R<F]R#0HC#0H-
M"B,@=')Y('1O(&AI="!A;&P@=&AE('!O<W-I8FEL:71I97,@:&5R90T*<')E
M9FEX/2]U<W(-"F5X96-?<')E9FEX/2]U<W(-"G-B:6YD:7(]+W5S<B]S8FEN
M#0IL:6)E>&5C9&ER/2]U<W(O;&EB+V%M86YD80T*(`T*4$%42#TD<V)I;F1I
M<CHD;&EB97AE8V1I<CHO=7-R+V)I;CHO8FEN.B]U<W(O<V)I;CHO<V)I;CHO
M=7-R+W5C8CHO=7-R+VQO8V%L+V)I;@T*97AP;W)T(%!!5$@-"@T*:68@6R`M
M9"`B+W1M<"]A;6%N9&$B(%T[('1H96X-"@E$0D=&24Q%/2]T;7`O86UA;F1A
M+V-H86YG97(N9&5B=6<-"F5L<V4-"@E$0D=&24Q%/2]D978O;G5L;`T*9FD-
M"@T*55-%7U9%4E-)3TY?4U5&1DE815,](FYO(@T*:68@=&5S="`B)%5315]6
M15)324].7U-51D9)6$53(B`](")Y97,B.R!T:&5N#0H)4U5&/2(M,BXT+C)P
M,B(-"F5L<V4-"@E3548]#0IF:0T*#0IM>6YA;64])#`-"G1A<&4]8&%M9V5T
M8V]N9B13548@=&%P961E=F`-"E1!4$4]8&%M9V5T8V]N9B13548@8VAA;F=E
M<F1E=F`[(&5X<&]R="!405!%(",@9F]R(&UT>"!C;VUM86YD#0II9B!;("(D
M=&%P92(@/2`B+V1E=B]N=6QL(B`M;R`B)%1!4$4B(#T@(B]D978O;G5L;"(@
M73L@=&AE;@T*("!E8VAO(")";W1H('1A<&5D978@86YD(&-H86YG97)D978@
M;75S="!B92!S<&5C:69I960@:6X@8V]N9FEG(&9I;&4B.PT*("!E>&ET(#([
M#0IF:0T*350](B]B:6XO;70B#0I-5$8](BUF(@T*3518/2)M='@@+68@)%1!
M4$4B#0I$1#TO8FEN+V1D#0IF:7)S='-L;W0],0T*;&%S='-L;W0],C`-"B,@
M8V]U;G1E9"!F<F]M(#$@(2$A#0IC;&5A;G-L;W0],C$-"FUA>'=A:71T:6UE
M/3(P,`T*#0IC:&%N9V5R9FEL93U@86UG971C;VYF)%-51B!C:&%N9V5R9FEL
M96`-"@T*8VQE86YF:6QE/21C:&%N9V5R9FEL92UC;&5A;@T*86-C97-S9FEL
M93TD8VAA;F=E<F9I;&4M86-C97-S#0I;("$@+68@)&-L96%N9FEL92!=("8F
M(&5C:&\@,"`^("1C;&5A;F9I;&4-"EL@(2`M9B`D86-C97-S9FEL92!=("8F
M(&5C:&\@,"`^("1A8V-E<W-F:6QE#0IC;&5A;F-O=6YT/6!C870@)&-L96%N
M9FEL96`-"F%C8V5S<V-O=6YT/6!C870@)&%C8V5S<V9I;&5@#0HC#0H-"G=A
M:71?9F]R7W1A<&4H*2![#0H@("!T:6UE7W)E;6%I;FEN9STD;6%X=V%I='1I
M;64-"B`@('1A<&5?;VYL:6YE#0H@("!W:&EL92!;("1T87!E7W)E861Y(#T@
M(D9!3%-%(B`M82`D=&EM95]R96UA:6YI;F<@+6=T(#`@73L@9&\-"B`@("`@
M('-L965P(#4-"B`@("`@('1I;65?<F5M86EN:6YG/20H*"`D=&EM95]R96UA
M:6YI;F<@+2`U("DI#0H@("`@("!T87!E7V]N;&EN90T*("`@9&]N90T*#0H@
M("!I9B!;("1T:6UE7W)E;6%I;FEN9R`M;&4@,"!=.R!T:&5N#0H@("`@("!E
M8VAO("(@("`@("T^($1R:79E(%1I;65D($]U="(@/CX@)$1"1T9)3$4-"B`@
M("`@(&5C:&\@(C`@1')I=F4@=&EM960@;W5T(@T*("`@("`@97AI="`Q#0H@
M("!F:0T*?0T*#0H-"B,-"@T*=&%P95]O;FQI;F4H*2![#0H@("!I9B!;(&`D
M350@)$U41B`D=&%P92!S=&%T=7,@?"!G<F5P("UC:2!O;FQI;F5@("UE<2`Q
M(%T[('1H96X-"B`@("`@(&5C:&\@(B`@("`@+3X@1')I=F4@4F5A9'DB(#X^
M("1$0D=&24Q%#0H@("`@("!T87!E7W)E861Y/2)44E5%(@T*("`@96QS90T*
M("`@("`@96-H;R`B("`@("`M/B!$<FEV92!.;W0@4F5A9'DB(#X^("1$0D=&
M24Q%#0H@("`@("!T87!E7W)E861Y/2)&04Q312(-"B`@(&9I#0I]#0H)(`T*
M(PT*#0IR96%D<W1A='5S*"D@>PT*("!U<V5D/6`D3518('-T871U<R!\#0H@
M("`@87=K("<O16QE;65N="`P7#I&=6QL+R![<')I;G0@)#=].R`O16QE;65N
M="`P7#I%;7!T>2\@>W!R:6YT("TQ?3LG8`T*#0H@(&EF(%L@+7H@(B1U<V5D
M(B!=.R!T:&5N#0H@("`@=7-E9#TB+3$B.PT*("!F:0T*?0T*#0H-"F5J96-T
M*"D@>PT*("!R96%D<W1A='5S(`T*("!I9B!;("1U<V5D("UG="`P(%T[=&AE
M;@T*("`@("1-5"`D351&("1T87!E(&]F9B`^("]D978O;G5L;"`R/B8Q#0H@
M("`@)$U46"!U;FQO860@)'5S960@/B`O9&5V+VYU;&P@,CXF,0T*("`@(&5C
M:&\@,"`D=&%P90T*("`@('-L965P(#$P#0H@("`@97AI="`P#0H@(&5L<V4-
M"B`@("!E8VAO("(P($1R:79E('=A<R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0H-"B`@("`C(%-L;W0@
M)&-L96%N<VQO="!M:6=H="!C;VYT86EN(&%N(&]R9&EN87)Y('1A<&4@<F%T
M:&5R('1H86X@82!C;&5A;FEN9PT*("`@(",@=&%P92X@02!C;&5A;FEN9R!T
M87!E(&%U=&\M96IE8W1S.R!A;B!O<F1I;F%R>2!T87!E(&1O97,@;F]T+@T*
M("`@(",@5V4@=&AE<F5F;W)E(&AA=F4@=&\@<F5A9"!T:&4@<W1A='5S(&%G
M86EN('1O(&-H96-K('=H870-"B`@("`C(&%C='5A;&QY(&AA<'!E;F5D+@T*
M("`@(')E861S=&%T=7,-"@D-"@T*("`@(&EF(%L@)'5S960@+6=T(#`@73MT
M:&5N#0H@("`@("!E8VAO("(@("`@("T^('5N;&]A9"`D=7-E9"(@/CX@)$1"
M1T9)3$4-"B`@("`@(')E<SU@)$U4("1-5$8@)'1A<&4@;V9F.R`D3518('5N
M;&]A9"`D=7-E9"`^+V1E=B]N=6QL(#(^)C%@#0H@("`@("!S=&%T=7,])#\-
M"B`@("`@(&5C:&\@(B`@("`@+3X@<W1A='5S("1S=&%T=7,B(#X^("1$0D=&
M24Q%#0H@("`@("!E8VAO("(@("`@("T^(')E<R`@("`D<F5S(B`^/B`D1$)'
M1DE,10T*("`@("`@:68@6R`D<W1A='5S("UN92`P(%T[=&AE;@T*("`@("`@
M("!E8VAO("(D<F5S(@T*("`@("`@("!E>&ET(#(-"B`@("`@(&9I#0H@("`@
M9FD-"B`@("!I9B!;("1W:&EC:'-L;W0@/2!A9'9A;F-E(%T[=&AE;@T*("`@
M("`@96-H;R`B)&QO860@+V1E=B]N=6QL(@T*("`@("`@97AI="`P#0H@("`@
M9FD-"B`@("!E8VAO("(@("`@("T^(&QO860@("`D;&]A9"(@/CX@)$1"1T9)
M3$4-"@D@("`@("`@#0H@("`@<F5S/6`D3518(&QO860@)&QO860@/B]D978O
M;G5L;"`R/B8Q8`T*("`@('-T871U<STD/PT*("`@(&5C:&\@(B`@("`@+3X@
M<W1A='5S("1S=&%T=7,B(#X^("1$0D=&24Q%#0H@("`@96-H;R`B("`@("`M
M/B!R97,@("`@)')E<R(@/CX@)$1"1T9)3$4-"B`@("!I9B!;("1S=&%T=7,@
M+65Q(#`@73MT:&5N#0H@("`@("!E8VAO("(@("`@("T^(')E=R`D;&]A9"(@
M/CX@)$1"1T9)3$4-"B`@("`@(&5C:&\@(B1L;V%D("1T87!E(@T*("`@("`@
M=V%I=%]F;W)?=&%P90T*("`@("`@)$U4("1-5$8@)'1A<&4@<F5W:6YD#0H@
M("`@("`D1$0@:68])'1A<&4@8V]U;G0],2`^/B`D1$)'1DE,12`R/B8Q#0H@
M("`@("!W86ET7V9O<E]T87!E#0H@("`@("!E>&ET(#`-"B`@("!E;'-E#0H@
M("`@("!E8VAO("(D;&]A9"`D<F5S(@T*("`@("`@97AI="`R#0H@("`@9FD-
M"GT-"B,-"FEN9F\H*2![#0H@(')E861S=&%T=7,-"B`@96-H;R`B("`@("`M
M/B!I;F9O("`@)'5S960B(#X^("1$0D=&24Q%#0H@(&EF(%L@)'5S960@+6QT
M(#`@73MT:&5N#0H@("`@96-H;R`B,"`D;&%S='-L;W0@,2(-"B`@96QS90T*
M("`@(&5C:&\@(B1U<V5D("1L87-T<VQO="`Q(@T*("!F:0T*("!E>&ET(#`-
M"GT-"B,-"F5C:&\@07)G<R`B+3XB("(D0"(@/CX@)$1"1T9)3$4-"G=H:6QE
M(%L@)",@+6=E(#$@73MD;PT*("!C87-E("0Q(&EN#0H@("`@+7-L;W0I#0H)
M("`@<VAI9G0-"@D@("!L;V%D<VQO="`D*@T*"2`@(#L[#0H@("`@+6EN9F\I
M#0H)("`@<VAI9G0-"@D@("!I;F9O#0H)("`@.SL-"B`@("`M<F5S970I#0H)
M("`@('-H:69T#0H)("`@(')E<V5T#0H)("`@(#L[#0H@("`@+65J96-T*0T*
M"2`@("!S:&EF=`T*"2`@("!E:F5C=`T*"2`@("`[.PT*("`@("HI#0H@("`@
M("`@96-H;R`B56YK;F]W;B!O<'1I;VX@)#$B#0H@("`@("`@97AI="`R#0H@
8("`@("`@.SL-"B`@97-A8PT*9&]N90T*
`
end