From: Eric Bollengier Date: Thu, 29 Sep 2022 08:22:14 +0000 (+0200) Subject: Send progress information for Migration and Copy Jobs X-Git-Tag: Beta-15.0.0~434 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=38f694351f35e4d72bacb1b5b09707ad17915491;p=thirdparty%2Fbacula.git Send progress information for Migration and Copy Jobs --- diff --git a/bacula/src/dird/getmsg.c b/bacula/src/dird/getmsg.c index b831689ca..d46a11e96 100644 --- a/bacula/src/dird/getmsg.c +++ b/bacula/src/dird/getmsg.c @@ -294,7 +294,7 @@ int bget_dirmsg(JCR *jcr, BSOCK *bs, BSOCK_CLIENT_TYPE role) continue; } /* Get Progress: files, bytes, bytes/sec */ - if (role==BSOCK_TYPE_FD && bs->msg[0] == 'P') { /* Progress report */ + if (bs->msg[0] == 'P') { /* Progress report */ uint32_t files, bps; uint64_t bytes; if ((sscanf(bs->msg, "Progress JobId=%ld files=%ld bytes=%lld bps=%ld\n", diff --git a/bacula/src/dird/mac.c b/bacula/src/dird/mac.c index 1c08a59d0..cd17fe764 100644 --- a/bacula/src/dird/mac.c +++ b/bacula/src/dird/mac.c @@ -529,6 +529,11 @@ bool do_mac(JCR *jcr) } wsd = wjcr->store_bsock; + /* Send progress information for the Storage Daemon Job, will fill + * information from "status dir" + */ + wsd->fsend("sendprogress\n"); + /* * Start conversation with read Storage daemon */ @@ -538,6 +543,12 @@ bool do_mac(JCR *jcr) goto bail_out; } sd = jcr->store_bsock; + + /* Send progress information for the Storage Daemon Job, will fill + * information from "status dir" + */ + sd->fsend("sendprogress\n"); + if (jcr->client) { jcr->sd_calls_client = jcr->client->sd_calls_client; } diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index 27f1f07b0..a1a4b656b 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -371,15 +371,7 @@ int save_file(JCR *jcr, FF_PKT *ff_pkt, bool top_level) bctx.jcr = jcr; - time_t now = time(NULL); - if (jcr->last_stat_time == 0) { - jcr->last_stat_time = now; - jcr->stat_interval = 30; /* Default 30 seconds */ - } else if (now >= jcr->last_stat_time + jcr->stat_interval) { - jcr->dir_bsock->fsend("Progress JobId=%ld files=%ld bytes=%lld bps=%ld\n", - jcr->JobId, jcr->JobFiles, jcr->JobBytes, jcr->LastRate); - jcr->last_stat_time = now; - } + jcr->sendProgressStatus(); if (jcr->is_canceled() || jcr->is_incomplete()) { Dmsg0(100, "Job canceled by user or marked incomplete.\n"); diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index f318cf6d5..25800af59 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -259,6 +259,7 @@ JCR *new_fd_jcr() /* TODO remove the ifdef as soon as the feature has been well tested */ jcr->set_killable(true); #endif /*DEVELOPER*/ + jcr->stat_interval = 0; /* Always send progress status */ jcr->sd_calls_client_bsock = NULL; jcr->sd_calls_client = false; jcr->ff = init_find_files(); diff --git a/bacula/src/filed/restore.c b/bacula/src/filed/restore.c index ed14c2fd7..057350fa9 100644 --- a/bacula/src/filed/restore.c +++ b/bacula/src/filed/restore.c @@ -465,15 +465,7 @@ void do_restore(JCR *jcr) Dsm_check(200); while ((bget_ret = fdmsg->bget_msg(&bmsg)) >= 0 && !job_canceled(jcr)) { - time_t now = time(NULL); - if (jcr->last_stat_time == 0) { - jcr->last_stat_time = now; - jcr->stat_interval = 30; /* Default 30 seconds */ - } else if (now >= jcr->last_stat_time + jcr->stat_interval) { - jcr->dir_bsock->fsend("Progress JobId=%ld files=%ld bytes=%lld bps=%ld\n", - jcr->JobId, jcr->JobFiles, jcr->JobBytes, jcr->LastRate); - jcr->last_stat_time = now; - } + jcr->sendProgressStatus(); /* Remember previous stream type */ rctx.prev_stream = rctx.stream; diff --git a/bacula/src/filed/verify_vol.c b/bacula/src/filed/verify_vol.c index 5adf8d5dc..305e674b1 100644 --- a/bacula/src/filed/verify_vol.c +++ b/bacula/src/filed/verify_vol.c @@ -350,6 +350,8 @@ void do_verify_volume(JCR *jcr) * Get a record from the Storage daemon */ while ((bget_ret = fdmsg->bget_msg(&bmsg)) >= 0 && !job_canceled(jcr)) { + jcr->sendProgressStatus(); + /* Remember previous stream type */ vctx.prev_stream = vctx.stream; diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index 4e657d6f6..a37414239 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -358,7 +358,10 @@ public: char *job_group; /* Specific permission for a job */ POOLMEM *StatusErrMsg; /* Error message displayed in the job report */ char StatusInfo[MAX_NAME_LENGTH]; /* Additionnal information about the error status */ + time_t last_stat_time; /* Last time stats sent to Dir */ + time_t stat_interval; /* Stats send interval default 30s, set to -1 to disable */ uint32_t getErrors() { return JobErrors + SDErrors; }; /* Get error count */ + bool sendProgressStatus(); /* Send the progress status to the dir (SD/FD) */ /* Daemon specific part of JCR */ /* This should be empty in the library */ @@ -466,8 +469,6 @@ public: BXATTR *bxattr; /* Extended Attributes for backup/restore */ int32_t last_type; /* type of last file saved/verified */ int incremental; /* set if incremental for SINCE */ - time_t last_stat_time; /* Last time stats sent to Dir */ - time_t stat_interval; /* Stats send interval */ utime_t mtime; /* begin time for SINCE */ int listing; /* job listing in estimate */ long Ticket; /* Ticket */ diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index 2724126c8..3e5afa4b7 100644 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -406,6 +406,7 @@ JCR *new_jcr(int size, JCR_free_HANDLER *daemon_free_jcr) jcr->setJobLevel(L_NONE); jcr->setJobStatus(JS_Created); /* ready to run */ jcr->job_task = JOB_TASK_ZERO; + jcr->stat_interval = -1; #ifndef HAVE_WIN32 struct sigaction sigtimer; sigtimer.sa_flags = 0; @@ -901,6 +902,32 @@ static int get_status_priority(int JobStatus) return priority; } +#define Job_Progress "Progress JobId=%ld files=%ld bytes=%lld bps=%ld\n" +/* + * Send Current progress status + */ +bool JCR::sendProgressStatus() +{ + if (stat_interval < 0) { /* Disabled */ + return true; + } + if (dir_bsock) { + time_t now = time(NULL); + if (stat_interval == 0) { + stat_interval = 30; /* Default 30 seconds */ + } + if (last_stat_time == 0) { + last_stat_time = now; + + } else if (now >= last_stat_time + stat_interval) { + dir_bsock->fsend("Progress JobId=%ld files=%ld bytes=%lld bps=%ld\n", + JobId, JobFiles, JobBytes, LastRate); + last_stat_time = now; + } + } + return true; +} + /* * Send Job status to Director * ATTN: Only the SD like components are expected to send there job status diff --git a/bacula/src/stored/append.c b/bacula/src/stored/append.c index 4ec9555ae..9dd474af2 100644 --- a/bacula/src/stored/append.c +++ b/bacula/src/stored/append.c @@ -242,6 +242,9 @@ fi_checked: rec.FileIndex, rec.VolSessionId, stream_to_ascii(buf1, rec.Stream,rec.FileIndex), rec.data_len); + + jcr->sendProgressStatus(); + /* * Check for any last minute Storage daemon preparation * of the files being backed up proir to doing so. E.g. diff --git a/bacula/src/stored/dircmd.c b/bacula/src/stored/dircmd.c index 8319bd763..23ceecc16 100644 --- a/bacula/src/stored/dircmd.c +++ b/bacula/src/stored/dircmd.c @@ -97,6 +97,7 @@ static void label_volume_if_ok(DCR *dcr, char *oldname, int Slot, int relabel); static bool try_autoload_device(JCR *jcr, DCR *dcr, int slot, const char *VolName); static void send_dir_busy_message(BSOCK *dir, DEVICE *dev); +static bool sd_sendprogress_cmd(JCR *jcr); bool user_shstore_lock(DCR *dcr); void user_shstore_unlock(DCR *dcr); bool dedup_cmd(JCR *jcr); /* BEEF */ @@ -148,6 +149,7 @@ static struct dir_cmds cmds[] = { {"run", run_cmd, 0}, {"statistics", collect_cmd, 0}, {"store_mngr", query_store, 0}, + {"sendprogress", sd_sendprogress_cmd, 0}, // {"query", query_cmd, 0}, {NULL, NULL} /* list terminator */ }; @@ -2054,6 +2056,14 @@ static void send_dir_busy_message(BSOCK *dir, DEVICE *dev) } } +/* Send progress information to the director if needed (for copy/migration in general) */ +static bool sd_sendprogress_cmd(JCR *jcr) +{ + jcr->stat_interval = 60; + return true; +} + + #if COMMUNITY bool user_shstore_lock(DCR *dcr) { return true; } diff --git a/bacula/src/stored/fd_cmds.c b/bacula/src/stored/fd_cmds.c index bff3cadb3..b2d7eb2af 100644 --- a/bacula/src/stored/fd_cmds.c +++ b/bacula/src/stored/fd_cmds.c @@ -130,7 +130,7 @@ void run_job(JCR *jcr) * Otherwise we do the commands that the client sends * which are for normal backup or restore jobs. */ - Dmsg3(050, "==== JobType=%c run_job=%d sd_client=%d\n", jcr->getJobType(), jcr->JobId, jcr->sd_client); + Dmsg3(50, "==== JobType=%c run_job=%d sd_client=%d\n", jcr->getJobType(), jcr->JobId, jcr->sd_client); if (jcr->is_JobType(JT_BACKUP) && jcr->sd_client) { jcr->session_opened = true; Dmsg0(050, "Do: receive for 3000 OK data then append\n"); diff --git a/bacula/src/stored/read.c b/bacula/src/stored/read.c index 28e9a94ab..7dc167ff7 100644 --- a/bacula/src/stored/read.c +++ b/bacula/src/stored/read.c @@ -381,5 +381,6 @@ static bool mac_record_cb(DCR *dcr, DEV_RECORD *rec) FI_to_ascii(buf1, rec->FileIndex), rec->VolSessionId, stream_to_ascii(buf2, rec->Stream, rec->FileIndex), rec->data_len); + jcr->sendProgressStatus(); return ok; }