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 You have to apply 2.2.8-jobmedia-fix.patch too.
9 Apply this patch to Bacula 2.2.8 (and possibly any prior 2.2.x version) with:
12 patch -p0 <2.2.8-jobmedia.patch
13 patch -p0 <2.2.8-jobmedia-fix.patch
14 ./configure <your-options>
20 Index: src/stored/device.c
21 ===================================================================
22 --- src/stored/device.c (revision 6391)
23 +++ src/stored/device.c (working copy)
26 Bacula® - The Network Backup Solution
28 - Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
29 + Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
31 The main author of Bacula is Kern Sibbald, with contributions from
32 many others, a complete list can be found in the file AUTHORS.
34 return ok; /* device locked */
37 +void set_start_vol_position(DCR *dcr)
39 + DEVICE *dev = dcr->dev;
40 + /* Set new start position */
41 + if (dev->is_tape()) {
42 + dcr->StartBlock = dev->block_num;
43 + dcr->StartFile = dev->file;
45 + dcr->StartBlock = (uint32_t)dev->file_addr;
46 + dcr->StartFile = (uint32_t)(dev->file_addr >> 32);
51 * We have a new Volume mounted, so reset the Volume parameters
52 * concerning this job. The global changes were made earlier
54 void set_new_volume_parameters(DCR *dcr)
57 - DEVICE *dev = dcr->dev;
58 if (dcr->NewVol && !dir_get_volume_info(dcr, GET_VOL_INFO_FOR_WRITE)) {
59 Jmsg1(jcr, M_ERROR, 0, "%s", jcr->errmsg);
61 - /* Set new start/end positions */
62 - if (dev->is_tape()) {
63 - dcr->StartBlock = dev->block_num;
64 - dcr->StartFile = dev->file;
66 - dcr->StartBlock = (uint32_t)dev->file_addr;
67 - dcr->StartFile = (uint32_t)(dev->file_addr >> 32);
69 - /* Reset indicies */
70 - dcr->VolFirstIndex = 0;
71 - dcr->VolLastIndex = 0;
72 + set_new_file_parameters(dcr);
73 jcr->NumWriteVolumes++;
74 - dcr->NewVol = false;
75 - dcr->WroteVol = false;
81 void set_new_file_parameters(DCR *dcr)
83 - DEVICE *dev = dcr->dev;
84 + set_start_vol_position(dcr);
86 - /* Set new start/end positions */
87 - if (dev->is_tape()) {
88 - dcr->StartBlock = dev->block_num;
89 - dcr->StartFile = dev->file;
91 - dcr->StartBlock = (uint32_t)dev->file_addr;
92 - dcr->StartFile = (uint32_t)(dev->file_addr >> 32);
95 dcr->VolFirstIndex = 0;
96 dcr->VolLastIndex = 0;
97 Index: src/stored/mac.c
98 ===================================================================
99 --- src/stored/mac.c (revision 6391)
100 +++ src/stored/mac.c (working copy)
103 - * SD -- mac.c -- responsible for doing
104 - * migration, archive, and copy jobs.
106 - * Kern Sibbald, January MMVI
111 Bacula® - The Network Backup Solution
113 - Copyright (C) 2006-2006 Free Software Foundation Europe e.V.
114 + Copyright (C) 2006-2008 Free Software Foundation Europe e.V.
116 The main author of Bacula is Kern Sibbald, with contributions from
117 many others, a complete list can be found in the file AUTHORS.
119 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
120 Switzerland, email:ftf@fsfeurope.org.
123 + * SD -- mac.c -- responsible for doing
124 + * migration, archive, and copy jobs.
126 + * Kern Sibbald, January MMVI
135 jcr->dcr->VolFirstIndex = jcr->dcr->VolLastIndex = 0;
136 jcr->run_time = time(NULL);
137 + set_start_vol_position(jcr->dcr);
139 ok = read_records(jcr->read_dcr, record_cb, mount_next_read_volume);
141 Index: src/stored/protos.h
142 ===================================================================
143 --- src/stored/protos.h (revision 6391)
144 +++ src/stored/protos.h (working copy)
146 bool open_device(DCR *dcr);
147 bool first_open_device(DCR *dcr);
148 bool fixup_device_block_write_error(DCR *dcr);
149 +void set_start_vol_position(DCR *dcr);
150 void set_new_volume_parameters(DCR *dcr);
151 void set_new_file_parameters(DCR *dcr);
152 bool is_device_unmounted(DEVICE *dev);