{
POOL_DBR pr;
+ /* If we find a job to migrate it is previous_jr.JobId */
if (!get_job_to_migrate(jcr)) {
return false;
}
POOL *pool;
char ed1[100];
BSOCK *sd;
- JOB *job, *tjob;
- JCR *tjcr;
+ JOB *job, *prev_job;
+ JCR *prev_jcr;
if (jcr->previous_jr.JobId == 0) {
jcr->JobStatus = JS_Terminated;
migration_cleanup(jcr, jcr->JobStatus);
return true; /* no work */
}
- Dmsg4(000, "Target: Name=%s JobId=%d Type=%c Level=%c\n",
+
+ Dmsg4(000, "Previous:: Name=%s JobId=%d Type=%c Level=%c\n",
jcr->previous_jr.Name, jcr->previous_jr.JobId,
jcr->previous_jr.JobType, jcr->previous_jr.JobLevel);
LockRes();
job = (JOB *)GetResWithName(R_JOB, jcr->jr.Name);
- tjob = (JOB *)GetResWithName(R_JOB, jcr->previous_jr.Name);
+ prev_job = (JOB *)GetResWithName(R_JOB, jcr->previous_jr.Name);
UnlockRes();
- if (!job || !tjob) {
+ if (!job || !prev_job) {
return false;
}
/*
- * Target jcr is the new Job that corresponds to the original
- * target job. It "runs" at the same time as the current
+ * prev_jcr is the new Job that corresponds to the original
+ * job. It "runs" at the same time as the current
* migration job and becomes a new backup job that replaces
* the original backup job. Most operations on the current
- * migration jcr are also done on the target jcr.
+ * migration jcr are also done on the prev_jcr.
*/
- tjcr = jcr->previous_jcr = new_jcr(sizeof(JCR), dird_free_jcr);
- memcpy(&tjcr->previous_jr, &jcr->previous_jr, sizeof(tjcr->previous_jr));
+ prev_jcr = jcr->previous_jcr = new_jcr(sizeof(JCR), dird_free_jcr);
+ memcpy(&prev_jcr->previous_jr, &jcr->previous_jr, sizeof(prev_jcr->previous_jr));
- /* Turn the tjcr into a "real" job */
- set_jcr_defaults(tjcr, tjob);
- if (!setup_job(tjcr)) {
+ /* Turn the prev_jcr into a "real" job */
+ set_jcr_defaults(prev_jcr, prev_job);
+ if (!setup_job(prev_jcr)) {
return false;
}
/* Set output PoolId and FileSetId. */
- tjcr->jr.PoolId = jcr->jr.PoolId;
- tjcr->jr.FileSetId = jcr->jr.FileSetId;
+ prev_jcr->jr.PoolId = jcr->jr.PoolId;
+ prev_jcr->jr.FileSetId = jcr->jr.FileSetId;
/*
* Get the PoolId used with the original job. Then
* find the pool name from the database record.
*/
memset(&pr, 0, sizeof(pr));
- pr.PoolId = tjcr->previous_jr.PoolId;
+ pr.PoolId = prev_jcr->previous_jr.PoolId;
if (!db_get_pool_record(jcr, jcr->db, &pr)) {
Jmsg(jcr, M_FATAL, 0, _("Pool for JobId %s not in database. ERR=%s\n"),
edit_int64(pr.PoolId, ed1), db_strerror(jcr->db));
/* ***FIXME*** */
/* If pool storage specified, use it for restore */
- copy_storage(tjcr, pool->storage);
+ copy_storage(prev_jcr, pool->storage);
/* If the original backup pool has a NextPool, make sure a
* record exists in the database.
* put the "NextPool" resource pointer in our jcr so that we
* can pull the Storage reference from it.
*/
- tjcr->pool = jcr->pool = pool->NextPool;
- tjcr->jr.PoolId = jcr->jr.PoolId = pr.PoolId;
+ prev_jcr->pool = jcr->pool = pool->NextPool;
+ prev_jcr->jr.PoolId = jcr->jr.PoolId = pr.PoolId;
}
/* If pool storage specified, use it instead of job storage for backup */
edit_uint64(jcr->JobId, ed1), jcr->Job);
set_jcr_job_status(jcr, JS_Running);
- set_jcr_job_status(tjcr, JS_Running);
+ set_jcr_job_status(prev_jcr, JS_Running);
Dmsg2(000, "JobId=%d JobLevel=%c\n", jcr->jr.JobId, jcr->jr.JobLevel);
if (!db_update_job_start_record(jcr, jcr->db, &jcr->jr)) {
Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db));
return false;
}
- if (!db_update_job_start_record(tjcr, tjcr->db, &tjcr->jr)) {
- Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(tjcr->db));
+ if (!db_update_job_start_record(prev_jcr, prev_jcr->db, &prev_jcr->jr)) {
+ Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(prev_jcr->db));
return false;
}
*/
Dmsg0(110, "Open connection with storage daemon\n");
set_jcr_job_status(jcr, JS_WaitSD);
- set_jcr_job_status(tjcr, JS_WaitSD);
+ set_jcr_job_status(prev_jcr, JS_WaitSD);
/*
* Start conversation with Storage daemon
*/
* Now start a job with the Storage daemon
*/
Dmsg2(000, "Read store=%s, write store=%s\n",
- ((STORE *)tjcr->storage->first())->hdr.name,
+ ((STORE *)prev_jcr->storage->first())->hdr.name,
((STORE *)jcr->storage->first())->hdr.name);
- if (!start_storage_daemon_job(jcr, tjcr->storage, jcr->storage)) {
+ if (!start_storage_daemon_job(jcr, prev_jcr->storage, jcr->storage)) {
return false;
}
Dmsg0(150, "Storage daemon connection OK\n");
}
set_jcr_job_status(jcr, JS_Running);
- set_jcr_job_status(tjcr, JS_Running);
+ set_jcr_job_status(prev_jcr, JS_Running);
/* Pickup Job termination data */
/* Note, the SD stores in jcr->JobFiles/ReadBytes/JobBytes/Errors */
const char *sql_jobids_from_job =
"SELECT DISTINCT Job.JobId FROM Job,Pool"
- " WHERE Job.Name=%s AND Pool.Name='%s' AND Job.PoolId=Pool.PoolId"
+ " WHERE Job.Name='%s' AND Pool.Name='%s' AND Job.PoolId=Pool.PoolId"
" ORDER by Job.StartTime";
* that have been matched by the regex, so now we need
* to look up their jobids.
*/
- JobIds = get_pool_memory(PM_MESSAGE);
JobIds[0] = 0;
foreach_dlist(item, item_chain) {
Dmsg1(000, "Got Job: %s\n", item->item);
goto ok_out;
}
Dmsg1(000, "Job Jobids=%s\n", JobIds);
- free_pool_memory(JobIds);
delete item_chain;
break;
case MT_SMALLEST_VOL:
Mmsg(query, sql_smallest_vol, jcr->pool->hdr.name);
- JobIds = get_pool_memory(PM_MESSAGE);
JobIds[0] = 0;
if (!db_sql_query(jcr->db, query.c_str(), jobid_handler, (void *)JobIds)) {
Jmsg(jcr, M_FATAL, 0,
break;
case MT_OLDEST_VOL:
Mmsg(query, sql_oldest_vol, jcr->pool->hdr.name);
- JobIds = get_pool_memory(PM_MESSAGE);
JobIds[0] = 0;
if (!db_sql_query(jcr->db, query.c_str(), jobid_handler, (void *)JobIds)) {
Jmsg(jcr, M_FATAL, 0,
break;
case MT_POOL_OCCUPANCY:
Mmsg(query, sql_pool_bytes, jcr->pool->hdr.name);
- JobIds = get_pool_memory(PM_MESSAGE);
JobIds[0] = 0;
if (!db_sql_query(jcr->db, query.c_str(), jobid_handler, (void *)JobIds)) {
Jmsg(jcr, M_FATAL, 0,
set_jcr_job_status(prev_jcr, TermCode);
-
update_job_end_record(prev_jcr);
Mmsg(query, "UPDATE Job SET StartTime='%s',EndTime='%s',"
if (RunTime <= 0) {
kbps = 0;
} else {
- kbps = (double)jcr->jr.JobBytes / (1000 * RunTime);
+ kbps = (double)jcr->SDJobBytes / (1000 * RunTime);
}
jcr->JobPriority,
edit_uint64_with_commas(jcr->SDJobFiles, ec1),
edit_uint64_with_commas(jcr->SDJobBytes, ec2),
- edit_uint64_with_suffix(jcr->jr.JobBytes, ec3),
+ edit_uint64_with_suffix(jcr->SDJobBytes, ec3),
(float)kbps,
prev_jcr ? prev_jcr->VolumeName : "",
jcr->VolSessionId,
sd_term_msg,
term_code);
- Dmsg1(100, "Leave migrate_cleanup() previous_jcr=0x%x\n", jcr->previous_jcr);
+ Dmsg1(000, "migrate_cleanup() previous_jcr=0x%x\n", jcr->previous_jcr);
if (jcr->previous_jcr) {
- free_jcr(jcr->previous_jcr);
+// free_jcr(jcr->previous_jcr);
+// jcr->previous_jcr = NULL;
}
+ Dmsg0(000, "Leave migrate_cleanup()\n");
}
pool_ctl[pool].max_used = pool_ctl[pool].in_use;
}
V(mutex);
- Dmsg3(1800, "sm_get_pool_memory reuse %x to %s:%d\n", buf, fname, lineno);
+ Dmsg3(1800, "sm_get_pool_memory reuse %p to %s:%d\n", buf, fname, lineno);
sm_new_owner(fname, lineno, (char *)buf);
return (POOLMEM *)((char *)buf+HEAD_SIZE);
}
pool_ctl[pool].max_used = pool_ctl[pool].in_use;
}
V(mutex);
- Dmsg3(1800, "sm_get_pool_memory give %x to %s:%d\n", buf, fname, lineno);
+ Dmsg3(1800, "sm_get_pool_memory give %p to %s:%d\n", buf, fname, lineno);
return (POOLMEM *)((char *)buf+HEAD_SIZE);
}
/* Don't let him free the same buffer twice */
for (next=pool_ctl[pool].free_buf; next; next=next->next) {
if (next == buf) {
- Dmsg4(1800, "bad free_pool_memory %x pool=%d from %s:%d\n", buf, pool, fname, lineno);
+ Dmsg4(1800, "free_pool_memory %p pool=%d from %s:%d\n", buf, pool, fname, lineno);
+ Dmsg4(1800, "bad free_pool_memory %p pool=%d from %s:%d\n", buf, pool, fname, lineno);
V(mutex); /* unblock the pool */
ASSERT(next != buf); /* attempt to free twice */
}
buf->next = pool_ctl[pool].free_buf;
pool_ctl[pool].free_buf = buf;
}
- Dmsg4(1800, "free_pool_memory %x pool=%d from %s:%d\n", buf, pool, fname, lineno);
+ Dmsg4(1800, "free_pool_memory %p pool=%d from %s:%d\n", buf, pool, fname, lineno);
V(mutex);
}
buf->next = pool_ctl[pool].free_buf;
pool_ctl[pool].free_buf = buf;
}
- Dmsg2(1800, "free_pool_memory %x pool=%d\n", buf, pool);
+ Dmsg2(1800, "free_pool_memory %p pool=%d\n", buf, pool);
V(mutex);
}
V(mutex);
Emsg1(M_ABORT, 0, _("Out of memory requesting %d bytes\n"), size);
}
- Dmsg2(900, "Old buf=0x%x new buf=0x%x\n", cp, buf);
+ Dmsg2(900, "Old buf=%p new buf=%p\n", cp, buf);
((struct abufhead *)buf)->ablen = size;
pool = ((struct abufhead *)buf)->pool;
if (size > pool_ctl[pool].max_allocated) {
}
mem = buf+HEAD_SIZE;
V(mutex);
- Dmsg3(900, "Old buf=0x%x new buf=0x%x mem=0x%x\n", cp, buf, mem);
+ Dmsg3(900, "Old buf=%p new buf=%p mem=%p\n", cp, buf, mem);
}
int POOL_MEM::strcat(const char *str)
add_msg_dest(daemon_msgs, MD_STDOUT, i, NULL, NULL);
}
#endif
- Dmsg1(050, "Create daemon global message resource 0x%x\n", daemon_msgs);
+ Dmsg1(050, "Create daemon global message resource %p\n", daemon_msgs);
return;
}
daemon_msgs->dest_chain = temp_chain;
memcpy(daemon_msgs->send_msg, msg->send_msg, sizeof(msg->send_msg));
}
- Dmsg2(250, "Copy message resource 0x%x to 0x%x\n", msg, temp_chain);
+ Dmsg2(250, "Copy message resource %p to %p\n", msg, temp_chain);
}
for (d=msg->dest_chain; d; d=d->next) {
if (dest_code == d->dest_code && ((where == NULL && d->where == NULL) ||
(strcmp(where, d->where) == 0))) {
- Dmsg4(850, "Add to existing d=%x msgtype=%d destcode=%d where=%s\n",
+ Dmsg4(850, "Add to existing d=%p msgtype=%d destcode=%d where=%s\n",
d, msg_type, dest_code, NPRT(where));
set_bit(msg_type, d->msg_types);
set_bit(msg_type, msg->send_msg); /* set msg_type bit in our local */
if (mail_cmd) {
d->mail_cmd = bstrdup(mail_cmd);
}
- Dmsg5(850, "add new d=%x msgtype=%d destcode=%d where=%s mailcmd=%s\n",
+ Dmsg5(850, "add new d=%p msgtype=%d destcode=%d where=%s mailcmd=%s\n",
d, msg_type, dest_code, NPRT(where), NPRT(d->mail_cmd));
msg->dest_chain = d;
}
DEST *d;
for (d=msg->dest_chain; d; d=d->next) {
- Dmsg2(850, "Remove_msg_dest d=%x where=%s\n", d, NPRT(d->where));
+ Dmsg2(850, "Remove_msg_dest d=%p where=%s\n", d, NPRT(d->where));
if (bit_is_set(msg_type, d->msg_types) && (dest_code == d->dest_code) &&
((where == NULL && d->where == NULL) ||
(strcmp(where, d->where) == 0))) {
- Dmsg3(850, "Found for remove d=%x msgtype=%d destcode=%d\n",
+ Dmsg3(850, "Found for remove d=%p msgtype=%d destcode=%d\n",
d, msg_type, dest_code);
clear_bit(msg_type, d->msg_types);
Dmsg0(850, "Return rem_msg_dest\n");
POOLMEM *cmd, *line;
int len, stat;
- Dmsg1(850, "Close_msg jcr=0x%x\n", jcr);
+ Dmsg1(580, "Close_msg jcr=%p\n", jcr);
if (jcr == NULL) { /* NULL -> global chain */
msgs = daemon_msgs;
if (msgs == NULL) {
return;
}
- Dmsg1(850, "===Begin close msg resource at 0x%x\n", msgs);
+ Dmsg1(850, "===Begin close msg resource at %p\n", msgs);
cmd = get_pool_memory(PM_MESSAGE);
for (d=msgs->dest_chain; d; ) {
if (d->fd) {
P(msg_queue_mutex);
jcr->msg_queue->append(item);
V(msg_queue_mutex);
-// Dmsg1(000, "queue item=%lu\n", (long unsigned)item);
}
free_memory(pool_buf);
}
P(msg_queue_mutex);
jcr->dequeuing = true;
foreach_dlist(item, jcr->msg_queue) {
-// Dmsg1(000, "dequeue item=%lu\n", (long unsigned)item);
Jmsg(jcr, item->type, item->mtime, "%s", item->msg);
}
jcr->msg_queue->destroy();