]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix btape autochanger handling
authorKern Sibbald <kern@sibbald.com>
Fri, 2 Apr 2004 09:26:14 +0000 (09:26 +0000)
committerKern Sibbald <kern@sibbald.com>
Fri, 2 Apr 2004 09:26:14 +0000 (09:26 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1173 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/ReleaseNotes
bacula/kernstodo
bacula/scripts/mtx-changer.in
bacula/src/filed/status.c
bacula/src/lib/bpipe.c
bacula/src/lib/signal.c
bacula/src/stored/autochanger.c
bacula/src/stored/btape.c
bacula/src/version.h

index a644726239fb520084aa3d328e1c23d4d509114c..8ee823ec5caf45e7c3fe698910b3eb701cfe5054 100644 (file)
@@ -33,12 +33,16 @@ Items to note:  !!!!!
   at the end of the tape. For most tape drives, this is totally            
   transparent and nothing needs to be done. For FreeBSD see below.
 - FreeBSD users NOTE!!!!!
-  You MUST add the following two records to your SD Device resource for
+  You may need the following two records to your SD Device resource for
   tape drives.
 
      TWOEOF = yes
      Fast Forward Space File = no
 
+  The "Fast Forward Space File" is surely needed, and the TWOEOF          
+  is needed on some systems and not others. Running the btape
+  "test" command will tell you.
+
 - The daemon protocol has changed, you must update everything at once.
 - The database level has been updated. You must either re-initialize
   your databases with:
@@ -176,4 +180,3 @@ Additional changes:
 - Fixed thread race problem in multiple simultaneous jobs to
   a single Volume where the volume lable is not in the first 
   tape block, so the tape is not recognized.
-
index f9ea23b2a6eb0c96b570bea1a09ae092dd6d61ed..4e0a39c934368058cb8abf7b9268813e25e71de4 100644 (file)
@@ -83,6 +83,7 @@ From Chris Hull:
 
 
 For version 1.35:
+- Add code to check for tape alerts -- tapeinfo.
 - Make sure list of Volumes needed is in correct order for restore.
   See havana.
 - Remove paths (and files that reference them) that have no trailing slash   
@@ -114,8 +115,9 @@ For version 1.35:
    name last backed up, the completefile is dumped.On Windows systems, with
    creation date of files, we can be evensmarter about this and not count
    entirely upon the length.On a restore, the full and all incrementals
-   since it will beapplied in sequence to restore the file.  - Add a
-   regression test for dbcheck.  - Add disk seeking on restore.  - Allow
+   since it will beapplied in sequence to restore the file.  
+- Add a regression test for dbcheck.  
+- Add disk seeking on restore.  - Allow
    for optional cancelling of SD and FD in case DIR
   gets a fatal error. Requested by Jesse Guardiani <jesse@wingnet.net>
 - Bizarre message: Error: Could not open WriteBootstrap file:
@@ -140,7 +142,6 @@ For version 1.35:
   The dates you will find in your restore log seem to be the original
    creation dates
 - Volume "add"ed to Pool gets recycled in first use. VolBytes=0
-- Get rid of 0 dates in LastWritten, ...
 - If a tape is recycled while it is mounted, Stanislav Tvrudy must do an
   additional mount to deblock the job.
 - From Johan Decock:
index eaa0eefd6fbd1c22c99f61ab6783deb000b5ffa8..c5d202cc34371904660a4951fcdaf2ede40638ae 100644 (file)
@@ -10,6 +10,7 @@
 #    you will have the following input to this script:
 #
 #  mtx-changer "changer-device" "command" "slot" "archive-device" "drive-index"
+#                 $1              $2       $3        $4               $5
 #
 #  for example:
 #
index 5565deeebc3de38ba0be0b2f574a6dfdafe82cb3..b3077d05c2b0fb6b31c436ef8bdbcb8014c5a6c7 100755 (executable)
@@ -222,7 +222,7 @@ static void  list_terminated_jobs(void sendit(const char *msg, int len, void *sa
         dt, JobName);
       sendit(buf, strlen(buf), arg);
    }
-   sendit("\n", 1, arg);
+   sendit("====\n", 1, arg);
    unlock_last_jobs_list();
 }
 
@@ -249,7 +249,6 @@ int status_cmd(JCR *jcr)
 
    bnet_fsend(user, "\n");
    do_status(bsock_sendit, (void *)user);
