]> git.sur5r.net Git - bacula/bacula/commitdiff
- This version has a new DIR -- SD protocol. Both
authorKern Sibbald <kern@sibbald.com>
Mon, 28 Mar 2005 22:06:08 +0000 (22:06 +0000)
committerKern Sibbald <kern@sibbald.com>
Mon, 28 Mar 2005 22:06:08 +0000 (22:06 +0000)
  must be updated at the same time.
- Begin implementation of passing all the Storage and Device
  possibilities to the SD for examination during the reserve
  phase.
- Modify the reserve and acquire code in the SD to make a
  job wait if the device is not available.
- Implement New Volume Each Job in DIR and pass to SD, not yet
  used.
- Remove init/update of the Device resource in DIR
- Remove passing PoolId to SD and back.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1903 91ce42f0-d328-0410-95d8-f526ca767f89

18 files changed:
bacula/ReleaseNotes
bacula/examples/python/NewVolume.py
bacula/kernstodo
bacula/src/dird/dird.c
bacula/src/dird/dird_conf.c
bacula/src/dird/dird_conf.h
bacula/src/dird/getmsg.c
bacula/src/dird/msgchan.c
bacula/src/dird/next_vol.c
bacula/src/dird/ua_update.c
bacula/src/jcr.h
bacula/src/stored/acquire.c
bacula/src/stored/askdir.c
bacula/src/stored/dev.h
bacula/src/stored/dircmd.c
bacula/src/stored/job.c
bacula/src/stored/wait.c
bacula/src/version.h

index 13e985bfe604834704970a06c9fac359db6fedcf..9d61aa680a4b555d8ab21954ec726634f5211204 100644 (file)
@@ -1,10 +1,12 @@
 
-          Release Notes for Bacula 1.37.6
+          Release Notes for Bacula 1.37.10
 
   Bacula code: Total files = 414 Total lines = 123,723 (*.h *.c *.in)
 
 
 Major Changes:
+- This version has a new DIR <--> SD protocol. Both must be
+  upgraded at the same time.
 - This version has a new database format that is not compatible
   with previous databases. The upgrade scripts should work, but
   they are not yet tested.
@@ -214,4 +216,3 @@ def NewVolume(j):
     bacula.set(jcr=j, VolumeName="TestA-001")
     return 1
 ====
-
index 3a1df0cf4f59f118d431f7a17281d0397945a5ae..b6df07e6f55ccf5273120fceef897ca75c4f4a16 100644 (file)
@@ -7,6 +7,6 @@ def NewVolume(j):
     print "Client=" + client
     numvol = bacula.get(j, "NumVols");
     print "NumVols=", numvol
-#   bacula.set(jcr=j, JobReport="Python New Volume set for Job.\n") 
-#   bacula.set(jcr=j, VolumeName="TestA-001")
+    bacula.set(jcr=j, JobReport="Python New Volume set for Job.\n") 
+    bacula.set(jcr=j, VolumeName="TestA-001")
     return 1
index fdc72f9276376380e7cc61c1a0753a25c5b6008b..ccc09c81f8ecda845d41b0cc57ab6cc4ff837bed 100644 (file)
@@ -20,12 +20,10 @@ Version 1.37                Kern (see below)
 
 Autochangers:
 - 3. Prevent two drives requesting the same Volume in any given
-     autochanger.
-- 3. Check if a Volume is mounted on another drive in an Autochanger.
+     autochanger, by checking if a Volume is mounted on another drive
+     in an Autochanger.
 - 7. Implement new Console commands to allow offlining/reserving drives,
      and possibly manipulating the autochanger (much asked for).
-- 8. Automatic updating of Drive status from SD to DIR when something
-     changes (Volume, offline, append, read, ...).
   
 For 1.37:
 - If the user puts "Purge Oldest Volume = yes" or "Recycle Oldest Volume = yes"
@@ -35,7 +33,6 @@ For 1.37:
 - Implement "NewVolumeEachJob = yes|no" in Dir.
 - Make "update slots" when pointing to Autochanger, remove
   all Volumes from other drives.
-- Don't start a second file job if one is already running.
 - Add Python writable variable for changing the Priority,
     Client, Storage, JobStatus (error), ...
 - SD Python
@@ -43,17 +40,21 @@ For 1.37:
 - FD Python
   - Python script to save with Python, not save, save with Bacula.
   - Python script to do backup.
-- When Python creates a new label, the tape is immediately
-  recycled and no label created. This happens when using   
-  autolabeling -- even when Python doesn't generate the name.
 - Create a new GUI chapter explaining all the GUI programs.
 - Look at Preben's acl.c error handling code.
 - Look at adding full Volume and Pool information to a Volume 
   label so that bscan can get *all* the info. 
 - Scratch Pool where the volumes can be re-assigned to any Pool.
 - Implement Maximum Job Spool Size
