1 Index: src/stored/match_bsr.c
2 ===================================================================
3 --- src/stored/match_bsr.c (révision 8116)
4 +++ src/stored/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 * delinked from the bsr chain. This will avoid the above
20 * problem and make traversal of the bsr chain more efficient.
26 - * This routine needs to be fixed to only look at items that
27 - * are not marked as done. Otherwise, it can find a bsr
28 - * that has already been consumed, and this will cause the
29 - * bsr to be used, thus we may seek back and re-read the
30 - * same records, causing an error. This deficiency must
31 - * be fixed. For the moment, it has been kludged in
32 - * read_record.c to avoid seeking back if find_next_bsr
33 - * returns a bsr pointing to a smaller address (file/block).
34 + * Get the smallest file number from this volfile part
35 + * Don't use "done" elements
37 -static BSR *find_smallest_volfile(BSR *found_bsr, BSR *bsr)
38 +static bool get_smallest_volfile(BSR_VOLFILE *vf, uint32_t *ret)
40 - BSR *return_bsr = found_bsr;
43 - uint32_t found_bsr_sfile, bsr_sfile;
44 - uint32_t found_bsr_sblock, bsr_sblock;
48 - /* Find the smallest file in the found_bsr */
49 - vf = found_bsr->volfile;
50 - found_bsr_sfile = vf->sfile;
51 - while ( (vf=vf->next) ) {
52 - if (vf->sfile < found_bsr_sfile) {
53 - found_bsr_sfile = vf->sfile;
54 + for (; vf ; vf = vf->next) {
57 + min_val = MIN(min_val, vf->sfile);
59 + min_val = vf->sfile;
68 - /* Find the smallest file in the bsr */
70 - bsr_sfile = vf->sfile;
71 - while ( (vf=vf->next) ) {
72 - if (vf->sfile < bsr_sfile) {
73 - bsr_sfile = vf->sfile;
75 + * Get the smallest block number from this volblock part
76 + * Don't use "done" elements
78 +static bool get_smallest_volblock(BSR_VOLBLOCK *vb, uint32_t *ret)
83 + for (; vb ; vb = vb->next) {
86 + min_val = MIN(min_val, vb->sblock);
88 + min_val = vb->sblock;
100 +static BSR *find_smallest_volfile(BSR *found_bsr, BSR *bsr)
102 + BSR *return_bsr = found_bsr;
103 + uint32_t found_bsr_sfile=0, bsr_sfile=0;
104 + uint32_t found_bsr_sblock=0, bsr_sblock=0;
106 + if (!get_smallest_volfile(found_bsr->volfile, &found_bsr_sfile)) {
107 + return bsr; /* found_bsr seems to be done...*/
110 + if (!get_smallest_volfile(bsr->volfile, &bsr_sfile)) {
111 + return found_bsr; /* bsr seems to be done... */
114 /* if the bsr file is less than the found_bsr file, return bsr */
115 if (found_bsr_sfile > bsr_sfile) {
117 } else if (found_bsr_sfile == bsr_sfile) {
118 - /* Files are equal */
119 - /* find smallest block in found_bsr */
120 - vb = found_bsr->volblock;
121 - found_bsr_sblock = vb->sblock;
122 - while ( (vb=vb->next) ) {
123 - if (vb->sblock < found_bsr_sblock) {
124 - found_bsr_sblock = vb->sblock;
126 + /* Files are equal, use block to find the smallest */
127 + if (!get_smallest_volblock(found_bsr->volblock, &found_bsr_sblock)) {
128 + return bsr; /* Should not be there */
130 - /* Find smallest block in bsr */
131 - vb = bsr->volblock;
132 - bsr_sblock = vb->sblock;
133 - while ( (vb=vb->next) ) {
134 - if (vb->sblock < bsr_sblock) {
135 - bsr_sblock = vb->sblock;
138 + if (!get_smallest_volblock(bsr->volblock, &bsr_sblock)) {
139 + return found_bsr; /* Should not be there */
142 /* Compare and return the smallest */
143 if (found_bsr_sblock > bsr_sblock) {
147 + Dmsg5(dbglevel, "find_smallest_volfile bsr=0x%p %i > %i | %i > %i\n",
148 + return_bsr, found_bsr_sfile, bsr_sfile, found_bsr_sblock, bsr_sblock);
153 static int match_all(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec,
154 SESSION_LABEL *sessrec, bool done, JCR *jcr)
156 - Dmsg0(050, "Enter match_all\n");
157 + Dmsg1(050, "Enter match_all bsr=0x%p\n", bsr);
159 -// Dmsg0(dbglevel, "bsr->done set\n");
160 + Dmsg1(dbglevel, "bsr->done set bsr=0x%p\n", bsr);
163 if (!match_volume(bsr, bsr->volume, volrec, 1)) {
165 rec->Block, bsr->volblock->sblock, bsr->volblock->eblock);
168 - Dmsg3(dbglevel, "OK bsr Block=%u. bsr=%u,%u\n",
169 - rec->Block, bsr->volblock->sblock, bsr->volblock->eblock);
171 if (!match_sesstime(bsr, bsr->sesstime, rec, 1)) {
172 Dmsg2(dbglevel, "Fail on sesstime. bsr=%u rec=%u\n",
174 Dmsg3(dbglevel, "match on findex=%d. bsr=%d,%d\n",
175 rec->FileIndex, bsr->FileIndex->findex, bsr->FileIndex->findex2);
177 + Dmsg3(dbglevel, "OK bsr Block=%u. bsr=%u,%u\n",
178 + rec->Block, bsr->volblock->sblock, bsr->volblock->eblock);
180 if (!match_fileregex(bsr, rec, jcr)) {
181 Dmsg1(dbglevel, "Fail on fileregex='%s'\n", bsr->fileregex);
185 static int match_volblock(BSR *bsr, BSR_VOLBLOCK *volblock, DEV_RECORD *rec, bool done)
188 - * Currently block matching does not work correctly for disk
189 - * files in all cases, so it is "turned off" by the following
190 - * return statement.
196 return 1; /* no specification matches all */
199 if (rec->state & REC_ISTAPE) {
200 return 1; /* All File records OK for this match */
202 -// Dmsg3(dbglevel, "match_volblock: sblock=%u eblock=%u recblock=%u\n",
203 -// volblock->sblock, volblock->eblock, rec->Block);
204 + Dmsg3(dbglevel, "match_volblock: sblock=%u eblock=%u recblock=%u\n",
205 + volblock->sblock, volblock->eblock, rec->Block);
208 + /* Don't reject the call if we are called with a small offset */
209 + uint32_t min = (volblock->sblock)?volblock->sblock-1:0;
211 + /* We have call where rec->Block is the block after EndBlock
212 + * But, we are already decoding rec->Block-1Block records
214 + uint32_t max = volblock->eblock+DEFAULT_BLOCK_SIZE;
215 if (volblock->sblock <= rec->Block && volblock->eblock >= rec->Block) {
216 +// if (min <= rec->Block && max >= rec->Block) {
219 /* Once we get past last eblock, we are done */
220 Index: src/stored/read_record.c
221 ===================================================================
222 --- src/stored/read_record.c (révision 8116)
223 +++ src/stored/read_record.c (copie de travail)
225 Dmsg2(100, "All done=(file:block) %u:%u\n", dev->file, dev->block_num);
227 } else if (rec->match_stat == 0) { /* no match */
228 - Dmsg4(100, "BSR no match: clear rem=%d FI=%d before set_eof pos %u:%u\n",
229 - rec->remainder, rec->FileIndex, dev->file, dev->block_num);
230 + Dmsg7(100, "BSR no match: clear rem=%d FI=%d rec->Block=%d dev->LastBlock=%d dev->EndBlock=%d before set_eof pos %u:%u\n",
231 + rec->remainder, rec->FileIndex, rec->Block, dev->LastBlock, dev->EndBlock, dev->file, dev->block_num);
233 rec->state &= ~REC_PARTIAL_RECORD;
234 if (try_repositioning(jcr, rec, dcr)) {
237 if (dev->file > bsr->volfile->sfile ||
238 (dev->file == bsr->volfile->sfile && dev->block_num > bsr->volblock->sblock)) {
239 + Dmsg4(dbglvl, _("Reposition from (file:block) %u:%u to %u:%u\n"),
240 + dev->file, dev->block_num, bsr->volfile->sfile,
241 + bsr->volblock->sblock);
242 + Jmsg(jcr, M_ERROR, 0, _("Reposition from (file:block) %u:%u to %u:%u\n"),
243 + dev->file, dev->block_num, bsr->volfile->sfile,
244 + bsr->volblock->sblock);
248 Index: src/stored/bls.c
249 ===================================================================
250 --- src/stored/bls.c (révision 8116)
251 +++ src/stored/bls.c (copie de travail)
254 if (file_is_included(ff, attr->fname) && !file_is_excluded(ff, attr->fname)) {
256 - Pmsg5(-1, _("FileIndex=%d VolSessionId=%d VolSessionTime=%d Stream=%d DataLen=%d\n"),
257 - rec->FileIndex, rec->VolSessionId, rec->VolSessionTime, rec->Stream, rec->data_len);
258 + Pmsg6(-1, _("FileIndex=%d VolSessionId=%d VolSessionTime=%d Stream=%d DataLen=%d Block=%x\n"),
259 + rec->FileIndex, rec->VolSessionId, rec->VolSessionTime, rec->Stream, rec->data_len, rec->Block);
261 print_ls_output(jcr, attr);
263 Index: src/stored/parse_bsr.c
264 ===================================================================
265 --- src/stored/parse_bsr.c (révision 8116)
266 +++ src/stored/parse_bsr.c (copie de travail)
268 for (bsr=root_bsr; bsr; bsr=bsr->next) {
269 bsr->root = root_bsr;
271 + dump_bsr(root_bsr, true);
275 Index: src/stored/bscan.c
276 ===================================================================
277 --- src/stored/bscan.c (révision 8146)
278 +++ src/stored/bscan.c (copie de travail)
283 - Pmsg5(000, _("Record: SessId=%u SessTim=%u FileIndex=%d Stream=%d len=%u\n"),
284 + Pmsg6(000, _("Record: SessId=%u SessTim=%u FileIndex=%d Stream=%d len=%u block=%u\n"),
285 rec->VolSessionId, rec->VolSessionTime, rec->FileIndex,
286 - rec->Stream, rec->data_len);
287 + rec->Stream, rec->data_len, rec->Block);
290 * Check for Start or End of Session Record
291 Index: src/stored/record.c
292 ===================================================================
293 --- src/stored/record.c (révision 8116)
294 +++ src/stored/record.c (copie de travail)
296 rec->Block = block->BlockNumber;
297 rec->File = ((DEVICE *)block->dev)->file;
299 - rec->Block = ((DEVICE *)block->dev)->EndBlock;
300 - rec->File = ((DEVICE *)block->dev)->EndFile;
301 + rec->Block = ((DEVICE *)block->dev)->block_num;
302 + rec->File = ((DEVICE *)block->dev)->file;
306 Index: src/stored/block.c
307 ===================================================================
308 --- src/stored/block.c (révision 8116)
309 +++ src/stored/block.c (copie de travail)
310 @@ -1119,8 +1119,8 @@
311 uint64_t addr = dev->file_addr + block->read_len - 1;
312 dcr->EndBlock = (uint32_t)addr;
313 dcr->EndFile = (uint32_t)(addr >> 32);
314 - dev->block_num = dcr->EndBlock;
315 - dev->file = dcr->EndFile;
316 + dev->block_num = (uint32_t)(dev->file_addr);
317 + dev->file = (uint32_t)(dev->file_addr >> 32);
319 dcr->VolMediaId = dev->VolCatInfo.VolMediaId;
320 dev->file_addr += block->read_len;