From: Eric Bollengier Date: Thu, 18 Dec 2008 10:28:39 +0000 (+0000) Subject: ebl revert to old find_smallest_volfile() X-Git-Tag: Release-7.0.0~3611 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=b10a14710c7779e80eb44b571ab50bc624962a5b;p=bacula%2Fbacula ebl revert to old find_smallest_volfile() git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8184 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/patches/testing/bsr_addr.patch b/bacula/patches/testing/bsr_addr.patch index 865b5a88c7..c24684d138 100644 --- a/bacula/patches/testing/bsr_addr.patch +++ b/bacula/patches/testing/bsr_addr.patch @@ -131,22 +131,14 @@ Index: src/stored/match_bsr.c static int match_stream(BSR *bsr, BSR_STREAM *stream, DEV_RECORD *rec, bool done); static int match_all(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, SESSION_LABEL *sessrec, bool done, JCR *jcr); static int match_block_sesstime(BSR *bsr, BSR_SESSTIME *sesstime, DEV_BLOCK *block); -@@ -255,68 +246,123 @@ +@@ -255,7 +246,29 @@ } /* - * ***FIXME*** -- * This routine needs to be fixed to only look at items that -- * are not marked as done. Otherwise, it can find a bsr -- * that has already been consumed, and this will cause the -- * bsr to be used, thus we may seek back and re-read the -- * same records, causing an error. This deficiency must -- * be fixed. For the moment, it has been kludged in -- * read_record.c to avoid seeking back if find_next_bsr -- * returns a bsr pointing to a smaller address (file/block). + * Get the smallest address from this voladdr part + * Don't use "done" elements - */ ++ */ +static bool get_smallest_voladdr(BSR_VOLADDR *va, uint64_t *ret) +{ + bool ok=false; @@ -166,72 +158,24 @@ Index: src/stored/match_bsr.c + return ok; +} + -+/* -+ * Get the smallest file number from this volfile part -+ * Don't use "done" elements -+ */ -+static bool get_smallest_volfile(BSR_VOLFILE *vf, uint32_t *ret) -+{ -+ bool ok=false; -+ uint32_t min_val=0; -+ -+ for (; vf ; vf = vf->next) { -+ if (!vf->done) { -+ if (ok) { -+ min_val = MIN(min_val, vf->sfile); -+ } else { -+ min_val = vf->sfile; -+ ok=true; -+ } -+ } -+ } -+ *ret = min_val; -+ return ok; -+} -+ -+/* -+ * Get the smallest block number from this volblock part -+ * Don't use "done" elements -+ */ -+static bool get_smallest_volblock(BSR_VOLBLOCK *vb, uint32_t *ret) -+{ -+ bool ok=false; -+ uint32_t min_val=0; -+ -+ for (; vb ; vb = vb->next) { -+ if (!vb->done) { -+ if (ok) { -+ min_val = MIN(min_val, vb->sblock); -+ } else { -+ min_val = vb->sblock; -+ ok=true; -+ } -+ } -+ } -+ *ret = min_val; -+ return ok; -+} -+ -+/* ++/* FIXME + * This routine needs to be fixed to only look at items that + * are not marked as done. Otherwise, it can find a bsr + * that has already been consumed, and this will cause the +@@ -264,6 +277,7 @@ + * be fixed. For the moment, it has been kludged in + * read_record.c to avoid seeking back if find_next_bsr + * returns a bsr pointing to a smaller address (file/block). + * -+ */ + */ static BSR *find_smallest_volfile(BSR *found_bsr, BSR *bsr) { - BSR *return_bsr = found_bsr; -- BSR_VOLFILE *vf; -- BSR_VOLBLOCK *vb; -- uint32_t found_bsr_sfile, bsr_sfile; -- uint32_t found_bsr_sblock, bsr_sblock; -+ uint32_t found_bsr_sfile=0, bsr_sfile=0; -+ uint32_t found_bsr_sblock=0, bsr_sblock=0; -+ uint64_t found_bsr_saddr=0, bsr_saddr=0; +@@ -272,7 +286,19 @@ + BSR_VOLBLOCK *vb; + uint32_t found_bsr_sfile, bsr_sfile; + uint32_t found_bsr_sblock, bsr_sblock; ++ uint64_t found_bsr_saddr, bsr_saddr; -- /* Find the smallest file in the found_bsr */ -- vf = found_bsr->volfile; -- found_bsr_sfile = vf->sfile; -- while ( (vf=vf->next) ) { -- if (vf->sfile < found_bsr_sfile) { -- found_bsr_sfile = vf->sfile; + /* if we have VolAddr, use it, else try with File and Block */ + if (get_smallest_voladdr(found_bsr->voladdr, &found_bsr_saddr)) { + if (get_smallest_voladdr(bsr->voladdr, &bsr_saddr)) { @@ -240,63 +184,13 @@ Index: src/stored/match_bsr.c + } else { + return found_bsr; + } - } - } - -- /* Find the smallest file in the bsr */ -- vf = bsr->volfile; -- bsr_sfile = vf->sfile; -- while ( (vf=vf->next) ) { -- if (vf->sfile < bsr_sfile) { -- bsr_sfile = vf->sfile; -- } -+ if (!get_smallest_volfile(found_bsr->volfile, &found_bsr_sfile)) { -+ return bsr; /* found_bsr seems to be done...*/ - } -+ -+ if (!get_smallest_volfile(bsr->volfile, &bsr_sfile)) { -+ return found_bsr; /* bsr seems to be done... */ ++ } + } - - /* if the bsr file is less than the found_bsr file, return bsr */ - if (found_bsr_sfile > bsr_sfile) { - return_bsr = bsr; - } else if (found_bsr_sfile == bsr_sfile) { -- /* Files are equal */ -- /* find smallest block in found_bsr */ -- vb = found_bsr->volblock; -- found_bsr_sblock = vb->sblock; -- while ( (vb=vb->next) ) { -- if (vb->sblock < found_bsr_sblock) { -- found_bsr_sblock = vb->sblock; -- } -+ /* Files are equal, use block to find the smallest */ -+ if (!get_smallest_volblock(found_bsr->volblock, &found_bsr_sblock)) { -+ return bsr; /* Should not be there */ - } -- /* Find smallest block in bsr */ -- vb = bsr->volblock; -- bsr_sblock = vb->sblock; -- while ( (vb=vb->next) ) { -- if (vb->sblock < bsr_sblock) { -- bsr_sblock = vb->sblock; -- } -+ -+ if (!get_smallest_volblock(bsr->volblock, &bsr_sblock)) { -+ return found_bsr; /* Should not be there */ - } + - /* Compare and return the smallest */ - if (found_bsr_sblock > bsr_sblock) { - return_bsr = bsr; - } - } -+ Dmsg5(dbglevel, "find_smallest_volfile bsr=0x%p %i > %i | %i > %i\n", -+ return_bsr, found_bsr_sfile, bsr_sfile, found_bsr_sblock, bsr_sblock); - return return_bsr; - } - -@@ -374,20 +420,20 @@ + /* Find the smallest file in the found_bsr */ + vf = found_bsr->volfile; + found_bsr_sfile = vf->sfile; +@@ -374,20 +400,20 @@ volrec->VolumeName); if (!match_volfile(bsr, bsr->volfile, rec, 1)) { @@ -326,7 +220,7 @@ Index: src/stored/match_bsr.c if (!match_sesstime(bsr, bsr->sesstime, rec, 1)) { Dmsg2(dbglevel, "Fail on sesstime. bsr=%u rec=%u\n", -@@ -605,42 +651,35 @@ +@@ -605,42 +631,35 @@ return 0; } @@ -382,7 +276,7 @@ Index: src/stored/match_bsr.c } return 0; } -@@ -733,3 +772,29 @@ +@@ -733,3 +752,29 @@ } return 0; }