]> git.sur5r.net Git - bacula/bacula/commitdiff
Attempt to fix bug #1128 InChanger flag cleared during Migration
authorKern Sibbald <kern@sibbald.com>
Tue, 26 Aug 2008 13:14:38 +0000 (13:14 +0000)
committerKern Sibbald <kern@sibbald.com>
Tue, 26 Aug 2008 13:14:38 +0000 (13:14 +0000)
     job when reading from one autochanger and writing to another.

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

bacula/patches/2.4.2-inchanger.patch [new file with mode: 0644]
bacula/src/cats/sql_update.c
bacula/src/dird/catreq.c
bacula/src/dird/dird.c
bacula/src/version.h
bacula/technotes-2.4

diff --git a/bacula/patches/2.4.2-inchanger.patch b/bacula/patches/2.4.2-inchanger.patch
new file mode 100644 (file)
index 0000000..5b3e566
--- /dev/null
@@ -0,0 +1,100 @@
+
+  Attempt to fix bug #1128 InChanger flag cleared during Migration
+  job when reading from one autochanger and writing to another.
+  Testing is needed.
+  Apply this patch to Bacula version 2.4.2 with:
+
+  cd <bacula-source>
+  patch -p0 <2.4.2-inchanger.patch
+  ./configure <your options>
+  make
+  ...
+  make install
+
+
+Index: src/dird/catreq.c
+===================================================================
+--- src/dird/catreq.c  (revision 7507)
++++ src/dird/catreq.c  (working copy)
+@@ -83,7 +83,7 @@
+    jcr->MediaId = mr->MediaId;
+    pm_strcpy(jcr->VolumeName, mr->VolumeName);
+    bash_spaces(mr->VolumeName);
+-   stat = bnet_fsend(sd, OK_media, mr->VolumeName, mr->VolJobs,
++   stat = sd->fsend(OK_media, mr->VolumeName, mr->VolJobs,
+       mr->VolFiles, mr->VolBlocks, edit_uint64(mr->VolBytes, ed1),
+       mr->VolMounts, mr->VolErrors, mr->VolWrites,
+       edit_uint64(mr->MaxVolBytes, ed2),
+@@ -266,11 +266,22 @@
+          }
+       }
+       Dmsg2(400, "Update media: BefVolJobs=%u After=%u\n", mr.VolJobs, sdmr.VolJobs);
++
+       /* Check if the volume has been written by the job, 
+        * and update the LastWritten field if needed */
+       if (mr.VolBlocks != sdmr.VolBlocks) {
+          mr.LastWritten = sdmr.LastWritten;
+       }
++
++      /*
++       * Update to point to the last device used to write the Volume.
++       *   However, do so only if we are writing the tape, i.e.
++       *   the number of VolWrites has increased.
++       */
++      if (jcr->wstore && jcr->wstore->StorageId && sdmr.VolWrites > mr.VolWrites) {
++         mr.StorageId = jcr->wstore->StorageId;
++      }
++
+       /* Copy updated values to original media record */
+       mr.VolJobs      = sdmr.VolJobs;
+       mr.VolFiles     = sdmr.VolFiles;
+@@ -285,14 +296,6 @@
+       mr.VolWriteTime = sdmr.VolWriteTime;
+       mr.VolParts     = sdmr.VolParts;
+       bstrncpy(mr.VolStatus, sdmr.VolStatus, sizeof(mr.VolStatus));
+-      /*
+-       * Update to point to the last device used to write the Volume.
+-       *   However, do so only if we are writing the tape, i.e.
+-       *   the number of VolBlocks has increased.
+-       */
+-      if (jcr->wstore && jcr->wstore->StorageId && mr.VolBlocks != sdmr.VolBlocks) {
+-         mr.StorageId = jcr->wstore->StorageId;
+-      }
+       Dmsg2(400, "db_update_media_record. Stat=%s Vol=%s\n", mr.VolStatus, mr.VolumeName);
+       /*
+Index: src/dird/dird.c
+===================================================================
+--- src/dird/dird.c    (revision 7507)
++++ src/dird/dird.c    (working copy)
+@@ -914,6 +914,7 @@
+          db_create_storage_record(NULL, db, &sr);
+          store->StorageId = sr.StorageId;   /* set storage Id */
+          if (!sr.created) {                 /* if not created, update it */
++            sr.AutoChanger = store->autochanger;
+             db_update_storage_record(NULL, db, &sr);
+          }
+Index: src/cats/sql_update.c
+===================================================================
+--- src/cats/sql_update.c      (revision 7507)
++++ src/cats/sql_update.c      (working copy)
+@@ -1,7 +1,7 @@
+ /*
+    Bacula® - The Network Backup Solution
+-   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.
+@@ -445,7 +445,8 @@
+ db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
+ {
+    char ed1[50], ed2[50];
+-   if (mr->InChanger != 0 && mr->Slot != 0) {
++   if (mr->InChanger != 0 && mr->Slot != 0 && mr->StorageId != 0 &&
++       mr->MediaId != 0) {
+       Mmsg(mdb->cmd, "UPDATE Media SET InChanger=0 WHERE "
+            "Slot=%d AND StorageId=%s AND MediaId!=%s",
+             mr->Slot, 
index 5b524108d4288b9f156691a13551226a78c19467..d77d025654b039e0f8cf4f580f26e0348109c099 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   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.
@@ -445,7 +445,8 @@ void
 db_make_inchanger_unique(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
 {
    char ed1[50], ed2[50];
-   if (mr->InChanger != 0 && mr->Slot != 0) {
+   if (mr->InChanger != 0 && mr->Slot != 0 && mr->StorageId != 0 &&
+       mr->MediaId != 0) {
       Mmsg(mdb->cmd, "UPDATE Media SET InChanger=0 WHERE "
            "Slot=%d AND StorageId=%s AND MediaId!=%s",
             mr->Slot, 
index 224d5e7e2b59d6b60a6412df36d0edf1a903005f..9d2409de954162e2f022eb59d30c0702716c7d1f 100644 (file)
@@ -83,7 +83,7 @@ static int send_volume_info_to_storage_daemon(JCR *jcr, BSOCK *sd, MEDIA_DBR *mr
    jcr->MediaId = mr->MediaId;
    pm_strcpy(jcr->VolumeName, mr->VolumeName);
    bash_spaces(mr->VolumeName);
-   stat = bnet_fsend(sd, OK_media, mr->VolumeName, mr->VolJobs,
+   stat = sd->fsend(OK_media, mr->VolumeName, mr->VolJobs,
       mr->VolFiles, mr->VolBlocks, edit_uint64(mr->VolBytes, ed1),
       mr->VolMounts, mr->VolErrors, mr->VolWrites,
       edit_uint64(mr->MaxVolBytes, ed2),
@@ -266,11 +266,22 @@ void catalog_request(JCR *jcr, BSOCK *bs)
          }
       }
       Dmsg2(400, "Update media: BefVolJobs=%u After=%u\n", mr.VolJobs, sdmr.VolJobs);
+
       /* Check if the volume has been written by the job, 
        * and update the LastWritten field if needed */
       if (mr.VolBlocks != sdmr.VolBlocks) {
          mr.LastWritten = sdmr.LastWritten;
       }
