From: Kern Sibbald Date: Tue, 14 Jul 2009 13:44:46 +0000 (+0000) Subject: Send bootstrap directly from DIR to SD X-Git-Tag: Release-3.0.2~84 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=bf6b76e5ff53adbead6cb0b358289c8ed07abcf0;p=bacula%2Fbacula Send bootstrap directly from DIR to SD git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8982 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index caced8435d..b24cff0eae 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -543,43 +543,6 @@ bool send_exclude_list(JCR *jcr) return true; } - -/* - * Send bootstrap file if any to the socket given (FD or SD). - * This is used for restore, verify VolumeToCatalog, and - * for migration. - */ -bool send_bootstrap_file(JCR *jcr, BSOCK *sock) -{ - FILE *bs; - char buf[1000]; - const char *bootstrap = "bootstrap\n"; - - Dmsg1(400, "send_bootstrap_file: %s\n", jcr->RestoreBootstrap); - if (!jcr->RestoreBootstrap) { - return true; - } - bs = fopen(jcr->RestoreBootstrap, "rb"); - if (!bs) { - berrno be; - Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"), - jcr->RestoreBootstrap, be.bstrerror()); - set_jcr_job_status(jcr, JS_ErrorTerminated); - return false; - } - sock->fsend(bootstrap); - while (fgets(buf, sizeof(buf), bs)) { - sock->fsend("%s", buf); - } - sock->signal(BNET_EOD); - fclose(bs); - if (jcr->unlink_bsr) { - unlink(jcr->RestoreBootstrap); - jcr->unlink_bsr = false; - } - return true; -} - /* TODO: drop this with runscript.old_proto in bacula 1.42 */ static char runbefore[] = "RunBeforeJob %s\n"; static char runafter[] = "RunAfterJob %s\n"; diff --git a/bacula/src/dird/msgchan.c b/bacula/src/dird/msgchan.c index 1ccfb81c0c..c00f81b9d7 100644 --- a/bacula/src/dird/msgchan.c +++ b/bacula/src/dird/msgchan.c @@ -439,6 +439,43 @@ void wait_for_storage_daemon_termination(JCR *jcr) set_jcr_job_status(jcr, JS_Terminated); } +/* + * Send bootstrap file to Storage daemon. + * This is used for restore, verify VolumeToCatalog, migration, + * and copy Jobs. + */ +bool send_bootstrap_file(JCR *jcr, BSOCK *sd) +{ + FILE *bs; + char buf[1000]; + const char *bootstrap = "bootstrap\n"; + + Dmsg1(400, "send_bootstrap_file: %s\n", jcr->RestoreBootstrap); + if (!jcr->RestoreBootstrap) { + return true; + } + bs = fopen(jcr->RestoreBootstrap, "rb"); + if (!bs) { + berrno be; + Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"), + jcr->RestoreBootstrap, be.bstrerror()); + set_jcr_job_status(jcr, JS_ErrorTerminated); + return false; + } + sd->fsend(bootstrap); + while (fgets(buf, sizeof(buf), bs)) { + sd->fsend("%s", buf); + } + sd->signal(BNET_EOD); + fclose(bs); + if (jcr->unlink_bsr) { + unlink(jcr->RestoreBootstrap); + jcr->unlink_bsr = false; + } + return true; +} + + #ifdef needed #define MAX_TRIES 30 #define WAIT_TIME 2 diff --git a/bacula/src/dird/protos.h b/bacula/src/dird/protos.h index ba73912b27..2ae354104c 100644 --- a/bacula/src/dird/protos.h +++ b/bacula/src/dird/protos.h @@ -97,7 +97,6 @@ extern int connect_to_file_daemon(JCR *jcr, int retry_interval, int max_retry_time, int verbose); extern bool send_include_list(JCR *jcr); extern bool send_exclude_list(JCR *jcr); -extern bool send_bootstrap_file(JCR *jcr, BSOCK *sock); extern bool send_level_command(JCR *jcr); extern int get_attributes_and_put_in_catalog(JCR *jcr); extern void get_attributes_and_compare_to_catalog(JCR *jcr, JobId_t JobId); @@ -162,6 +161,7 @@ extern bool start_storage_daemon_job(JCR *jcr, alist *rstore, alist *wstore, extern bool start_storage_daemon_message_thread(JCR *jcr); extern int bget_dirmsg(BSOCK *bs); extern void wait_for_storage_daemon_termination(JCR *jcr); +extern bool send_bootstrap_file(JCR *jcr, BSOCK *sd); /* next_vol.c */ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, int index, diff --git a/bacula/src/dird/restore.c b/bacula/src/dird/restore.c index 3e88b59941..434842255f 100644 --- a/bacula/src/dird/restore.c +++ b/bacula/src/dird/restore.c @@ -57,7 +57,9 @@ static char storaddr[] = "storage address=%s port=%d ssl=0\n"; /* Responses received from File daemon */ static char OKrestore[] = "2000 OK restore\n"; static char OKstore[] = "2000 OK storage\n"; -static char OKbootstrap[] = "2000 OK bootstrap\n"; + +/* Responses received from the Storage daemon */ +static char OKbootstrap[] = "3000 OK bootstrap\n"; /* * Do a restore of the specified files @@ -67,7 +69,7 @@ static char OKbootstrap[] = "2000 OK bootstrap\n"; */ bool do_restore(JCR *jcr) { - BSOCK *fd; + BSOCK *fd, *sd; JOB_DBR rjr; /* restore job record */ char replace, *where, *cmd; char empty = '\0'; @@ -114,13 +116,23 @@ bool do_restore(JCR *jcr) if (!connect_to_storage_daemon(jcr, 10, SDConnectTimeout, 1)) { goto bail_out; } + sd = jcr->store_bsock; /* * Now start a job with the Storage daemon */ if (!start_storage_daemon_job(jcr, jcr->rstorage, NULL)) { goto bail_out; } - if (!jcr->store_bsock->fsend("run")) { + + /* + * Send the bootstrap file -- what Volumes/files to restore + */ + if (!send_bootstrap_file(jcr, sd) || + !response(jcr, sd, OKbootstrap, "Bootstrap", DISPLAY_ERROR)) { + goto bail_out; + } + + if (!sd->fsend("run")) { goto bail_out; } /* @@ -157,15 +169,6 @@ bool do_restore(JCR *jcr) goto bail_out; } - /* - * Send the bootstrap file -- what Volumes/files to restore - */ - if (!send_bootstrap_file(jcr, fd) || - !response(jcr, fd, OKbootstrap, "Bootstrap", DISPLAY_ERROR)) { - goto bail_out; - } - - if (!send_runscripts_commands(jcr)) { goto bail_out; } diff --git a/bacula/src/dird/verify.c b/bacula/src/dird/verify.c index 7694bd44d7..926fed7ee9 100644 --- a/bacula/src/dird/verify.c +++ b/bacula/src/dird/verify.c @@ -53,7 +53,9 @@ static char storaddr[] = "storage address=%s port=%d ssl=0\n"; /* Responses received from File daemon */ static char OKverify[] = "2000 OK verify\n"; static char OKstore[] = "2000 OK storage\n"; -static char OKbootstrap[] = "2000 OK bootstrap\n"; + +/* Responses received from the Storage daemon */ +static char OKbootstrap[] = "3000 OK bootstrap\n"; /* Forward referenced functions */ static void prt_fname(JCR *jcr); @@ -201,6 +203,7 @@ bool do_verify(JCR *jcr) edit_uint64(jcr->JobId, ed1), level_to_str(jcr->get_JobLevel()), jcr->Job); if (jcr->get_JobLevel() == L_VERIFY_VOLUME_TO_CATALOG) { + BSOCK *sd; /* * Start conversation with Storage daemon */ @@ -214,7 +217,15 @@ bool do_verify(JCR *jcr) if (!start_storage_daemon_job(jcr, jcr->rstorage, NULL)) { return false; } - if (!jcr->store_bsock->fsend("run")) { + sd = jcr->store_bsock; + /* + * Send the bootstrap file -- what Volumes/files to restore + */ + if (!send_bootstrap_file(jcr, sd) || + !response(jcr, sd, OKbootstrap, "Bootstrap", DISPLAY_ERROR)) { + goto bail_out; + } + if (!sd->fsend("run")) { return false; } /* @@ -272,14 +283,6 @@ bool do_verify(JCR *jcr) goto bail_out; } - /* - * Send the bootstrap file -- what Volumes/files to restore - */ - if (!send_bootstrap_file(jcr, fd) || - !response(jcr, fd, OKbootstrap, "Bootstrap", DISPLAY_ERROR)) { - goto bail_out; - } - if (!jcr->RestoreBootstrap) { Jmsg0(jcr, M_FATAL, 0, _("Deprecated feature ... use bootstrap.\n")); goto bail_out; diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index f227bbf519..ddc3900096 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -183,7 +183,10 @@ public: bool is_job_canceled() {return job_canceled(this); }; int32_t get_JobType() { return m_JobType; }; int32_t get_JobLevel() { return m_JobLevel; }; - + bool no_client_used() { + return (m_JobType == JT_MIGRATE || m_JobType == JT_COPY || + m_JobLevel == L_VIRTUAL_FULL); + }; const char *get_OperationName(); /* in lib/jcr.c */ const char *get_ActionName(bool past); /* in lib/jcr.c */ void set_JobLevel(int32_t JobLevel); /* in lib/jcr.c */ @@ -399,7 +402,6 @@ public: alist *reserve_msgs; /* reserve fail messages */ bool write_part_after_job; /* Set to write part after job */ bool PreferMountedVols; /* Prefer mounted vols rather than new */ - bool need_fd; /* set if we need FD connection */ /* Parmaters for Open Read Session */ BSR *bsr; /* Bootstrap record -- has everything */ diff --git a/bacula/src/stored/dircmd.c b/bacula/src/stored/dircmd.c index 47370524a1..524b207629 100644 --- a/bacula/src/stored/dircmd.c +++ b/bacula/src/stored/dircmd.c @@ -938,10 +938,6 @@ static bool release_cmd(JCR *jcr) static bool bootstrap_cmd(JCR *jcr) { - /* If getting the bootstrap file succeeds, we do not need - * the FD because we will be reading. - */ - jcr->need_fd = false; return get_bootstrap_file(jcr, jcr->dir_bsock); } diff --git a/bacula/src/stored/job.c b/bacula/src/stored/job.c index de9b2bb50c..4bb402fc4e 100644 --- a/bacula/src/stored/job.c +++ b/bacula/src/stored/job.c @@ -146,7 +146,6 @@ bool job_cmd(JCR *jcr) jcr->PreferMountedVols = PreferMountedVols; jcr->authenticated = false; - jcr->need_fd = true; /* * Pass back an authorization key for the File daemon @@ -174,7 +173,7 @@ bool run_cmd(JCR *jcr) /* If we do not need the FD, we are doing a migrate, copy, or virtual * backup. */ - if (!jcr->need_fd) { + if (jcr->no_client_used()) { do_mac(jcr); return false; } diff --git a/bacula/technotes b/bacula/technotes index 424a97e2c4..975ad18264 100644 --- a/bacula/technotes +++ b/bacula/technotes @@ -3,6 +3,7 @@ General: 13Jul09 +kes Send bootstrap directly from DIR to SD kes Create build scripts for Win64 somewhat equilavent to the Win32 ones. 10Jul09 ebl Print correct JobId in bls, should fix #1331 @@ -11,7 +12,6 @@ kes Apply python detect patch from Bastian Friedrich