]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Implement regression that explicitly tests swapping a Volume
authorKern Sibbald <kern@sibbald.com>
Sat, 3 May 2008 09:01:28 +0000 (09:01 +0000)
committerKern Sibbald <kern@sibbald.com>
Sat, 3 May 2008 09:01:28 +0000 (09:01 +0000)
     from one drive to another.
kes  Enhance disk-changer to detect most error conditions.
kes  Fix SD code so that it properly swaps a Volume between drives.
     This fixes bug #1083.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6881 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/kernstodo
bacula/scripts/disk-changer.in
bacula/src/stored/dev.h
bacula/src/stored/mount.c
bacula/src/stored/reserve.c
bacula/src/version.h
bacula/technotes-2.3

index aa08419aa96ca1d6b70f1536eaa48e8793047961..6bd65639d98d5c7fdc8e8178a2520b47d87f41c7 100644 (file)
@@ -114,6 +114,7 @@ Professional Needs:
 
 Priority:
 ================
 
 Priority:
 ================
+- Check for FD compatibility -- eg .nobackup ...
 - Re-check new dcr->reserved_volume
 - Softlinks that point to non-existent file are not restored in restore all,
   but are restored if the file is individually selected.  BUG!
 - Re-check new dcr->reserved_volume
 - Softlinks that point to non-existent file are not restored in restore all,
   but are restored if the file is individually selected.  BUG!
index 8a901558bc57c8b2a06dda35df87f66b8bc0ba44..208bc95553ddf88e7fddd46830d0614b17cc9647 100644 (file)
@@ -4,7 +4,7 @@
 #
 #  Written by Kern Sibbald
 #
 #
 #  Written by Kern Sibbald
 #
-#  Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
+#  Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
 #
 #  The main author of Bacula is Kern Sibbald, with contributions from
 #  many others, a complete list can be found in the file AUTHORS.
 #
 #  The main author of Bacula is Kern Sibbald, with contributions from
 #  many others, a complete list can be found in the file AUTHORS.
@@ -191,7 +191,12 @@ case $cmd in
    unload)
       debug "Doing disk -f $ctl unload $slot $device $drive"
       get_dir
    unload)
       debug "Doing disk -f $ctl unload $slot $device $drive"
       get_dir
-      ld=`cat $dir/loaded${drive}`
+      if [ -f $dir/loaded${drive} ]; then
+        ld=`cat $dir/loaded${drive}`
+      else 
+        echo "Storage Element $slot is Already Full"
+        exit 1
+      fi
       if [ $slot -eq $ld ]; then
         echo "0" >$dir/loaded${drive}
         unlink $device 2>/dev/null >/dev/null
       if [ $slot -eq $ld ]; then
         echo "0" >$dir/loaded${drive}
         unlink $device 2>/dev/null >/dev/null
@@ -205,25 +210,37 @@ case $cmd in
    load)
       debug "Doing disk $ctl load $slot $device $drive"
       get_dir
    load)
       debug "Doing disk $ctl load $slot $device $drive"
       get_dir
+      i=0
+      while [ $i -le $maxdrive ]; do
+        if [ -f $dir/loaded${i} ]; then
+           ld=`cat $dir/loaded${i}`
+        else    
+           ld=0
+        fi
+        if [ $ld -eq $slot ]; then
+           echo "Drive ${i} Full (Storage element ${ld} loaded)"
+           exit 1
+        fi
+        i=`expr $i + 1`
+      done
       if [ -f $dir/loaded${drive} ]; then
         ld=`cat $dir/loaded${drive}`
       else
         ld=0
       fi
       if [ -f $dir/loaded${drive} ]; then
         ld=`cat $dir/loaded${drive}`
       else
         ld=0
       fi
-      if [ $ld -eq 0 ]; then
-        echo "0" >$dir/loaded${drive}
-        unlink $device 2>/dev/null >/dev/null
-        rm -f $device
-        ln -s $dir/slot${slot} $device
-        rtn=$?
-        if [ $rtn -eq 0 ]; then
-           echo $slot >$dir/loaded${drive}
-        fi
-        exit $rtn
-      else
+      if [ $ld -ne 0 ]; then
         echo "Drive ${drive} Full (Storage element ${ld} loaded)"
         exit 1
       fi
         echo "Drive ${drive} Full (Storage element ${ld} loaded)"
         exit 1
       fi
