]> git.sur5r.net Git - bacula/bacula/commitdiff
Fully implement AlwaysOpen -- kes18Jul02
authorKern Sibbald <kern@sibbald.com>
Thu, 18 Jul 2002 08:53:14 +0000 (08:53 +0000)
committerKern Sibbald <kern@sibbald.com>
Thu, 18 Jul 2002 08:53:14 +0000 (08:53 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@62 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/stored/device.c
bacula/src/version.h

index cf21a50594b94b5d6869c128402590a485b9382d..22cd01ca1b9674a7c430de06bc45de48ffa27a60 100644 (file)
@@ -176,7 +176,10 @@ int release_device(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
    Dmsg1(90, "release_device device is %s\n", dev_is_tape(dev)?"tape":"disk");
    if (dev->state & ST_READ) {
       dev->state &= ~ST_READ;        /* clear read bit */
-      if (!dev_is_tape(dev)) {
+      if (!dev_is_tape(dev) || !(dev->capabilities & CAP_ALWAYSOPEN)) {
+        if (dev->capabilities & CAP_OFFLINEUNMOUNT) {
+           offline_dev(dev);
+        }
         close_dev(dev);
       }
       /******FIXME**** send read volume usage statistics to director */
@@ -190,10 +193,12 @@ int release_device(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
         dev->VolCatInfo.VolCatFiles++;             /* increment number of files */
         /* Note! do volume update before close, which zaps VolCatInfo */
         dir_update_volume_info(jcr, &dev->VolCatInfo, 0); /* send Volume info to Director */
-        if (!dev_is_tape(dev)) {
+
+        if (!dev_is_tape(dev) || !(dev->capabilities & CAP_ALWAYSOPEN)) {
+           if (dev->capabilities & CAP_OFFLINEUNMOUNT) {
+              offline_dev(dev);
+           }
            close_dev(dev);
-        } else {
-            Dmsg0(90, "Device is tape leave open in release_device\n");
         }
       } else {
         dir_create_job_media_record(jcr);
@@ -247,8 +252,18 @@ mount_next_vol:
       memset(&dev->VolHdr, 0, sizeof(dev->VolHdr));
       dev->state &= ~ST_LABEL;       /* label not yet read */
 
-      /* Rewind device */                                   
+      if (!dev_is_tape(dev) || !(dev->capabilities & CAP_ALWAYSOPEN)) {
+        if (dev->capabilities & CAP_OFFLINEUNMOUNT) {
+           offline_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->capabilities & CAP_OFFLINEUNMOUNT) {
+           offline_dev(dev);
+        }
         if (!rewind_dev(dev)) {
             Jmsg2(jcr, M_WARNING, 0, _("Rewind error on device %s. ERR=%s\n"), 
                  dev_name(dev), strerror_dev(dev));
@@ -635,10 +650,6 @@ int fixup_device_block_write_error(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
           PrevVolName, edit_uint64_with_commas(dev->VolCatInfo.VolCatBytes, b1),
           edit_uint64_with_commas(dev->VolCatInfo.VolCatBlocks, b2));
 
-      if (!dev_is_tape(dev)) {          /* If file, */
-        close_dev(dev);                 /* yes, close it */
-      }
-
       /* Unlock, but leave BLOCKED */
       unlock_device(dev);
       if (!mount_next_volume(jcr, dev, label_blk, 1)) {
index 5a6f3c2df87ddf2e69c762838232576ad17b2f3e..b13c5478aa1c5419d4f51f35cce5ade1b35430e9 100644 (file)
@@ -1,8 +1,8 @@
 /* */
 #define VERSION "1.23"
 #define VSTRING "1"
-#define DATE    "16 July 2002"
-#define LSMDATE "16Jul02"
+#define DATE    "18 July 2002"
+#define LSMDATE "18Jul02"
 
 /* Debug flags */
 #define DEBUG 1