-   bnet_fsend(user, "====\n");
 
    bnet_sig(user, BNET_EOD);
    return 1;
index cc176f031c7df341d33883e241ae867dc94bb11e..50d81e596e4952b484fccd0f0f32da3d009811ef 100644 (file)
@@ -191,7 +191,7 @@ int close_bpipe(BPIPE *bpipe)
         if (stat != 0) {
            stat = ECHILD;
         }
-         Dmsg1(200, "status =%d\n", stat);
+         Dmsg1(200, "child status=%d\n", stat);
       } else if (WIFSIGNALED(chldstatus)) {  /* process died */
         stat = ECHILD;
          Dmsg0(200, "Signaled\n");
@@ -229,12 +229,24 @@ int run_program(char *prog, int wait, POOLMEM *results)
    }
    if (results) {
       mp_chr(results)[0] = 0;
-      stat1 = fgets(mp_chr(results), sizeof_pool_memory(results), bpipe->rfd) == NULL;
+      fgets(mp_chr(results), sizeof_pool_memory(results), bpipe->rfd);       
+      if (feof(bpipe->rfd)) {
+        stat1 = 0;
+      } else {
+        stat1 = ferror(bpipe->rfd);
+      }
+      if (stat1 < 0) {
+         Dmsg2(100, "Run program fgets stat=%d ERR=%s\n", stat1, strerror(errno));
+      } else if (stat1 != 0) {
+         Dmsg1(100, "Run program fgets stat=%d\n", stat1);
+      }
    } else {
       stat1 = 0;
    }
    stat2 = close_bpipe(bpipe);
-   return stat2 != 0 ? stat2 : stat1; 
+   stat1 = stat2 != 0 ? stat2 : stat1;
+   Dmsg1(100, "Run program returning %d\n", stat1);
+   return stat1;
 }
 
 
index 82027beca48e1d70f12475816b0502f2e8078a8d..48e65c8d474c2561584f8e356e842f166c4fdd6b 100644 (file)
@@ -70,7 +70,7 @@ static void signal_handler(int sig)
    if (already_dead) {
       exit(1);
    }
