From 7277c7881c4afc7d9a513d879c71ab5441fd729e Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Fri, 4 Sep 2009 12:38:05 +0200 Subject: [PATCH] Final tweaks to certification btape fill scripts and code --- bacula/src/lib/crc32.c | 17 ++++--- bacula/src/stored/btape.c | 63 +++++++++++++++---------- regress/scripts/bacula-sd-btape.conf.in | 1 + regress/tests/btape-fill-full-changer | 7 ++- regress/tests/btape-test-changer | 5 +- regress/tests/certify-changer | 1 + 6 files changed, 59 insertions(+), 35 deletions(-) diff --git a/bacula/src/lib/crc32.c b/bacula/src/lib/crc32.c index f464efb5be..a9c18a9dfa 100644 --- a/bacula/src/lib/crc32.c +++ b/bacula/src/lib/crc32.c @@ -1,15 +1,7 @@ -/* - * 32 bit CRC. Algorithm from RFC 2083 (png format) - * - * By Kern Sibbald, January 2001 - * - * Version $Id$ - * - */ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2006 Free Software Foundation Europe e.V. + Copyright (C) 2000-2009 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -33,6 +25,13 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * 32 bit CRC. Algorithm from RFC 2083 (png format) + * + * By Kern Sibbald, January 2001 + * + */ + #ifdef GENERATE_STATIC_CRC_TABLE /* diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index b91c89a492..bcff336806 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -37,8 +37,6 @@ * Note, this program reads stored.conf, and will only * talk to devices that are configured. * - * Version $Id$ - * */ #include "bacula.h" @@ -381,7 +379,7 @@ static void print_total_speed() { char ec1[50]; kbs = (double)total_size / (1000 * total_time); - Pmsg2(000, _("TotalVolumeCapacity=%sB. Total Write rate = %.1f KB/s\n"), + Pmsg2(000, _("Total Volume bytes=%sB. Total Write rate = %.1f KB/s\n"), edit_uint64_with_suffix(total_size, ec1), kbs); } @@ -404,7 +402,7 @@ static void print_speed(uint64_t bytes) total_size += bytes; kbs = (double)bytes / (1000 * now); - Pmsg2(000, _("VolumeCapacity=%sB. Write rate = %.1f KB/s\n"), + Pmsg2(000, _("Volume bytes=%sB. Write rate = %.1f KB/s\n"), edit_uint64_with_suffix(bytes, ec1), kbs); } @@ -2154,9 +2152,9 @@ static void fillcmd() #endif } - /* Get out after writing 100 blocks to the second tape */ - if (++BlockNumber > 100 && stop != 0) { /* get out */ - Pmsg0(000, _("Wrote 100 blocks on second tape. Done.\n")); + /* Get out after writing 1000 blocks to the second tape */ + if (++BlockNumber > 1000 && stop != 0) { /* get out */ + Pmsg0(000, _("Wrote 1000 blocks on second tape. Done.\n")); break; } } @@ -2170,14 +2168,15 @@ static void fillcmd() FI_to_ascii(buf1, rec.FileIndex), rec.VolSessionId, stream_to_ascii(buf2, rec.Stream, rec.FileIndex), rec.data_len); - /* Get out after writing 100 blocks to the second tape */ - if (BlockNumber > 100 && stop != 0) { /* get out */ + /* Get out after writing 1000 blocks to the second tape */ + if (BlockNumber > 1000 && stop != 0) { /* get out */ char ed1[50]; Pmsg1(-1, "Done writing %s records ...\n", edit_uint64_with_commas(write_count, ed1)); break; } - } + } /* end big for loop */ + if (vol_num > 1) { Dmsg0(100, "Write_end_session_label()\n"); /* Create Job status for end of session label */ @@ -2230,25 +2229,30 @@ static void fillcmd() Pmsg2(0, _("Could not create state file: %s ERR=%s\n"), buf, be.bstrerror()); exit_code = 1; + ok = false; } now = time(NULL); (void)localtime_r(&now, &tm); strftime(buf1, sizeof(buf1), "%H:%M:%S", &tm); - if (simple) { - Pmsg3(01, _("\n\n%s Done filling tape at %d:%d. Now beginning re-read of tape ...\n"), - buf1, jcr->dcr->dev->file, jcr->dcr->dev->block_num); - } else { - Pmsg3(0, _("\n\n%s Done filling tapes at %d:%d. Now beginning re-read of first tape ...\n"), - buf1, jcr->dcr->dev->file, jcr->dcr->dev->block_num); - } + if (ok) { + if (simple) { + Pmsg3(0, _("\n\n%s Done filling tape at %d:%d. Now beginning re-read of tape ...\n"), + buf1, jcr->dcr->dev->file, jcr->dcr->dev->block_num); + } else { + Pmsg3(0, _("\n\n%s Done filling tapes at %d:%d. Now beginning re-read of first tape ...\n"), + buf1, jcr->dcr->dev->file, jcr->dcr->dev->block_num); + } - jcr->dcr->block = block; - if (!do_unfill()) { - Pmsg0(000, _("do_unfill failed.\n")); - exit_code = 1; + jcr->dcr->block = block; + if (!do_unfill()) { + Pmsg0(000, _("do_unfill failed.\n")); + exit_code = 1; + ok = false; + } + } else { + Pmsg1(000, _("%s: Error during test.\n"), buf1); } - dev->min_block_size = min_block_size; free_memory(rec.data); } @@ -2300,6 +2304,11 @@ static void unfillcmd() this_block = NULL; } +/* + * This is the second part of the fill command. After the tape or + * tapes are written, we are called here to reread parts, particularly + * the last block. + */ static bool do_unfill() { DEV_BLOCK *block = dcr->block; @@ -2310,7 +2319,7 @@ static bool do_unfill() VolBytes = 0; LastBlock = 0; - Dmsg0(20, "Enter do_unfill\n"); + Pmsg0(000, "Enter do_unfill\n"); dev->set_cap(CAP_ANONVOLS); /* allow reading any volume */ dev->clear_cap(CAP_LABEL); /* don't label anything here */ @@ -2348,8 +2357,10 @@ static bool do_unfill() } autochanger = autoload_device(dcr, 1, NULL); if (autochanger != 1) { + Pmsg1(100, "Autochanger returned: %d\n", autochanger); dev->close(); get_cmd(_("Mount first tape. Press enter when ready: ")); + Pmsg0(000, "\n"); } } @@ -2410,8 +2421,10 @@ static bool do_unfill() autochanger = autoload_device(dcr, 1, NULL); if (autochanger != 1) { + Pmsg1(100, "Autochanger returned: %d\n", autochanger); dev->close(); get_cmd(_("Mount second tape. Press enter when ready: ")); + Pmsg0(000, "\n"); } dev->clear_read(); @@ -2562,7 +2575,7 @@ static int flush_block(DEV_BLOCK *block, int dump) } kbs = (double)dev->VolCatInfo.VolCatBytes / (1000 * now); vol_size = dev->VolCatInfo.VolCatBytes; - Pmsg4(000, _("End of tape %d:%d. VolumeCapacity=%s. Write rate = %.1f KB/s\n"), + Pmsg4(000, _("End of tape %d:%d. Volume Bytes=%s. Write rate = %.1f KB/s\n"), dev->file, dev->block_num, edit_uint64_with_commas(dev->VolCatInfo.VolCatBytes, ec1), kbs); @@ -2891,10 +2904,12 @@ bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr) } autochanger = autoload_device(dcr, 1, NULL); if (autochanger != 1) { + Pmsg1(100, "Autochanger returned: %d\n", autochanger); fprintf(stderr, _("Mount blank Volume on device %s and press return when ready: "), dev->print_name()); dev->close(); getchar(); + Pmsg0(000, "\n"); } labelcmd(); VolumeName = NULL; diff --git a/regress/scripts/bacula-sd-btape.conf.in b/regress/scripts/bacula-sd-btape.conf.in index be843a6093..3d5b6076ba 100644 --- a/regress/scripts/bacula-sd-btape.conf.in +++ b/regress/scripts/bacula-sd-btape.conf.in @@ -47,6 +47,7 @@ Device { Archive Device = @tape_drive@ AutomaticMount = yes; # when device opened, read it AlwaysOpen = yes; + Autochanger = yes; RemovableMedia = yes; @@sbindir@/tape_options Maximum Block Size = 64512 diff --git a/regress/tests/btape-fill-full-changer b/regress/tests/btape-fill-full-changer index 1097dfe005..e778c68fb2 100755 --- a/regress/tests/btape-fill-full-changer +++ b/regress/tests/btape-fill-full-changer @@ -20,6 +20,11 @@ start_test # cp ${cwd}/bin/bacula-sd.conf ${cwd}/tmp/1 sed -e 's%64512%262144%' ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf +# +# Limit Volume size for debugging without waiting too long +# +# cp ${cwd}/bin/bacula-sd.conf ${cwd}/tmp/1 +# sed -e 's%# MaximumVolumeSize = 400M% MaximumVolumeSize = 400M%' ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf if test "$debug" -eq 1 ; then $bin/btape -c bin/bacula-sd.conf Drive-0 </dev/null 2>&1 +grep "^The last block on the second tape matches\. Test succeeded\." ${cwd}/tmp/log1.out >/dev/null 2>&1 if [ $? != 0 ] ; then echo " " echo " " diff --git a/regress/tests/btape-test-changer b/regress/tests/btape-test-changer index 9fa56f4c8c..fe240ed6e9 100755 --- a/regress/tests/btape-test-changer +++ b/regress/tests/btape-test-changer @@ -18,13 +18,16 @@ start_test if test "$debug" -eq 1 ; then $bin/btape -c bin/bacula-sd.conf Drive-0 <>${outf} echo "lspci:" >>${outf} lspci -vv >>${outf} + # If we have an autoloader, load the tape in slot1 if test ! x$AUTOCHANGER = x/dev/null ; then a=`bin/mtx-changer $AUTOCHANGER loaded $SLOT1 $TAPE_DRIVE $DRIVE1` -- 2.39.5