+      echo "0" >$dir/loaded${drive}
+      unlink $device 2>/dev/null >/dev/null
+      rm -f $device
+      ln -s $dir/slot${slot} $device
+      rtn=$?
+      if [ $rtn -eq 0 ]; then
+        echo $slot >$dir/loaded${drive}
+      fi
+      exit $rtn
       ;;
 
    list) 
       ;;
 
    list) 
index 619460ef1d028b9b636ab207dd22861072ee3792..7a3f07665b31f90385bdf0a4c57bf299d28aaf86 100644 (file)
@@ -542,6 +542,7 @@ public:
 class VOLRES { 
    bool m_swapping;                   /* set when swapping to another drive */
    bool m_in_use;                     /* set when volume reserved or in use */
 class VOLRES { 
    bool m_swapping;                   /* set when swapping to another drive */
    bool m_in_use;                     /* set when volume reserved or in use */
+   int32_t m_slot;                    /* slot of swapping volume */
 public:
    dlink link;
    char *vol_name;                    /* Volume name */
 public:
    dlink link;
    char *vol_name;                    /* Volume name */
@@ -553,6 +554,8 @@ public:
    bool is_in_use() const { return m_in_use; };
    void set_in_use() { m_in_use = true; };
    void clear_in_use() { m_in_use = false; };
    bool is_in_use() const { return m_in_use; };
    void set_in_use() { m_in_use = true; };
    void clear_in_use() { m_in_use = false; };
+   void set_slot(int32_t slot) { m_slot = slot; };
+   int32_t get_slot() const { return m_slot; };
 };
 
 
 };
 
 
index f0d0baf8ee287a6f9435b3ecac1f3ccbc7c534a9..b38f17979678a3dcce5035603a60051c091478f5 100644 (file)
@@ -160,7 +160,7 @@ mount_next_vol:
       autochanger = false;
       VolCatInfo.Slot = 0;
    }
       autochanger = false;
       VolCatInfo.Slot = 0;
    }