-- Implement EOF/EOV labels for ANSI labels
-- Implement IBM labels.
+- 28-Mar 23:19 rufus-sd: acquire.c:379 Device "DDS-4" (/dev/nst0) 
+  is busy reading. Job 6 canceled.
+- Remove all old Device resource code in Dir and code to pass it
+  back in SD.
+- Fix code to either handle updating NumVol or to calculate it in
+  Dir next_vol.c
+- Finish implementation of passing all Storage and Device needs to
+  the SD.
+
 
 Maybe in 1.37:
 - By the way: on page http://www.bacula.org/?page=tapedrives , at the 
@@ -1268,3 +1269,9 @@ Block Position: 0
 #5   Events that call a Python program 
      (Implemented in Dir/SD)
 - Make sure the Device name is in the Query packet returned.
+- Don't start a second file job if one is already running.
+- Implement EOF/EOV labels for ANSI labels
+- Implement IBM labels.
+- When Python creates a new label, the tape is immediately
+  recycled and no label created. This happens when using   
+  autolabeling -- even when Python doesn't generate the name.
index cb15fe7481844abb77e4538670428fac94fab661..9fed95bc7afac06e2ff605225f6484815cfe54b9 100644 (file)
@@ -441,7 +441,7 @@ void reload_config(int sig)
    SDConnectTimeout = director->SDConnectTimeout;
    Dmsg0(0, "Director's configuration file reread.\n");
 
-   init_device_resources();          /* Update Device resources */
+// init_device_resources();          /* Update Device resources */
 
    /* Now release saved resources, if no jobs using the resources */
    if (njobs == 0) {
index fe4a02374a1fbed498579391225f5cd160f9ea78..5830f20eaad30ac6429ff5b050899e0296e7ea56 100644 (file)
@@ -236,6 +236,7 @@ RES_ITEM job_items[] = {
    {"spoolattributes",store_yesno, ITEM(res_job.SpoolAttributes), 1, ITEM_DEFAULT, 0},
    {"spooldata",   store_yesno, ITEM(res_job.spool_data), 1, ITEM_DEFAULT, 0},
    {"rerunfailedlevels",   store_yesno, ITEM(res_job.rerun_failed_levels), 1, ITEM_DEFAULT, 0},
+   {"newvolumeeachjob",   store_yesno, ITEM(res_job.NewVolEachJob), 1, ITEM_DEFAULT, 0},
    {"runbeforejob", store_str,  ITEM(res_job.RunBeforeJob), 0, 0, 0},
    {"runafterjob",  store_str,  ITEM(res_job.RunAfterJob),  0, 0, 0},
    {"runafterfailedjob",  store_str,  ITEM(res_job.RunAfterFailedJob),  0, 0, 0},
index b2491a25c36b5e90fde62286a919a77f7226ad34..a295f5ff3d44e7cc0429efb0afcadf3c1d0e153e 100644 (file)
@@ -220,7 +220,7 @@ public:
    char *address;
    char *password;
    char *media_type;
-   alist *device;                     /* Device name(s) */
+   alist *device;                     /* Alternate devices for this Storage */
    int  autochanger;                  /* set if autochanger */
    uint32_t MaxConcurrentJobs;        /* Maximume concurrent jobs */
    uint32_t NumConcurrentJobs;        /* number of concurrent jobs running */
@@ -275,6 +275,7 @@ public:
    int SpoolAttributes;               /* Set to spool attributes in SD */
    int spool_data;                    /* Set to spool data in SD */
    int rerun_failed_levels;           /* Upgrade to rerun failed levels */
+   int NewVolEachJob;                 /* Mount new volume each Job */
    uint32_t MaxConcurrentJobs;        /* Maximume concurrent jobs */
    int RescheduleOnError;             /* Set to reschedule on error */
    int RescheduleTimes;               /* Number of times to reschedule job */
@@ -286,7 +287,7 @@ public:
    SCHED     *schedule;               /* When -- Automatic schedule */
    CLIENT    *client;                 /* Who to backup */
    FILESET   *fileset;                /* What to backup -- Fileset */
-   alist     *storage;                /* Where is device -- Storage daemon */
+   alist     *storage;                /* Where is device -- list of Storage to be used */
    POOL      *pool;                   /* Where is media -- Media Pool */
    POOL      *full_pool;              /* Pool for Full backups */
    POOL      *inc_pool;               /* Pool for Incremental backups */
index c50956258e4cf6796c3775fb1cf4825255d5ed05..aafbd42d0cda43d3f5d9ea131b35a769d1e7c5f2 100644 (file)
 static char *find_msg_start(char *msg);
 
 static char Job_status[] = "Status Job=%127s JobStatus=%d\n";
+#ifdef needed
 static char Device_update[]   = "DevUpd Job=%127s "
    "device=%127s "
    "append=%d read=%d num_writers=%d "
    "open=%d labeled=%d offline=%d "
    "reserved=%d max_writers=%d "
    "autoselect=%d autochanger=%d "
-   "poolid=%lld "
    "changer_name=%127s media_type=%127s volume_name=%127s\n";
+#endif
 
 
 static char OK_msg[] = "1000 OK\n";
@@ -226,6 +227,7 @@ int bget_dirmsg(BSOCK *bs)
         free_jcr(jcr);
         continue;
       }
+#ifdef needec
       /* No JCR for Device Updates! */
       if (bs->msg[0] = 'D') {         /* Device update */
         DEVICE *dev;
@@ -241,9 +243,9 @@ int bget_dirmsg(BSOCK *bs)
             &dev_num_writers, &dev_open,
             &dev_labeled, &dev_offline, &dev_reserved,
             &dev_max_writers, &dev_autoselect, 
-            &dev_autochanger, &dev_PoolId,
+            &dev_autochanger, 
             changer_name.c_str(), media_type.c_str(),
-            volume_name.c_str()) != 16) {
+            volume_name.c_str()) != 15) {
             Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
         } else {
            unbash_spaces(dev_name);
@@ -276,6 +278,7 @@ int bget_dirmsg(BSOCK *bs)
         }
         continue;
       }
