From 4bdec3244306439a51253c9004418f974ea590cf Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Thu, 2 Jul 2009 11:36:26 +0000 Subject: [PATCH] Make estimate command accurate compatible. Should fix #1318 git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8947 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/backup.c | 5 +++-- bacula/src/dird/protos.h | 2 ++ bacula/src/dird/ua_cmds.c | 9 +++++++++ bacula/src/filed/accurate.c | 8 ++++++-- bacula/src/filed/estimate.c | 6 ++++++ bacula/src/filed/protos.h | 1 + bacula/technotes | 1 + 7 files changed, 28 insertions(+), 4 deletions(-) diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index 2c30e83aa1..029dfa0c89 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -144,8 +144,9 @@ bool send_accurate_current_files(JCR *jcr) Jmsg(jcr, M_FATAL, 0, _("Cannot find previous jobids.\n")); return false; } - Jmsg(jcr, M_INFO, 0, _("Sending Accurate information.\n")); - + if (jcr->JobId) { /* display the message only for real jobs */ + Jmsg(jcr, M_INFO, 0, _("Sending Accurate information.\n")); + } /* to be able to allocate the right size for htable */ POOLMEM *nb = get_pool_memory(PM_FNAME); *nb = 0; /* clear buffer */ diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index dc66f8d3c5..ba73912b27 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -57,6 +57,8 @@ extern bool do_backup_init(JCR *jcr); extern bool do_backup(JCR *jcr); extern void backup_cleanup(JCR *jcr, int TermCode); extern void update_bootstrap_file(JCR *jcr); +extern bool send_accurate_current_files(JCR *jcr); + /* vbackup.c */ extern bool do_vbackup_init(JCR *jcr); diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index ca513b6458..2e5defaa99 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -1274,6 +1274,15 @@ static int estimate_cmd(UAContext *ua, const char *cmd) goto bail_out; } + /* + * If the job is in accurate mode, we send the list of + * all files to FD. + */ + jcr->accurate = job->accurate; + if (!send_accurate_current_files(jcr)) { + goto bail_out; + } + bnet_fsend(jcr->file_bsock, "estimate listing=%d\n", listing); while (bnet_recv(jcr->file_bsock) >= 0) { ua->send_msg("%s", jcr->file_bsock->msg); diff --git a/bacula/src/filed/accurate.c b/bacula/src/filed/accurate.c index d7ff043757..e36ad80e5f 100644 --- a/bacula/src/filed/accurate.c +++ b/bacula/src/filed/accurate.c @@ -128,12 +128,17 @@ bool accurate_send_deleted_list(JCR *jcr) term_find_files(ff_pkt); bail_out: /* TODO: clean htable when this function is not reached ? */ + accurate_free(jcr); + return true; +} + +void accurate_free(JCR *jcr) +{ if (jcr->file_list) { jcr->file_list->destroy(); free(jcr->file_list); jcr->file_list = NULL; } - return true; } static bool accurate_add_file(JCR *jcr, char *fname, char *lstat) @@ -231,7 +236,6 @@ int accurate_cmd(JCR *jcr) if (!jcr->accurate || job_canceled(jcr) || jcr->get_JobLevel()==L_FULL) { return true; } - if (sscanf(dir->msg, "accurate files=%ld", &nb) != 1) { dir->fsend(_("2991 Bad accurate command\n")); return false; diff --git a/bacula/src/filed/estimate.c b/bacula/src/filed/estimate.c index a4fd06d8da..c4fe78f905 100644 --- a/bacula/src/filed/estimate.c +++ b/bacula/src/filed/estimate.c @@ -50,8 +50,14 @@ int make_estimate(JCR *jcr) set_jcr_job_status(jcr, JS_Running); set_find_options((FF_PKT *)jcr->ff, jcr->incremental, jcr->mtime); + /* in accurate mode, we overwrite the find_one check function */ + if (jcr->accurate) { + set_find_changed_function((FF_PKT *)jcr->ff, accurate_check_file); + } + stat = find_files(jcr, (FF_PKT *)jcr->ff, tally_file, NULL); + accurate_free(jcr); return stat; } diff --git a/bacula/src/filed/protos.h b/bacula/src/filed/protos.h index 72300f18c6..b5daaa8c19 100644 --- a/bacula/src/filed/protos.h +++ b/bacula/src/filed/protos.h @@ -54,6 +54,7 @@ bool parse_acl_stream(JCR *jcr, int stream); bool accurate_send_deleted_list(JCR *jcr); bool accurate_check_file(JCR *jcr, FF_PKT *ff_pkt); bool accurate_mark_file_as_seen(JCR *jcr, char *fname); +void accurate_free(JCR *jcr); /* from backup.c */ bool encode_and_send_attributes(JCR *jcr, FF_PKT *ff_pkt, int &data_stream); diff --git a/bacula/technotes b/bacula/technotes index 959cbf212b..f229aecb4d 100644 --- a/bacula/technotes +++ b/bacula/technotes @@ -4,6 +4,7 @@ General: 02Jul09 kes Another fix for bug #1311 to get the correct last_full_time +ebl Make estimate command accurate compatible. Should fix #1318 01Jul09 kes Fix bug #1317 Allow duplicate jobs = no does not work kes Eliminate double job report when do_xxx_init() returns failure -- 2.39.5