From: Kern Sibbald Date: Tue, 8 May 2007 07:07:37 +0000 (+0000) Subject: kes Merge patch from Sergey Svishchev that preserves X-Git-Tag: Release-7.0.0~6407 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ecf33f65329d2ac71403eb26962800c9c2f4664e;p=bacula%2Fbacula kes Merge patch from Sergey Svishchev that preserves the original jobb's FileSetId. kes Merge patch from Sergey Svishchev that implements spooling in migration jobs. Not yet tested. kes Merge patch from Jorj Bauer that implements reading conf file from a pipe. However, do it with open_bpipe() rather than popen. Not yet tested. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4724 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index 62e49cec39..ee4c826812 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -274,12 +274,12 @@ bool db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) if (jr->JobId == 0) { Mmsg(mdb->cmd, "SELECT VolSessionId,VolSessionTime," "PoolId,StartTime,EndTime,JobFiles,JobBytes,JobTDate,Job,JobStatus," -"Type,Level,ClientId,Name,PriorJobId,RealEndTime,JobId " +"Type,Level,ClientId,Name,PriorJobId,RealEndTime,JobId,FileSetId " "FROM Job WHERE Job='%s'", jr->Job); } else { Mmsg(mdb->cmd, "SELECT VolSessionId,VolSessionTime," "PoolId,StartTime,EndTime,JobFiles,JobBytes,JobTDate,Job,JobStatus," -"Type,Level,ClientId,Name,PriorJobId,RealEndTime,JobId " +"Type,Level,ClientId,Name,PriorJobId,RealEndTime,JobId,FileSetId " "FROM Job WHERE JobId=%s", edit_int64(jr->JobId, ed1)); } @@ -314,6 +314,7 @@ bool db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr) if (jr->JobId == 0) { jr->JobId = str_to_int64(row[16]); } + jr->FileSetId = str_to_int64(row[17]); sql_free_result(mdb); db_unlock(mdb); diff --git a/bacula/src/dird/migrate.c b/bacula/src/dird/migrate.c index ba49810cd6..b820b8bce7 100644 --- a/bacula/src/dird/migrate.c +++ b/bacula/src/dird/migrate.c @@ -182,6 +182,8 @@ bool do_migration_init(JCR *jcr) return false; } + jcr->spool_data = job->spool_data; /* turn on spooling if requested in job */ + /* Create a migation jcr */ mig_jcr = jcr->mig_jcr = new_jcr(sizeof(JCR), dird_free_jcr); memcpy(&mig_jcr->previous_jr, &jcr->previous_jr, sizeof(mig_jcr->previous_jr)); @@ -198,9 +200,8 @@ bool do_migration_init(JCR *jcr) /* Now reset the job record from the previous job */ memcpy(&mig_jcr->jr, &jcr->previous_jr, sizeof(mig_jcr->jr)); - /* Update the jr to reflect the new values of PoolId, FileSetId, and JobId. */ + /* Update the jr to reflect the new values of PoolId and JobId. */ mig_jcr->jr.PoolId = jcr->jr.PoolId; - mig_jcr->jr.FileSetId = jcr->jr.FileSetId; mig_jcr->jr.JobId = mig_jcr->JobId; Dmsg4(dbglevel, "mig_jcr: Name=%s JobId=%d Type=%c Level=%c\n", diff --git a/bacula/src/lib/lex.c b/bacula/src/lib/lex.c index e7fcc559e5..f5f098f68b 100644 --- a/bacula/src/lib/lex.c +++ b/bacula/src/lib/lex.c @@ -133,7 +133,12 @@ LEX *lex_close_file(LEX *lf) Dmsg1(dbglvl, "Close lex file: %s\n", lf->fname); of = lf->next; - fclose(lf->fd); + if (lf->bpipe) { + close_bpipe(lf->bpipe); + lf->bpipe = NULL; + } else { + fclose(lf->fd); + } Dmsg1(dbglvl, "Close cfg file %s\n", lf->fname); free(lf->fname); if (of) { @@ -164,10 +169,18 @@ LEX *lex_open_file(LEX *lf, const char *filename, LEX_ERROR_HANDLER *scan_error) { LEX *nf; FILE *fd; + BPIPE *bpipe = NULL; char *fname = bstrdup(filename); - if ((fd = fopen(fname, "rb")) == NULL) { + if (fname[0] == '|') { + if ((bpipe = open_bpipe(fname, 0, "rb")) == NULL) { + free(fname); + return NULL; + } + fd = bpipe->rfd; + } else if ((fd = fopen(fname, "rb")) == NULL) { + free(fname); return NULL; } Dmsg1(400, "Open config file: %s\n", fname); @@ -188,6 +201,7 @@ LEX *lex_open_file(LEX *lf, const char *filename, LEX_ERROR_HANDLER *scan_error) lex_set_default_error_handler(lf); } lf->fd = fd; + lf->bpipe = bpipe; lf->fname = fname; lf->state = lex_none; lf->ch = L_EOL; diff --git a/bacula/src/lib/lex.h b/bacula/src/lib/lex.h index b91bdbfefc..6a0caea39e 100644 --- a/bacula/src/lib/lex.h +++ b/bacula/src/lib/lex.h @@ -1,17 +1,7 @@ -/* - * lex.h - * - * Lexical scanning of configuration files, used by parsers. - * - * Kern Sibbald, MM - * - * Version $Id$ - * - */ /* Bacula® - The Network Backup Solution - Copyright (C) 2000-2006 Free Software Foundation Europe e.V. + Copyright (C) 2000-2007 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -35,6 +25,16 @@ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich, Switzerland, email:ftf@fsfeurope.org. */ +/* + * lex.h + * + * Lexical scanning of configuration files, used by parsers. + * + * Kern Sibbald, MM + * + * Version $Id$ + * + */ #ifndef _LEX_H #define _LEX_H @@ -92,6 +92,8 @@ enum lex_state { #define LOPT_NO_IDENT 0x1 /* No Identifiers -- use string */ #define LOPT_STRING 0x2 /* Force scan for string */ +class BPIPE; /* forward reference */ + /* Lexical context */ typedef struct s_lex_context { struct s_lex_context *next; /* pointer to next lexical context */ @@ -114,6 +116,7 @@ typedef struct s_lex_context { void (*scan_error)(const char *file, int line, struct s_lex_context *lc, const char *msg, ...); int err_type; /* message level for scan_error (M_..) */ void *caller_ctx; /* caller private data */ + BPIPE *bpipe; /* set if we are piping */ } LEX; typedef void (LEX_ERROR_HANDLER)(const char *file, int line, LEX *lc, const char *msg, ...); diff --git a/bacula/src/stored/mac.c b/bacula/src/stored/mac.c index 27f3543872..2edbbefa91 100644 --- a/bacula/src/stored/mac.c +++ b/bacula/src/stored/mac.c @@ -100,10 +100,12 @@ bool do_mac(JCR *jcr) Dmsg2(200, "===== After acquire pos %u:%u\n", jcr->dcr->dev->file, jcr->dcr->dev->block_num); - set_jcr_job_status(jcr, JS_Running); dir_send_job_status(jcr); + begin_data_spool(jcr->dcr); + begin_attribute_spool(jcr); + jcr->dcr->VolFirstIndex = jcr->dcr->VolLastIndex = 0; jcr->run_time = time(NULL); @@ -127,12 +129,24 @@ ok_out: Dmsg2(200, "Flush block to device pos %u:%u\n", dev->file, dev->block_num); } + if (!ok) { + discard_data_spool(jcr->dcr); + } else { + /* Note: if commit is OK, the device will remain locked */ + commit_data_spool(jcr->dcr); + } if (ok && dev->is_dvd()) { ok = dvd_close_job(jcr->dcr); /* do DVD cleanup if any */ } /* Release the device -- and send final Vol info to DIR */ release_device(jcr->dcr); + + if (!ok || job_canceled(jcr)) { + discard_attribute_spool(jcr); + } else { + commit_attribute_spool(jcr); + } } if (jcr->read_dcr) { @@ -143,13 +157,6 @@ ok_out: free_restore_volume_list(jcr); - - if (!ok || job_canceled(jcr)) { - discard_attribute_spool(jcr); - } else { - commit_attribute_spool(jcr); - } - dir_send_job_status(jcr); /* update director */ diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index 6a0837ed42..9e17ba56fe 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -1,6 +1,14 @@ Technical notes on version 2.1 General: +08May07 +kes Merge patch from Sergey Svishchev that preserves + the original jobb's FileSetId. +kes Merge patch from Sergey Svishchev that implements + spooling in migration jobs. Not yet tested. +kes Merge patch from Jorj Bauer that implements + reading conf file from a pipe. However, do it with open_bpipe() + rather than popen. Not yet tested. 07May07 kes Fix an ugly bug where the VolCatBytes were getting updated during a restore.