+#endif
       return n;
    }
 }
index 233b30fbc1c02a82a3ee312add799ef7eeb8d7e8..cd00b7170a155efe9971e980a801acf1fc1511ed 100644 (file)
 /* Commands sent to Storage daemon */
 static char jobcmd[]     = "JobId=%d job=%s job_name=%s client_name=%s "
    "type=%d level=%d FileSet=%s NoAttr=%d SpoolAttr=%d FileSetMD5=%s "
-   "SpoolData=%d WritePartAfterJob=%d";
-static char use_device[] = "use device=%s media_type=%s pool_name=%s "
-   "pool_type=%s PoolId=%s append=%d\n";
-static char query_device[] = "query device=%s";
+   "SpoolData=%d WritePartAfterJob=%d NewVol=%d\n";
+static char use_storage[] = "use storage media_type=%s pool_name=%s "
+   "pool_type=%s append=%d\n";
+static char use_device[] = "use device=%s\n";
+//static char query_device[] = "query device=%s";
 
 /* Response from Storage daemon */
 static char OKjob[]      = "3000 OK Job SDid=%d SDtime=%d Authorization=%100s\n";
@@ -99,6 +100,7 @@ bool connect_to_storage_daemon(JCR *jcr, int retry_interval,
  * Here we ask the SD to send us the info for a 
  *  particular device resource.
  */
+#ifdef needed
 bool update_device_res(JCR *jcr, DEVICE *dev)
 {
    POOL_MEM device_name; 
@@ -117,6 +119,7 @@ bool update_device_res(JCR *jcr, DEVICE *dev)
    }
    return true;
 }
+#endif
 
 /*
  * Start a job with the Storage daemon
@@ -143,7 +146,8 @@ int start_storage_daemon_job(JCR *jcr, alist *store, int append)
    bnet_fsend(sd, jobcmd, jcr->JobId, jcr->Job, jcr->job->hdr.name,
              jcr->client->hdr.name, jcr->JobType, jcr->JobLevel,
              jcr->fileset->hdr.name, !jcr->pool->catalog_files,
-             jcr->job->SpoolAttributes, jcr->fileset->MD5, jcr->spool_data, jcr->write_part_after_job);
+             jcr->job->SpoolAttributes, jcr->fileset->MD5, jcr->spool_data, 
+             jcr->write_part_after_job, jcr->job->NewVolEachJob);
    Dmsg1(100, ">stored: %s\n", sd->msg);
    unbash_spaces(jcr->job->hdr.name);
    unbash_spaces(jcr->client->hdr.name);
@@ -183,31 +187,30 @@ int start_storage_daemon_job(JCR *jcr, alist *store, int append)
     */
 // foreach_alist(storage, store) {
       storage = (STORE *)store->first();
+      pm_strcpy(media_type, storage->media_type);
+      bash_spaces(media_type);
+      bnet_fsend(sd, use_storage, media_type.c_str(), pool_name.c_str(), 
+                pool_type.c_str(), append);
+
       DEVICE *dev;
