]> git.sur5r.net Git - bacula/bacula/commitdiff
Second cut of drive switching during backup
authorKern Sibbald <kern@sibbald.com>
Wed, 12 Mar 2008 15:01:42 +0000 (15:01 +0000)
committerKern Sibbald <kern@sibbald.com>
Wed, 12 Mar 2008 15:01:42 +0000 (15:01 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6592 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/stored/acquire.c
bacula/src/stored/ansi_label.c
bacula/src/stored/autochanger.c
bacula/src/stored/label.c
bacula/src/stored/reserve.c
bacula/technotes-2.3

index aa5d0b1c94868012c3580b0a64b75ce7faabadd1..96835fb1c093130d1850e435f606e31d50166f47 100644 (file)
@@ -318,7 +318,7 @@ DCR *acquire_device_for_append(DCR *dcr)
    bool do_mount = false;
    bool release = false;
    bool have_vol;
-   DEVICE *dev = dcr->dev;
+   DEVICE * volatile dev = dcr->dev;
    JCR *jcr = dcr->jcr;
 
    init_device_wait_timers(dcr);
@@ -355,18 +355,25 @@ DCR *acquire_device_for_append(DCR *dcr)
        *  dcr->VolumeName is what we pass into the routines, or
        *    get back from the subroutines.
        */
-      if (!have_vol &&
-          !(dir_find_next_appendable_volume(dcr) &&
-            strcmp(dev->VolHdr.VolumeName, dcr->VolumeName) == 0)) { /* wrong tape mounted */
-         /* Wrong tape mounted, release it, then fall through to get correct one */
-         Dmsg3(50, "Wrong tape mounted. Wanted:%s, got:%s, dev=%s release and try mount.\n",
-              dcr->VolumeName, dev->VolHdr.VolumeName, dev->print_name());
-         /* Release drive only if tape really in drive */
+      do_mount = false;
+      release = false;
+      /* If we do not have a volume, see if we can find one */
+      if (!have_vol) {
+         have_vol = dir_find_next_appendable_volume(dcr);
+         dev = dcr->dev;
+      }
+      if (have_vol) {
+         do_mount = true;
+         /* Make sure it is what we we have on the drive */
          if (dev->VolHdr.VolumeName[0]) {
-            release = true;
+            /* If we already have the volume, mount/release are not needed */
+            do_mount = strcmp(dev->VolHdr.VolumeName, dcr->VolumeName) != 0;
+            if (do_mount) {
+               release = true;
+            }
          }
-         do_mount = true;
-      } else {
+      }
+      if (have_vol && !do_mount) {
          /*
           * At this point, the correct tape is already mounted, so
           *   we do not need to do mount_next_write_volume(), unless
index e8978ec7bce2b05e616fd4306f6a512ecac9472f..8796ad4823a0cf79e9c804a1a81aa181aea62770 100644 (file)
@@ -65,7 +65,7 @@ static bool same_label_names(char *bacula_name, char *ansi_name);
  */ 
 int read_ansi_ibm_label(DCR *dcr) 
 {
-   DEVICE *dev = dcr->dev;
+   DEVICE * volatile dev = dcr->dev;
    JCR *jcr = dcr->jcr;
    char label[80];                    /* tape label */
    int stat, i;
@@ -148,6 +148,7 @@ int read_ansi_ibm_label(DCR *dcr)
                }
                *q = 0;
                reserve_volume(dcr, dev->VolHdr.VolumeName);
+               dev = dcr->dev;            /* may have changed in reserve_volume */
                Dmsg2(100, "Wanted ANSI Vol %s got %6s\n", VolName, dev->VolHdr.VolumeName);
                Mmsg2(jcr->errmsg, _("Wanted ANSI Volume \"%s\" got \"%s\"\n"), VolName, dev->VolHdr.VolumeName);
                return VOL_NAME_ERROR;
index d04171d28ab2e6cd5fd49e2c8d1ba6714bbfb1fd..cd0b19a84cd8ad28ce5eac77baf20ca21ff1e4a7 100644 (file)
@@ -111,7 +111,7 @@ bool init_autochangers()
 int autoload_device(DCR *dcr, int writing, BSOCK *dir)
 {
    JCR *jcr = dcr->jcr;
-   DEVICE *dev = dcr->dev;
+   DEVICE * volatile dev = dcr->dev;
    int slot;
    int drive = dev->drive_index;
    int rtn_stat = -1;                 /* error status */
index 18b1aaa7b54b4e7b86de197554694dcf0c8870c5..19d5630990ce5cd7d87887a90c832074fef822f7 100644 (file)
@@ -67,7 +67,7 @@ static void create_volume_label_record(DCR *dcr, DEV_RECORD *rec);
 int read_dev_volume_label(DCR *dcr)
 {
    JCR *jcr = dcr->jcr;
-   DEVICE *dev = dcr->dev;
+   DEVICE * volatile dev = dcr->dev;
    char *VolName = dcr->VolumeName;
    DEV_RECORD *record;
    bool ok = false;
@@ -218,6 +218,7 @@ int read_dev_volume_label(DCR *dcr)
       stat = VOL_NAME_ERROR;
       goto bail_out;
    }
+   dev = dcr->dev;                    /* may have changed in reserve volume */
 
    /* Compare Volume Names */
    Dmsg2(130, "Compare Vol names: VolName=%s hdr=%s\n", VolName?VolName:"*", dev->VolHdr.VolumeName);
@@ -310,7 +311,7 @@ bool write_volume_label_to_block(DCR *dcr)
 bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName, 
                                    const char *PoolName, bool relabel, bool dvdnow)
 {
-   DEVICE *dev = dcr->dev;
+   DEVICE * volatile dev = dcr->dev;
 
 
    Dmsg0(150, "write_volume_label()\n");
@@ -405,6 +406,7 @@ bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName,
            dev->VolHdr.VolumeName, dev->print_name());
       goto bail_out;
    }
+   dev = dcr->dev;                    /* may have changed in reserve_volume */
 
    dev->clear_append();               /* remove append since this is PRE_LABEL */
    return true;
index 06d55b348c5d7e896f38bc319bcaf27b3242c2f3..1aafd357f047cf937c00ae1ef08d333a6d7472bc 100644 (file)
@@ -311,7 +311,7 @@ static void free_vol_item(VOLRES *vol)
 VOLRES *reserve_volume(DCR *dcr, const char *VolumeName)
 {
    VOLRES *vol, *nvol;
-   DEVICE *dev = dcr->dev;
+   DEVICE * volatile dev = dcr->dev;
 
    ASSERT(dev != NULL);
 
@@ -435,7 +435,7 @@ void switch_device(DCR *dcr, DEVICE *dev)
    dcr->VolCatInfo.Slot = save_dcr.VolCatInfo.Slot;
    bstrncpy(dcr->pool_name, save_dcr.pool_name, sizeof(dcr->pool_name));
    bstrncpy(dcr->pool_type, save_dcr.pool_type, sizeof(dcr->pool_type));
-   bstrncpy(dcr->dev_name, save_dcr.dev_name, sizeof(dcr->dev_name));
+   bstrncpy(dcr->dev_name, dev->dev_name, sizeof(dcr->dev_name));
 
    dev->reserved_device++;
    dcr->reserved_device = true;
index fbe03d9e6b7a4d36896a6261fd8cb60a36103468..4b186e36b55774ef2223dfa240f7045c3ca07171 100644 (file)
@@ -1,6 +1,8 @@
               Technical notes on version 2.3
 
 General:
+12Mar08
+kes  Second cut of drive switching during backup.
 11Mar08
 kes  Fix Win32 build.
 kes  Update Win32 version of wxWidgets to most recent version.