]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/1.36.2/1.36.2-restore-speed.patch
ebl Add patch to allow a more easy selection for restore
[bacula/bacula] / bacula / patches / 1.36.2 / 1.36.2-restore-speed.patch
1
2  This patch will fix a subtle bug that was introduced in 1.36.2
3  which causes Bacula to be very slow restoring a few files. This
4  is because it reads completely to the end of the Volume rather
5  than stopping when all the files on the Volume are loaded. The
6  introduction of the bug was caused by a patch that fixed 
7  Bacula truncating tapes after a restore.
8
9  Apply the patch to 1.36.2 with the following:
10  
11  cd <bacula-source>
12  patch -p0 <1.36.2-restore-speed.patch
13  make 
14  ...
15
16  Note that all source files will be rebuilt during the make.
17
18 Index: src/jcr.h
19 ===================================================================
20 RCS file: /cvsroot/bacula/bacula/src/jcr.h,v
21 retrieving revision 1.76.4.1
22 diff -u -u -b -r1.76.4.1 jcr.h
23 --- src/jcr.h   27 Feb 2005 21:53:28 -0000      1.76.4.1
24 +++ src/jcr.h   17 Mar 2005 14:14:18 -0000
25 @@ -243,6 +243,7 @@
26  
27     /* Parmaters for Open Read Session */
28     BSR *bsr;                          /* Bootstrap record -- has everything */
29 +   bool mount_next_volume;            /* set to cause next volume mount */
30     uint32_t read_VolSessionId;
31     uint32_t read_VolSessionTime;
32     uint32_t read_StartFile;
33 Index: src/stored/read_record.c
34 ===================================================================
35 RCS file: /cvsroot/bacula/bacula/src/stored/read_record.c,v
36 retrieving revision 1.47.4.1
37 diff -u -u -b -r1.47.4.1 read_record.c
38 --- src/stored/read_record.c    15 Feb 2005 11:51:04 -0000      1.47.4.1
39 +++ src/stored/read_record.c    17 Mar 2005 14:14:18 -0000
40 @@ -5,13 +5,16 @@
41   *    archive. It uses a callback to pass you each record in turn,
42   *    as well as a callback for mounting the next tape.  It takes
43   *    care of reading blocks, applying the bsr, ...
44 + *    Note, this routine is really the heart of the restore routines,
45 + *    and we are *really* bit pushing here so be careful about making
46 + *    any modifications.
47   *
48   *    Kern E. Sibbald, August MMII
49   *
50 - *   Version $Id$
51 + *   Version $Id$
52   */
53  /*
54 -   Copyright (C) 2000-2004 Kern Sibbald and John Walker
55 +   Copyright (C) 2000-2005 Kern Sibbald
56  
57     This program is free software; you can redistribute it and/or
58     modify it under the terms of the GNU General Public License as
59 @@ -57,6 +60,7 @@
60  
61     recs = New(dlist(rec, &rec->link));
62     position_to_first_file(jcr, dev);
63 +   jcr->mount_next_volume = false;
64  
65     for ( ; ok && !done; ) {
66        if (job_canceled(jcr)) {
67 @@ -66,12 +70,11 @@
68        if (!read_block_from_device(dcr, CHECK_BLOCK_NUMBERS)) {
69          if (dev->at_eot()) {
70             DEV_RECORD *trec = new_record();
71 -
72              Jmsg(jcr, M_INFO, 0, "End of Volume at file %u on device %s, Volume \"%s\"\n",
73                  dev->file, dev_name(dev), dcr->VolumeName);
74             if (!mount_cb(dcr)) {
75                 Jmsg(jcr, M_INFO, 0, "End of all volumes.\n");
76 -              ok = false;
77 +              ok = false;            /* Stop everything */
78                /*
79                 * Create EOT Label so that Media record may
80                 *  be properly updated because this is the last
81 @@ -81,8 +84,13 @@
82                trec->File = dev->file;
83                ok = record_cb(dcr, trec);
84                free_record(trec);
85 +              if (jcr->mount_next_volume) {
86 +                 jcr->mount_next_volume = false;
87 +                 dev->state &= ~ST_EOT;
88 +              }
89                break;
90             }
91 +           jcr->mount_next_volume = false;
92             /*
93              * We just have a new tape up, now read the label (first record)
94              *  and pass it off to the callback routine, then continue
95 @@ -113,10 +121,10 @@
96             display_tape_error_status(jcr, dev);
97             if (forge_on || jcr->ignore_label_errors) {
98                fsr_dev(dev, 1);       /* try skipping bad record */
99 -               Dmsg0(000, "Did fsr\n");
100 +               Pmsg0(000, "Did fsr\n");
101                continue;              /* try to continue */
102             }
103 -           ok = false;
104 +           ok = false;               /* stop everything */
105             break;
106          }
107        }
108 @@ -259,7 +267,11 @@
109        Dmsg2(300, "Current postion (file:block) %d:%d\n",
110          dev->file, dev->block_num);
111        jcr->bsr->mount_next_volume = false;
112 -//    dev->state |= ST_EOT;
113 +      if (!dev->at_eot()) {
114 +        /* Set EOT flag to force mount of next Volume */
115 +        jcr->mount_next_volume = true;
116 +        dev->state |= ST_EOT;
117 +      }
118        rec->Block = 0;
119        return 1;
120     }