-      /* Loop over alternative storages until one is OK */
+      /* Loop over alternative storage Devices until one is OK */
       foreach_alist(dev, storage->device) {
         pm_strcpy(device_name, dev->hdr.name);
-        pm_strcpy(media_type, storage->media_type);
         bash_spaces(device_name);
-        bash_spaces(media_type);
-        bnet_fsend(sd, use_device, device_name.c_str(),
-                   media_type.c_str(), pool_name.c_str(), pool_type.c_str(),
-                   PoolId, append);
+        bnet_fsend(sd, use_device, device_name.c_str());
          Dmsg1(100, ">stored: %s", sd->msg);
-        if (bget_dirmsg(sd) > 0) {
-            Dmsg1(100, "<stored: %s", sd->msg);
-           /* ****FIXME**** save actual device name */
-           ok = sscanf(sd->msg, OK_device, device_name.c_str()) == 1;
-           if (ok) {
-              break;
-           }
-        } else {
-           POOL_MEM err_msg;
-           pm_strcpy(err_msg, sd->msg); /* save message */
-            Jmsg(jcr, M_WARNING, 0, _("\n"
-               "     Storage daemon didn't accept Device \"%s\" because:\n     %s"),
-              device_name.c_str(), err_msg.c_str()/* sd->msg */);
-        }
+      }
+      bnet_sig(sd, BNET_EOD);
+      if (bget_dirmsg(sd) > 0) {
+         Dmsg1(100, "<stored: %s", sd->msg);
+        /* ****FIXME**** save actual device name */
+        ok = sscanf(sd->msg, OK_device, device_name.c_str()) == 1;
+      } else {
+        POOL_MEM err_msg;
+        pm_strcpy(err_msg, sd->msg); /* save message */
+         Jmsg(jcr, M_WARNING, 0, _("\n"
+            "     Storage daemon didn't accept Device \"%s\" because:\n     %s"),
+           device_name.c_str(), err_msg.c_str()/* sd->msg */);
       }
 //    if (!ok) {
 //      break;
@@ -331,7 +334,7 @@ void wait_for_storage_daemon_termination(JCR *jcr)
    set_jcr_job_status(jcr, JS_Terminated);
 }
 
-
+#ifdef needed
 #define MAX_TRIES 30
 #define WAIT_TIME 2
 extern "C" void *device_thread(void *arg)
@@ -381,3 +384,4 @@ void init_device_resources()
       Jmsg1(NULL, M_ABORT, 0, _("Cannot create message thread: %s\n"), be.strerror(status));
    }
 }
+#endif
index 53e941eaba2f205970bfa370643e92909d10d1d0..ccf37a4bfc920f82d71a360c7476c60bfaae4375 100644 (file)
@@ -98,6 +98,32 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, bool create)
            }
         }
 
+        if (!ok) {
+           MEDIA_DBR smr;
+           POOL_DBR pr;
+           POOLMEM *query;
+           char ed1[50], ed2[50];
+           /*
+            * 6. Try pulling a volume from the Scratch pool
+            */ 
+            memset(&pr, 0, sizeof(pr));
+             bstrncpy(pr.Name, "Scratch", 7);
+            if (db_get_pool_record(jcr, jcr->db, &pr)) {
+               memset(&smr, 0, sizeof(smr));
+               smr.PoolId = pr.PoolId;
+                bstrncpy(smr.VolStatus, "Append", sizeof(smr.VolStatus));  /* want only appendable volumes */
+               bstrncpy(smr.MediaType, mr->MediaType, sizeof(smr.MediaType));
+               if (db_find_next_volume(jcr, jcr->db, 1, InChanger, &smr)) {
+                  query = get_pool_memory(PM_MESSAGE);
+                  db_lock(jcr->db);
+                   Mmsg(query, "UPDATE Media SET PoolId=%s WHERE MediaId=%s",
+                       edit_int64(mr->PoolId, ed1),
+                       edit_int64(mr->MediaId, ed2));
+                  ok = db_sql_query(jcr->db, query, NULL, NULL);  
+                  db_unlock(jcr->db);
+               }
+            }
+        }
         /*
          *  Look at more drastic ways to find an Appendable Volume
          */
