From 65052a6823fd17d1e53dded33020646853326b7c Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Mon, 4 Dec 2006 13:00:01 +0000 Subject: [PATCH] kes Add job report indication of whether or not VSS and Encryption were used by the FD. kes Modify sparseBlock variable name to make the code clearer. kes Add more sparse tests to regress using gigaslam sparse file generator. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3745 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/dird/backup.c | 20 +++++++++++++++++--- bacula/src/filed/backup.c | 11 ++++++----- bacula/src/filed/job.c | 14 ++++++++------ bacula/src/filed/pythonfd.c | 6 +++--- bacula/src/jcr.h | 2 ++ bacula/technotes-1.39 | 5 +++++ 6 files changed, 41 insertions(+), 17 deletions(-) diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index 641d8fc9c5..1975e5b078 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -53,8 +53,11 @@ static char storaddr[] = "storage address=%s port=%d ssl=%d\n"; static char OKbackup[] = "2000 OK backup\n"; static char OKstore[] = "2000 OK storage\n"; static char EndJob[] = "2800 End Job TermCode=%d JobFiles=%u " + "ReadBytes=%lld JobBytes=%lld Errors=%u " + "VSS=%d Encrypt=%d\n"; +/* Pre 1.39.29 (04Dec06) EndJob */ +static char OldEndJob[] = "2800 End Job TermCode=%d JobFiles=%u " "ReadBytes=%lld JobBytes=%lld Errors=%u\n"; - /* * Called here before the job is run to do the job * specific setup. @@ -259,12 +262,17 @@ int wait_for_job_termination(JCR *jcr) bool fd_ok = false; uint32_t JobFiles, Errors; uint64_t ReadBytes, JobBytes; + int VSS = 0; + int Encrypt = 0; set_jcr_job_status(jcr, JS_Running); /* Wait for Client to terminate */ while ((n = bget_dirmsg(fd)) >= 0) { - if (!fd_ok && sscanf(fd->msg, EndJob, &jcr->FDJobStatus, &JobFiles, - &ReadBytes, &JobBytes, &Errors) == 5) { + if (!fd_ok && + (sscanf(fd->msg, EndJob, &jcr->FDJobStatus, &JobFiles, + &ReadBytes, &JobBytes, &Errors, &VSS, &Encrypt) == 7 || + sscanf(fd->msg, OldEndJob, &jcr->FDJobStatus, &JobFiles, + &ReadBytes, &JobBytes, &Errors) == 5)) { fd_ok = true; set_jcr_job_status(jcr, jcr->FDJobStatus); Dmsg1(100, "FDStatus=%c\n", (char)jcr->JobStatus); @@ -292,6 +300,8 @@ int wait_for_job_termination(JCR *jcr) jcr->Errors = Errors; jcr->ReadBytes = ReadBytes; jcr->JobBytes = JobBytes; + jcr->VSS = VSS; + jcr->Encrypt = Encrypt; } else { Jmsg(jcr, M_FATAL, 0, _("No Job status returned from FD.\n")); } @@ -446,6 +456,8 @@ void backup_cleanup(JCR *jcr, int TermCode) " SD Bytes Written: %s (%sB)\n" " Rate: %.1f KB/s\n" " Software Compression: %s\n" +" VSS: %s\n" +" Encryption: %s\n" " Volume name(s): %s\n" " Volume Session Id: %d\n" " Volume Session Time: %d\n" @@ -478,6 +490,8 @@ void backup_cleanup(JCR *jcr, int TermCode) edit_uint64_with_suffix(jcr->SDJobBytes, ec6), (float)kbps, compress, + jcr->VSS?"yes":"no", + jcr->Encrypt?"yes":"no", jcr->VolumeName, jcr->VolSessionId, jcr->VolSessionTime, diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index 62ebcf6fcf..343552ed6c 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -595,7 +595,8 @@ static int save_file(FF_PKT *ff_pkt, void *vjcr, bool top_level) * We return 1 on sucess and 0 on errors. * * ***FIXME*** - * We use ff_pkt->statp.st_size when FO_SPARSE. + * We use ff_pkt->statp.st_size when FO_SPARSE to know when to stop + * reading. * Currently this is not a problem as the only other stream, resource forks, * are not handled as sparse files. */ @@ -720,23 +721,23 @@ int send_data(JCR *jcr, int stream, FF_PKT *ff_pkt, DIGEST *digest, * Read the file data */ while ((sd->msglen=(uint32_t)bread(&ff_pkt->bfd, rbuf, rsize)) > 0) { - bool sparseBlock = false; /* Check for sparse blocks */ if (ff_pkt->flags & FO_SPARSE) { ser_declare; + bool haveBlock = true; if (sd->msglen == rsize && fileAddr+sd->msglen < (uint64_t)ff_pkt->statp.st_size || ((ff_pkt->type == FT_RAW || ff_pkt->type == FT_FIFO) && (uint64_t)ff_pkt->statp.st_size == 0)) { - sparseBlock = is_buf_zero(rbuf, rsize); + haveBlock = !is_buf_zero(rbuf, rsize); } - if (!sparseBlock) { + if (haveBlock) { ser_begin(wbuf, SPARSE_FADDR_SIZE); ser_uint64(fileAddr); /* store fileAddr in begin of buffer */ } fileAddr += sd->msglen; /* update file address */ - if (sparseBlock) { + if (!haveBlock) { continue; /* skip block of zeros */ } } diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index f6cb4a91a3..6ceacea896 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -137,7 +137,8 @@ static char OKstore[] = "2000 OK storage\n"; static char OKjob[] = "2000 OK Job %s (%s) %s,%s,%s"; static char OKsetdebug[] = "2000 OK setdebug=%d\n"; static char BADjob[] = "2901 Bad Job\n"; -static char EndJob[] = "2800 End Job TermCode=%d JobFiles=%u ReadBytes=%s JobBytes=%s Errors=%u\n"; +static char EndJob[] = "2800 End Job TermCode=%d JobFiles=%u ReadBytes=%s" + " JobBytes=%s Errors=%u VSS=%d Encrypt=%d\n"; static char OKRunBefore[] = "2000 OK RunBefore\n"; static char OKRunBeforeNow[] = "2000 OK RunBeforeNow\n"; static char OKRunAfter[] = "2000 OK RunAfter\n"; @@ -1269,7 +1270,7 @@ static int storage_cmd(JCR *jcr) /* - * Do a backup. For now, we handle only Full and Incremental. + * Do a backup. */ static int backup_cmd(JCR *jcr) { @@ -1278,17 +1279,17 @@ static int backup_cmd(JCR *jcr) int ok = 0; int SDJobStatus; char ed1[50], ed2[50]; + bool bDoVSS = false; #if defined(WIN32_VSS) // capture state here, if client is backed up by multiple directors // and one enables vss and the other does not then enable_vss can change // between here and where its evaluated after the job completes. - bool bDoVSS = false; - bDoVSS = g_pVSSClient && enable_vss; - if (bDoVSS) + if (bDoVSS) { /* Run only one at a time */ P(vss_mutex); + } #endif set_jcr_job_status(jcr, JS_Blocked); @@ -1460,7 +1461,8 @@ cleanup: bnet_fsend(dir, EndJob, jcr->JobStatus, jcr->JobFiles, edit_uint64(jcr->ReadBytes, ed1), - edit_uint64(jcr->JobBytes, ed2), jcr->Errors); + edit_uint64(jcr->JobBytes, ed2), jcr->Errors, (int)bDoVSS, + jcr->pki_encrypt); Dmsg1(110, "End FD msg: %s\n", dir->msg); return 0; /* return and stop command loop */ diff --git a/bacula/src/filed/pythonfd.c b/bacula/src/filed/pythonfd.c index 8e4469956d..0ea3fc2892 100644 --- a/bacula/src/filed/pythonfd.c +++ b/bacula/src/filed/pythonfd.c @@ -201,7 +201,7 @@ static PyObject *job_write(PyObject *self, PyObject *args) char *text = NULL; if (!PyArg_ParseTuple(args, "s:write", &text)) { - Dmsg0(000, "Parse tuple error in job_write\n"); + Pmsg0(000, "Parse tuple error in job_write\n"); return NULL; } if (text) { @@ -219,7 +219,7 @@ static PyObject *set_job_events(PyObject *self, PyObject *arg) Dmsg0(100, "In set_job_events.\n"); if (!PyArg_ParseTuple(arg, "O", &eObject)) { - Dmsg0(000, "Parse error looking for Object argument\n"); + Pmsg0(000, "Parse error looking for Object argument\n"); return NULL; } jcr = get_jcr_from_PyObject(self); @@ -268,7 +268,7 @@ int generate_job_event(JCR *jcr, const char *event) if (result == NULL) { if (PyErr_Occurred()) { PyErr_Print(); - Dmsg1(000, "Error in Python method %s\n", event); + Pmsg1(000, "Error in Python method %s\n", event); } } else { stat = 1; diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index 916f6b9416..4380efc723 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -249,6 +249,8 @@ public: bool needs_sd; /* set if SD needed by Job */ bool cloned; /* set if cloned */ bool unlink_bsr; /* Unlink bsr file created */ + bool VSS; /* VSS used by FD */ + bool Encrypt; /* Encryption used by FD */ #endif /* DIRECTOR_DAEMON */ diff --git a/bacula/technotes-1.39 b/bacula/technotes-1.39 index a609f9044c..aa65c156e0 100644 --- a/bacula/technotes-1.39 +++ b/bacula/technotes-1.39 @@ -2,6 +2,11 @@ General: 04Dec06 +kes Add job report indication of whether or not VSS and Encryption were + used by the FD. +kes Modify sparseBlock variable name to make the code clearer. +kes Add more sparse tests to regress using gigaslam sparse file + generator. kes Enable data encryption code. kes Add gigaslam.c to src/tools. It creates a 1GB file that contains only two blocks -- i.e. it is a real sparse file. -- 2.39.5