From: Kern Sibbald Date: Fri, 16 Jul 2004 07:23:41 +0000 (+0000) Subject: Pool + label cleanups from bug reports X-Git-Tag: Release-7.0.0~9304 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=4b098ad305642ea18e0de0ab7538d9cdefded9e0;p=bacula%2Fbacula Pool + label cleanups from bug reports git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1469 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/kernstodo b/bacula/kernstodo index 61eee4feaa..254d5dcc3c 100644 --- a/bacula/kernstodo +++ b/bacula/kernstodo @@ -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. diff --git a/bacula/src/dird/admin.c b/bacula/src/dird/admin.c index 9a2288b7b2..746f629b4f 100644 --- a/bacula/src/dird/admin.c +++ b/bacula/src/dird/admin.c @@ -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); diff --git a/bacula/src/dird/inc_conf.c b/bacula/src/dird/inc_conf.c index 45cc42e6a4..d3df0b8fd4 100644 --- a/bacula/src/dird/inc_conf.c +++ b/bacula/src/dird/inc_conf.c @@ -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} }; diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index 80108dec34..0a21271352 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -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; diff --git a/bacula/src/dird/jobq.c b/bacula/src/dird/jobq.c index 8040ed77e0..785e3fd863 100755 --- a/bacula/src/dird/jobq.c +++ b/bacula/src/dird/jobq.c @@ -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) { diff --git a/bacula/src/dird/sql_cmds.c b/bacula/src/dird/sql_cmds.c index 247cf50924..26afbc4e9f 100644 --- a/bacula/src/dird/sql_cmds.c +++ b/bacula/src/dird/sql_cmds.c @@ -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"; diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index fa8dfe9559..b4ec277fe0 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -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 */ diff --git a/bacula/src/dird/ua_label.c b/bacula/src/dird/ua_label.c index 972f5c6fa5..2b3c95cdd5 100644 --- a/bacula/src/dird/ua_label.c +++ b/bacula/src/dird/ua_label.c @@ -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 { diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index 71546d31c7..29eb20f6c8 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -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 */ diff --git a/bacula/src/lib/dlist.c b/bacula/src/lib/dlist.c index 5fe1b4e529..74f9fe7131 100644 --- a/bacula/src/lib/dlist.c +++ b/bacula/src/lib/dlist.c @@ -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; diff --git a/bacula/src/lib/dlist.h b/bacula/src/lib/dlist.h index 084e414dc9..49403d966c 100644 --- a/bacula/src/lib/dlist.h +++ b/bacula/src/lib/dlist.h @@ -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(); diff --git a/bacula/src/lib/parse_conf.c b/bacula/src/lib/parse_conf.c index 662842eb73..1e64fb2765 100755 --- a/bacula/src/lib/parse_conf.c +++ b/bacula/src/lib/parse_conf.c @@ -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); diff --git a/bacula/src/lib/tree.c b/bacula/src/lib/tree.c index b8fed2297a..ced63a2454 100755 --- a/bacula/src/lib/tree.c +++ b/bacula/src/lib/tree.c @@ -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; diff --git a/bacula/src/stored/dircmd.c b/bacula/src/stored/dircmd.c index 13a7f933a6..4d340ceb3d 100644 --- a/bacula/src/stored/dircmd.c +++ b/bacula/src/stored/dircmd.c @@ -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; } diff --git a/bacula/src/stored/label.c b/bacula/src/stored/label.c index a4ce64e641..38388ab12c 100644 --- a/bacula/src/stored/label.c +++ b/bacula/src/stored/label.c @@ -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; } diff --git a/bacula/src/version.h b/bacula/src/version.h index 08e8412a87..fa475a3102 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -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