]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/testing/fix_1190.patch
ebl Too many external segfault in this way
[bacula/bacula] / bacula / patches / testing / fix_1190.patch
1 Index: match_bsr.c
2 ===================================================================
3 --- match_bsr.c (révision 8116)
4 +++ match_bsr.c (copie de travail)
5 @@ -36,15 +36,6 @@
6  
7  /*
8   * ***FIXME***
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).
17 - *
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.
21 @@ -255,68 +246,88 @@
22  }
23  
24  /*
25 - * ***FIXME***
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
36   */
37 -static BSR *find_smallest_volfile(BSR *found_bsr, BSR *bsr)
38 +static bool get_smallest_volfile(BSR_VOLFILE *vf, uint32_t *ret)
39  {
40 -   BSR *return_bsr = found_bsr;
41 -   BSR_VOLFILE *vf;
42 -   BSR_VOLBLOCK *vb;
43 -   uint32_t found_bsr_sfile, bsr_sfile;
44 -   uint32_t found_bsr_sblock, bsr_sblock;
45 +   bool ok=false;
46 +   uint32_t min_val=0;
47  
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) {
55 +      if (!vf->done) {
56 +         if (ok) {
57 +            min_val = MIN(min_val, vf->sfile);
58 +         } else {
59 +            min_val = vf->sfile;
60 +            ok=true;
61 +         }
62        }
63     }
64 +   *ret = min_val;
65 +   return ok;
66 +}
67  
68 -   /* Find the smallest file in the bsr */
69 -   vf = bsr->volfile;
70 -   bsr_sfile = vf->sfile;
71 -   while ( (vf=vf->next) ) {
72 -      if (vf->sfile < bsr_sfile) {
73 -         bsr_sfile = vf->sfile;
74 +/*
75 + * Get the smallest block number from this volblock part
76 + * Don't use "done" elements
77 + */
78 +static bool get_smallest_volblock(BSR_VOLBLOCK *vb, uint32_t *ret)
79 +{
80 +   bool ok=false;
81 +   uint32_t min_val=0;
82 +
83 +   for (; vb ; vb = vb->next) {
84 +      if (!vb->done) {
85 +         if (ok) {
86 +            min_val = MIN(min_val, vb->sblock);
87 +         } else {
88 +            min_val = vb->sblock;
89 +            ok=true;
90 +         }
91        }
92     }
93 +   *ret = min_val;
94 +   return ok;
95 +}
96 +
97 +/*
98 + *
99 + */
100 +static BSR *find_smallest_volfile(BSR *found_bsr, BSR *bsr)
101 +{
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;
105 +
106 +   if (!get_smallest_volfile(found_bsr->volfile, &found_bsr_sfile)) {
107 +      return bsr;               /* found_bsr seems to be done...*/
108 +   }
109 +   
110 +   if (!get_smallest_volfile(bsr->volfile, &bsr_sfile)) {
111 +      return found_bsr;         /* bsr seems to be done... */
112 +   }
113      
114     /* if the bsr file is less than the found_bsr file, return bsr */
115     if (found_bsr_sfile > bsr_sfile) {
116        return_bsr = bsr;
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;
125 -         }
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 */
129        }
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;
136 -         }
137 +
138 +      if (!get_smallest_volblock(bsr->volblock, &bsr_sblock)) {
139 +         return found_bsr;      /* Should not be there */
140        }
141 +
142        /* Compare and return the smallest */
143        if (found_bsr_sblock > bsr_sblock) {
144           return_bsr = bsr;
145        }
146     }
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);
149     return return_bsr;
150  }
151  
152 @@ -360,9 +371,9 @@
153  static int match_all(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec,
154                       SESSION_LABEL *sessrec, bool done, JCR *jcr)
155  {
156 -   Dmsg0(050, "Enter match_all\n");
157 +   Dmsg1(050, "Enter match_all bsr=0x%p\n", bsr);
158     if (bsr->done) {
159 -//    Dmsg0(dbglevel, "bsr->done set\n");
160 +      Dmsg1(dbglevel, "bsr->done set bsr=0x%p\n", bsr);
161        goto no_match;
162     }
163     if (!match_volume(bsr, bsr->volume, volrec, 1)) {
164 @@ -386,8 +397,6 @@
165           rec->Block, bsr->volblock->sblock, bsr->volblock->eblock);
166        goto no_match;
167     }
168 -   Dmsg3(dbglevel, "OK bsr Block=%u. bsr=%u,%u\n", 
169 -      rec->Block, bsr->volblock->sblock, bsr->volblock->eblock);
170  
171     if (!match_sesstime(bsr, bsr->sesstime, rec, 1)) {
172        Dmsg2(dbglevel, "Fail on sesstime. bsr=%u rec=%u\n",
173 @@ -411,6 +420,9 @@
174     Dmsg3(dbglevel, "match on findex=%d. bsr=%d,%d\n",
175           rec->FileIndex, bsr->FileIndex->findex, bsr->FileIndex->findex2);
176  
177 +   Dmsg3(dbglevel, "OK bsr Block=%u. bsr=%u,%u\n", 
178 +      rec->Block, bsr->volblock->sblock, bsr->volblock->eblock);
179 +
180     if (!match_fileregex(bsr, rec, jcr)) {
181       Dmsg1(dbglevel, "Fail on fileregex='%s'\n", bsr->fileregex);
182       goto no_match;
183 @@ -607,14 +619,7 @@
184  
185  static int match_volblock(BSR *bsr, BSR_VOLBLOCK *volblock, DEV_RECORD *rec, bool done)
186  {
187 -   /*
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.
191 -    */
192 -   return 1;
193  
194 -
195     if (!volblock) {
196        return 1;                       /* no specification matches all */
197     }
198 @@ -622,9 +627,19 @@
199     if (rec->state & REC_ISTAPE) {
200        return 1;                       /* All File records OK for this match */
201     }
202 -//  Dmsg3(dbglevel, "match_volblock: sblock=%u eblock=%u recblock=%u\n",
203 -//             volblock->sblock, volblock->eblock, rec->Block);
204 -   if (volblock->sblock <= rec->Block && volblock->eblock >= rec->Block) {
205 +   Dmsg3(dbglevel, "match_volblock: sblock=%u eblock=%u recblock=%u\n",
206 +         volblock->sblock, volblock->eblock, rec->Block);
207 +
208 +   /* FIXME */
209 +   /* Don't reject the call if we are called with a small offset */
210 +   uint32_t min = (volblock->sblock>DEFAULT_BLOCK_SIZE)?volblock->sblock-DEFAULT_BLOCK_SIZE:0;
211 +
212 +   /* We have call where rec->Block is the block after EndBlock 
213 +    * But, we are already decoding rec->Block-1Block records
214 +    */
215 +   uint32_t max = volblock->eblock+DEFAULT_BLOCK_SIZE;
216 +//   if (volblock->sblock <= rec->Block && volblock->eblock >= rec->Block) {
217 +   if (min <= rec->Block && max >= rec->Block) {
218        return 1;
219     }
220     /* Once we get past last eblock, we are done */
221 Index: read_record.c
222 ===================================================================
223 --- read_record.c       (révision 8116)
224 +++ read_record.c       (copie de travail)
225 @@ -261,8 +261,8 @@
226                 Dmsg2(100, "All done=(file:block) %u:%u\n", dev->file, dev->block_num);
227                 break;
228              } else if (rec->match_stat == 0) {  /* no match */
229 -               Dmsg4(100, "BSR no match: clear rem=%d FI=%d before set_eof pos %u:%u\n",
230 -                  rec->remainder, rec->FileIndex, dev->file, dev->block_num);
231 +               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",
232 +                     rec->remainder, rec->FileIndex, rec->Block, dev->LastBlock, dev->EndBlock, dev->file, dev->block_num);
233                 rec->remainder = 0;
234                 rec->state &= ~REC_PARTIAL_RECORD;
235                 if (try_repositioning(jcr, rec, dcr)) {
236 @@ -346,6 +346,9 @@
237         */
238        if (dev->file > bsr->volfile->sfile ||             
239           (dev->file == bsr->volfile->sfile && dev->block_num > bsr->volblock->sblock)) {
240 +         Dmsg4(dbglvl, _("Reposition from (file:block) %u:%u to %u:%u\n"),
241 +            dev->file, dev->block_num, bsr->volfile->sfile,
242 +            bsr->volblock->sblock);
243           return false;
244        }
245        if (verbose) {
246 Index: parse_bsr.c
247 ===================================================================
248 --- parse_bsr.c (révision 8116)
249 +++ parse_bsr.c (copie de travail)
250 @@ -190,6 +190,9 @@
251     for (bsr=root_bsr; bsr; bsr=bsr->next) {
252        bsr->root = root_bsr;
253     }
254 +   if (verbose) {
255 +      dump_bsr(root_bsr, true);
256 +   }
257     return root_bsr;
258  }
259  
260 Index: bls.c
261 ===================================================================
262 --- bls.c       (révision 8116)
263 +++ bls.c       (copie de travail)
264 @@ -400,8 +400,8 @@
265  
266        if (file_is_included(ff, attr->fname) && !file_is_excluded(ff, attr->fname)) {
267           if (verbose) {
268 -            Pmsg5(-1, _("FileIndex=%d VolSessionId=%d VolSessionTime=%d Stream=%d DataLen=%d\n"),
269 -                  rec->FileIndex, rec->VolSessionId, rec->VolSessionTime, rec->Stream, rec->data_len);
270 +            Pmsg6(-1, _("FileIndex=%d VolSessionId=%d VolSessionTime=%d Stream=%d DataLen=%d Block=%x\n"),
271 +                  rec->FileIndex, rec->VolSessionId, rec->VolSessionTime, rec->Stream, rec->data_len, rec->Block);
272           }
273           print_ls_output(jcr, attr);
274           num_files++;
275 Index: bscan.c
276 ===================================================================
277 --- bscan.c     (révision 8146)
278 +++ bscan.c     (copie de travail)
279 @@ -420,9 +420,9 @@
280     }
281  
282     if (list_records) {
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);
288     }
289     /*
290      * Check for Start or End of Session Record