]> git.sur5r.net Git - bacula/bacula/commitdiff
Autochanger cleanups
authorKern Sibbald <kern@sibbald.com>
Wed, 17 Jul 2002 19:57:17 +0000 (19:57 +0000)
committerKern Sibbald <kern@sibbald.com>
Wed, 17 Jul 2002 19:57:17 +0000 (19:57 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@59 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/cats/sql_update.c
bacula/src/dird/catreq.c
bacula/src/lib/util.c
bacula/src/stored/askdir.c
bacula/src/stored/device.c

index e195d2f8f1739028b4e0aa84eaad4f6d600ba965..deddb794df809eda956f3236bc34b89a21a45a14 100644 (file)
@@ -201,12 +201,12 @@ db_update_media_record(B_DB *mdb, MEDIA_DBR *mr)
 
    Mmsg(&mdb->cmd, "UPDATE Media SET VolJobs=%d,\
  VolFiles=%d, VolBlocks=%d, VolBytes=%s, VolMounts=%d, VolErrors=%d,\
- VolWrites=%d, VolMaxBytes=%s, LastWritten=\"%s\", VolStatus=\"%s\" \
- WHERE VolumeName=\"%s\"",
+ VolWrites=%d, VolMaxBytes=%s, LastWritten=\"%s\", VolStatus=\"%s\",\
Slot=%d WHERE VolumeName=\"%s\"",
    mr->VolJobs, mr->VolFiles, mr->VolBlocks, edit_uint64(mr->VolBytes, ed1),
    mr->VolMounts, mr->VolErrors, mr->VolWrites, 
    edit_uint64(mr->VolMaxBytes, ed2), dt, 
-   mr->VolStatus, mr->VolumeName);
+   mr->VolStatus, mr->Slot, mr->VolumeName);
 
    stat = UPDATE_DB(mdb, mdb->cmd);
    db_unlock(mdb);
