X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fstored%2Fblock.c;h=5efc332669f878680dc1585a0a2cc6f80ec77757;hb=ada27b1a435802523f568fd94b81e393dcbabe71;hp=eb16996014265e29166c21436efe95f5dd0687f2;hpb=8cc7bb82e197877ebd975b6c9dbc219157700eeb;p=bacula%2Fbacula diff --git a/bacula/src/stored/block.c b/bacula/src/stored/block.c index eb16996014..5efc332669 100644 --- a/bacula/src/stored/block.c +++ b/bacula/src/stored/block.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2001-2007 Free Software Foundation Europe e.V. + Copyright (C) 2001-2008 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. @@ -273,6 +273,7 @@ static bool unser_block_header(JCR *jcr, DEVICE *dev, DEV_BLOCK *block) dev->dev_errno = EIO; Mmsg4(dev->errmsg, _("Volume data error at %u:%u! Wanted ID: \"%s\", got \"%s\". Buffer discarded.\n"), dev->file, dev->block_num, BLKHDR2_ID, Id); + Dmsg1(50, "%s", dev->errmsg); if (block->read_errors == 0 || verbose >= 2) { Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg); } @@ -373,7 +374,6 @@ bool write_block_to_device(DCR *dcr) if (dcr->NewVol) { /* Note, setting a new volume also handles any pending new file */ set_new_volume_parameters(dcr); - dcr->NewFile = false; /* this handled for new file too */ } else { set_new_file_parameters(dcr); } @@ -575,9 +575,12 @@ bool write_block_to_dev(DCR *dcr) dev->VolCatInfo.VolCatName, dev->file, dev->block_num, dev->print_name(), wlen, stat); } - Dmsg7(100, "=== Write error. fd=%d size=%u rtn=%d dev_blk=%d blk_blk=%d errno=%d: ERR=%s\n", - dev->fd(), wlen, stat, dev->block_num, block->BlockNumber, - dev->dev_errno, strerror(dev->dev_errno)); + if (debug_level >= 100) { + berrno be; + Dmsg7(100, "=== Write error. fd=%d size=%u rtn=%d dev_blk=%d blk_blk=%d errno=%d: ERR=%s\n", + dev->fd(), wlen, stat, dev->block_num, block->BlockNumber, + dev->dev_errno, be.bstrerror(dev->dev_errno)); + } ok = terminate_writing_volume(dcr); if (!ok && !forge_on) { @@ -701,6 +704,11 @@ static void reread_last_block(DCR *dcr) #endif } +/* + * If this routine is called, we do our bookkeeping and + * then assure that the volume will not be written any + * more. + */ static bool terminate_writing_volume(DCR *dcr) { DEVICE *dev = dcr->dev; @@ -742,7 +750,7 @@ static bool terminate_writing_volume(DCR *dcr) dev->VolCatInfo.VolCatParts = dev->num_dvd_parts; } - if (!dir_update_volume_info(dcr, false)) { + if (!dir_update_volume_info(dcr, false, true)) { ok = false; } Dmsg1(100, "dir_update_volume_info terminate writing -- %s\n", ok?"OK":"ERROR"); @@ -766,9 +774,10 @@ static bool terminate_writing_volume(DCR *dcr) /* This may not be fatal since we already wrote an EOF */ Jmsg(dcr->jcr, M_ERROR, 0, "%s", dev->errmsg); } + bail_out: dev->set_ateot(); /* no more writing this tape */ - Dmsg1(100, "Leave terminate_writing_volume -- %s\n", ok?"OK":"ERROR"); + Dmsg1(50, "*** Leave terminate_writing_volume -- %s\n", ok?"OK":"ERROR"); return ok; } @@ -793,7 +802,7 @@ static bool do_new_file_bookkeeping(DCR *dcr) return false; } dev->VolCatInfo.VolCatFiles = dev->file; - if (!dir_update_volume_info(dcr, false)) { + if (!dir_update_volume_info(dcr, false, false)) { Dmsg0(190, "Error from update_vol_info.\n"); terminate_writing_volume(dcr); dev->dev_errno = EIO; @@ -851,7 +860,7 @@ static bool do_dvd_size_checks(DCR *dcr) dev->VolCatInfo.VolCatParts = dev->num_dvd_parts; - if (!dir_update_volume_info(dcr, false)) { + if (!dir_update_volume_info(dcr, false, false)) { Dmsg0(190, "Error from update_vol_info.\n"); dev->dev_errno = EIO; return false; @@ -1008,8 +1017,19 @@ reread: dev->set_ateof(); return false; /* return eof */ } + /* Continue here for successful read */ + block->read_len = stat; /* save length read */ + if (block->read_len == 80 && + (dcr->VolCatInfo.LabelType != B_BACULA_LABEL || + dcr->device->label_type != B_BACULA_LABEL)) { + /* ***FIXME*** should check label */ + Dmsg2(100, "Ignore 80 byte ANSI label at %u:%u\n", dev->file, dev->block_num); + dev->clear_eof(); + goto reread; /* skip ANSI/IBM label */ + } + if (block->read_len < BLKHDR2_LENGTH) { dev->dev_errno = EIO; Mmsg4(dev->errmsg, _("Volume data error at %u:%u! Very short block of %d bytes on device %s discarded.\n"),