]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Implement code to pass the MediaId to the SD. The SD then uses
authorKern Sibbald <kern@sibbald.com>
Tue, 14 Nov 2006 20:57:51 +0000 (20:57 +0000)
committerKern Sibbald <kern@sibbald.com>
Tue, 14 Nov 2006 20:57:51 +0000 (20:57 +0000)
     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

bacula/src/dird/catreq.c
bacula/src/dird/dird_conf.c
bacula/src/dird/dird_conf.h
bacula/src/dird/migrate.c
bacula/src/dird/ua_restore.c
bacula/src/dird/ua_tree.c
bacula/src/stored/askdir.c
bacula/src/stored/dev.h
bacula/technotes-1.39

index 860dfbbaadf1bfd8e3baf4c044b085b9e3f2b2b5..892cd221f6843106ef8f4cb43f424e9ade734481 100644 (file)
@@ -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)) {
index ae3f975850051499907d59ce8815b70fb6cfb32e..9021d8b6fd94fd8ba2f8f8b19a67076306fb6b4a 100644 (file)
@@ -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},
index 67ec18d747c939d2274dd20efdb7f4c1691eb4fe..a479809333012190bd774e68f313b231e5d17fb1 100644 (file)
@@ -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 {
index 4c6b4c706f5fc34c2faf5c9902200295c4f3a4bb..d92b4750e01e9df41c44293b3a4945a457117df8 100644 (file)
@@ -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));
index 090c78bbaef78cb1d84a958afb6c07fb56aad1f6..236cca75f97246dc89891c6e2d726b2f04ee63af 100644 (file)
@@ -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"));
index 5c4f30812453126bb3fe72b0b31ff217d189eab1..1e7a0c5d477e72284fe9e3f1c5a64c2baada0965 100644 (file)
@@ -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;
 }
index bc5e737d8b3ccb8d724bdae3e1334d4a2567f378..2d0ea57584d4a9167ee6f24537633a9698bbb0c5 100644 (file)
@@ -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, "<dird %s", dir->msg);
+    Dmsg1(100, "<dird %s", dir->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");
index b35f9d8d23394a62d674aad16e36076b08aa0f6e..dfc4cd7e4634faa36d0e5bff483a6805e157f5da 100644 (file)
@@ -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 */
index 491fd3dff1e167bb9f30e493aef805ace9fe6d88..a4e30bb07fd0da014713b573e236402f31defc8a 100644 (file)
@@ -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