+
+      /*
+       * Update to point to the last device used to write the Volume.
+       *   However, do so only if we are writing the tape, i.e.
+       *   the number of VolWrites has increased.
+       */
+      if (jcr->wstore && jcr->wstore->StorageId && sdmr.VolWrites > mr.VolWrites) {
+         mr.StorageId = jcr->wstore->StorageId;
+      }
+
       /* Copy updated values to original media record */
       mr.VolJobs      = sdmr.VolJobs;
       mr.VolFiles     = sdmr.VolFiles;
@@ -285,14 +296,6 @@ void catalog_request(JCR *jcr, BSOCK *bs)
       mr.VolWriteTime = sdmr.VolWriteTime;
       mr.VolParts     = sdmr.VolParts;
       bstrncpy(mr.VolStatus, sdmr.VolStatus, sizeof(mr.VolStatus));
-      /*
-       * Update to point to the last device used to write the Volume.
-       *   However, do so only if we are writing the tape, i.e.
-       *   the number of VolBlocks has increased.
-       */
-      if (jcr->wstore && jcr->wstore->StorageId && mr.VolBlocks != sdmr.VolBlocks) {
-         mr.StorageId = jcr->wstore->StorageId;
-      }
 
       Dmsg2(400, "db_update_media_record. Stat=%s Vol=%s\n", mr.VolStatus, mr.VolumeName);
       /*
index 760c1e5c8d3acf30716373c8a217c00563fe1308..d7a3d3c4fc68c9dbb1ff99b4d755c40bc0cf2ef1 100644 (file)
@@ -914,6 +914,7 @@ static bool check_catalog()
          db_create_storage_record(NULL, db, &sr);
          store->StorageId = sr.StorageId;   /* set storage Id */
          if (!sr.created) {                 /* if not created, update it */
+            sr.AutoChanger = store->autochanger;
             db_update_storage_record(NULL, db, &sr);
          }
 
index 8e1f368e8a8316b9e5942fcb66d0d1dd9dc9fd70..5355414598358720418f65510b355cb7d99c9f3a 100644 (file)
@@ -4,8 +4,8 @@
 
 #undef  VERSION
 #define VERSION "2.4.3"
-#define BDATE   "24 August 2008"
-#define LSMDATE "24Aug08"
+#define BDATE   "26 August 2008"
+#define LSMDATE "26Aug08"
 
 #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n"
 #define BYEAR "2008"       /* year for copyright messages in progs */
index 0f9b6002e829ebbfaf16b7fa2060fd02e38fa1a4..03bc56b15fae81f06e34a1cc2e55374521ffd69f 100644 (file)
@@ -1,6 +1,9 @@
               Technical notes on version 2.4
 
 General:
+26Aug08
+kes  Attempt to fix bug #1128 InChanger flag cleared during Migration
+     job when reading from one autochanger and writing to another.
 24Aug08
 kes  Add more information to SD acquire.c INFO messages.
 kes  Fix NULL Volume name error when reading and the drive must