]> git.sur5r.net Git - bacula/bacula/commitdiff
More updates to btape fill command
authorKern Sibbald <kern@sibbald.com>
Mon, 26 May 2003 13:35:56 +0000 (13:35 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 26 May 2003 13:35:56 +0000 (13:35 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@547 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/stored/block.c
bacula/src/stored/btape.c
bacula/src/stored/dev.c

index 18520cf21adf05cef6d60c1f05a48d453b375da3..5e81ce5b8707b1652f4ae32b77d579b4ec28011c 100644 (file)
@@ -347,7 +347,6 @@ int write_block_to_dev(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
    if (hit_max1 || hit_max2) {  
       char ed1[50];
       uint64_t max_cap;
-      dev->state |= ST_WEOT;
       Dmsg0(10, "==== Output bytes Triggered medium max capacity.\n");
       if (hit_max1) {
         max_cap = dev->max_volume_size;
@@ -361,6 +360,7 @@ int write_block_to_dev(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
       dev->EndFile  = dev->file;
       weof_dev(dev, 1);              /* end the tape */
       weof_dev(dev, 1);              /* write second eof */
+      dev->state |= (ST_EOF | ST_EOT | ST_WEOT);
       return 0;
    }
 
@@ -385,7 +385,6 @@ int write_block_to_dev(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
        * conditions.  In any case, we probably want to
        * simulate an End of Medium.
        */
-      dev->state |= ST_EOF | ST_EOT | ST_WEOT;
       clrerror_dev(dev, -1);
 
       if (dev->dev_errno == 0) {
@@ -407,6 +406,7 @@ int write_block_to_dev(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
       dev->EndFile  = dev->file;
       weof_dev(dev, 1);              /* end the tape */
       weof_dev(dev, 1);              /* write second eof */
+      dev->state |= (ST_EOF | ST_EOT | ST_WEOT);
        
       ok = TRUE;
 #define CHECK_LAST_BLOCK
@@ -428,15 +428,14 @@ int write_block_to_dev(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
         if (ok && bsr_dev(dev, 1) != 0) {
            ok = FALSE;
             Jmsg(jcr, M_ERROR, 0, _("Back space record at EOT failed. ERR=%s\n"), strerror(dev->dev_errno));
-           /* ****FIXME*****
+           /*
             *  On FreeBSD systems, if the user got here, it is likely that his/her
              *    tape drive is "frozen".  The correct thing to do is a 
             *    rewind(), but if we do that, higher levels in cleaning up, will
             *    most likely write the EOS record over the beginning of the
             *    tape.  The rewind *is* done later in mount.c when another
-            *    tape is requested. However, it should be done here. In that
-            *    case, we need to send back some fatal error status to avoid
-            *    future writes.
+            *    tape is requested. Note, the clrerror_dev() call in bsr_dev()
+            *    calls ioctl(MTCERRSTAT), which *should* fix the problem.
             */
         }
         if (ok) {
index e6a671801eab23dceb80c0f83319cdbddb04cc93..c20fad8df7c582380fe290cf5452ad17ee910d67 100644 (file)
@@ -1351,20 +1351,17 @@ bail_out:
  */
 static void record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec)
 {
-
    SESSION_LABEL label;
-   if (stop > 1) {                   /* on second tape */
+
+   if (stop > 1 && !dumped) {        /* on second tape */
+      dumped = 1;
+      dump_block(block, "First block on second tape");
       Pmsg4(-1, "Blk: FileIndex=%d: block=%u size=%d vol=%s\n", 
           rec->FileIndex, block->BlockNumber, block->block_len, dev->VolHdr.VolName);
       Pmsg6(-1, "   Rec: VId=%d VT=%d FI=%s Strm=%s len=%d state=%x\n",
           rec->VolSessionId, rec->VolSessionTime, 
           FI_to_ascii(rec->FileIndex), stream_to_ascii(rec->Stream, rec->FileIndex),
           rec->data_len, rec->state);
-
-      if (!dumped) {
-        dumped = 1;
-         dump_block(block, "Block not written to previous tape");
-      }
    }
    if (rec->FileIndex < 0) {
       if (verbose > 1) {
index 091382b6da2424e1d9d744c2e4079424726d9505..104e70cbf06abd7532ff82328f8134f23d459ff5 100644 (file)
@@ -1040,6 +1040,8 @@ clrerror_dev(DEVICE *dev, int func)
 {
    /* Read and clear SCSI error status */
    union mterrstat mt_errstat;
+   Pmsg2(000, "Doing MTIOCERRSTAT errno=%d ERR=%s\n", dev->dev_errno,
+      strerror(dev->dev_errno));
    ioctl(dev->fd, MTIOCERRSTAT, (char *)&mt_errstat);
 }
 #endif