-   Dmsg1(200, "autoload_dev returns %d\n", autochanger);
+   Dmsg1(150, "autoload_dev returns %d\n", autochanger);
    /*
     * If we autochanged to correct Volume or (we have not just
     *   released the Volume AND we can automount) we go ahead
    /*
     * If we autochanged to correct Volume or (we have not just
     *   released the Volume AND we can automount) we go ahead
@@ -473,7 +473,7 @@ bool DCR::is_suitable_volume_mounted()
 void DCR::do_swapping()
 {
    if (dev->must_unload()) {
 void DCR::do_swapping()
 {
    if (dev->must_unload()) {
-      Dmsg0(150, "mount_next_volume release=1\n");
+      Dmsg1(100, "swapping: unloading %s\n", dev->print_name());
       unload_autochanger(this, -1);
       release_volume();
       dev->clear_unload();
       unload_autochanger(this, -1);
       release_volume();
       dev->clear_unload();
@@ -484,9 +484,14 @@ void DCR::do_swapping()
     *  volume to our drive.
     */
    if (dev->swap_dev) {
     *  volume to our drive.
     */
    if (dev->swap_dev) {
-      Dmsg1(100, "Swap unloading %s\n", dev->swap_dev->print_name());
       if (dev->swap_dev->must_unload()) {
       if (dev->swap_dev->must_unload()) {
+         if (dev->vol) {
+            dev->Slot = dev->vol->get_slot();
+         }
+         Dmsg2(100, "Swap unloading slot=%d %s\n", dev->Slot, 
+               dev->swap_dev->print_name());
          unload_dev(this, dev->swap_dev);
          unload_dev(this, dev->swap_dev);
+         dev->Slot = -1;
       }
       if (dev->vol) {
          dev->vol->clear_swapping();
       }
       if (dev->vol) {
          dev->vol->clear_swapping();
@@ -496,6 +501,7 @@ void DCR::do_swapping()
       dev->swap_dev = NULL;
    }
    if (dev->must_load()) {
       dev->swap_dev = NULL;
    }
    if (dev->must_load()) {
+      Dmsg1(100, "swapping: must load %s\n", dev->print_name());
       dev->clear_load();
       dev->clear_volhdr();               /* force "load" */
    }
       dev->clear_load();
       dev->clear_volhdr();               /* force "load" */
    }
index fc580bc0e5b744b2dfb96a5355cb8878cef9f7eb..7dbede4b7c8aca7a395bafa95866eccadaba50db 100644 (file)
@@ -394,13 +394,18 @@ VOLRES *reserve_volume(DCR *dcr, const char *VolumeName)
       if (dev != vol->dev) {
          /* Caller wants to switch Volume to another device */
          if (!vol->dev->is_busy() && !vol->is_swapping()) {
       if (dev != vol->dev) {
          /* Caller wants to switch Volume to another device */
          if (!vol->dev->is_busy() && !vol->is_swapping()) {
+            int32_t slot;
             Dmsg3(dbglvl, "==== Swap vol=%s from dev=%s to %s\n", 
                VolumeName, vol->dev->print_name(), dev->print_name());
             free_volume(dev);            /* free any volume attached to our drive */
             Dmsg3(dbglvl, "==== Swap vol=%s from dev=%s to %s\n", 
                VolumeName, vol->dev->print_name(), dev->print_name());
             free_volume(dev);            /* free any volume attached to our drive */
+            dcr->dev = vol->dev;         /* temp point to other dev */
+            slot = get_autochanger_loaded_slot(dcr);  /* get slot */
+            dcr->dev = dev;              /* restore dev */
+            vol->set_slot(slot);         /* save slot */
             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_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 */
+            dev->set_load();             /* then reload on our drive */
             vol->dev->vol = NULL;        /* remove volume from other drive */
             vol->dev = dev;              /* point the Volume at our drive */
             dev->vol = vol;              /* point our drive at the Volume */
             vol->dev->vol = NULL;        /* remove volume from other drive */
             vol->dev = dev;              /* point the Volume at our drive */
             dev->vol = vol;              /* point our drive at the Volume */
@@ -1330,8 +1335,8 @@ bail_out:
 
 
 /*
 
 
 /*
- * We reserve the device for appending by incrementing the 
- *  reserved_device. We do virtually all the same work that
+ * We reserve the device for appending by incrementing
+ *  num_reserved(). We do virtually all the same work that
  *  is done in acquire_device_for_append(), but we do
  *  not attempt to mount the device. This routine allows
  *  the DIR to reserve multiple devices before *really* 
  *  is done in acquire_device_for_append(), but we do
  *  not attempt to mount the device. This routine allows
  *  the DIR to reserve multiple devices before *really* 
index 40e7b9d8bf83637bb5008d5aa92e5089da019573..0fae6a841d59fce8e53532add71e5c45fe4204b6 100644 (file)
@@ -3,9 +3,9 @@
  */
 
 #undef  VERSION
  */
 
 #undef  VERSION
-#define VERSION "2.3.19"
-#define BDATE   "02 May 2008"
-#define LSMDATE "02May08"
+#define VERSION "2.3.20"
+#define BDATE   "03 May 2008"
+#define LSMDATE "03May08"
 
 #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n"
 #define BYEAR "2008"       /* year for copyright messages in progs */
 
 #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n"
 #define BYEAR "2008"       /* year for copyright messages in progs */
index 96cdb8b566cde5d0cc074ad3265fd1dd8c329fb8..9f70887825db30ff039db6ee3175d3767c9a802e 100644 (file)
@@ -24,6 +24,12 @@ Add long term statistics job table
 
 
 General:
 
 
 General:
+03May08
+kes  Implement regression that explicitly tests swapping a Volume
+     from one drive to another.
+kes  Enhance disk-changer to detect most error conditions.
+kes  Fix SD code so that it properly swaps a Volume between drives.
+     This fixes bug #1083.
 02May08
 kes  Apply libdbi patch from Joao Freitas for regress and for 
      Bacula trunk. Regress now works with libdbi. Nice.
 02May08
 kes  Apply libdbi patch from Joao Freitas for regress and for 
      Bacula trunk. Regress now works with libdbi. Nice.