Mailinglist Archive: opensuse-bugs (8956 mails)

< Previous Next >
[Bug 193251] oops working with SCSI tape library
  • From: bugzilla_noreply@xxxxxxxxxx
  • Date: Mon, 9 Oct 2006 11:27:41 -0600 (MDT)
  • Message-id: <20061009172741.16ECFED8@xxxxxxxxxxxxxxxxxxxxxx>
https://bugzilla.novell.com/show_bug.cgi?id=193251





------- Comment #5 from sp@xxxxxxxxxxxxx 2006-10-09 11:27 MST -------
(In reply to comment #4)
> Oh, and please attach the script. I'm desperately looking for a testcase.
>

Sorry.
I didn't test OpenSUSE 10.2,
in our office vestion 10.1 is working well with a few changes.
And it is not so easy now to test it. (to inseart SCSI cards, restart
production computers, etc.)

So below is a part of our backup script (perl).
It is a big script and with specific for our enveroment things,
sorry. I don't think you can use it for testing.

In Internet 2 months ago, when I had this problem, I found it is a common
problem of kernel 2.6.16 with SCSI tapes, so I've got 2.6.17 and it is working
well now.

Sorry again, Looks like I can not help more.

-----------

.......

our($BackupProg); $BackupProg = "/bin/tar --verbose --create
--file=/dev/nst0l --blocking-factor=128 --multi-volume";
our($BackupProgDebug); $BackupProgDebug = "/bin/tar --verbose --verbose
--create --file=/dev/nst0l --blocking-factor=128 --multi-volume";


......

# Get all dirs
$Debug && print ("Debug: Get a list of not empty directories for daily
backup!\n");
@TmpDailyBackupDirs = <$BackupDir/*_1>; # Dirs have to be in
format: NAME_1
# But we need only directories and not empty ones.
foreach my $dir (@TmpDailyBackupDirs) {
if ( -d $dir ) {
opendir(DIR, $dir) or die "ERROR: can't open directory \"$dir\" to
read: $!\nAborting Backup!\n\n";
while ( defined($FileNameInDir = readdir(DIR)) ) {
next if $FileNameInDir =~ /^\.\.?$/; # Skip . and ..
push(@DailyBackupDirs , $dir); # Save this directory name
( it is a not empty dir )
last;
}
closedir(DIR);
}
}

$Temp = $#DailyBackupDirs + 1;
$Debug && print ("Debug: Performing Daily Backup ($WeekDay)!\n");
$Debug && print ("Debug: For $Temp not empty directories!\n");

print ("Loading a tape ...\n");
LOADING:
# Load a tape
$Debug && print "Command: $MTX load $LibElement\n";
$Return = system( "$MTX load $LibElement 1>$ToBackupTempFile 2>&1");
$exit_value = $Return >> 8;
$signal_num = $Return & 127;
$dumped_core = $Return & 128;
if( $Return == 0 ) {}
elsif ($exit_value == 1 ) {
chomp($Temp = `$Cat $ToBackupTempFile`);
unlink("$ToBackupTempFile");
if ( $Temp =~ /^source Element Address (\d+) is Empty/ )
{
if ( $1 == $LibElement ) {
print("ERROR: MTX command failed ($Temp) !\n Check the presens
of a tape casset in slot: $LibElement.\n");
print(" To see a status use a commant: mtx status \n");

if( $UsingSpareTape == 0 && $SpareSlot != 0 )
{
print("WARNING: Trying to load a spare tape:
$SpareSlot.\n");
&SendMail_SpareUsing($LibElement); # Send a mail with
notification: $LibElement is empty
$UsingSpareTape = 1;
$LibElement = $SpareSlot; # will use a spare
tape
goto LOADING;
}
print("\n Aborting backup!\n");
return 1;
}
else {
print "\n====================================================";
print "WARNING: Unexpected error message from the tape
labrary\n";
print "WARNING: '$Temp'\n";
print "WARNING: but we are trying to use the tape slot number
$LibElement.\n";
print "WARNING: We will try to continue ....\n";
print
"====================================================\n\n";
}
}
elsif ( $Temp =~ /^Drive 0 Full \(Storage Element (\d+) loaded\)/ )
{
$LoadCnt++;
if( $LoadCnt > $MaxLoadCnt )
{
print("ERROR: Could not load a tape during 4 hours\.\n\n
Aborting backup!\n");
return 1;
}
$Temp =~ s/^Drive 0 Full \(Storage Element (\d+) loaded\)/$1/;
print("WARNING: Currently Tape $Temp is busy! Waiting 10 min to
check it again....");
sleep(600); # 10 min. sleep
print("\n");
goto LOADING;
} else {
print("ERROR: MTX command failed (Check correctness of device:
/dev/changer ) !\n\n Aborting backup!\n");
return 1;
}
} elsif ($exit_value > 1) {
print("ERROR: MTX ran with non-zero exit status $Return\n\n Aborting
backup!\n");
exit 1;
} elsif ($signal_num ) {
print("ERROR: MTX was interrupted by signal $signal_num\n\n Aborting
backup!\n");
return 1;
}

# OK (== tape is loaded)
$TapeLoaded = 1; # Set Flag (to unload a tape later)

# Check correctness of tape devices initialization.
sleep(20); # Wait a little, while a tape will ready
for( ; $WaitReady > 0 ; $WaitReady-- )
{
print ("Get a tapeinfo ...\n");
$Debug && print "Command: $TAPEINFO -f /dev/scsitape\n";
$Return = system( "$TAPEINFO -f /dev/scsitape 1>$ToBackupTempFile
2>&1");
$exit_value = $Return >> 8;
$signal_num = $Return & 127;
$dumped_core = $Return & 128;
if( $Return == 0 ) {}
elsif ($exit_value == 1 ) {
print("ERROR: TAPEINFO command failed (Check correctness of device:
/dev/scsitape ) !\n\n Aborting backup!\n");
return 1;
} elsif ($exit_value > 1) {
print("ERROR: TAPEINFO ran with non-zero exit status $Return\n\n
Aborting backup!\n");
return 1;
} elsif ($signal_num ) {
print("ERROR: TAPEINFO was interrupted by signal $signal_num\n\n
Aborting backup!\n");
return 1;
}

chomp($Temp = `$Cat $ToBackupTempFile`);
unlink("$ToBackupTempFile");
last if ( $Temp =~ /^Ready: yes/m ); # READY !
if( $WaitReady == 1 )
{
print("ERROR: Tape is not ready for backup. Cannot wait longer.\n\n
Aborting backup!\n");
return 1;
}

sleep(20);
}

# Init tape devices
$Debug && print "Debug: Init tape devices.\n";
$Debug && print "Command: $STINIT -f /etc/stinit.def >/dev/null\n";
$Return = system( "$STINIT -f /etc/stinit.def >/dev/null");
$exit_value = $Return >> 8;
$signal_num = $Return & 127;
$dumped_core = $Return & 128;
if( $Return == 0 ) {}
elsif ($exit_value == 1 ) {
print("ERROR: STINIT command failed (Check a configuration file:
/etc/stinit.def ) !\n\nAborting backup!\n");
return 1;
} elsif ($exit_value > 1) {
print("ERROR: STINIT ran with non-zero exit status $Return\n\nAborting
backup!\n");
return 1;
}



if( $Rewind )
{
print ("Rewind a tape ...\n");
$Debug && print "Command: $SCSITAPE -f /dev/scsitape rewind\n";
$Return = system( "$SCSITAPE -f /dev/scsitape rewind");
$exit_value = $Return >> 8;
$signal_num = $Return & 127;
$dumped_core = $Return & 128;
if( $Return == 0 ) {}
elsif ($exit_value == 1 ) {
print("ERROR: SCSITAPE command failed (Check correctness of device:
/dev/scsitape ) !\n\nAborting backup!\n");
return 1;
} elsif ($exit_value > 1) {
print("ERROR: SCSITAPE ran with non-zero exit status
$Return\n\nAborting backup!\n");
return 1;
} elsif ($signal_num ) {
print("ERROR: SCSITAPE was interrupted by signal
$signal_num\n\nAborting backup!\n");
return 1;
}
}
else
{
print ("Go to the end of tape ...\n");
$Debug && print "Command: $SCSITAPE -f /dev/scsitape eod\n";
sleep(1);
$Return = system( "$SCSITAPE -f /dev/scsitape eod");
$exit_value = $Return >> 8;
$signal_num = $Return & 127;
$dumped_core = $Return & 128;
if( $Return == 0 ) {}
elsif ($exit_value == 1 ) {
print("ERROR: SCSITAPE command failed (Check correctness of device:
/dev/scsitape ) !\n\nAborting backup!\n");
return 1;
} elsif ($exit_value > 1) {
print("ERROR: SCSITAPE ran with non-zero exit status
$Return\n\nAborting backup!\n");
return 1;
} elsif ($signal_num ) {
print("ERROR: SCSITAPE was interrupted by signal
$signal_num\n\nAborting backup!\n");
return 1;
}
}


# Making a backup to the tape for every found directory (as a new volume)
foreach my $dir (@DailyBackupDirs) {

# Get and store the start offset for a new volume.
$Debug && print "Get Tape Offset at the beginning of a new volume
backup\n";
$Debug && print "Command: $MT -f /dev/nst0l tell >
$ToBackupTempFile\n";
$Return = 0xffff & system("$MT -f /dev/nst0l tell >
$ToBackupTempFile");
if( $Return == 0 ) {
chomp($Usage = `$Cat $ToBackupTempFile`);
unlink("$ToBackupTempFile");
($Usage) = ( $Usage =~ /^At block (\d+)\./ );
$Debug && print "Tape Usage=$Usage\n";
}
elsif ($Return == 0xff00 ) {
print("ERROR: $MT tell command failed!\n\nAborting backup!\n");
return 1;
} elsif ($Return > 0x80) {
$Return >>= 8;
print("ERROR: $MT tell ran with non-zero exit status
$Return\n\nAborting backup!\n");
return 1;
} else {
print "ERROR: $MT tell ran with";
if ($Return & 0x80){
$Return &= ~0x80;
print "coredump from ";
}
print "signal $Return\n\nAborting backup!\n";
return 1;
}
$BackupOffset{$dir} = $Usage;
$TapeUsage = $Usage;
$Debug && print "Tape Offset now is: $Usage\n";


# Create a file volume string for current beckaup directoty
$TapeLabel=basename($dir)."\.d".$BackupDay."\.".$WeekDay;

$Debug && print ("Debug: Doing Backup of $dir !\n");
print("Creating Backup with VOLUME NAME = \"$TapeLabel\"\n");
print("Please, wait ...\n\n");

$Debug && print ("Goto directory: $dir !\n");
if( ! chdir($dir) )
{
print("ERROR: Could not change directory to \"$dir\" !\n\nAborting
backup!\n");
return 1;
}


$Debug && print "Command: $BackupProg --label=$TapeLabel \.\n";
$Return = system( "$BackupProg --label=$TapeLabel \.
1>>$BackupErrorFile 2>&1");
$exit_value = $Return >> 8;
$signal_num = $Return & 127;
$dumped_core = $Return & 128;
if( $Return == 0 ) {}
elsif ($exit_value == 1 ) {
print("ERROR: Backup program failed (see error file:
$BackupErrorFile) !\n\nAborting backup!\n");
return 1;
} elsif ($exit_value > 1) {
print("ERROR: TAR ran with non-zero exit status $exit_value\n");
`$Cat $BackupErrorFile`;
print("ERROR: Aborting backup!\n");
return 1;
} elsif ($signal_num ) {
print("ERROR: TAR was interrupted by signal $signal_num\n\nAborting
backup!\n");
return 1;
}

# We working as root, so I hope we will not have any error output here
chomp($DirSize = `$Du -hs .`);
$DirSize =~ s/^\s*(\S+).*$/$1/;
$BackupDirSize{$dir} = $DirSize;

print "<<Backup of $dir is done (dir. size: $DirSize).>>\n";
print "Clean directory: $dir.\n";
$Debug && print "Command: RM -rf *\n";
$Return = system( "$RM -rf * 1>>$BackupErrorFile 2>&1");
#$Return = system( "$RM -rf .* 1>>$BackupErrorFile 2>&1");
print "\n";
}

$Debug && print "Debug: Get Tape Usage at the end of backup\n";
$Debug && print "Command: $MT -f /dev/nst0l tell > $ToBackupTempFile\n";
$Return = 0xffff & system("$MT -f /dev/nst0l tell > $ToBackupTempFile");
if( $Return == 0 ) {
chomp($Usage = `$Cat $ToBackupTempFile`);
unlink("$ToBackupTempFile");
($Usage) = ( $Usage =~ /^At block (\d+)\./ );
$Debug && print "Tape Usage=$Usage\n";
}
elsif ($Return == 0xff00 ) {
print("ERROR: $MT tell command failed!\n\nAborting backup!\n");
return 1;
} elsif ($Return > 0x80) {
$Return >>= 8;
print("ERROR: $MT tell ran with non-zero exit status
$Return\n\nAborting backup!\n");
return 1;
} else {
print "ERROR: $MT -f /dev/nst0l tell ran with";
if ($Return & 0x80){
$Return &= ~0x80;
print "coredump from ";
}
print "signal $Return\n\nAborting backup!\n";
return 1;
}
$TapeUsage = $Usage; # save current tape usage to report it later

print ("Ejecting tape ...\n");
$Debug && print "Command: $SCSITAPE -f /dev/scsitape eject\n";
$Return = system( "$SCSITAPE -f /dev/scsitape eject");
$exit_value = $Return >> 8;
$signal_num = $Return & 127;
$dumped_core = $Return & 128;
if( $Return == 0 ) {}
elsif ($exit_value == 1 ) {
print("ERROR: SCSITAPE command failed (Check correctness of device:
/dev/scsitape )!\n\nAborting backup!\n");
return 1;
} elsif ($exit_value > 1) {
print("ERROR: SCSITAPE ran with non-zero exit status
$Return\n\nAborting backup!\n");
return 1;
} elsif ($signal_num ) {
print("ERROR: SCSITAPE was interrupted by signal
$signal_num\n\nAborting backup!\n");
return 1;
}

print ("UnLoading tape ...\n");
$Return = system( "$MTX unload $LibElement 1>$ToBackupTempFile
2>&1");
$exit_value = $Return >> 8;
$signal_num = $Return & 127;
$dumped_core = $Return & 128;
if( $Return == 0 ) {}
elsif ($exit_value == 1 ) {
print("ERROR: MTX command failed (Check correctness of device name:
/dev/changer ) !\n\nAborting backup!\n");
print("\nYOU SHOULD UNLOAD TAPE MANUALY, try command: mtx unload\n\n");
$TapeLoaded = 0; # don't try again
return 1;
} elsif ($exit_value > 1) {
print("ERROR: MTX ran with non-zero exit status $Return\n\nAborting
backup!\n");
print("\nYOU SHOULD UNLOAD TAPE MANUALY, try command: mtx unload\n\n");
$TapeLoaded = 0; # don't try again
return 1;
} elsif ($signal_num ) {
print("ERROR: MTX was interrupted by signal $signal_num\n\nAborting
backup!\n");
print("\nYOU SHOULD UNLOAD TAPE MANUALY, try command: mtx unload\n\n");
$TapeLoaded = 0; # don't try again
return 1;
}

$TapeLoaded = 0; # OK, unset flag, so we will not try to unload tape at
the end of this program.


return 0;


--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.

< Previous Next >