]> git.sur5r.net Git - bacula/bacula/commitdiff
Pool + label cleanups from bug reports
authorKern Sibbald <kern@sibbald.com>
Fri, 16 Jul 2004 07:23:41 +0000 (07:23 +0000)
committerKern Sibbald <kern@sibbald.com>
Fri, 16 Jul 2004 07:23:41 +0000 (07:23 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1469 91ce42f0-d328-0410-95d8-f526ca767f89

16 files changed:
bacula/kernstodo
bacula/src/dird/admin.c
bacula/src/dird/inc_conf.c
bacula/src/dird/job.c
bacula/src/dird/jobq.c
bacula/src/dird/sql_cmds.c
bacula/src/dird/ua_cmds.c
bacula/src/dird/ua_label.c
bacula/src/dird/ua_status.c
bacula/src/lib/dlist.c
bacula/src/lib/dlist.h
bacula/src/lib/parse_conf.c
bacula/src/lib/tree.c
bacula/src/stored/dircmd.c
bacula/src/stored/label.c
bacula/src/version.h

index 61eee4feaa0759a5eedffcb2e8fd19f4a7ce95b8..254d5dcc3c90f60e41ae634d4e3afae8d058552d 100644 (file)
@@ -1,8 +1,8 @@
                  Kern's ToDo List
-                   06 July 2004
+                   14 July 2004
 
 1.35 Items to do:
-- Require resource names to be unique.
+- Make sure that all errors from libacl are printed.
 - Add new DCR calling sequences everywhere in SD.
   This will permit simultaneous use of multiple 
   devices by a single job.
@@ -13,7 +13,6 @@
 - Document a get out of jail procedure if everything breaks if 
   you lost/broke the Catalog -- do the same for "I know my
   file is there how do I get it back?".
-- Look at Win32 inc problem when new directory added files not saved???
 - Make FD run on Win95 if possible:
    The error I when I installed 1.34.2 clients:
    The BACULA-FD file is  
@@ -27,6 +26,7 @@
 - Look at adding Client run command that will use the
   port opened by the client.
 - Fix find_device in stored/dircmd.c:462
+- Make entering multiple Storage names in Dir illegal.
 
 Documentation to do: (any release a little bit at a time)
 - Document query file format.
@@ -1098,3 +1098,5 @@ Block Position: 0
 - Test new despooling error recovery code when partition fills.
 - Sort Scheduled jobs status listing by start time.
 - Add priority to Scheduled jobs status listing.
+- Look at Win32 inc problem when new directory added files not saved???
+- Require resource names to be unique.
index 9a2288b7b20870f8fdbc425bcdd3d281bb353323..746f629b4fa52834215f9702ea18cc057f2b3d8a 100644 (file)
@@ -94,21 +94,21 @@ static void admin_cleanup(JCR *jcr, int TermCode)
 
    msg_type = M_INFO;                /* by default INFO message */
    switch (jcr->JobStatus) {
-      case JS_Terminated:
-         term_msg = _("Admin OK");
-        break;
-      case JS_FatalError:
-      case JS_ErrorTerminated:
-         term_msg = _("*** Admin Error ***"); 
-        msg_type = M_ERROR;          /* Generate error message */
-        break;
-      case JS_Canceled:
-         term_msg = _("Admin Canceled");
-        break;
-      default:
-        term_msg = term_code;
-         sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus);
-        break;
+   case JS_Terminated:
+      term_msg = _("Admin OK");
+      break;
+   case JS_FatalError:
+   case JS_ErrorTerminated:
+      term_msg = _("*** Admin Error ***"); 
+      msg_type = M_ERROR;         /* Generate error message */
+      break;
+   case JS_Canceled:
+      term_msg = _("Admin Canceled");
+      break;
+   default:
+      term_msg = term_code;
+      sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus);
+      break;
    }
    bstrftime(sdt, sizeof(sdt), jcr->jr.StartTime);
    bstrftime(edt, sizeof(edt), jcr->jr.EndTime);
