]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/match_bsr.c
- Implement first cut of Migration.
[bacula/bacula] / bacula / src / stored / match_bsr.c
index eb3411d8bf71767d85e5b7e274fad382ab55025d..0b38996036dd4951311edc1bd22eaaed7d993080 100755 (executable)
@@ -6,27 +6,22 @@
  *
  *   Version $Id$
  */
-
 /*
-   Copyright (C) 2000-2005 Kern Sibbald
+   Copyright (C) 2002-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2 of
-   the License, or (at your option) any later version.
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public
-   License along with this program; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
+
 #include "bacula.h"
 #include "stored.h"
 #ifdef HAVE_FNMATCH
@@ -164,13 +159,17 @@ BSR *find_next_bsr(BSR *root_bsr, DEVICE *dev)
 {
    BSR *bsr;
    BSR *found_bsr = NULL;
+   bool no_file_seek = !dev->is_tape();
+#ifdef FILE_SEEK
+   no_file_seek = false;
+#endif
 
    if (!root_bsr || !root_bsr->use_positioning ||
-       !root_bsr->reposition /* || !dev->is_tape()*/) {
-      Dmsg2(100, "No nxt_bsr use_pos=%d repos=%d\n", root_bsr->use_positioning, root_bsr->reposition);
+       !root_bsr->reposition || no_file_seek) {
+      Dmsg2(300, "No nxt_bsr use_pos=%d repos=%d\n", root_bsr->use_positioning, root_bsr->reposition);
       return NULL;
    }
