]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix watchdog crash in btape+detect more Device config problems in btape test + fix...
authorKern Sibbald <kern@sibbald.com>
Mon, 29 Dec 2003 11:57:37 +0000 (11:57 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 29 Dec 2003 11:57:37 +0000 (11:57 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@964 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/dird/sql_cmds.c
bacula/src/lib/watchdog.c
bacula/src/stored/btape.c
bacula/src/stored/dev.c

index d02a0b44dd663c786c1cb50bc88bd6ad3bb0f5e1..c91580148868fb993128f005297258bd3959e20c 100644 (file)
@@ -254,8 +254,8 @@ char *uar_inc_dec =
    "AND JobMedia.MediaId=Media.MediaId "
    "AND Job.Level IN ('I', 'D') AND JobStatus='T' "
    "AND Job.FileSetId=FileSet.FileSetId "
-   "%s"
-   "AND FileSet.FileSet='%s' ";
+   "AND FileSet.FileSet='%s' "
+   "%s";
 
 char *uar_list_temp = 
    "SELECT JobId,Level,JobFiles,StartTime,VolumeName,StartFile,"
index 9ee2de331c589b2263fc1eba790b3c1be5ce741e..bcba37e56552d162fa395910c1d9fe6dd6e7a972 100755 (executable)
@@ -45,7 +45,7 @@ static void *watchdog_thread(void *arg);
 /* Static globals */
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t  timer = PTHREAD_COND_INITIALIZER;
-static int quit;
+static bool quit;
 static bool wd_is_init = false;
 
 /* Forward referenced callback functions */
@@ -69,7 +69,7 @@ int start_watchdog(void)
 
    Dmsg0(200, "Initialising NicB-hacked watchdog thread\n");
    watchdog_time = time(NULL);
-   quit = FALSE;
+   quit = false;
    if ((stat = pthread_create(&wd_tid, NULL, watchdog_thread, NULL)) != 0) {
       return stat;
    }
@@ -89,7 +89,7 @@ int stop_watchdog(void)
    watchdog_t *p, *n;
 
    if (!wd_is_init) {
-      Emsg0(M_ABORT, 0, "BUG! stop_watchdog called before start_watchdog\n");
+      return 0;
    }
 
    Dmsg0(200, "Sending stop signal to NicB-hacked watchdog thread\n");
index e7d1426e6be407c1b74bf3a3c69a1022dd90f360..aca13e57e9ca569d0eed893eb25f647ee478ba09 100644 (file)
@@ -953,6 +953,19 @@ test_again:
                 "   Fast Forward Space File = no\n\n"
                 "to your Device resource for this drive.\n");
    }
+
+   Pmsg0(-1, "\n");
+   Pmsg0(0, _("Now forward spacing 4 more files.\n"));
+   if (!fsf_dev(dev, 4)) {
+      Pmsg1(0, "Bad status from fsr. ERR=%s\n", strerror_dev(dev));
+      goto bail_out;
+   }
+   Pmsg2(-1, _("We should be in file 5. I am at file %d. This is %s\n"), 
+      dev->file, dev->file == 5 ? "correct!" : "NOT correct!!!!");
+   if (dev->file != 5) {
+      goto bail_out;
+   }
+
    return 1;
 
 bail_out:
@@ -985,7 +998,7 @@ static void testcmd()
       goto all_done;
    }
    if (stat == -1) {                 /* first test failed */
-      if (dev_cap(dev, CAP_EOM)) {
+      if (dev_cap(dev, CAP_EOM) || dev_cap(dev, CAP_FASTFSF)) {
          Pmsg0(-1, "\nAppend test failed. Attempting again.\n"
                    "Setting \"Hardware End of Medium = no\n"
                    "    and \"Fast Forward Space File = no\n"
index b55b0077804b76a0292d38cbad7af8b9efc58aa5..23ae6502089dbc5f449c588940a6a0ebd4aa0dfa 100644 (file)
@@ -458,7 +458,7 @@ eod_dev(DEVICE *dev)
        * Move file by file to the end of the tape
        */
       int file_num;
-      for (file_num=0; !(dev->state & ST_EOT); ) {
+      for (file_num=dev->file; !(dev->state & ST_EOT); file_num++) {
          Dmsg0(200, "eod_dev: doing fsf 1\n");
         if (!fsf_dev(dev, 1)) {
             Dmsg0(200, "fsf_dev error.\n");
@@ -468,7 +468,8 @@ eod_dev(DEVICE *dev)
          * Avoid infinite loop. ***FIXME*** possibly add code
          *   to set EOD or to turn off CAP_FASTFSF if on.
          */
-        if (file_num++ != (int)dev->file) {
+        if (file_num == (int)dev->file) {
+            Dmsg1(000, "fsf_dev did not advance from file %d\n", file_num);
            return 0;                 /* we are not progressing, bail out */
         }
       }
@@ -479,8 +480,14 @@ eod_dev(DEVICE *dev)
     * the second EOF.
     */
    if (dev_cap(dev, CAP_BSFATEOM)) {
-      stat =  bsf_dev(dev, 1);
-      dev->file++;                   /* keep same file */
+      struct mtget mt_stat;
+      /* Backup over EOF */
+      stat = bsf_dev(dev, 1);
+      /* If BSF worked and fileno is known (not -1), set file */
+      if (stat == 0 && ioctl(dev->fd, MTIOCGET, (char *)&mt_stat) == 0 &&
+         mt_stat.mt_fileno >= 0) {
+        dev->file = mt_stat.mt_fileno;
+      }
    } else {
       update_pos_dev(dev);                  /* update position */
       stat = 1;