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" element in account
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" element in account
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);
154 static int match_volblock(BSR *bsr, BSR_VOLBLOCK *volblock, DEV_RECORD *rec, bool done)
157 - * Currently block matching does not work correctly for disk
158 - * files in all cases, so it is "turned off" by the following
159 - * return statement.
165 return 1; /* no specification matches all */
168 if (rec->state & REC_ISTAPE) {
169 return 1; /* All File records OK for this match */
171 -// Dmsg3(dbglevel, "match_volblock: sblock=%u eblock=%u recblock=%u\n",
172 -// volblock->sblock, volblock->eblock, rec->Block);
173 + Dmsg3(dbglevel, "match_volblock: sblock=%u eblock=%u recblock=%u\n",
174 + volblock->sblock, volblock->eblock, rec->Block);
176 if (volblock->sblock <= rec->Block && volblock->eblock >= rec->Block) {
179 Index: src/stored/bscan.c
180 ===================================================================
181 --- src/stored/bscan.c (révision 8146)
182 +++ src/stored/bscan.c (copie de travail)
187 - Pmsg5(000, _("Record: SessId=%u SessTim=%u FileIndex=%d Stream=%d len=%u\n"),
188 + Pmsg6(000, _("Record: SessId=%u SessTim=%u FileIndex=%d Stream=%d len=%u block=%u\n"),
189 rec->VolSessionId, rec->VolSessionTime, rec->FileIndex,
190 - rec->Stream, rec->data_len);
191 + rec->Stream, rec->data_len, rec->Block);
194 * Check for Start or End of Session Record
195 Index: src/stored/block.c
196 ===================================================================
197 --- src/stored/block.c (révision 8116)
198 +++ src/stored/block.c (copie de travail)
199 @@ -1116,7 +1116,7 @@
200 dcr->EndBlock = dev->EndBlock;
201 dcr->EndFile = dev->EndFile;
203 - uint64_t addr = dev->file_addr + block->read_len - 1;
204 + uint64_t addr = dev->file_addr + block->read_len;
205 dcr->EndBlock = (uint32_t)addr;
206 dcr->EndFile = (uint32_t)(addr >> 32);
207 dev->block_num = dcr->EndBlock;