-   Dmsg2(100, "use_pos=%d repos=%d\n", root_bsr->use_positioning, root_bsr->reposition);
+   Dmsg2(300, "use_pos=%d repos=%d\n", root_bsr->use_positioning, root_bsr->reposition);
    root_bsr->mount_next_volume = false;
    for (bsr=root_bsr; bsr; bsr=bsr->next) {
       if (bsr->done || !match_volume(bsr, bsr->volume, &dev->VolHdr, 1)) {
@@ -253,7 +252,7 @@ static BSR *find_smallest_volfile(BSR *found_bsr, BSR *bsr)
 bool match_set_eof(BSR *bsr, DEV_RECORD *rec)
 {
    BSR *rbsr = rec->bsr;
-   Dmsg1(100, "match_set %d\n", rbsr != NULL);
+   Dmsg1(300, "match_set %d\n", rbsr != NULL);
    if (!rbsr) {
       return false;
    }
@@ -262,7 +261,7 @@ bool match_set_eof(BSR *bsr, DEV_RECORD *rec)
    if (rbsr->count && rbsr->found >= rbsr->count) {
       rbsr->done = true;
       rbsr->root->reposition = true;
-      Dmsg2(100, "match_set_eof reposition count=%d found=%d\n",
+      Dmsg2(500, "match_set_eof reposition count=%d found=%d\n",
          rbsr->count, rbsr->found);
       return true;
    }
@@ -279,32 +278,34 @@ static int match_all(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec,
                      SESSION_LABEL *sessrec, bool done)
 {
    if (bsr->done) {
+      Dmsg0(300, "bsr->done set\n");
       goto no_match;
    }
    if (!match_volume(bsr, bsr->volume, volrec, 1)) {
+      Dmsg2(300, "bsr vol=%s != rec vol=%s\n", bsr->volume, volrec);
       goto no_match;
    }
    if (!match_volfile(bsr, bsr->volfile, rec, 1)) {
-      Dmsg2(100, "Fail on file. bsr=%d rec=%d\n", bsr->volfile->efile,
+      Dmsg2(300, "Fail on file. bsr=%d rec=%d\n", bsr->volfile->efile,
          rec->File);
       goto no_match;
    }
    if (!match_sesstime(bsr, bsr->sesstime, rec, 1)) {
-      Dmsg2(100, "Fail on sesstime. bsr=%d rec=%d\n",
+      Dmsg2(300, "Fail on sesstime. bsr=%d rec=%d\n",
          bsr->sesstime->sesstime, rec->VolSessionTime);
       goto no_match;
    }
 
    /* NOTE!! This test MUST come after the sesstime test */
    if (!match_sessid(bsr, bsr->sessid, rec)) {
-      Dmsg2(100, "Fail on sessid. bsr=%d rec=%d\n",
+      Dmsg2(300, "Fail on sessid. bsr=%d rec=%d\n",
          bsr->sessid->sessid, rec->VolSessionId);
       goto no_match;
    }
 
    /* NOTE!! This test MUST come after sesstime and sessid tests */
    if (!match_findex(bsr, bsr->FileIndex, rec, 1)) {
-      Dmsg2(100, "Fail on findex. bsr=%d rec=%d\n",
+      Dmsg2(300, "Fail on findex. bsr=%d rec=%d\n",
          bsr->FileIndex->findex2, rec->FileIndex);
       goto no_match;
    }
@@ -327,22 +328,28 @@ static int match_all(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec,
     *   the rec->bsr = bsr optimization above.
     */
    if (!match_jobid(bsr, bsr->JobId, sessrec, 1)) {
+      Dmsg0(300, "fail on JobId\n");
       goto no_match;
 
    }
    if (!match_job(bsr, bsr->job, sessrec, 1)) {
+      Dmsg0(300, "fail on Job\n");
       goto no_match;
    }
    if (!match_client(bsr, bsr->client, sessrec, 1)) {
+      Dmsg0(300, "fail on Client\n");
       goto no_match;
    }
    if (!match_job_type(bsr, bsr->JobType, sessrec, 1)) {
+      Dmsg0(300, "fail on Job type\n");
       goto no_match;
    }
    if (!match_job_level(bsr, bsr->JobLevel, sessrec, 1)) {
+      Dmsg0(300, "fail on Job level\n");
       goto no_match;
    }
    if (!match_stream(bsr, bsr->stream, rec, 1)) {
+      Dmsg0(300, "fail on stream\n");
       goto no_match;
    }
    return 1;
@@ -362,7 +369,7 @@ static int match_volume(BSR *bsr, BSR_VOLUME *volume, VOLUME_LABEL *volrec, bool
    if (!volume) {
       return 0;                       /* Volume must match */
    }
-   if (strcmp(volume->VolumeName, volrec->VolName) == 0) {
+   if (strcmp(volume->VolumeName, volrec->VolumeName) == 0) {
       return 1;
    }
    if (volume->next) {
@@ -450,7 +457,7 @@ static int match_volfile(BSR *bsr, BSR_VOLFILE *volfile, DEV_RECORD *rec, bool d
    if (!(rec->state & REC_ISTAPE)) {
       return 1;                       /* All File records OK for this match */
    }
-// Dmsg3(100, "match_volfile: sfile=%d efile=%d recfile=%d\n",
+// Dmsg3(300, "match_volfile: sfile=%d efile=%d recfile=%d\n",
 //             volfile->sfile, volfile->efile, rec->File);
    if (volfile->sfile <= rec->File && volfile->efile >= rec->File) {
       return 1;
@@ -467,7 +474,7 @@ static int match_volfile(BSR *bsr, BSR_VOLFILE *volfile, DEV_RECORD *rec, bool d
    if (volfile->done && done) {
       bsr->done = true;
       bsr->root->reposition = true;
-      Dmsg2(100, "bsr done from volfile rec=%d volefile=%d\n",
+      Dmsg2(300, "bsr done from volfile rec=%d volefile=%d\n",
          rec->File, volfile->efile);
    }
    return 0;
@@ -504,7 +511,7 @@ static int match_sesstime(BSR *bsr, BSR_SESSTIME *sesstime, DEV_RECORD *rec, boo
    if (sesstime->done && done) {
       bsr->done = true;
       bsr->root->reposition = true;
-      Dmsg0(100, "bsr done from sesstime\n");
+      Dmsg0(300, "bsr done from sesstime\n");
    }
    return 0;
 }
@@ -550,7 +557,7 @@ static int match_findex(BSR *bsr, BSR_FINDEX *findex, DEV_RECORD *rec, bool done
    if (findex->done && done) {
       bsr->done = true;
       bsr->root->reposition = true;
-      Dmsg1(100, "bsr done from findex %d\n", rec->FileIndex);
+      Dmsg1(300, "bsr done from findex %d\n", rec->FileIndex);
    }
    return 0;
 }