]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/mount.c
Fix for reused thread ids by FreeBSD + qfill command
[bacula/bacula] / bacula / src / stored / mount.c
index 5c601d3f3c1d9d00246b965e4d7a9cd2428d291e..f47f53c347c3671db4657cb2c5b14e1c9e085f3b 100644 (file)
@@ -75,30 +75,13 @@ mount_next_vol:
       jcr->VolumeName[0] = 0;
 
       if (!dev_is_tape(dev) || !dev_cap(dev, CAP_ALWAYSOPEN)) {
-        if (dev_cap(dev, CAP_OFFLINEUNMOUNT)) {
-           offline_dev(dev);
-        /*            
-          * Note, this rewind probably should not be here (it wasn't
-         *  in prior versions of Bacula), but on FreeBSD, this is
-          *  needed in the case the tape was "frozen" due to an error
-         *  such as backspacing after writing and EOF. If it is not
-         *  done, all future references to the drive get and I/O error.
-         */
-        } else if (!rewind_dev(dev)) {
-            Jmsg2(jcr, M_WARNING, 0, _("Rewind error on device %s. ERR=%s\n"), 
-                 dev_name(dev), strerror_dev(dev));
-        }
+        offline_or_rewind_dev(dev);
         close_dev(dev);
       }
 
       /* If we have not closed the device, then at least rewind the tape */
       if (dev->state & ST_OPENED) {
-        if (dev_cap(dev, CAP_OFFLINEUNMOUNT)) {
-           offline_dev(dev);
-        } else if (!rewind_dev(dev)) {
-            Jmsg2(jcr, M_WARNING, 0, _("Rewind error on device %s. ERR=%s\n"), 
-                 dev_name(dev), strerror_dev(dev));
-        }
+        offline_or_rewind_dev(dev);
       }
       ask = 1;                       /* ask operator to mount tape */
    }
@@ -131,7 +114,7 @@ mount_next_vol:
 
    dev->state &= ~(ST_APPEND|ST_READ|ST_EOT|ST_WEOT|ST_EOF);
 
-   jcr->VolFirstFile = jcr->JobFiles; /* first update of Vol FileIndex */
+   jcr->VolFirstIndex = jcr->JobFiles; /* first update of Vol FileIndex */
    for ( ;; ) {
       int vol_label_status;
       autochanger = autoload_device(jcr, dev, 1, NULL);
@@ -148,6 +131,7 @@ mount_next_vol:
 
       release = 1;                    /* release next time if we "recurse" */
 
+ask_again:
       if (ask && !dir_ask_sysop_to_mount_next_volume(jcr, dev)) {
          Dmsg0(100, "Error return ask_sysop ...\n");
         return 0;              /* error return */
@@ -243,11 +227,9 @@ read_volume:
 mount_error:
         /* Send error message */
          Jmsg1(jcr, M_WARNING, 0, "%s", jcr->errmsg);                         
-        if (autochanger) {
-           invalidate_slot_in_catalog(jcr);
-        }
          Dmsg0(100, "Default\n");
-        goto mount_next_vol;
+        ask = 1;
+        goto ask_again;
       }
       break;
    }
@@ -306,6 +288,7 @@ mount_error:
       dev->VolCatInfo.VolCatFiles = 0;
       dev->VolCatInfo.VolCatErrors = 0;
       dev->VolCatInfo.VolCatBlocks = 0;
+      dev->VolCatInfo.VolCatRBytes = 0;
       if (recycle) {
         dev->VolCatInfo.VolCatMounts++;  
         dev->VolCatInfo.VolCatRecycles++;
@@ -356,7 +339,7 @@ mount_error:
                 dev_file(dev));
         } else {
             Jmsg(jcr, M_ERROR, 0, _("I canot write on this volume because:\n\
-The number of files mismatch! Volume=%d Catalog=%d\n"), 
+The number of files mismatch! Volume=%u Catalog=%u\n"), 
                 dev_file(dev), dev->VolCatInfo.VolCatFiles);
             strcpy(dev->VolCatInfo.VolCatStatus, "Error");
             Dmsg0(200, "dir_update_vol_info. Set Error.\n");
@@ -386,7 +369,7 @@ int mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
       close_dev(dev);
       dev->state &= ~ST_READ; 
       if (!acquire_device_for_read(jcr, dev, block)) {
-         Emsg2(M_FATAL, 0, "Cannot open Dev=%s, Vol=%s\n", dev_name(dev),
+         Jmsg2(jcr, M_FATAL, 0, "Cannot open Dev=%s, Vol=%s\n", dev_name(dev),
               jcr->VolumeName);
         return 0;
       }