]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Fix creating first JobMedia record during Migration to include
authorKern Sibbald <kern@sibbald.com>
Fri, 15 Feb 2008 08:33:57 +0000 (08:33 +0000)
committerKern Sibbald <kern@sibbald.com>
Fri, 15 Feb 2008 08:33:57 +0000 (08:33 +0000)
     proper index. This caused slow restores of migrated jobs.

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

bacula/patches/2.2.8-jobmedia.patch [new file with mode: 0644]
bacula/src/stored/device.c
bacula/src/stored/mac.c
bacula/src/stored/protos.h
bacula/technotes-2.1

diff --git a/bacula/patches/2.2.8-jobmedia.patch b/bacula/patches/2.2.8-jobmedia.patch
new file mode 100644 (file)
index 0000000..497c9c7
--- /dev/null
@@ -0,0 +1,149 @@
+
+ This patch fixes a migration bug that always has a zero index entry
+ (JobMedia record) as the first entry. This causes Bacula to search
+ for the first record during a restore rather than seek directly to
+ it.
+
+ Apply this patch to Bacula 2.2.8 (and possibly any prior 2.2.x version) with:
+
+ cd <bacula-source>
+ patch -p0 <2.2.8-jobmedia.patch
+ ./configure <your-options>
+ make
+ ...
+ make install
+
+
+Index: src/stored/device.c
+===================================================================
+--- src/stored/device.c        (revision 6391)
++++ src/stored/device.c        (working copy)
+@@ -1,7 +1,7 @@
+ /*
+    Bacula® - The Network Backup Solution
+-   Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
++   Copyright (C) 2000-2007 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.
+@@ -200,6 +200,19 @@
+    return ok;                               /* device locked */
+ }
++void set_start_vol_position(DCR *dcr)
++{
++   DEVICE *dev = dcr->dev;
++   /* Set new start position */
++   if (dev->is_tape()) {
++      dcr->StartBlock = dev->block_num;
++      dcr->StartFile = dev->file;
++   } else {
++      dcr->StartBlock = (uint32_t)dev->file_addr;
++      dcr->StartFile  = (uint32_t)(dev->file_addr >> 32);
++   }
++}
++
+ /*
+  * We have a new Volume mounted, so reset the Volume parameters
+  *  concerning this job.  The global changes were made earlier
+@@ -208,24 +221,11 @@
+ void set_new_volume_parameters(DCR *dcr)
+ {
+    JCR *jcr = dcr->jcr;
+-   DEVICE *dev = dcr->dev;
+    if (dcr->NewVol && !dir_get_volume_info(dcr, GET_VOL_INFO_FOR_WRITE)) {
+       Jmsg1(jcr, M_ERROR, 0, "%s", jcr->errmsg);
+    }
+-   /* Set new start/end positions */
+-   if (dev->is_tape()) {
+-      dcr->StartBlock = dev->block_num;
+-      dcr->StartFile = dev->file;
+-   } else {
+-      dcr->StartBlock = (uint32_t)dev->file_addr;
+-      dcr->StartFile  = (uint32_t)(dev->file_addr >> 32);
+-   }
+-   /* Reset indicies */
+-   dcr->VolFirstIndex = 0;
+-   dcr->VolLastIndex = 0;
++   set_new_file_parameters(dcr);
+    jcr->NumWriteVolumes++;
+-   dcr->NewVol = false;
+-   dcr->WroteVol = false;
+ }
+ /*
+@@ -235,16 +235,8 @@
+  */
+ void set_new_file_parameters(DCR *dcr)
+ {
+-   DEVICE *dev = dcr->dev;
++   set_start_vol_position(dcr);
+-   /* Set new start/end positions */
+-   if (dev->is_tape()) {
+-      dcr->StartBlock = dev->block_num;
+-      dcr->StartFile = dev->file;
+-   } else {
+-      dcr->StartBlock = (uint32_t)dev->file_addr;
+-      dcr->StartFile  = (uint32_t)(dev->file_addr >> 32);
+-   }
+    /* Reset indicies */
+    dcr->VolFirstIndex = 0;
+    dcr->VolLastIndex = 0;
+Index: src/stored/mac.c
+===================================================================
+--- src/stored/mac.c   (revision 6391)
++++ src/stored/mac.c   (working copy)
+@@ -1,15 +1,7 @@
+ /*
+- * SD -- mac.c --  responsible for doing
+- *     migration, archive, and copy jobs.
+- *
+- *     Kern Sibbald, January MMVI
+- *
+- *   Version $Id$
+- */
+-/*
+    Bacula® - The Network Backup Solution
+-   Copyright (C) 2006-2006 Free Software Foundation Europe e.V.
++   Copyright (C) 2006-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.
+@@ -33,6 +25,14 @@
+    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+    Switzerland, email:ftf@fsfeurope.org.
+ */
++/*
++ * SD -- mac.c --  responsible for doing
++ *     migration, archive, and copy jobs.
++ *
++ *     Kern Sibbald, January MMVI
++ *
++ *   Version $Id$
++ */
+ #include "bacula.h"
+ #include "stored.h"
+@@ -108,6 +108,7 @@
+    jcr->dcr->VolFirstIndex = jcr->dcr->VolLastIndex = 0;
+    jcr->run_time = time(NULL);
++   set_start_vol_position(jcr->dcr);
+    ok = read_records(jcr->read_dcr, record_cb, mount_next_read_volume);
+    goto ok_out;
+Index: src/stored/protos.h
+===================================================================
+--- src/stored/protos.h        (revision 6391)
++++ src/stored/protos.h        (working copy)
+@@ -126,6 +126,7 @@
+ bool     open_device(DCR *dcr);
+ bool     first_open_device(DCR *dcr);
+ bool     fixup_device_block_write_error(DCR *dcr);
++void     set_start_vol_position(DCR *dcr);
+ void     set_new_volume_parameters(DCR *dcr);
+ void     set_new_file_parameters(DCR *dcr);
+ bool     is_device_unmounted(DEVICE *dev);
index 7e8656974f9342f259cb42be8082c06a869ea3b2..b38b512d0bba87783189ab5d40f589c78febd802 100644 (file)
@@ -1,7 +1,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
+   Copyright (C) 2000-2007 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.
@@ -200,6 +200,19 @@ bail_out:
    return ok;                               /* device locked */
 }
 