index cf4d2dc85424fb4b196fe18f2a4013b53b87a693..7d7b21b599fbb134f2f4b0e01b649aab72e4d41b 100644 (file)
@@ -47,8 +47,7 @@ static char Get_Vol_Info[] = "CatReq Job=%127s GetVolInfo VolName=%127s\n";
 static char Update_media[] = "CatReq Job=%127s UpdateMedia VolName=%s\
  VolJobs=%d VolFiles=%d VolBlocks=%d VolBytes=%" lld " VolMounts=%d\
  VolErrors=%d VolWrites=%d VolMaxBytes=%" lld " EndTime=%d VolStatus=%10s\
- FirstIndex=%d LastIndex=%d StartFile=%d EndFile=%d \
- StartBlock=%d EndBlock=%d relabel=%d Slot=%d\n";
+ Slot=%d relabel=%d\n";
 
 static char Create_job_media[] = "CatReq Job=%127s CreateJobMedia \
  FirstIndex=%d LastIndex=%d StartFile=%d EndFile=%d \
@@ -167,8 +166,7 @@ MediaType=%s\n", mr.PoolId, jcr->PoolId, mr.VolStatus, mr.MediaType);
    } else if (sscanf(bs->msg, Update_media, &Job, &mr.VolumeName, &mr.VolJobs,
       &mr.VolFiles, &mr.VolBlocks, &mr.VolBytes, &mr.VolMounts, &mr.VolErrors,
       &mr.VolWrites, &mr.VolMaxBytes, &mr.LastWritten, &mr.VolStatus, 
-      &jm.FirstIndex, &jm.LastIndex, &jm.StartFile, &jm.EndFile,
-      &jm.StartBlock, &jm.EndBlock, &relabel, &mr.Slot) == 20) {
+      &mr.Slot, &relabel) == 14) {
       /*     
        * Update Media Record
        */
index 44f4e026a8664d9e948581535c363bc06ebcf81c..290563355e17c6b8c651f281f331bc2478cebf26 100644 (file)
@@ -559,12 +559,12 @@ int run_program(char *prog, int wait, POOLMEM *results)
    int chldstatus = 0;
    pid_t pid1, pid2;
    int pfd[2];
-   int i;
 
    
    build_argc_argv(prog);
-#ifdef lots_of_debug
+#ifdef xxxxxxxxxxx
    printf("argc=%d\n", bargc);
+   int i;
    for (i=0; i<bargc; i++) {
       printf("argc=%d argv=%s\n", i, bargv[i]);
    }
index 4d4d86ce8dfa960e8fa00f3b6411c44134725b81..48517d3ea5eb9433b96ba009ebe46e97e8f7811e 100644 (file)
@@ -36,8 +36,7 @@ static char Get_Vol_Info[] = "CatReq Job=%s GetVolInfo VolName=%s\n";
 static char Update_media[] = "CatReq Job=%s UpdateMedia VolName=%s\
  VolJobs=%d VolFiles=%d VolBlocks=%d VolBytes=%" lld " VolMounts=%d\
  VolErrors=%d VolWrites=%d VolMaxBytes=%" lld " EndTime=%d VolStatus=%s\
- FirstIndex=%d LastIndex=%d StartFile=%d EndFile=%d \
- StartBlock=%d EndBlock=%d relabel=%d Slot=%d\n";
+ Slot=%d relabel=%d\n";
 
 static char Create_job_media[] = "CatReq Job=%s CreateJobMedia \
  FirstIndex=%d LastIndex=%d StartFile=%d EndFile=%d \
@@ -160,11 +159,7 @@ int dir_update_volume_info(JCR *jcr, VOLUME_CAT_INFO *vol, int relabel)
       vol->VolCatBlocks, vol->VolCatBytes, 
       vol->VolCatMounts, vol->VolCatErrors,
       vol->VolCatWrites, vol->VolCatMaxBytes, EndTime, 
-      vol->VolCatStatus, 
-      jcr->VolFirstFile, jcr->JobFiles,
-      jcr->start_file, jcr->end_file,
-      jcr->start_block, jcr->end_block,
-      relabel, vol->Slot);
+      vol->VolCatStatus, vol->Slot, relabel);
    Dmsg1(20, "update_volume_data(): %s", dir->msg);
    if (bnet_recv(dir) <= 0) {
       Dmsg0(90, "updateVolCatInfo error bnet_recv\n");
index 118862f448791a59d088f324d02ed0b01e2fadc7..cf21a50594b94b5d6869c128402590a485b9382d 100644 (file)
@@ -221,21 +221,20 @@ int release_device(JCR *jcr, DEVICE *dev, DEV_BLOCK *block)
  */
 static int mount_next_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, int release)
 {
-   int recycle, ask, retry = 0;
+   int recycle, ask, retry = 0, autochanger;
 
    Dmsg0(90, "Enter mount_next_volume()\n");
 
 mount_next_vol:
    if (retry++ > 5) {
-      Mmsg0(&dev->errmsg, _("Too many retries.\n"));
+      Jmsg(jcr, M_FATAL, 0, _("Too many errors on device %s.\n"), dev_name(dev));
       return 0;
    }
    if (job_cancelled(jcr)) {
-      Mmsg0(&dev->errmsg, _("Job cancelled.\n"));
+      Jmsg(jcr, M_FATAL, 0, _("Job cancelled.\n"));
       return 0;
    }
-   recycle = 0;
-   ask = 0;
+   recycle = ask = autochanger = 0;
    if (release) {
       Dmsg0(500, "mount_next_volume release=1\n");
       /* 
@@ -345,6 +344,7 @@ mount_next_vol:
          Dmsg1(100, "After changer, status=%d\n", status);
         if (status == 0) {           /* did we succeed? */
            ask = 0;                  /* yes, got vol, no need to ask sysop */
+           autochanger = 1;          /* tape loaded by changer */
         }
       }
 
@@ -407,6 +407,13 @@ read_volume:
         default:
            /* Send error message */
             Jmsg(jcr, M_WARNING, 0, "%s", jcr->errmsg);                         
+           if (autochanger) {
+               Jmsg(jcr, M_ERROR, 0, _("Autochanger Volume %s not found in slot %d.\n\
+    Setting slot to zero in catalog.\n"),
+                 jcr->VolumeName, jcr->VolCatInfo.Slot);
+              jcr->VolCatInfo.Slot = 0; /* invalidate slot */
+              dir_update_volume_info(jcr, &jcr->VolCatInfo, 1);  /* set slot */
+           }
            goto mount_next_vol;
       }
       break;