]> git.sur5r.net Git - bacula/bacula/commitdiff
Prevent a Volume that is being swapped from being freed from
authorKern Sibbald <kern@sibbald.com>
Thu, 1 May 2008 20:05:56 +0000 (20:05 +0000)
committerKern Sibbald <kern@sibbald.com>
Thu, 1 May 2008 20:05:56 +0000 (20:05 +0000)
     the volume list. This will most likely fix, at least partially,
     bug #1083.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@6872 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/patches/2.2.8-strippath.patch
bacula/src/stored/reserve.c
bacula/technotes-2.1

index 0aae25245b50d57bc7fe5cc6a256b82ee8024b7b..2e2f037bbe0c2b110b0485f0fd678ad4b85f398f 100644 (file)
@@ -49,7 +49,7 @@ Index: src/filed/backup.c
 +      pm_strcpy(ff_pkt->link_save, ff_pkt->link);
 +      Dmsg2(500, "strcpy link_save=%d link=%d\n", strlen(ff_pkt->link_save),
 +         strlen(ff_pkt->link));
-+      sm_check(__FILE__, __LINE__, true);
++//    sm_check(__FILE__, __LINE__, true);
 +   }
  
     /* 
@@ -98,6 +98,6 @@ Index: src/filed/backup.c
        strcpy(ff_pkt->link, ff_pkt->link_save);
 +      Dmsg2(500, "strcpy link=%d link_save=%d\n", strlen(ff_pkt->link),
 +          strlen(ff_pkt->link_save));
-+      sm_check(__FILE__, __LINE__, true);
++//    sm_check(__FILE__, __LINE__, true);
     }
  }
index 429cc87b71b95765d2f5c33bf6ce956a689587f5..35b4f090ea59cf23542151d7e68e93bb33c6422b 100644 (file)
@@ -388,22 +388,24 @@ VOLRES *reserve_volume(DCR *dcr, const char *VolumeName)
       nvol->dev = NULL;                  /* don't zap dev entry */
       free_vol_item(nvol);
 
-      /* Check if we are trying to use the Volume on a different drive */
+      /*
+       * Check if we are trying to use the Volume on a different drive   
+       *  dev      is our device
+       *  vol->dev is where the Volume we want is
+       */
       if (dev != vol->dev) {
          /* Caller wants to switch Volume to another device */
          if (!vol->dev->is_busy() && !vol->is_swapping()) {
             Dmsg4(dbglvl, "==== jid=%u Swap vol=%s from dev=%s to %s\n", jid(),
                VolumeName, vol->dev->print_name(), dev->print_name());
             free_volume(dev);            /* free any volume attached to our drive */
-            vol->dev->set_unload();      /* unload our drive */
+            vol->dev->set_unload();      /* unload the other drive */
             vol->set_swapping();         /* swap from other drive */
             dev->swap_dev = vol->dev;    /* remember to get this vol */
             vol->dev->set_load();        /* then reload on our drive */
             vol->dev->vol = NULL;        /* remove volume from other drive */
-            vol->dev = dev;              /* point it at our drive */
-            dev->vol = vol;              /* point our drive at it */
-            Dmsg3(dbglvl, "==== Swap vol=%s from dev=%s to %s\n", 
-               VolumeName, vol->dev->print_name(), dev->print_name());
+            vol->dev = dev;              /* point the Volume at our drive */
+            dev->vol = vol;              /* point our drive at the Volume */
          } else {
             Dmsg4(dbglvl, "jid=%u ==== Swap not possible Vol busy vol=%s from dev=%s to %s\n", jid(),
                VolumeName, vol->dev->print_name(), dev->print_name());
@@ -591,11 +593,14 @@ bool free_volume(DEVICE *dev)
    }
    lock_volumes();
    vol = dev->vol;
-   dev->vol = NULL;
-   vol_list->remove(vol);
-   Dmsg3(dbglvl, "jid=%u === free_volume %s dev=%s\n", jid(), vol->vol_name, dev->print_name());
-   free_vol_item(vol);
-   debug_list_volumes("free_volume");
+   /* Don't free a volume while it is being swapped */
+   if (!vol->is_swapping()) {
+      dev->vol = NULL;
+      vol_list->remove(vol);
+      Dmsg3(dbglvl, "jid=%u === free_volume %s dev=%s\n", jid(), vol->vol_name, dev->print_name());
+      free_vol_item(vol);
+      debug_list_volumes("free_volume");
+   }
    unlock_volumes();
    return true;
 }
index a378f7ba20d7a52523881e2100a943a682803a08..d12c12415f313707c33d8f8479567bc227f36654 100644 (file)
@@ -2,6 +2,9 @@
 
 General:
 01May08
+kes  Prevent a Volume that is being swapped from being freed from
+     the volume list. This will most likely fix, at least partially,
+     bug #1083.
 kes  Fix strippath so that it does not get a buffer overrun and crash FD.
      This fixes bug #1078.
 kes  Make inability to change owner/group when creating a dir only a