+void set_start_vol_position(DCR *dcr)
+{
+   DEVICE *dev = dcr->dev;
+   /* Set new start position */
+   if (dev->is_tape()) {
+      dcr->StartBlock = dev->block_num;
+      dcr->StartFile = dev->file;
+   } else {
+      dcr->StartBlock = (uint32_t)dev->file_addr;
+      dcr->StartFile  = (uint32_t)(dev->file_addr >> 32);
+   }
+}
+
 /*
  * We have a new Volume mounted, so reset the Volume parameters
  *  concerning this job.  The global changes were made earlier
@@ -208,24 +221,11 @@ bail_out:
 void set_new_volume_parameters(DCR *dcr)
 {
    JCR *jcr = dcr->jcr;
-   DEVICE *dev = dcr->dev;
    if (dcr->NewVol && !dir_get_volume_info(dcr, GET_VOL_INFO_FOR_WRITE)) {
       Jmsg1(jcr, M_ERROR, 0, "%s", jcr->errmsg);
    }
-   /* Set new start/end positions */
-   if (dev->is_tape()) {
-      dcr->StartBlock = dev->block_num;
-      dcr->StartFile = dev->file;
-   } else {
-      dcr->StartBlock = (uint32_t)dev->file_addr;
-      dcr->StartFile  = (uint32_t)(dev->file_addr >> 32);
-   }
-   /* Reset indicies */
-   dcr->VolFirstIndex = 0;
-   dcr->VolLastIndex = 0;
+   set_new_file_parameters(dcr);
    jcr->NumWriteVolumes++;
-   dcr->NewVol = false;
-   dcr->WroteVol = false;
 }
 
 /*
@@ -235,16 +235,8 @@ void set_new_volume_parameters(DCR *dcr)
  */
 void set_new_file_parameters(DCR *dcr)
 {
-   DEVICE *dev = dcr->dev;
+   set_start_vol_position(dcr);
 
-   /* Set new start/end positions */
-   if (dev->is_tape()) {
-      dcr->StartBlock = dev->block_num;
-      dcr->StartFile = dev->file;
-   } else {
-      dcr->StartBlock = (uint32_t)dev->file_addr;
-      dcr->StartFile  = (uint32_t)(dev->file_addr >> 32);
-   }
    /* Reset indicies */
    dcr->VolFirstIndex = 0;
    dcr->VolLastIndex = 0;
index 11528ad84cbe60ed8da97868dfa0604cdf3807f8..59e4c1ff61967692a8680820376429b91e68a3ec 100644 (file)
@@ -1,15 +1,7 @@
-/*
- * SD -- mac.c --  responsible for doing
- *     migration, archive, and copy jobs.
- *
- *     Kern Sibbald, January MMVI
- *
- *   Version $Id$
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2006-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2006-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.
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ * SD -- mac.c --  responsible for doing
+ *     migration, archive, and copy jobs.
+ *
+ *     Kern Sibbald, January MMVI
+ *
+ *   Version $Id$
+ */
 
 #include "bacula.h"
 #include "stored.h"
@@ -108,6 +108,7 @@ bool do_mac(JCR *jcr)
 
    jcr->dcr->VolFirstIndex = jcr->dcr->VolLastIndex = 0;
    jcr->run_time = time(NULL);
+   set_start_vol_position(jcr->dcr);
 
    ok = read_records(jcr->read_dcr, record_cb, mount_next_read_volume);
    goto ok_out;
index 0a673d0141ddc704a510a78af914d8dedfd61517..7d1b75a3e23895bbcbeb780eaff892aba28543e3 100644 (file)
@@ -126,6 +126,7 @@ void    dvd_remove_empty_part(DCR *dcr);
 bool     open_device(DCR *dcr);
 bool     first_open_device(DCR *dcr);
 bool     fixup_device_block_write_error(DCR *dcr);
+void     set_start_vol_position(DCR *dcr);
 void     set_new_volume_parameters(DCR *dcr);
 void     set_new_file_parameters(DCR *dcr);
 bool     is_device_unmounted(DEVICE *dev);
index cc75afd623b6a3e6f79fffe7c771180c924a187c..13b794b1043f8daf36080f040c3c733ae734ef79 100644 (file)
@@ -1,6 +1,9 @@
               Technical notes on version 2.2
 
 General:
+14Feb08
+kes  Fix creating first JobMedia record during Migration to include
+     proper index. This caused slow restores of migrated jobs.
 10Feb08
 kes  Fix bug #1047, which had a heap overrun when stripping certain paths,
      and do not strip paths on symbolic links.