2 ===================================================================
3 --- match_bsr.c (révision 8116)
4 +++ match_bsr.c (copie de travail)
9 - * find_smallest_volfile needs to be fixed to only look at items that
10 - * are not marked as done. Otherwise, it can find a bsr
11 - * that has already been consumed, and this will cause the
12 - * bsr to be used, thus we may seek back and re-read the
13 - * same records, causing an error. This deficiency must
14 - * be fixed. For the moment, it has been kludged in
15 - * read_record.c to avoid seeking back if find_next_bsr
16 - * returns a bsr pointing to a smaller address (file/block).
18 - * Also for efficiency, once a bsr is done, it really should be
19 + * For efficiency, once a bsr is done, it really should be
20 * delinked from the bsr chain. This will avoid the above
21 * problem and make traversal of the bsr chain more efficient.
28 +static bool volfile_min(BSR_VOLFILE *volfile, uint32_t *ret)
31 + uint32_t bsr_sfile=0;
33 + /* Find the smallest file in the volfile */
35 + for (vf = volfile; vf ; vf = vf->next) {
38 + bsr_sfile = MIN(bsr_sfile, vf->sfile);
40 + bsr_sfile = vf->sfile;
50 +static bool volblock_min(BSR_VOLBLOCK *volblock, uint32_t *ret)
53 + uint32_t bsr_sblock=0;
56 + for (vb = volblock; vb ; vb = vb->next) {
59 + bsr_sblock = MIN(bsr_sblock, vb->sblock);
61 + bsr_sblock = vb->sblock;
73 - * This routine needs to be fixed to only look at items that
74 - * are not marked as done. Otherwise, it can find a bsr
75 - * that has already been consumed, and this will cause the
76 - * bsr to be used, thus we may seek back and re-read the
77 - * same records, causing an error. This deficiency must
78 - * be fixed. For the moment, it has been kludged in
79 - * read_record.c to avoid seeking back if find_next_bsr
80 - * returns a bsr pointing to a smaller address (file/block).
81 + * This routine compare 2 bsr and return the one with the
82 + * smallest volfile/volblock
84 static BSR *find_smallest_volfile(BSR *found_bsr, BSR *bsr)
86 BSR *return_bsr = found_bsr;
89 - uint32_t found_bsr_sfile, bsr_sfile;
90 - uint32_t found_bsr_sblock, bsr_sblock;
91 + uint32_t found_bsr_sfile=0, bsr_sfile=0;
92 + uint32_t found_bsr_sblock=0, bsr_sblock=0;
94 - /* Find the smallest file in the found_bsr */
95 - vf = found_bsr->volfile;
96 - found_bsr_sfile = vf->sfile;
97 - while ( (vf=vf->next) ) {
98 - if (vf->sfile < found_bsr_sfile) {
99 - found_bsr_sfile = vf->sfile;
101 + if (!volfile_min(found_bsr->volfile, &found_bsr_sfile)) {
102 + /* the found_bsr contains no volfile, it must be mark as done
103 + * we can skip it and try the next one
105 + return bsr; /* No unused volfile in found_bsr, try bsr */
108 - /* Find the smallest file in the bsr */
110 - bsr_sfile = vf->sfile;
111 - while ( (vf=vf->next) ) {
112 - if (vf->sfile < bsr_sfile) {
113 - bsr_sfile = vf->sfile;
115 + if (!volfile_min(bsr->volfile, &bsr_sfile)) {
116 + /* the next bsr contains no volfile, it must be mark as done
117 + * we can skip it a keep the previous one
119 + return found_bsr; /* No unused volfile in bsr */
122 /* if the bsr file is less than the found_bsr file, return bsr */
123 @@ -297,26 +319,21 @@
124 } else if (found_bsr_sfile == bsr_sfile) {
125 /* Files are equal */
126 /* find smallest block in found_bsr */
127 - vb = found_bsr->volblock;
128 - found_bsr_sblock = vb->sblock;
129 - while ( (vb=vb->next) ) {
130 - if (vb->sblock < found_bsr_sblock) {
131 - found_bsr_sblock = vb->sblock;
133 + if (!volblock_min(found_bsr->volblock, &found_bsr_sblock)) {
134 + return bsr; /* should not fail */
136 - /* Find smallest block in bsr */
137 - vb = bsr->volblock;
138 - bsr_sblock = vb->sblock;
139 - while ( (vb=vb->next) ) {
140 - if (vb->sblock < bsr_sblock) {
141 - bsr_sblock = vb->sblock;
144 + if (!volblock_min(bsr->volblock, &bsr_sblock)) {
145 + return found_bsr; /* should not fail */
148 /* Compare and return the smallest */
149 if (found_bsr_sblock > bsr_sblock) {
153 + Dmsg5(dbglevel, "find_smallest_volfile bsr=0x%p %i > %i | %i > %i\n",
154 + return_bsr, found_bsr_sfile, bsr_sfile, found_bsr_sblock, bsr_sblock);
159 static int match_all(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec,
160 SESSION_LABEL *sessrec, bool done, JCR *jcr)
162 - Dmsg0(050, "Enter match_all\n");
163 + Dmsg1(050, "Enter match_all bsr=0x%p\n", bsr);
165 // Dmsg0(dbglevel, "bsr->done set\n");
168 * files in all cases, so it is "turned off" by the following
175 return 1; /* no specification matches all */
178 if (rec->state & REC_ISTAPE) {
179 return 1; /* All File records OK for this match */
181 -// Dmsg3(dbglevel, "match_volblock: sblock=%u eblock=%u recblock=%u\n",
182 -// volblock->sblock, volblock->eblock, rec->Block);
183 + Dmsg3(dbglevel, "match_volblock: sblock=%u eblock=%u recblock=%u\n",
184 + volblock->sblock, volblock->eblock, rec->Block);
185 if (volblock->sblock <= rec->Block && volblock->eblock >= rec->Block) {
189 ===================================================================
190 --- read_record.c (révision 8116)
191 +++ read_record.c (copie de travail)
194 if (dev->file > bsr->volfile->sfile ||
195 (dev->file == bsr->volfile->sfile && dev->block_num > bsr->volblock->sblock)) {
196 + Jmsg(jcr, M_ERROR, 0, _("Reposition from (file:block) %u:%u to %u:%u\n"),
197 + dev->file, dev->block_num, bsr->volfile->sfile,
198 + bsr->volblock->sblock);
203 ===================================================================
204 --- parse_bsr.c (révision 8116)
205 +++ parse_bsr.c (copie de travail)
207 BSR *root_bsr = new_bsr();
210 - Dmsg1(300, "Enter parse_bsf %s\n", fname);
211 + Dmsg2(300, "Enter parse_bsf %s 0x%p\n", fname, bsr);
212 if ((lc = lex_open_file(lc, fname, s_err)) == NULL) {
214 Emsg2(M_ERROR_TERM, 0, _("Cannot open bootstrap file %s: %s\n"),
216 for (bsr=root_bsr; bsr; bsr=bsr->next) {
217 bsr->root = root_bsr;
219 + dump_bsr(root_bsr, true);
224 ===================================================================
225 --- bscan.c (révision 8136)
226 +++ bscan.c (copie de travail)
231 - Pmsg5(000, _("Record: SessId=%u SessTim=%u FileIndex=%d Stream=%d len=%u\n"),
232 + Pmsg6(000, _("Record: SessId=%u SessTim=%u FileIndex=%d Stream=%d len=%u block=%u\n"),
233 rec->VolSessionId, rec->VolSessionTime, rec->FileIndex,
234 - rec->Stream, rec->data_len);
235 + rec->Stream, rec->data_len, rec->Block);
238 * Check for Start or End of Session Record