]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/block.c
kes Improve SD reserve debug code.
[bacula/bacula] / bacula / src / stored / block.c
index d23182a7eed9ed00022e6668fdce554fa55130e7..5efc332669f878680dc1585a0a2cc6f80ec77757 100644 (file)
@@ -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.
@@ -374,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);
       }
@@ -576,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) {
@@ -702,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;
@@ -743,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");
@@ -767,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;
 }
 
@@ -794,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;
@@ -852,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;
@@ -1013,7 +1021,7 @@ reread:
    /* Continue here for successful read */
 
    block->read_len = stat;      /* save length read */
-   if (dev->at_eof() && block->read_len == 80 && 
+   if (block->read_len == 80 && 
         (dcr->VolCatInfo.LabelType != B_BACULA_LABEL ||
          dcr->device->label_type != B_BACULA_LABEL)) {
       /* ***FIXME*** should check label */