-   Dmsg1(200, "sig=%d\n", sig);
+   Dmsg2(200, "sig=%d %s\n", sig, sig_names[sig]);
    /* Ignore certain signals */
    if (sig == SIGCHLD || sig == SIGUSR2) {
       return;
index 72237ad63a230c406888ed3ed5884d4c5c160049..5eb229500e1f648f2b10b44491ccc10739b6db65 100644 (file)
@@ -30,7 +30,7 @@
 #include "stored.h"                   /* pull in Storage Deamon headers */
 
 /* Forward referenced functions */
-static char *edit_device_codes(JCR *jcr, char *omsg, char *imsg, char *cmd);
+char *edit_device_codes(JCR *jcr, char *omsg, char *imsg, char *cmd);
 static int get_autochanger_loaded_slot(JCR *jcr);
 
 
@@ -258,7 +258,7 @@ bail_out:
  *  cmd = command string (load, unload, ...) 
  *
  */
-static char *edit_device_codes(JCR *jcr, char *omsg, char *imsg, char *cmd) 
+char *edit_device_codes(JCR *jcr, char *omsg, char *imsg, char *cmd) 
 {
    char *p;
    const char *str;
index 8c815cc8e56149a6ea4158d21bbe0e714a7a1082..dd6546324a32a56be0a7e290fc1e024729aee154 100644 (file)
@@ -39,6 +39,7 @@
 
 /* External subroutines */
 extern void free_config_resources();
+extern char *edit_device_codes(JCR *jcr, char *omsg, char *imsg, char *cmd);
 
 /* Exported variables */
 int quit = 0;
@@ -82,7 +83,6 @@ static void set_volume_name(char *VolName, int volnum);
 static void rawfill_cmd();
 static void bfill_cmd();
 static bool open_the_device();
-static char *edit_device_codes(JCR *jcr, char *omsg, char *imsg, char *cmd);
 static void autochangercmd();
 static void do_unfill();
 
@@ -1037,9 +1037,10 @@ static int autochanger_test()
 {
    POOLMEM *results, *changer;
    int slot, status, loaded;
-   int timeout = 120;
+   int timeout = jcr->device->max_changer_wait;
    int sleep_time = 0;
 
+   Dmsg1(100, "Max changer wait = %d sec\n", timeout);
    if (!dev_cap(dev, CAP_AUTOCHANGER)) {
       return 1;
    }
@@ -1075,38 +1076,51 @@ try_again:
    if (status == 0) {
       loaded = atoi(results);
    } else {
-      Pmsg1(-1, _("3991 Bad autochanger \"load slot\" status=%d.\n"), status);
-      loaded = -1;             /* force unload */
+      Pmsg1(-1, _("3991 Bad autochanger command: %s\n"), changer);
+      Pmsg2(-1, _("3991 status=%d result=%s\n"), status, results);
       goto bail_out;
    }
    if (loaded) {
       Pmsg1(-1, "Slot %d loaded. I am going to unload it.\n", loaded);
    } else {
-      Pmsg0(-1, "Nothing loaded into the drive. OK.\n");
+      Pmsg0(-1, "Nothing loaded in the drive. OK.\n");
    }
    Dmsg1(100, "Results from loaded query=%s\n", results);
    if (loaded) {
+      jcr->VolCatInfo.Slot = loaded;
       offline_or_rewind_dev(dev);
       /* We are going to load a new tape, so close the device */
       force_close_dev(dev);
-      Pmsg0(-1, _("3302 Issuing autochanger \"unload\" command.\n"));
+      Pmsg2(-1, _("3302 Issuing autochanger \"unload %d %d\" command.\n"),
+        loaded, dev->drive_index);
       changer = edit_device_codes(jcr, changer, 
                      jcr->device->changer_command, "unload");
-      status = run_program(changer, timeout, NULL);
+      status = run_program(changer, timeout, results);
       Pmsg2(-1, "unload status=%s %d\n", status==0?"OK":"Bad", status);
+      if (status != 0) {
+         Pmsg1(-1, _("3992 Bad autochanger command: %s\n"), changer);
+         Pmsg2(-1, _("3992 status=%d result=%s\n"), status, results);
+      }
    }
 
    /*
     * Load the Slot 1
     */
-   Pmsg1(-1, _("3303 Issuing autochanger \"load slot %d\" command.\n"), slot);
+   
+   slot = 1;
+   jcr->VolCatInfo.Slot = slot;
+   Pmsg2(-1, _("3303 Issuing autochanger \"load slot %d %d\" command.\n"), 
+      slot, dev->drive_index);
    changer = edit_device_codes(jcr, changer, jcr->device->changer_command, "load");
-   Dmsg1(200, "Changer=%s\n", changer);
-   status = run_program(changer, timeout, NULL);
+   Dmsg1(100, "Changer=%s\n", changer);
+   force_close_dev(dev);
+   status = run_program(changer, timeout, results);
    if (status == 0) {
-      Pmsg1(-1,  _("3304 Autochanger \"load slot %d\" status is OK.\n"), slot);
+      Pmsg2(-1,  _("3303 Autochanger \"load slot %d %d\" status is OK.\n"),
+        slot, dev->drive_index);
    } else {
-      Pmsg1(-1,  _("3992 Bad autochanger \"load slot\" status=%d.\n"), status);
+      Pmsg1(-1, _("3993 Bad autochanger command: %s\n"), changer);
+      Pmsg2(-1, _("3993 status=%d result=%s\n"), status, results);
       goto bail_out;
    }
 
@@ -2624,6 +2638,7 @@ static void set_volume_name(char *VolName, int volnum)
    dcr->VolCatInfo.Slot = volnum;
 }
 
+#ifdef xxx
 /*
  * Edit codes into ChangerCommand
  *  %% = %
@@ -2701,6 +2716,7 @@ static char *edit_device_codes(JCR *jcr, char *omsg, char *imsg, char *cmd)
    }
    return omsg;
 }
+#endif
 
 #ifdef xxxx_needed
 /* 
index cbf2da5184a3a95247ed105303bdb09de686767d..604d5452d0ea5f85ca5e558fb081780f547b6aa8 100644 (file)
@@ -2,8 +2,8 @@
 #undef  VERSION
 #define VERSION "1.33.6"
 #define VSTRING "1"
-#define BDATE   "01 Apr 2004"
-#define LSMDATE "01Apr04"
+#define BDATE   "02 Apr 2004"
+#define LSMDATE "02Apr04"
 
 /* Debug flags */
 #undef  DEBUG