2 This patch fixes a migration bug that always has a zero index entry
3 (JobMedia record) as the first entry. This causes Bacula to search
4 for the first record during a restore rather than seek directly to
7 Apply this patch to Bacula 2.2.8 (and possibly any prior 2.2.x version) with:
10 patch -p0 <2.2.8-jobmedia.patch
11 ./configure <your-options>
17 Index: src/stored/device.c
18 ===================================================================
19 --- src/stored/device.c (revision 6391)
20 +++ src/stored/device.c (working copy)
23 Bacula® - The Network Backup Solution
25 - Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
26 + Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
28 The main author of Bacula is Kern Sibbald, with contributions from
29 many others, a complete list can be found in the file AUTHORS.
31 return ok; /* device locked */
34 +void set_start_vol_position(DCR *dcr)
36 + DEVICE *dev = dcr->dev;
37 + /* Set new start position */
38 + if (dev->is_tape()) {
39 + dcr->StartBlock = dev->block_num;
40 + dcr->StartFile = dev->file;
42 + dcr->StartBlock = (uint32_t)dev->file_addr;
43 + dcr->StartFile = (uint32_t)(dev->file_addr >> 32);
48 * We have a new Volume mounted, so reset the Volume parameters
49 * concerning this job. The global changes were made earlier
51 void set_new_volume_parameters(DCR *dcr)
54 - DEVICE *dev = dcr->dev;
55 if (dcr->NewVol && !dir_get_volume_info(dcr, GET_VOL_INFO_FOR_WRITE)) {
56 Jmsg1(jcr, M_ERROR, 0, "%s", jcr->errmsg);
58 - /* Set new start/end positions */
59 - if (dev->is_tape()) {
60 - dcr->StartBlock = dev->block_num;
61 - dcr->StartFile = dev->file;
63 - dcr->StartBlock = (uint32_t)dev->file_addr;
64 - dcr->StartFile = (uint32_t)(dev->file_addr >> 32);
66 - /* Reset indicies */
67 - dcr->VolFirstIndex = 0;
68 - dcr->VolLastIndex = 0;
69 + set_new_file_parameters(dcr);
70 jcr->NumWriteVolumes++;
71 - dcr->NewVol = false;
72 - dcr->WroteVol = false;
78 void set_new_file_parameters(DCR *dcr)
80 - DEVICE *dev = dcr->dev;
81 + set_start_vol_position(dcr);
83 - /* Set new start/end positions */
84 - if (dev->is_tape()) {
85 - dcr->StartBlock = dev->block_num;
86 - dcr->StartFile = dev->file;
88 - dcr->StartBlock = (uint32_t)dev->file_addr;
89 - dcr->StartFile = (uint32_t)(dev->file_addr >> 32);
92 dcr->VolFirstIndex = 0;
93 dcr->VolLastIndex = 0;
94 Index: src/stored/mac.c
95 ===================================================================
96 --- src/stored/mac.c (revision 6391)
97 +++ src/stored/mac.c (working copy)
100 - * SD -- mac.c -- responsible for doing
101 - * migration, archive, and copy jobs.
103 - * Kern Sibbald, January MMVI
108 Bacula® - The Network Backup Solution
110 - Copyright (C) 2006-2006 Free Software Foundation Europe e.V.
111 + Copyright (C) 2006-2008 Free Software Foundation Europe e.V.
113 The main author of Bacula is Kern Sibbald, with contributions from
114 many others, a complete list can be found in the file AUTHORS.
116 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
117 Switzerland, email:ftf@fsfeurope.org.
120 + * SD -- mac.c -- responsible for doing
121 + * migration, archive, and copy jobs.
123 + * Kern Sibbald, January MMVI
132 jcr->dcr->VolFirstIndex = jcr->dcr->VolLastIndex = 0;
133 jcr->run_time = time(NULL);
134 + set_start_vol_position(jcr->dcr);
136 ok = read_records(jcr->read_dcr, record_cb, mount_next_read_volume);
138 Index: src/stored/protos.h
139 ===================================================================
140 --- src/stored/protos.h (revision 6391)
141 +++ src/stored/protos.h (working copy)
143 bool open_device(DCR *dcr);
144 bool first_open_device(DCR *dcr);
145 bool fixup_device_block_write_error(DCR *dcr);
146 +void set_start_vol_position(DCR *dcr);
147 void set_new_volume_parameters(DCR *dcr);
148 void set_new_file_parameters(DCR *dcr);
149 bool is_device_unmounted(DEVICE *dev);