index b9a016c70a31443aac51ba5d663ada7c5e0937e8..558fcf240257e3c3cdc7f4dfdd987888ee7fb2b0 100644 (file)
@@ -260,7 +260,7 @@ static void update_vol_pool(UAContext *ua, char *val, MEDIA_DBR *mr, POOL_DBR *o
 {
    POOL_DBR pr;
    POOLMEM *query;
-   char ed1[50];
+   char ed1[50], ed2[50];
 
    memset(&pr, 0, sizeof(pr));
    bstrncpy(pr.Name, val, sizeof(pr.Name));
@@ -272,8 +272,9 @@ static void update_vol_pool(UAContext *ua, char *val, MEDIA_DBR *mr, POOL_DBR *o
     */
    query = get_pool_memory(PM_MESSAGE);
    db_lock(ua->db);
-   Mmsg(query, "UPDATE Media SET PoolId=%d WHERE MediaId=%s",
-      mr->PoolId, edit_int64(mr->MediaId, ed1));
+   Mmsg(query, "UPDATE Media SET PoolId=%s WHERE MediaId=%s",
+      edit_int64(mr->PoolId, ed1),
+      edit_int64(mr->MediaId, ed2));
    if (!db_sql_query(ua->db, query, NULL, NULL)) {
       bsendmsg(ua, "%s", db_strerror(ua->db));
    } else {
index b79cf61bcf084b3c8ffd05e705b9c1207a849c40..5accb7efb69991f3a72ef9017aa06590d04700bc 100644 (file)
@@ -247,6 +247,7 @@ struct JCR {
    int CurVol;                        /* Current Volume count */
    DIRRES* director;                  /* Director resource */
    bool write_part_after_job;         /* Set to write part after job */
+   bool NewVolEachJob;                /* Allow using new volume */
    
    uint32_t FileId;                   /* Last file id inserted */
 
index 303fe650a83184e97770209ad38830463b5e3371..29cdd7b0ec58b0a1593367cf6bac196468ddaa03 100644 (file)
@@ -144,6 +144,8 @@ bool reserve_device_for_read(DCR *dcr)
 
    ASSERT(dcr);
 
+   init_device_wait_timers(dcr);
+
    dev->block(BST_DOING_ACQUIRE);
 
    Mmsg(jcr->errmsg, _("Device %s is BLOCKED due to user unmount.\n"),
@@ -373,10 +375,13 @@ bool reserve_device_for_append(DCR *dcr)
    bool first;
 
    ASSERT(dcr);
+
+   init_device_wait_timers(dcr);
+
    dev->block(BST_DOING_ACQUIRE);
 
-   Mmsg2(jcr->errmsg, _("Device %s is busy reading. Job %d canceled.\n"),
-        dev->print_name(), jcr->JobId);
+   Mmsg1(jcr->errmsg, _("Device %s is busy reading.\n"),
+        dev->print_name());
    for (first=true; dev->can_read(); first=false) {
       dev->unblock();
       if (!wait_for_device(dcr, jcr->errmsg, first)) {
@@ -389,7 +394,7 @@ bool reserve_device_for_append(DCR *dcr)
    Mmsg(jcr->errmsg, _("Device %s is BLOCKED due to user unmount.\n"),
        dev->print_name());
    for (first=true; device_is_unmounted(dev); first=false) {
-      dev->unblock();
+      dev->unblock();     
       if (!wait_for_device(dcr, jcr->errmsg, first))  {
         return false;
       }
@@ -401,8 +406,13 @@ bool reserve_device_for_append(DCR *dcr)
    for ( ;; ) {
       switch (can_reserve_drive(dcr)) {
       case 0:
-        /* ****FIXME**** Make wait */
-        goto bail_out;
+         Mmsg1(jcr->errmsg, _("Device %s is busy writing on another Volume.\n"), dev->print_name());
+        dev->unblock();      
+        if (!wait_for_device(dcr, jcr->errmsg, first))  {
+           return false;
+        }
+        dev->block(BST_DOING_ACQUIRE);
+        continue;
       case -1:
         goto bail_out;               /* error */
       default:
@@ -442,14 +452,12 @@ static int can_reserve_drive(DCR *dcr)
            /* OK, compatible device */
         } else {
            /* Drive not suitable for us */
-            Jmsg(jcr, M_WARNING, 0, _("Device %s is busy writing on another Volume.\n"), dev->print_name());
            return 0;                 /* wait */
         }
       } else {
         /* Device is available but not yet reserved, reserve it for us */
         bstrncpy(dev->pool_name, dcr->pool_name, sizeof(dev->pool_name));
         bstrncpy(dev->pool_type, dcr->pool_type, sizeof(dev->pool_type));
-        dev->PoolId = dcr->PoolId;
       }
       return 1;                      /* reserve drive */
    }
@@ -493,6 +501,8 @@ DCR *acquire_device_for_append(DCR *dcr)
    DEVICE *dev = dcr->dev;
    JCR *jcr = dcr->jcr;
 
+   init_device_wait_timers(dcr);
+
    dev->block(BST_DOING_ACQUIRE);
    Dmsg1(190, "acquire_append device is %s\n", dev_is_tape(dev)?"tape":"disk");
 
index 27e6a9fc3cac77dacd06043d5e009696cd9d2668..3f93b37adfb6e41cf20ef3ffad7630ad4eec2447 100644 (file)
@@ -42,13 +42,6 @@ static char Create_job_media[] = "CatReq Job=%s CreateJobMedia"
    " StartBlock=%u EndBlock=%u\n";
 static char FileAttributes[] = "UpdCat Job=%s FileAttributes ";
 static char Job_status[]     = "Status Job=%s JobStatus=%d\n";
-static char Device_update[] = "DevUpd Job=%s device=%s "
-   "append=%d read=%d num_writers=%d "
-   "open=%d labeled=%d offline=%d "
-   "reserved=%d max_writers=%d "
-   "autoselect=%d autochanger=%d "
-   "poolid=%s "
-   "changer_name=%s media_type=%s volume_name=%s\n";
 
 
 
@@ -63,6 +56,16 @@ static char OK_media[] = "1000 OK VolName=%127s VolJobs=%u VolFiles=%u"
 
 static char OK_create[] = "1000 OK CreateJobMedia\n";
 
+#ifdef needed
+
+static char Device_update[] = "DevUpd Job=%s device=%s "
+   "append=%d read=%d num_writers=%d "
+   "open=%d labeled=%d offline=%d "
+   "reserved=%d max_writers=%d "
+   "autoselect=%d autochanger=%d "
+   "changer_name=%s media_type=%s volume_name=%s\n";
+
+
 /* Send update information about a device to Director */
 bool dir_update_device(JCR *jcr, DEVICE *dev)
 {
@@ -70,7 +73,6 @@ bool dir_update_device(JCR *jcr, DEVICE *dev)
    POOL_MEM dev_name, VolumeName, MediaType, ChangerName;
    DEVRES *device = dev->device;
    bool ok;
-   char ed1[50];
    
    pm_strcpy(dev_name, device->hdr.name);
    bash_spaces(dev_name);
@@ -97,7 +99,6 @@ bool dir_update_device(JCR *jcr, DEVICE *dev)
       dev->is_offline()!=0, dev->reserved_device, 
       dev->is_tape()?100000:1,
       dev->autoselect, 0, 
-      edit_uint64(dev->PoolId, ed1),
       ChangerName.c_str(), MediaType.c_str(), VolumeName.c_str());
    Dmsg1(100, ">dird: %s\n", dir->msg);
    return ok;
@@ -131,6 +132,7 @@ bool dir_update_changer(JCR *jcr, AUTOCHANGER *changer)
    Dmsg1(100, ">dird: %s\n", dir->msg);
    return ok;
 }
+#endif
 
 
 /*
index eb7b38ea1ab3f4b2ee8d61c0dddafebc421b2c2f..545d2b2604b04535a960bad4e3b80d139f6a68bc 100644 (file)
@@ -236,7 +236,6 @@ public:
 
    VOLUME_CAT_INFO VolCatInfo;        /* Volume Catalog Information */
    VOLUME_LABEL VolHdr;               /* Actual volume label */
-   uint64_t PoolId;                   /* DB PoolId */
    char pool_name[MAX_NAME_LENGTH];   /* pool name */
    char pool_type[MAX_NAME_LENGTH];   /* pool type */
 
@@ -342,7 +341,6 @@ public:
    uint32_t EndBlock;                 /* Ending block written */
    int64_t spool_size;                /* Current spool size */
    int64_t max_spool_size;            /* Max job spool size */
-   uint64_t PoolId;                   /* PoolId from DB */
    char VolumeName[MAX_NAME_LENGTH];  /* Volume name */
    char pool_name[MAX_NAME_LENGTH];   /* pool name */
    char pool_type[MAX_NAME_LENGTH];   /* pool type */
index da15d3f943e1d936b6a8071518e9f1e1b49c0b9f..390297d56b13ad06de6916801e3fae6a35a56995 100644 (file)
@@ -63,7 +63,7 @@ extern bool use_cmd(JCR *jcr);
 extern bool run_cmd(JCR *jcr);
 extern bool status_cmd(JCR *sjcr);
 extern bool qstatus_cmd(JCR *jcr);
-extern bool query_cmd(JCR *jcr);
+//extern bool query_cmd(JCR *jcr);
 
 /* Forward referenced functions */
 static bool label_cmd(JCR *jcr);
@@ -107,9 +107,9 @@ static struct s_cmds cmds[] = {
    {"status",      status_cmd,      1},
    {".status",     qstatus_cmd,     1},
    {"unmount",     unmount_cmd,     0},
-   {"use device=", use_cmd,         0},
+   {"use storage", use_cmd,         0},
    {"run",         run_cmd,         0},
-   {"query",       query_cmd,       0},
+// {"query",       query_cmd,       0},
    {NULL,       NULL}                      /* list terminator */
 };
 
index 6c2ae1a454d64cf9862f353f5aba986ec33ca14a..8d6ab2e414873300c9b74a39eb1704a8f1e4853e 100644 (file)
@@ -36,15 +36,16 @@ extern uint32_t VolSessionTime;
 extern uint32_t newVolSessionId();
 
 /* Forward referenced functions */
-static bool use_device_cmd(JCR *jcr);
+static bool use_storage_cmd(JCR *jcr);
 
 /* Requests from the Director daemon */
 static char jobcmd[] = "JobId=%d job=%127s job_name=%127s client_name=%127s "
       "type=%d level=%d FileSet=%127s NoAttr=%d SpoolAttr=%d FileSetMD5=%127s "
-      "SpoolData=%d  WritePartAfterJob=%d";
-static char use_device[]  = "use device=%127s media_type=%127s "
-   "pool_name=%127s pool_type=%127s PoolId=%lld append=%d";
-static char query_device[] = "query device=%127s";
+      "SpoolData=%d WritePartAfterJob=%d NewVol=%d\n";
+static char use_storage[]  = "use storage media_type=%127s "
+   "pool_name=%127s pool_type=%127s append=%d\n";
+static char use_device[]  = "use device=%127s\n";
+//static char query_device[] = "query device=%127s";
 
 
 /* Responses sent to Director daemon */
@@ -54,9 +55,9 @@ static char NO_device[] = "3924 Device \"%s\" not in SD Device resources.\n";
 static char NOT_open[]  = "3925 Device \"%s\" could not be opened or does not exist.\n";
 static char BAD_use[]   = "3913 Bad use command: %s\n";
 static char BAD_job[]   = "3915 Bad Job command: %s\n";
-static char OK_query[]  = "3001 OK query\n";
-static char NO_query[]  = "3918 Query failed\n";
-static char BAD_query[] = "3917 Bad query command: %s\n";
+//static char OK_query[]  = "3001 OK query\n";
+//static char NO_query[]  = "3918 Query failed\n";
+//static char BAD_query[] = "3917 Bad query command: %s\n";
 
 /*
  * Director requests us to start a job
@@ -74,7 +75,9 @@ bool job_cmd(JCR *jcr)
    char auth_key[100];
    BSOCK *dir = jcr->dir_bsock;
    POOL_MEM job_name, client_name, job, fileset_name, fileset_md5;
-   int JobType, level, spool_attributes, no_attributes, spool_data, write_part_after_job;
+   int JobType, level, spool_attributes, no_attributes, spool_data;
+   int write_part_after_job, NewVol;
+
    JCR *ojcr;
 
    /*
@@ -84,7 +87,8 @@ bool job_cmd(JCR *jcr)
    if (sscanf(dir->msg, jobcmd, &JobId, job.c_str(), job_name.c_str(),
              client_name.c_str(),
              &JobType, &level, fileset_name.c_str(), &no_attributes,
-             &spool_attributes, fileset_md5.c_str(), &spool_data, &write_part_after_job) != 12) {
+             &spool_attributes, fileset_md5.c_str(), &spool_data, 
+             &write_part_after_job, &NewVol) != 13) {
       pm_strcpy(jcr->errmsg, dir->msg);
       bnet_fsend(dir, BAD_job, jcr->errmsg);
       Dmsg1(100, ">dird: %s\n", dir->msg);
@@ -123,6 +127,7 @@ bool job_cmd(JCR *jcr)
    jcr->write_part_after_job = write_part_after_job;
    jcr->fileset_md5 = get_pool_memory(PM_NAME);
    pm_strcpy(jcr->fileset_md5, fileset_md5);
+   jcr->NewVolEachJob = NewVol;
 
    jcr->authenticated = false;
 
@@ -142,7 +147,7 @@ bool use_cmd(JCR *jcr)
    /*
     * Wait for the device, media, and pool information
     */
-   if (!use_device_cmd(jcr)) {
+   if (!use_storage_cmd(jcr)) {
       set_jcr_job_status(jcr, JS_ErrorTerminated);
       memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key));
       return false;
@@ -256,12 +261,11 @@ void handle_filed_connection(BSOCK *fd, char *job_name)
  *    Ensure that the device exists and is opened, then store
  *     the media and pool info in the JCR.
  */
-static bool use_device_cmd(JCR *jcr)
+static bool use_storage_cmd(JCR *jcr)
 {
    POOL_MEM dev_name, media_type, pool_name, pool_type;
    BSOCK *dir = jcr->dir_bsock;
    DEVRES *device;
-   uint64_t PoolId;
    AUTOCHANGER *changer;
    int append;
    bool ok;
@@ -271,13 +275,22 @@ static bool use_device_cmd(JCR *jcr)
     *  use_device for each device that it wants to use.
     */
    Dmsg1(100, "<dird: %s", dir->msg);
-   ok = sscanf(dir->msg, use_device, dev_name.c_str(), media_type.c_str(),
-              pool_name.c_str(), pool_type.c_str(), &PoolId, &append) == 6;
+   ok = sscanf(dir->msg, use_storage, media_type.c_str(),
+              pool_name.c_str(), pool_type.c_str(), &append) == 4;
    if (ok) {
-      unbash_spaces(dev_name);
       unbash_spaces(media_type);
       unbash_spaces(pool_name);
       unbash_spaces(pool_type);
+      if (bnet_recv(dir) <= 0) {
+        return false;   
+      }
+      ok = sscanf(dir->msg, use_device, dev_name.c_str()) == 1;
+      if (!ok) {
+        return false;
+      }
+      /* Eat to BNET_EOD */
+      while (bnet_recv(dir) > 0) {
+      }
       LockRes();
       foreach_res(device, R_DEVICE) {
         /* Find resource, and make sure we were able to open it */
@@ -308,7 +321,6 @@ static bool use_device_cmd(JCR *jcr)
            bstrncpy(dcr->pool_type, pool_type, name_len);
            bstrncpy(dcr->media_type, media_type, name_len);
            bstrncpy(dcr->dev_name, dev_name, name_len);
-           dcr->PoolId = PoolId;
            jcr->dcr = dcr;
            if (append == SD_APPEND) {
               ok = reserve_device_for_append(dcr);
@@ -410,6 +422,7 @@ static bool use_device_cmd(JCR *jcr)
    return false;                     /* ERROR return */
 }
 
+#ifdef needed
 /*
  *   Query Device command from Director
  *   Sends Storage Daemon's information on the device to the
@@ -483,6 +496,8 @@ bool query_cmd(JCR *jcr)
    return true;
 }
 
+#endif
+
 
 /*
  * Destroy the Job Control Record and associated
index 92d7fd0aabc9b9ae6c1e8b9d15779e16b9302352..d863656ad30eb6d63980e35d0a2460609815abee 100644 (file)
@@ -172,6 +172,7 @@ bool wait_for_device(DCR *dcr, const char *msg, bool first)
    JCR *jcr = dcr->jcr;
    bool ok = false;
 
+   Dmsg0(100, "Enter wait_for_device\n");
    P(device_release_mutex);
 
    if (first) {
@@ -196,12 +197,12 @@ bool wait_for_device(DCR *dcr, const char *msg, bool first)
       timeout.tv_nsec = tv.tv_usec * 1000;
       timeout.tv_sec = tv.tv_sec + add_wait;
 
-      Dmsg3(000, "I'm going to sleep on device %s. HB=%d wait=%d\n", dev->print_name(),
-        (int)me->heartbeat_interval, dev->wait_sec);
+      Dmsg4(100, "I'm going to sleep on device %s. HB=%d wait=%d remwait=%d\n", dev->print_name(),
+        (int)me->heartbeat_interval, jcr->wait_sec, jcr->rem_wait_sec);
       start = time(NULL);
       /* Wait required time */
       stat = pthread_cond_timedwait(&wait_device_release, &device_release_mutex, &timeout);
-      Dmsg1(000, "Wokeup from sleep on device stat=%d\n", stat);
+      Dmsg1(100, "Wokeup from sleep on device stat=%d\n", stat);
 
       now = time(NULL);
       jcr->rem_wait_sec -= (now - start);
@@ -245,7 +246,7 @@ bool wait_for_device(DCR *dcr, const char *msg, bool first)
    }
 
    V(device_release_mutex);
-   Dmsg1(000, "Return from wait_device ok=%d\n", ok);
+   Dmsg1(100, "Return from wait_device ok=%d\n", ok);
    return ok;
 }
 
index 78b66093c2752e0dcef3dd67bffeecd42fe26bee..67af8ce40d7001b18b3bec2f3f57df01fb2acb8e 100644 (file)
@@ -1,8 +1,8 @@
 /* */
 #undef  VERSION
-#define VERSION "1.37.8"
-#define BDATE   "26 March 2005"
-#define LSMDATE "26Mar05"
+#define VERSION "1.37.10"
+#define BDATE   "28 March 2005"
+#define LSMDATE "29Mar05"
 
 /* Debug flags */
 #undef  DEBUG