index 45cc42e6a4fb147f490f531ea5ebbf998b38bd45..d3df0b8fd4f5b15a6c023c6eee4df49203c0f30b 100644 (file)
@@ -181,9 +181,9 @@ static struct s_fs_opt FS_options[] = {
    {"no",       INC_KW_KEEPATIME,     "0"},
    {"yes",      INC_KW_EXCLUDE,       "e"},
    {"no",       INC_KW_EXCLUDE,       "0"},
-   {"yes",           INC_KW_ACL,        "A"},
-   {"no",           INC_KW_ACL,         "0"},
-   {NULL,      0,                   0}
+   {"yes",      INC_KW_ACL,           "A"},
+   {"no",       INC_KW_ACL,           "0"},
+   {NULL,      0,                      0}
 };
 
 
index 80108dec347b4b6e60d14d0101b5b9076f97403c..0a21271352795978ccf59626f523a6bc482bf086 100644 (file)
@@ -156,7 +156,6 @@ static void *job_thread(void *arg)
    sm_check(__FILE__, __LINE__, true);
 
    for ( ;; ) {
-
       Dmsg0(200, "=====Start Job=========\n");
       jcr->start_time = time(NULL);     /* set the real start time */
       set_jcr_job_status(jcr, JS_Running);
@@ -585,9 +584,7 @@ void init_jcr_job_record(JCR *jcr)
  */
 void update_job_end_record(JCR *jcr)
 {
-   if (jcr->jr.EndTime == 0) {
-      jcr->jr.EndTime = time(NULL);
-   }
+   jcr->jr.EndTime = time(NULL);
    jcr->end_time = jcr->jr.EndTime;
    jcr->jr.JobId = jcr->JobId;
    jcr->jr.JobStatus = jcr->JobStatus;
index 8040ed77e0bef02a839ee91b431492dc592df1cd..785e3fd8632e5450f90bbe2588f0e8f95f39081b 100755 (executable)
@@ -458,6 +458,7 @@ void *jobq_server(void *arg)
             jcr->JobStatus != JS_Canceled && 
             jcr->job->RescheduleTimes > 0 && 
             jcr->reschedule_count < jcr->job->RescheduleTimes) {
+            char dt[50];
 
             /*
              * Reschedule this job by cleaning it up, but
@@ -467,6 +468,9 @@ void *jobq_server(void *arg)
            jcr->sched_time = time(NULL) + jcr->job->RescheduleInterval;
             Dmsg2(300, "Rescheduled Job %s to re-run in %d seconds.\n", jcr->Job,
               (int)jcr->job->RescheduleInterval);
+           bstrftime(dt, sizeof(dt), time(NULL));
+            Jmsg(jcr, M_INFO, 0, _("Rescheduled Job %s at %s to re-run in %d seconds.\n"),
+              jcr->Job, dt, (int)jcr->job->RescheduleInterval);
            jcr->JobStatus = JS_Created; /* force new status */
            dird_free_jcr(jcr);          /* partial cleanup old stuff */
            if (jcr->JobBytes == 0) {
index 247cf509244fe1968da87f8c519cd214991984de..26afbc4e9f9f401223f79f7472300c2af52e309d 100644 (file)
@@ -315,6 +315,7 @@ const char *uar_jobid_fileindex =
    "AND Path.Path='%s' "
    "AND Filename.Name='%s' "
    "AND Client.Name='%s' "
+   "AND Job.ClientId=Client.ClientId "
    "AND Path.PathId=File.PathId "
    "AND Filename.FilenameId=File.FilenameId "
    "ORDER BY Job.StartTime DESC LIMIT 1";
index fa8dfe955953d51aec7f1f20c376d5051a4a3ea2..b4ec277fe065be35d80416568f51085c20b5145f 100644 (file)
@@ -312,7 +312,7 @@ getVolName:
       mr.InChanger = InChanger;
       Dmsg1(200, "Create Volume %s\n", mr.VolumeName);
       if (!db_create_media_record(ua->jcr, ua->db, &mr)) {
-        bsendmsg(ua, db_strerror(ua->db));
+         bsendmsg(ua, "%s", db_strerror(ua->db));
         return 1;
       }
       if (i == startnum) {
@@ -322,7 +322,7 @@ getVolName:
    pr.NumVols += num;
    Dmsg0(200, "Update pool record.\n"); 
    if (db_update_pool_record(ua->jcr, ua->db, &pr) != 1) {
-      bsendmsg(ua, db_strerror(ua->db));
+      bsendmsg(ua, "%s", db_strerror(ua->db));
       return 1;
    }
    bsendmsg(ua, _("%d Volumes created in pool %s\n"), num, pr.Name);
@@ -544,7 +544,7 @@ static int create_cmd(UAContext *ua, const char *cmd)
       break;
 
    case -1:
-      bsendmsg(ua, db_strerror(ua->db));
+      bsendmsg(ua, "%s", db_strerror(ua->db));
       break;
 
    default:
@@ -795,7 +795,7 @@ static void update_volrecycle(UAContext *ua, char *val, MEDIA_DBR *mr)
 }
 
 /* Modify the Pool in which this Volume is located */
-static void update_volpool(UAContext *ua, char *val, MEDIA_DBR *mr)
+static void update_vol_pool(UAContext *ua, char *val, MEDIA_DBR *mr, POOL_DBR *opr)
 {
    POOL_DBR pr;
    POOLMEM *query;
@@ -816,12 +816,23 @@ static void update_volpool(UAContext *ua, char *val, MEDIA_DBR *mr)
       bsendmsg(ua, "%s", db_strerror(ua->db));
    } else {      
       bsendmsg(ua, _("New Pool is: %s\n"), pr.Name);
+      opr->NumVols--;
+      if (!db_update_pool_record(ua->jcr, ua->db, opr)) {
+         bsendmsg(ua, "%s", db_strerror(ua->db));
+      }
+      pr.NumVols++;
+      if (!db_update_pool_record(ua->jcr, ua->db, &pr)) {
+         bsendmsg(ua, "%s", db_strerror(ua->db));
+      }
+      db_make_inchanger_unique(ua->jcr, ua->db, mr);
    }
-   db_make_inchanger_unique(ua->jcr, ua->db, mr);
    db_unlock(ua->db);
    free_pool_memory(query);
 }
 
+/*
+ * Refresh the Volume information from the Pool record
+ */
 static void update_volfrompool(UAContext *ua, MEDIA_DBR *mr)
 {
    POOL_DBR pr;
@@ -869,6 +880,7 @@ static int update_volume(UAContext *ua)
 
    for (int i=0; kw[i]; i++) {
       int j;
+      POOL_DBR pr;
       if ((j=find_arg_with_value(ua, kw[i])) > 0) {
         if (!select_media_dbr(ua, &mr)) {
            return 0;
@@ -896,7 +908,13 @@ static int update_volume(UAContext *ua)
            update_volrecycle(ua, ua->argv[j], &mr);
            break;
         case 7:
-           update_volpool(ua, ua->argv[j], &mr);
+           memset(&pr, 0, sizeof(POOL_DBR));
+           pr.PoolId = mr.PoolId;
+           if (!db_get_pool_record(ua->jcr, ua->db, &pr)) {
+               bsendmsg(ua, "%s", db_strerror(ua->db));
+              break;
+           }
+           update_vol_pool(ua, ua->argv[j], &mr, &pr);
            break;
         case 8:
            update_volfrompool(ua, &mr);
@@ -1082,7 +1100,7 @@ static int update_volume(UAContext *ua)
          if (!get_cmd(ua, _("Enter new Pool name: "))) {
            return 0;
         }
-        update_volpool(ua, ua->cmd, &mr);
+        update_vol_pool(ua, ua->cmd, &mr, &pr);
         return 1;
 
       default:                       /* Done or error */
index 972f5c6fa50e40202dcb5206211a957217b35c1e..2b3c95cdd521f8658077a2381d851e702f2739e5 100644 (file)
@@ -41,7 +41,7 @@ typedef struct s_vol_list {
 /* Forward referenced functions */
 static int do_label(UAContext *ua, const char *cmd, int relabel);
 static void label_from_barcodes(UAContext *ua);
-static int send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, 
+static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, 
               POOL_DBR *pr, int relabel, bool media_record_exits);
 static vol_list_t *get_vol_list_from_SD(UAContext *ua, bool scan);
 static void free_vol_list(vol_list_t *vol_list);
@@ -228,7 +228,7 @@ int update_slots(UAContext *ua)
             mr.Slot = vl->Slot;
             mr.InChanger = 1;
             if (!db_update_media_record(ua->jcr, ua->db, &mr)) {
-                bsendmsg(ua, _("%s\n"), db_strerror(ua->db));
+                bsendmsg(ua, "%s", db_strerror(ua->db));
             } else {
                bsendmsg(ua, _(
                   "Catalog record for Volume \"%s\" updated to reference slot %d.\n"),
@@ -391,12 +391,18 @@ checkName:
    if (ok) {
       sd = ua->jcr->store_bsock;
       if (relabel) {
+        /* Delete the old media record */
         if (!db_delete_media_record(ua->jcr, ua->db, &omr)) {
             bsendmsg(ua, _("Delete of Volume \"%s\" failed. ERR=%s"),
               omr.VolumeName, db_strerror(ua->db));
         } else {
             bsendmsg(ua, _("Old volume \"%s\" deleted from catalog.\n"), 
               omr.VolumeName);
+           /* Update the number of Volumes in the pool */
+           pr.NumVols--;
+           if (!db_update_pool_record(ua->jcr, ua->db, &pr)) {
+               bsendmsg(ua, "%s", db_strerror(ua->db));
+           }
         }
       }
       if (ua->automount) {
@@ -512,6 +518,10 @@ static void label_from_barcodes(UAContext *ua)
            if (db_create_media_record(ua->jcr, ua->db, &mr)) {
                bsendmsg(ua, _("Catalog record for cleaning tape \"%s\" successfully created.\n"),
                  mr.VolumeName);
+              pr.NumVols++;          /* this is a bit suspect */
+              if (!db_update_pool_record(ua->jcr, ua->db, &pr)) {
+                  bsendmsg(ua, "%s", db_strerror(ua->db));
+              }
            } else {
                bsendmsg(ua, "Catalog error on cleaning tape: %s", db_strerror(ua->db));
            }
@@ -572,15 +582,15 @@ bool is_volume_name_legal(UAContext *ua, const char *name)
 /*
  * NOTE! This routine opens the SD socket but leaves it open
  */
-static int send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, 
-                             POOL_DBR *pr, int relabel, bool media_record_exists)
+static bool send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr, 
+                              POOL_DBR *pr, int relabel, bool media_record_exists)
 {
    BSOCK *sd;
    char dev_name[MAX_NAME_LENGTH];
-   int ok = FALSE;
+   bool ok = false;
 
    if (!(sd=open_sd_bsock(ua))) {
-      return 0;
+      return false;
    }
    bstrncpy(dev_name, ua->jcr->store->dev_name, sizeof(dev_name));
    bash_spaces(dev_name);
@@ -605,7 +615,7 @@ static int send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr,
    while (bnet_recv(sd) >= 0) {
       bsendmsg(ua, "%s", sd->msg);
       if (strncmp(sd->msg, "3000 OK label.", 14) == 0) {
-        ok = TRUE;
+        ok = true;
       } 
    }
    unbash_spaces(mr->VolumeName);
@@ -618,7 +628,7 @@ static int send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr,
         mr->InChanger = 1;
         if (!db_update_media_record(ua->jcr, ua->db, mr)) {
              bsendmsg(ua, "%s", db_strerror(ua->db));
-            ok = FALSE;
+            ok = false;
         }
       } else {                       /* create the media record */
         set_pool_dbr_defaults_in_media_dbr(mr, pr);
@@ -627,9 +637,14 @@ static int send_label_request(UAContext *ua, MEDIA_DBR *mr, MEDIA_DBR *omr,
         if (db_create_media_record(ua->jcr, ua->db, mr)) {
             bsendmsg(ua, _("Catalog record for Volume \"%s\", Slot %d  successfully created.\n"),
            mr->VolumeName, mr->Slot);
+           /* Update number of volumes in pool */
+           pr->NumVols++;
+           if (!db_update_pool_record(ua->jcr, ua->db, pr)) {
+               bsendmsg(ua, "%s", db_strerror(ua->db));
+           }
         } else {
             bsendmsg(ua, "%s", db_strerror(ua->db));
-           ok = FALSE;
+           ok = false;
         }
       }
    } else {
index 71546d31c71150049eb572cf74b18127a5a6ea61..29eb20f6c8df42fa68ca53804008e3fb1beaa2fa 100644 (file)
@@ -391,7 +391,7 @@ static void list_scheduled_jobs(UAContext *ua)
    int priority;
    bool hdr_printed = false;
    dlist sched;
-   sched_pkt *sp, *ip;
+   sched_pkt *sp;
 
    Dmsg0(200, "enter list_sched_jobs()\n");
 
@@ -420,11 +420,7 @@ static void list_scheduled_jobs(UAContext *ua)
         sp->priority = priority;
         sp->runtime = runtime;
         sp->pool = run->pool;
-        ip = (sched_pkt *)sched.binary_insert(sp, my_compare);
-        if (ip != sp) {
-           /* Identical entry already, we must explictly insert it */
-           sched.insert_after(sp, ip);
-        }
+        sched.binary_insert(sp, my_compare);
         num_jobs++;
       }
    } /* end for loop over resources */
index 5fe1b4e529d75abd85ecacd4a329320a9c686272..74f9fe7131985989eb734c517f82dde7b5932800 100644 (file)
@@ -103,10 +103,13 @@ void dlist::insert_after(void *item, void *where)
 }
 
 /*
+ *  Insert an item in the list, but only if it is unique
+ *  otherwise, the item is returned non inserted
+ *
  * Returns: item        if item inserted
  *         other_item   if same value already exists (item not inserted)
  */
-void *dlist::binary_insert(void *item, int compare(void *item1, void *item2))
+void *dlist::unique_binary_insert(void *item, int compare(void *item1, void *item2))
 {
    int comp;
    int low, high, cur;
@@ -197,6 +200,20 @@ void *dlist::binary_insert(void *item, int compare(void *item1, void *item2))
 }
 
 
+/*
+ *  Insert an item in the list, regardless if it is unique
+ *  or not.
+ */
+void dlist::binary_insert(void *item, int compare(void *item1, void *item2))
+{
+   void *ins_item = unique_binary_insert(item, compare);
+   /* If identical, insert after the one found */
+   if (ins_item != item) {
+      insert_after(item, ins_item);
+   }
+}
+
+
 void dlist::remove(void *item)
 {
    void *xitem;
index 084e414dc948aa93e584688d9748948dc6553a59..49403d966ca8dcddea7e9b5f1ecc8944c9dfe1d0 100644 (file)
@@ -65,7 +65,8 @@ public:
    void append(void *item);
    void insert_before(void *item, void *where);
    void insert_after(void *item, void *where);
-   void *dlist::binary_insert(void *item, int compare(void *item1, void *item2));
+   void *unique_binary_insert(void *item, int compare(void *item1, void *item2));
+   void binary_insert(void *item, int compare(void *item1, void *item2));
    void remove(void *item);
    bool empty();
    int  size();
index 662842eb73e735020fa37c4efe68ae180e5555ad..1e64fb2765824a8b72afc0a44db2563bc76b3edc 100755 (executable)
@@ -442,6 +442,10 @@ void store_res(LEX *lc, RES_ITEM *item, int index, int pass)
         scan_err3(lc, _("Could not find config Resource %s referenced on line %d : %s\n"), 
           lc->str, lc->line_no, lc->line);
      }
+     if (*(item->value)) {
+        scan_err3(lc, _("Attempt to redefine resource \"%s\" referenced on line %d : %s\n"), 
+          lc->str, lc->line_no, lc->line);
+     }
      *(item->value) = (char *)res;
    }
    scan_to_eol(lc);
index b8fed2297a6e39f6c6d3523bc669c698e66144a2..ced63a245446301123bd426337255d51b55ef015 100755 (executable)
@@ -290,7 +290,7 @@ static TREE_NODE *search_and_insert_tree_node(char *fname, int type,
    TREE_NODE *node, *found_node;
    node = new_tree_node(root);
    node->fname = fname;
-   found_node = (TREE_NODE *)parent->child.binary_insert(node, node_compare);
+   found_node = (TREE_NODE *)parent->child.unique_binary_insert(node, node_compare);
    if (found_node != node) {         /* already in list */
       free_tree_node(root);          /* free node allocated above */
       found_node->inserted = false;
index 13a7f933a6dec8786b53ed5e0d4133233cb81419..4d340ceb3d48a656165648f8ea8dae14344b2157 100644 (file)
@@ -407,7 +407,8 @@ static void label_volume_if_ok(JCR *jcr, DEVICE *dev, char *oldname,
         break;
       }
       pm_strcpy(&jcr->VolumeName, newname);
-      bnet_fsend(dir, _("3000 OK label. Volume=%s Device=%s\n"), 
+      /* The following 3000 OK label. string is scanned in ua_label.c */
+      bnet_fsend(dir, "3000 OK label. Volume=%s Device=%s\n", 
         newname, dev_name(dev));
       break;
    case VOL_NO_MEDIA:
@@ -421,7 +422,6 @@ Unknown status %d from read_volume_label()\n"), jcr->label_status);
 bail_out:
    free_block(block);
    give_back_device_lock(dev, &hold);
-
    return;
 }
 
index a4ce64e64168fe574def1982a743f2171288cea7..38388ab12c8ac8d72df3a9d859c4e34a57360266 100644 (file)
@@ -380,7 +380,7 @@ bool write_new_volume_label_to_dev(JCR *jcr, DEVICE *dev, const char *VolName, c
 {
    DEV_RECORD rec;   
    DEV_BLOCK *block;
-   bool stat = true;
+   bool ok = false;
 
 
    Dmsg0(99, "write_volume_label()\n");
@@ -403,31 +403,31 @@ bool write_new_volume_label_to_dev(JCR *jcr, DEVICE *dev, const char *VolName, c
    if (!write_record_to_block(block, &rec)) {
       Dmsg2(30, "Bad Label write on %s. ERR=%s\n", dev_name(dev), strerror_dev(dev));
       memset(&dev->VolHdr, 0, sizeof(dev->VolHdr));
-      free_block(block);
-      free_pool_memory(rec.data);
-      return false;
+      goto bail_out;
    } else {
       Dmsg2(30, "Wrote label of %d bytes to %s\n", rec.data_len, dev_name(dev));
    }
-   free_pool_memory(rec.data);
       
    Dmsg0(99, "Call write_block_to_dev()\n");
    if (!write_block_to_dev(jcr->dcr, block)) {
       memset(&dev->VolHdr, 0, sizeof(dev->VolHdr));
       Dmsg2(30, "Bad Label write on %s. ERR=%s\n", dev_name(dev), strerror_dev(dev));
-      stat = false;
+      goto bail_out;
    }
    Dmsg0(99, " Wrote block to device\n");
      
-   flush_dev(dev);
    weof_dev(dev, 1);
    dev->state |= ST_LABEL;
+   ok = true;
 
    if (debug_level >= 20)  {
       dump_volume_label(dev);
    }
+
+bail_out:
    free_block(block);
-   return stat;
+   free_pool_memory(rec.data);
+   return ok;
 }     
 
 
index 08e8412a87a75fed48c34d526c2ae358a2b45fa2..fa475a3102266270bb1bc24a23bf9864f94a30f5 100644 (file)
@@ -2,8 +2,8 @@
 #undef  VERSION
 #define VERSION "1.35.1"
 #define VSTRING "1"
-#define BDATE   "09 July 2004"
-#define LSMDATE "09Jul04"
+#define BDATE   "16 July 2004"
+#define LSMDATE "16Jul04"
 
 /* Debug flags */
 #undef  DEBUG