From: Eric Bollengier Date: Wed, 30 Sep 2009 12:47:21 +0000 (+0200) Subject: Send checksum only when the FD will use it X-Git-Tag: Release-7.0.0~2614 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f27fef9121b3d2dbf681af7261c11b339587e912;p=bacula%2Fbacula Send checksum only when the FD will use it --- diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index 30e1cd1e55..6d809b01ba 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -152,7 +152,11 @@ static int accurate_list_handler(void *ctx, int num_fields, char **row) } /* sending with checksum */ - if (num_fields == 6 && row[5][0] && row[5][1]) { /* skip checksum = '0' */ + if (jcr->use_accurate_chksum + && num_fields == 6 + && row[5][0] /* skip checksum = '0' */ + && row[5][1]) + { jcr->file_bsock->fsend("%s%s%c%s%c%s", row[0], row[1], 0, row[4], 0, row[5]); } else { @@ -162,6 +166,56 @@ static int accurate_list_handler(void *ctx, int num_fields, char **row) return 0; } +/* In this procedure, we check if the current fileset is using + * FileSet-> Include-> Options-> Accurate/Verify/BaseJob=checksum + */ +static bool is_checksum_needed_by_fileset(JCR *jcr) +{ + FILESET *f; + INCEXE *inc; + FOPTS *fopts; + bool in_block=false; + if (!jcr->job || !jcr->job->fileset) { + return false; + } + + f = jcr->job->fileset; + + for (int i=0; i < f->num_includes; i++) { + inc = f->include_items[i]; + + for (int j=0; j < inc->num_opts; j++) { + fopts = inc->opts_list[j]; + + for (char *k=fopts->opts; *k ; k++) { + switch (*k) { + case 'V': /* verify */ + in_block = (jcr->get_JobType() == JT_VERIFY); + break; + case 'J': /* Basejob */ + in_block = (jcr->get_JobLevel() == L_FULL); + break; + case 'C': /* Accurate */ + in_block = (jcr->get_JobLevel() != L_FULL); + break; + case ':': + in_block = false; + break; + case '5': /* MD5 */ + case '1': /* SHA1 */ + if (in_block) { + return true; + } + break; + default: + break; + } + } + } + } + return false; +} + /* * Send current file list to FD * DIR -> FD : accurate files=xxxx @@ -184,6 +238,9 @@ bool send_accurate_current_files(JCR *jcr) if (jcr->get_JobLevel() == L_BASE) { return true; } + + /* Don't send and store the checksum if fileset doesn't require it */ + jcr->use_accurate_chksum = is_checksum_needed_by_fileset(jcr); if (jcr->get_JobLevel() == L_FULL) { /* On Full mode, if no previous base job, no accurate things */ diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index 57d287c92b..f9378d82a2 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -347,6 +347,7 @@ public: bool stats_enabled; /* Keep all job records in a table for long term statistics */ bool no_maxtime; /* Don't check Max*Time for this JCR */ bool keep_sd_auth_key; /* Clear or not the SD auth key after connection*/ + bool use_accurate_chksum; /* Use or not checksum option in accurate code */ #endif /* DIRECTOR_DAEMON */