From: Kern Sibbald Date: Tue, 14 Nov 2006 20:57:51 +0000 (+0000) Subject: kes Implement code to pass the MediaId to the SD. The SD then uses X-Git-Tag: Release-2.0.0~294 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5b625944a92086e5bf1f9e19fbad3801fa9a005d;p=bacula%2Fbacula kes Implement code to pass the MediaId to the SD. The SD then uses this MediaId when creating JobMedia records. This fixes a bug with Migration where the MediaId got set to the second Volume read rather than the write Volume. Possibly (unlikely) fixes bug #709. kes Remove NextPool from Job resource. kes Edit a few numbers in the restore dialog with commas. kes Note, the DIR<->SD protocol has changed. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3623 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/catreq.c b/bacula/src/dird/catreq.c index 860dfbbaad..892cd221f6 100644 --- a/bacula/src/dird/catreq.c +++ b/bacula/src/dird/catreq.c @@ -48,7 +48,7 @@ static char Update_media[] = "CatReq Job=%127s UpdateMedia VolName=%s" static char Create_job_media[] = "CatReq Job=%127s CreateJobMedia " " FirstIndex=%u LastIndex=%u StartFile=%u EndFile=%u " - " StartBlock=%u EndBlock=%u Copy=%d Strip=%d\n"; + " StartBlock=%u EndBlock=%u Copy=%d Strip=%d MediaId=%" lld "\n"; /* Responses sent to Storage daemon */ @@ -56,7 +56,8 @@ static char OK_media[] = "1000 OK VolName=%s VolJobs=%u VolFiles=%u" " VolBlocks=%u VolBytes=%s VolMounts=%u VolErrors=%u VolWrites=%u" " MaxVolBytes=%s VolCapacityBytes=%s VolStatus=%s Slot=%d" " MaxVolJobs=%u MaxVolFiles=%u InChanger=%d VolReadTime=%s" - " VolWriteTime=%s EndFile=%u EndBlock=%u VolParts=%u LabelType=%d\n"; + " VolWriteTime=%s EndFile=%u EndBlock=%u VolParts=%u LabelType=%d" + " MediaId=%s\n"; static char OK_create[] = "1000 OK CreateJobMedia\n"; @@ -64,7 +65,7 @@ static char OK_create[] = "1000 OK CreateJobMedia\n"; static int send_volume_info_to_storage_daemon(JCR *jcr, BSOCK *sd, MEDIA_DBR *mr) { int stat; - char ed1[50], ed2[50], ed3[50], ed4[50], ed5[50]; + char ed1[50], ed2[50], ed3[50], ed4[50], ed5[50], ed6[50]; jcr->MediaId = mr->MediaId; pm_strcpy(jcr->VolumeName, mr->VolumeName); @@ -80,7 +81,8 @@ static int send_volume_info_to_storage_daemon(JCR *jcr, BSOCK *sd, MEDIA_DBR *mr edit_uint64(mr->VolWriteTime, ed5), mr->EndFile, mr->EndBlock, mr->VolParts, - mr->LabelType); + mr->LabelType, + edit_uint64(mr->MediaId, ed6)); unbash_spaces(mr->VolumeName); Dmsg2(100, "Vol Info for %s: %s", jcr->Job, sd->msg); return stat; @@ -96,6 +98,7 @@ void catalog_request(JCR *jcr, BSOCK *bs) POOLMEM *omsg; POOL_DBR pr; uint32_t Stripe; + uint64_t MediaId; utime_t VolFirstWritten; memset(&mr, 0, sizeof(mr)); @@ -286,15 +289,14 @@ void catalog_request(JCR *jcr, BSOCK *bs) */ } else if (sscanf(bs->msg, Create_job_media, &Job, &jm.FirstIndex, &jm.LastIndex, &jm.StartFile, &jm.EndFile, - &jm.StartBlock, &jm.EndBlock, &jm.Copy, &Stripe) == 9) { + &jm.StartBlock, &jm.EndBlock, &jm.Copy, &Stripe, &MediaId) == 10) { if (jcr->mig_jcr) { jm.JobId = jcr->mig_jcr->JobId; - jm.MediaId = jcr->MediaId; } else { jm.JobId = jcr->JobId; - jm.MediaId = jcr->MediaId; } + jm.MediaId = MediaId; Dmsg6(400, "create_jobmedia JobId=%d MediaId=%d SF=%d EF=%d FI=%d LI=%d\n", jm.JobId, jm.MediaId, jm.StartFile, jm.EndFile, jm.FirstIndex, jm.LastIndex); if (!db_create_jobmedia_record(jcr, jcr->db, &jm)) { diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index ae3f975850..9021d8b6fd 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -250,7 +250,6 @@ RES_ITEM job_items[] = { {"verifyjob", store_res, ITEM(res_job.verify_job), R_JOB, 0, 0}, {"jobtoverify", store_res, ITEM(res_job.verify_job), R_JOB, 0, 0}, {"jobdefs", store_res, ITEM(res_job.jobdefs), R_JOBDEFS, 0, 0}, - {"nextpool", store_res, ITEM(res_job.next_pool), R_POOL, 0, 0}, {"run", store_alist_str, ITEM(res_job.run_cmds), 0, 0, 0}, /* Root of where to restore files */ {"where", store_dir, ITEM(res_job.RestoreWhere), 0, 0, 0}, diff --git a/bacula/src/dird/dird_conf.h b/bacula/src/dird/dird_conf.h index 67ec18d747..a479809333 100644 --- a/bacula/src/dird/dird_conf.h +++ b/bacula/src/dird/dird_conf.h @@ -345,7 +345,6 @@ public: POOL *full_pool; /* Pool for Full backups */ POOL *inc_pool; /* Pool for Incremental backups */ POOL *diff_pool; /* Pool for Differental backups */ - POOL *next_pool; /* Next Pool for Migration */ char *selection_pattern; int selection_type; union { diff --git a/bacula/src/dird/migrate.c b/bacula/src/dird/migrate.c index 4c6b4c706f..d92b4750e0 100644 --- a/bacula/src/dird/migrate.c +++ b/bacula/src/dird/migrate.c @@ -311,7 +311,6 @@ static int dbid_handler(void *ctx, int num_fields, char **row) { idpkt *ids = (idpkt *)ctx; - Dmsg3(dbglevel, "count=%d Ids=%p %s\n", ids->count, ids->list, ids->list); if (ids->count == 0) { ids->list[0] = 0; } else { @@ -319,6 +318,7 @@ static int dbid_handler(void *ctx, int num_fields, char **row) } pm_strcat(ids->list, row[0]); ids->count++; + Dmsg3(dbglevel, "dbid_hdlr count=%d Ids=%p %s\n", ids->count, ids->list, ids->list); return 0; } @@ -344,7 +344,7 @@ static int unique_name_handler(void *ctx, int num_fields, char **row) memset(new_item, 0, sizeof(uitem)); new_item->item = bstrdup(row[0]); - Dmsg1(dbglevel, "Item=%s\n", row[0]); + Dmsg1(dbglevel, "Unique_name_hdlr Item=%s\n", row[0]); item = (uitem *)list->binary_insert((void *)new_item, item_compare); if (item != new_item) { /* already in list */ free(new_item->item); @@ -676,12 +676,14 @@ static bool get_job_to_migrate(JCR *jcr) p = ids.list; Jmsg(jcr, M_INFO, 0, _("The following %u JobIds will be migrated: %s\n"), ids.count, ids.list); + Dmsg2(dbglevel, "Before loop count=%d ids=%s\n", ids.count, ids.list); for (int i=1; i < (int)ids.count; i++) { JobId = 0; stat = get_next_jobid_from_list(&p, &JobId); - Dmsg2(dbglevel, "get_next_jobid stat=%d JobId=%u\n", stat, JobId); + Dmsg3(dbglevel, "get_jobid_no=%d stat=%d JobId=%u\n", i, stat, JobId); jcr->MigrateJobId = JobId; start_migration_job(jcr); + Dmsg0(dbglevel, "Back from start_migration_job\n"); if (stat < 0) { Jmsg(jcr, M_FATAL, 0, _("Invalid JobId found.\n")); goto bail_out; @@ -823,7 +825,7 @@ static bool regex_find_jobids(JCR *jcr, idpkt *ids, const char *query1, } /* Basic query for names */ Mmsg(query, query1, jcr->pool->hdr.name); - Dmsg1(dbglevel, "query1=%s\n", query.c_str()); + Dmsg1(dbglevel, "get name query1=%s\n", query.c_str()); if (!db_sql_query(jcr->db, query.c_str(), unique_name_handler, (void *)item_chain)) { Jmsg(jcr, M_FATAL, 0, @@ -839,7 +841,7 @@ static bool regex_find_jobids(JCR *jcr, idpkt *ids, const char *query1, free(last_item->item); item_chain->remove(last_item); } - Dmsg1(dbglevel, "Item=%s\n", item->item); + Dmsg1(dbglevel, "get name Item=%s\n", item->item); rc = regexec(&preg, item->item, nmatch, pmatch, 0); if (rc == 0) { last_item = NULL; /* keep this one */ @@ -862,7 +864,7 @@ static bool regex_find_jobids(JCR *jcr, idpkt *ids, const char *query1, foreach_dlist(item, item_chain) { Dmsg2(dbglevel, "Got %s: %s\n", type, item->item); Mmsg(query, query2, item->item, jcr->pool->hdr.name); - Dmsg1(dbglevel, "query2=%s\n", query.c_str()); + Dmsg1(dbglevel, "get id from name query2=%s\n", query.c_str()); if (!db_sql_query(jcr->db, query.c_str(), dbid_handler, (void *)ids)) { Jmsg(jcr, M_FATAL, 0, _("SQL failed. ERR=%s\n"), db_strerror(jcr->db)); diff --git a/bacula/src/dird/ua_restore.c b/bacula/src/dird/ua_restore.c index 090c78bbae..236cca75f9 100644 --- a/bacula/src/dird/ua_restore.c +++ b/bacula/src/dird/ua_restore.c @@ -130,6 +130,7 @@ int restore_cmd(UAContext *ua, const char *cmd) if (rx.bsr->JobId) { uint32_t selected_files; + char ed1[50]; if (!complete_bsr(ua, rx.bsr)) { /* find Vol, SessId, SessTime from JobIds */ bsendmsg(ua, _("Unable to construct a valid BSR. Cannot continue.\n")); goto bail_out; @@ -146,7 +147,8 @@ int restore_cmd(UAContext *ua, const char *cmd) bsendmsg(ua, _("\n1 file selected to be restored.\n\n")); } else { - bsendmsg(ua, _("\n%u files selected to be restored.\n\n"), rx.selected_files); + bsendmsg(ua, _("\n%s files selected to be restored.\n\n"), + edit_uint64_with_commas(rx.selected_files, ed1)); } } else { bsendmsg(ua, _("No files selected to be restored.\n")); diff --git a/bacula/src/dird/ua_tree.c b/bacula/src/dird/ua_tree.c index 5c4f308124..1e7a0c5d47 100644 --- a/bacula/src/dird/ua_tree.c +++ b/bacula/src/dird/ua_tree.c @@ -703,7 +703,8 @@ static int unmarkcmd(UAContext *ua, TREE_CTX *tree) } else if (count == 1) { bsendmsg(ua, _("1 file unmarked.\n")); } else { - bsendmsg(ua, _("%d files unmarked.\n"), count); + char ed1[50]; + bsendmsg(ua, _("%s files unmarked.\n"), edit_uint64_with_commas(count, ed1)); } return 1; } diff --git a/bacula/src/stored/askdir.c b/bacula/src/stored/askdir.c index bc5e737d8b..2d0ea57584 100644 --- a/bacula/src/stored/askdir.c +++ b/bacula/src/stored/askdir.c @@ -34,19 +34,17 @@ static char Update_media[] = "CatReq Job=%s UpdateMedia VolName=%s" " VolFirstWritten=%s VolParts=%u\n"; static char Create_job_media[] = "CatReq Job=%s CreateJobMedia" " FirstIndex=%u LastIndex=%u StartFile=%u EndFile=%u" - " StartBlock=%u EndBlock=%u Copy=%d Strip=%d\n"; + " StartBlock=%u EndBlock=%u Copy=%d Strip=%d MediaId=%s\n"; static char FileAttributes[] = "UpdCat Job=%s FileAttributes "; static char Job_status[] = "Status Job=%s JobStatus=%d\n"; - - /* Responses received from the Director */ static char OK_media[] = "1000 OK VolName=%127s VolJobs=%u VolFiles=%lu" " VolBlocks=%lu VolBytes=%lld VolMounts=%lu VolErrors=%lu VolWrites=%lu" " MaxVolBytes=%lld VolCapacityBytes=%lld VolStatus=%20s" " Slot=%ld MaxVolJobs=%lu MaxVolFiles=%lu InChanger=%ld" " VolReadTime=%lld VolWriteTime=%lld EndFile=%lu EndBlock=%lu" - " VolParts=%lu LabelType=%ld"; + " VolParts=%lu LabelType=%ld MediaId=%lld\n"; static char OK_create[] = "1000 OK CreateJobMedia\n"; @@ -162,7 +160,7 @@ static bool do_get_volume_info(DCR *dcr) return false; } memset(&vol, 0, sizeof(vol)); - Dmsg1(110, "msg); + Dmsg1(100, "msg); n = sscanf(dir->msg, OK_media, vol.VolCatName, &vol.VolCatJobs, &vol.VolCatFiles, &vol.VolCatBlocks, &vol.VolCatBytes, @@ -172,9 +170,9 @@ static bool do_get_volume_info(DCR *dcr) &vol.Slot, &vol.VolCatMaxJobs, &vol.VolCatMaxFiles, &InChanger, &vol.VolReadTime, &vol.VolWriteTime, &vol.EndFile, &vol.EndBlock, &vol.VolCatParts, - &vol.LabelType); - if (n != 21) { - Dmsg2(110, "Bad response from Dir fields=%d: %s", n, dir->msg); + &vol.LabelType, &vol.VolMediaId); + if (n != 22) { + Dmsg2(100, "Bad response from Dir fields=%d: %s", n, dir->msg); Mmsg(jcr->errmsg, _("Error getting Volume info: %s"), dir->msg); return false; } @@ -183,7 +181,7 @@ static bool do_get_volume_info(DCR *dcr) bstrncpy(dcr->VolumeName, vol.VolCatName, sizeof(dcr->VolumeName)); dcr->VolCatInfo = vol; /* structure assignment */ - Dmsg2(300, "do_reqest_vol_info return true slot=%d Volume=%s\n", + Dmsg2(100, "do_reqest_vol_info return true slot=%d Volume=%s\n", vol.Slot, vol.VolCatName); return true; } @@ -344,6 +342,7 @@ bool dir_create_jobmedia_record(DCR *dcr) { JCR *jcr = dcr->jcr; BSOCK *dir = jcr->dir_bsock; + char ed1[50]; /* If system job, do not update catalog */ if (jcr->JobType == JT_SYSTEM) { @@ -359,7 +358,8 @@ bool dir_create_jobmedia_record(DCR *dcr) dcr->VolFirstIndex, dcr->VolLastIndex, dcr->StartFile, dcr->EndFile, dcr->StartBlock, dcr->EndBlock, - dcr->Copy, dcr->Stripe); + dcr->Copy, dcr->Stripe, + edit_uint64(dcr->dev->VolCatInfo.VolMediaId, ed1)); Dmsg1(100, ">dird: %s", dir->msg); if (bnet_recv(dir) <= 0) { Dmsg0(190, "create_jobmedia error bnet_recv\n"); diff --git a/bacula/src/stored/dev.h b/bacula/src/stored/dev.h index b35f9d8d23..dfc4cd7e46 100644 --- a/bacula/src/stored/dev.h +++ b/bacula/src/stored/dev.h @@ -169,6 +169,7 @@ struct VOLUME_CAT_INFO { uint64_t VolCatCapacityBytes; /* capacity estimate */ uint64_t VolReadTime; /* time spent reading */ uint64_t VolWriteTime; /* time spent writing this Volume */ + int64_t VolMediaId; /* MediaId */ utime_t VolFirstWritten; /* Time of first write */ bool InChanger; /* Set if vol in current magazine */ char VolCatStatus[20]; /* Volume status */ diff --git a/bacula/technotes-1.39 b/bacula/technotes-1.39 index 491fd3dff1..a4e30bb07f 100644 --- a/bacula/technotes-1.39 +++ b/bacula/technotes-1.39 @@ -1,6 +1,15 @@ Technical notes on version 1.39 General: +14Nov06 +kes Implement code to pass the MediaId to the SD. The SD then uses + this MediaId when creating JobMedia records. This fixes a bug + with Migration where the MediaId got set to the second Volume + read rather than the write Volume. Possibly (unlikely) fixes + bug #709. +kes Remove NextPool from Job resource. +kes Edit a few numbers in the restore dialog with commas. +kes Note, the DIR<->SD protocol has changed. 13Nov06 kes Replace () by {} in configure.in for proper HP configuration. kes Shorten some lines over 80 characters in filed/backup.c