From e26b2fd871e3116966053204a8d9c4d86917c5cb Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Mon, 4 Nov 2019 15:57:39 +0100 Subject: [PATCH 01/23] file: move daemon private data to separate file --- core/src/filed/accurate.cc | 61 +++---- core/src/filed/authenticate.cc | 3 +- core/src/filed/backup.cc | 119 +++++++------- core/src/filed/compression.cc | 3 +- core/src/filed/crypto.cc | 120 +++++++------- core/src/filed/dir_cmd.cc | 280 ++++++++++++++++++--------------- core/src/filed/estimate.cc | 13 +- core/src/filed/fd_plugins.cc | 39 ++--- core/src/filed/fileset.cc | 37 +++-- core/src/filed/heartbeat.cc | 68 ++++---- core/src/filed/jcr_private.h | 88 +++++++++++ core/src/filed/restore.cc | 155 +++++++++--------- core/src/filed/sd_cmds.cc | 5 +- core/src/filed/status.cc | 27 ++-- core/src/filed/verify.cc | 30 ++-- core/src/filed/verify_vol.cc | 7 +- core/src/include/jcr.h | 61 +------ core/src/win32/filed/vss.cc | 33 ++-- 18 files changed, 621 insertions(+), 528 deletions(-) create mode 100644 core/src/filed/jcr_private.h diff --git a/core/src/filed/accurate.cc b/core/src/filed/accurate.cc index 084649e5c05..e31c5fc42cb 100644 --- a/core/src/filed/accurate.cc +++ b/core/src/filed/accurate.cc @@ -25,6 +25,7 @@ #include "filed/filed.h" #include "filed/accurate.h" #include "filed/filed_globals.h" +#include "filed/jcr_private.h" #include "filed/verify.h" #include "lib/attribs.h" #include "lib/bsock.h" @@ -38,11 +39,11 @@ bool AccurateMarkFileAsSeen(JobControlRecord* jcr, char* fname) { accurate_payload* temp; - if (!jcr->accurate || !jcr->file_list) { return false; } + if (!jcr->accurate || !jcr->impl_->file_list) { return false; } - temp = jcr->file_list->lookup_payload(fname); + temp = jcr->impl_->file_list->lookup_payload(fname); if (temp) { - jcr->file_list->MarkFileAsSeen(temp); + jcr->impl_->file_list->MarkFileAsSeen(temp); Dmsg1(debuglevel, "marked <%s> as seen\n", fname); } else { Dmsg1(debuglevel, "<%s> not found to be marked as seen\n", fname); @@ -55,11 +56,11 @@ bool accurate_unMarkFileAsSeen(JobControlRecord* jcr, char* fname) { accurate_payload* temp; - if (!jcr->accurate || !jcr->file_list) { return false; } + if (!jcr->accurate || !jcr->impl_->file_list) { return false; } - temp = jcr->file_list->lookup_payload(fname); + temp = jcr->impl_->file_list->lookup_payload(fname); if (temp) { - jcr->file_list->UnmarkFileAsSeen(temp); + jcr->impl_->file_list->UnmarkFileAsSeen(temp); Dmsg1(debuglevel, "unmarked <%s> as seen\n", fname); } else { Dmsg1(debuglevel, "<%s> not found to be unmarked as seen\n", fname); @@ -70,17 +71,17 @@ bool accurate_unMarkFileAsSeen(JobControlRecord* jcr, char* fname) bool AccurateMarkAllFilesAsSeen(JobControlRecord* jcr) { - if (!jcr->accurate || !jcr->file_list) { return false; } + if (!jcr->accurate || !jcr->impl_->file_list) { return false; } - jcr->file_list->MarkAllFilesAsSeen(); + jcr->impl_->file_list->MarkAllFilesAsSeen(); return true; } bool accurate_unMarkAllFilesAsSeen(JobControlRecord* jcr) { - if (!jcr->accurate || !jcr->file_list) { return false; } + if (!jcr->accurate || !jcr->impl_->file_list) { return false; } - jcr->file_list->UnmarkAllFilesAsSeen(); + jcr->impl_->file_list->UnmarkAllFilesAsSeen(); return true; } @@ -90,7 +91,7 @@ static inline bool AccurateLookup(JobControlRecord* jcr, { bool found = false; - *payload = jcr->file_list->lookup_payload(fname); + *payload = jcr->impl_->file_list->lookup_payload(fname); if (*payload) { found = true; Dmsg1(debuglevel, "lookup <%s> ok\n", fname); @@ -101,9 +102,9 @@ static inline bool AccurateLookup(JobControlRecord* jcr, void AccurateFree(JobControlRecord* jcr) { - if (jcr->file_list) { - delete jcr->file_list; - jcr->file_list = NULL; + if (jcr->impl_->file_list) { + delete jcr->impl_->file_list; + jcr->impl_->file_list = NULL; } } @@ -119,17 +120,19 @@ bool AccurateFinish(JobControlRecord* jcr) return retval; } - if (jcr->accurate && jcr->file_list) { + if (jcr->accurate && jcr->impl_->file_list) { if (jcr->is_JobLevel(L_FULL)) { - if (!jcr->rerunning) { retval = jcr->file_list->SendBaseFileList(); } + if (!jcr->rerunning) { + retval = jcr->impl_->file_list->SendBaseFileList(); + } } else { - retval = jcr->file_list->SendDeletedList(); + retval = jcr->impl_->file_list->SendDeletedList(); } AccurateFree(jcr); if (jcr->is_JobLevel(L_FULL)) { Jmsg(jcr, M_INFO, 0, _("Space saved with Base jobs: %lld MB\n"), - jcr->base_size / (1024 * 1024)); + jcr->impl_->base_size / (1024 * 1024)); } } @@ -159,7 +162,7 @@ bool AccurateCheckFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt) if (!jcr->accurate && !jcr->rerunning) { return true; } - if (!jcr->file_list) { return true; /** Not initialized properly */ } + if (!jcr->impl_->file_list) { return true; /** Not initialized properly */ } /** * Apply path stripping for lookup in accurate data. @@ -321,11 +324,11 @@ bool AccurateCheckFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt) /** * Compute space saved with basefile. */ - jcr->base_size += ff_pkt->statp.st_size; - jcr->file_list->MarkFileAsSeen(payload); + jcr->impl_->base_size += ff_pkt->statp.st_size; + jcr->impl_->file_list->MarkFileAsSeen(payload); } } else { - jcr->file_list->MarkFileAsSeen(payload); + jcr->impl_->file_list->MarkFileAsSeen(payload); } bail_out: @@ -350,18 +353,18 @@ bool AccurateCmd(JobControlRecord* jcr) #ifdef HAVE_LMDB if (me->always_use_lmdb || (me->lmdb_threshold > 0 && number_of_previous_files >= me->lmdb_threshold)) { - jcr->file_list = + jcr->impl_->file_list = new BareosAccurateFilelistLmdb(jcr, number_of_previous_files); } else { - jcr->file_list = + jcr->impl_->file_list = new BareosAccurateFilelistHtable(jcr, number_of_previous_files); } #else - jcr->file_list = + jcr->impl_->file_list = new BareosAccurateFilelistHtable(jcr, number_of_previous_files); #endif - if (!jcr->file_list->init()) { return false; } + if (!jcr->impl_->file_list->init()) { return false; } jcr->accurate = true; @@ -396,11 +399,11 @@ bool AccurateCmd(JobControlRecord* jcr) } } - jcr->file_list->AddFile(fname, fname_length, lstat, lstat_length, chksum, - chksum_length, delta_seq); + jcr->impl_->file_list->AddFile(fname, fname_length, lstat, lstat_length, + chksum, chksum_length, delta_seq); } - if (!jcr->file_list->EndLoad()) { return false; } + if (!jcr->impl_->file_list->EndLoad()) { return false; } return true; } diff --git a/core/src/filed/authenticate.cc b/core/src/filed/authenticate.cc index aae0e5b8f2f..a887ac31064 100644 --- a/core/src/filed/authenticate.cc +++ b/core/src/filed/authenticate.cc @@ -31,6 +31,7 @@ #include "include/bareos.h" #include "filed/filed.h" #include "filed/filed_globals.h" +#include "filed/jcr_private.h" #include "filed/restore.h" #include "lib/bnet.h" #include "lib/bsock.h" @@ -148,7 +149,7 @@ bool AuthenticateDirector(JobControlRecord* jcr) return false; } - jcr->director = director; + jcr->impl_->director = director; return dir->fsend("%s", (me->compatible) ? OK_hello_compat : OK_hello); } diff --git a/core/src/filed/backup.cc b/core/src/filed/backup.cc index 00dee36101f..7542ceacd4c 100644 --- a/core/src/filed/backup.cc +++ b/core/src/filed/backup.cc @@ -37,6 +37,7 @@ #include "filed/crypto.h" #include "filed/heartbeat.h" #include "filed/backup.h" +#include "filed/jcr_private.h" #include "include/ch.h" #include "findlib/attribs.h" #include "findlib/hardlink.h" @@ -130,52 +131,53 @@ bool BlastDataToStorageDaemon(JobControlRecord* jcr, if (!CryptoSessionStart(jcr, cipher)) { return false; } - SetFindOptions((FindFilesPacket*)jcr->ff, jcr->incremental, jcr->mtime); + SetFindOptions((FindFilesPacket*)jcr->impl_->ff, jcr->impl_->incremental, + jcr->impl_->mtime); /** * In accurate mode, we overload the find_one check function */ if (jcr->accurate) { - SetFindChangedFunction((FindFilesPacket*)jcr->ff, AccurateCheckFile); + SetFindChangedFunction((FindFilesPacket*)jcr->impl_->ff, AccurateCheckFile); } StartHeartbeatMonitor(jcr); if (have_acl) { - jcr->acl_data = (acl_data_t*)malloc(sizeof(acl_data_t)); - memset(jcr->acl_data, 0, sizeof(acl_data_t)); - jcr->acl_data->u.build = + jcr->impl_->acl_data = (acl_data_t*)malloc(sizeof(acl_data_t)); + memset(jcr->impl_->acl_data, 0, sizeof(acl_data_t)); + jcr->impl_->acl_data->u.build = (acl_build_data_t*)malloc(sizeof(acl_build_data_t)); - memset(jcr->acl_data->u.build, 0, sizeof(acl_build_data_t)); - jcr->acl_data->u.build->content = GetPoolMemory(PM_MESSAGE); + memset(jcr->impl_->acl_data->u.build, 0, sizeof(acl_build_data_t)); + jcr->impl_->acl_data->u.build->content = GetPoolMemory(PM_MESSAGE); } if (have_xattr) { - jcr->xattr_data = (xattr_data_t*)malloc(sizeof(xattr_data_t)); - memset(jcr->xattr_data, 0, sizeof(xattr_data_t)); - jcr->xattr_data->u.build = + jcr->impl_->xattr_data = (xattr_data_t*)malloc(sizeof(xattr_data_t)); + memset(jcr->impl_->xattr_data, 0, sizeof(xattr_data_t)); + jcr->impl_->xattr_data->u.build = (xattr_build_data_t*)malloc(sizeof(xattr_build_data_t)); - memset(jcr->xattr_data->u.build, 0, sizeof(xattr_build_data_t)); - jcr->xattr_data->u.build->content = GetPoolMemory(PM_MESSAGE); + memset(jcr->impl_->xattr_data->u.build, 0, sizeof(xattr_build_data_t)); + jcr->impl_->xattr_data->u.build->content = GetPoolMemory(PM_MESSAGE); } /** * Subroutine SaveFile() is called for each file */ - if (!FindFiles(jcr, (FindFilesPacket*)jcr->ff, SaveFile, PluginSave)) { + if (!FindFiles(jcr, (FindFilesPacket*)jcr->impl_->ff, SaveFile, PluginSave)) { ok = false; /* error */ jcr->setJobStatus(JS_ErrorTerminated); } - if (have_acl && jcr->acl_data->u.build->nr_errors > 0) { + if (have_acl && jcr->impl_->acl_data->u.build->nr_errors > 0) { Jmsg(jcr, M_WARNING, 0, _("Encountered %ld acl errors while doing backup\n"), - jcr->acl_data->u.build->nr_errors); + jcr->impl_->acl_data->u.build->nr_errors); } - if (have_xattr && jcr->xattr_data->u.build->nr_errors > 0) { + if (have_xattr && jcr->impl_->xattr_data->u.build->nr_errors > 0) { Jmsg(jcr, M_WARNING, 0, _("Encountered %ld xattr errors while doing backup\n"), - jcr->xattr_data->u.build->nr_errors); + jcr->impl_->xattr_data->u.build->nr_errors); } CloseVssBackupSession(jcr); @@ -186,23 +188,23 @@ bool BlastDataToStorageDaemon(JobControlRecord* jcr, sd->signal(BNET_EOD); /* end of sending data */ - if (have_acl && jcr->acl_data) { - FreePoolMemory(jcr->acl_data->u.build->content); - free(jcr->acl_data->u.build); - free(jcr->acl_data); - jcr->acl_data = NULL; + if (have_acl && jcr->impl_->acl_data) { + FreePoolMemory(jcr->impl_->acl_data->u.build->content); + free(jcr->impl_->acl_data->u.build); + free(jcr->impl_->acl_data); + jcr->impl_->acl_data = NULL; } - if (have_xattr && jcr->xattr_data) { - FreePoolMemory(jcr->xattr_data->u.build->content); - free(jcr->xattr_data->u.build); - free(jcr->xattr_data); - jcr->xattr_data = NULL; + if (have_xattr && jcr->impl_->xattr_data) { + FreePoolMemory(jcr->impl_->xattr_data->u.build->content); + free(jcr->impl_->xattr_data->u.build); + free(jcr->impl_->xattr_data); + jcr->impl_->xattr_data = NULL; } - if (jcr->big_buf) { - free(jcr->big_buf); - jcr->big_buf = NULL; + if (jcr->impl_->big_buf) { + free(jcr->impl_->big_buf); + jcr->impl_->big_buf = NULL; } CleanupCompression(jcr); @@ -323,7 +325,7 @@ static inline bool SetupEncryptionDigests(b_save_ctx& bsctx) /* TODO landonf: We should really only calculate the digest once, for * both verification and signing. */ - if (bsctx.jcr->crypto.pki_sign) { + if (bsctx.jcr->impl_->crypto.pki_sign) { bsctx.signing_digest = crypto_digest_new(bsctx.jcr, signing_algorithm); /* @@ -341,7 +343,7 @@ static inline bool SetupEncryptionDigests(b_save_ctx& bsctx) /* * Enable encryption */ - if (bsctx.jcr->crypto.pki_encrypt) { + if (bsctx.jcr->impl_->crypto.pki_encrypt) { SetBit(FO_ENCRYPT, bsctx.ff_pkt->flags); } retval = true; @@ -367,7 +369,7 @@ static inline bool TerminateSigningDigest(b_save_ctx& bsctx) } if (!CryptoSignAddSigner(signature, bsctx.signing_digest, - bsctx.jcr->crypto.pki_keypair)) { + bsctx.jcr->impl_->crypto.pki_keypair)) { Jmsg(bsctx.jcr, M_FATAL, 0, _("An error occurred while signing the stream.\n")); goto bail_out; @@ -461,13 +463,13 @@ static inline bool DoBackupAcl(JobControlRecord* jcr, FindFilesPacket* ff_pkt) { bacl_exit_code retval; - jcr->acl_data->filetype = ff_pkt->type; - jcr->acl_data->last_fname = jcr->last_fname; + jcr->impl_->acl_data->filetype = ff_pkt->type; + jcr->impl_->acl_data->last_fname = jcr->impl_->last_fname; if (jcr->IsPlugin()) { - retval = PluginBuildAclStreams(jcr, jcr->acl_data, ff_pkt); + retval = PluginBuildAclStreams(jcr, jcr->impl_->acl_data, ff_pkt); } else { - retval = BuildAclStreams(jcr, jcr->acl_data, ff_pkt); + retval = BuildAclStreams(jcr, jcr->impl_->acl_data, ff_pkt); } switch (retval) { @@ -475,7 +477,7 @@ static inline bool DoBackupAcl(JobControlRecord* jcr, FindFilesPacket* ff_pkt) return false; case bacl_exit_error: Jmsg(jcr, M_ERROR, 0, "%s", jcr->errmsg); - jcr->acl_data->u.build->nr_errors++; + jcr->impl_->acl_data->u.build->nr_errors++; break; case bacl_exit_ok: break; @@ -488,12 +490,12 @@ static inline bool DoBackupXattr(JobControlRecord* jcr, FindFilesPacket* ff_pkt) { BxattrExitCode retval; - jcr->xattr_data->last_fname = jcr->last_fname; + jcr->impl_->xattr_data->last_fname = jcr->impl_->last_fname; if (jcr->IsPlugin()) { - retval = PluginBuildXattrStreams(jcr, jcr->xattr_data, ff_pkt); + retval = PluginBuildXattrStreams(jcr, jcr->impl_->xattr_data, ff_pkt); } else { - retval = BuildXattrStreams(jcr, jcr->xattr_data, ff_pkt); + retval = BuildXattrStreams(jcr, jcr->impl_->xattr_data, ff_pkt); } switch (retval) { @@ -504,7 +506,7 @@ static inline bool DoBackupXattr(JobControlRecord* jcr, FindFilesPacket* ff_pkt) break; case BxattrExitCode::kError: Jmsg(jcr, M_ERROR, 0, "%s", jcr->errmsg); - jcr->xattr_data->u.build->nr_errors++; + jcr->impl_->xattr_data->u.build->nr_errors++; break; case BxattrExitCode::kSuccess: break; @@ -537,7 +539,7 @@ int SaveFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool top_level) if (jcr->IsCanceled() || jcr->IsIncomplete()) { return 0; } - jcr->num_files_examined++; /* bump total file count */ + jcr->impl_->num_files_examined++; /* bump total file count */ switch (ff_pkt->type) { case FT_LNKSAVED: /* Hard linked, file already saved */ @@ -562,8 +564,8 @@ int SaveFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool top_level) Dmsg1(100, "FT_PLUGIN_CONFIG saving: %s\n", ff_pkt->fname); break; case FT_DIRBEGIN: - jcr->num_files_examined--; /* correct file count */ - return 1; /* not used */ + jcr->impl_->num_files_examined--; /* correct file count */ + return 1; /* not used */ case FT_NORECURSE: Jmsg(jcr, M_INFO, 1, _(" Recursion turned off. Will not descend from %s into %s\n"), @@ -698,7 +700,7 @@ int SaveFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool top_level) Dmsg2(10, "Option plugin %s will be used to backup %s\n", ff_pkt->plugin, ff_pkt->fname); jcr->opt_plugin = true; - jcr->plugin_sp = &sp; + jcr->impl_->plugin_sp = &sp; PluginUpdateFfPkt(ff_pkt, &sp); do_plugin_set = true; break; @@ -742,7 +744,7 @@ int SaveFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool top_level) /* * Set up the encryption context and send the session data to the SD */ - if (has_file_data && jcr->crypto.pki_encrypt) { + if (has_file_data && jcr->impl_->crypto.pki_encrypt) { if (!CryptoSessionSend(jcr, sd)) { goto bail_out; } } @@ -883,7 +885,7 @@ int SaveFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool top_level) SendPluginName(jcr, sd, false); /* signal end of plugin data */ } if (ff_pkt->opt_plugin) { - jcr->plugin_sp = NULL; /* sp is local to this function */ + jcr->impl_->plugin_sp = NULL; /* sp is local to this function */ jcr->opt_plugin = false; } if (bsctx.digest) { CryptoDigestFree(bsctx.digest); } @@ -1217,7 +1219,8 @@ static int send_data(JobControlRecord* jcr, /* * For encryption, we must call finalize to push out any buffered data. */ - if (!CryptoCipherFinalize(bctx.cipher_ctx, (uint8_t*)jcr->crypto.crypto_buf, + if (!CryptoCipherFinalize(bctx.cipher_ctx, + (uint8_t*)jcr->impl_->crypto.crypto_buf, &bctx.encrypted_len)) { /* * Padding failed. Shouldn't happen. @@ -1231,7 +1234,7 @@ static int send_data(JobControlRecord* jcr, */ if (bctx.encrypted_len > 0) { sd->message_length = bctx.encrypted_len; /* set encrypted length */ - sd->msg = jcr->crypto.crypto_buf; /* set correct write buffer */ + sd->msg = jcr->impl_->crypto.crypto_buf; /* set correct write buffer */ if (!sd->send()) { if (!jcr->IsJobCanceled()) { Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), @@ -1313,7 +1316,7 @@ bool EncodeAndSendAttributes(JobControlRecord* jcr, jcr->lock(); jcr->JobFiles++; /* increment number of files sent */ ff_pkt->FileIndex = jcr->JobFiles; /* return FileIndex */ - PmStrcpy(jcr->last_fname, ff_pkt->fname); + PmStrcpy(jcr->impl_->last_fname, ff_pkt->fname); jcr->unlock(); /* @@ -1567,33 +1570,33 @@ static void CloseVssBackupSession(JobControlRecord* jcr) * STOP VSS ON WIN32 * Tell vss to close the backup session */ - if (jcr->pVSSClient) { + if (jcr->impl_->pVSSClient) { /* * We are about to call the BackupComplete VSS method so let all plugins * know that by raising the bEventVssBackupComplete event. */ GeneratePluginEvent(jcr, bEventVssBackupComplete); - if (jcr->pVSSClient->CloseBackup()) { + if (jcr->impl_->pVSSClient->CloseBackup()) { /* * Inform user about writer states */ - for (size_t i = 0; i < jcr->pVSSClient->GetWriterCount(); i++) { + for (size_t i = 0; i < jcr->impl_->pVSSClient->GetWriterCount(); i++) { int msg_type = M_INFO; - if (jcr->pVSSClient->GetWriterState(i) < 1) { + if (jcr->impl_->pVSSClient->GetWriterState(i) < 1) { msg_type = M_WARNING; jcr->JobErrors++; } Jmsg(jcr, msg_type, 0, _("VSS Writer (BackupComplete): %s\n"), - jcr->pVSSClient->GetWriterInfo(i)); + jcr->impl_->pVSSClient->GetWriterInfo(i)); } } /* * Generate Job global writer metadata */ - wchar_t* metadata = jcr->pVSSClient->GetMetadata(); + wchar_t* metadata = jcr->impl_->pVSSClient->GetMetadata(); if (metadata) { - FindFilesPacket* ff_pkt = jcr->ff; + FindFilesPacket* ff_pkt = jcr->impl_->ff; ff_pkt->fname = (char*)"*all*"; /* for all plugins */ ff_pkt->type = FT_RESTORE_FIRST; ff_pkt->LinkFI = 0; diff --git a/core/src/filed/compression.cc b/core/src/filed/compression.cc index 72151974190..a6e20391ad6 100644 --- a/core/src/filed/compression.cc +++ b/core/src/filed/compression.cc @@ -32,6 +32,7 @@ #include "include/bareos.h" #include "filed/filed.h" #include "filed/filed_globals.h" +#include "filed/jcr_private.h" #if defined(HAVE_LIBZ) #include @@ -46,7 +47,7 @@ namespace filedaemon { */ bool AdjustCompressionBuffers(JobControlRecord* jcr) { - findFILESET* fileset = jcr->ff->fileset; + findFILESET* fileset = jcr->impl_->ff->fileset; uint32_t compress_buf_size = 0; if (fileset) { diff --git a/core/src/filed/crypto.cc b/core/src/filed/crypto.cc index 7f8446bdcd3..36f38b4d078 100644 --- a/core/src/filed/crypto.cc +++ b/core/src/filed/crypto.cc @@ -31,6 +31,7 @@ #include "include/bareos.h" #include "filed/filed.h" +#include "filed/jcr_private.h" #include "filed/restore.h" #include "findlib/find_one.h" #include "lib/bsock.h" @@ -61,15 +62,15 @@ bool CryptoSessionStart(JobControlRecord* jcr, crypto_cipher_t cipher) * structure. We use a single session key for each backup, so we'll encode * the session data only once. */ - if (jcr->crypto.pki_encrypt) { + if (jcr->impl_->crypto.pki_encrypt) { uint32_t size = 0; /** * Create per-job session encryption context */ - jcr->crypto.pki_session = - crypto_session_new(cipher, jcr->crypto.pki_recipients); - if (!jcr->crypto.pki_session) { + jcr->impl_->crypto.pki_session = + crypto_session_new(cipher, jcr->impl_->crypto.pki_recipients); + if (!jcr->impl_->crypto.pki_session) { Jmsg(jcr, M_FATAL, 0, _("Cannot create a new crypto session probably unsupported cipher " "configured.\n")); @@ -79,7 +80,8 @@ bool CryptoSessionStart(JobControlRecord* jcr, crypto_cipher_t cipher) /** * Get the session data size */ - if (!CryptoSessionEncode(jcr->crypto.pki_session, (uint8_t*)0, &size)) { + if (!CryptoSessionEncode(jcr->impl_->crypto.pki_session, (uint8_t*)0, + &size)) { Jmsg(jcr, M_FATAL, 0, _("An error occurred while encrypting the stream.\n")); return false; @@ -88,13 +90,13 @@ bool CryptoSessionStart(JobControlRecord* jcr, crypto_cipher_t cipher) /** * Allocate buffer */ - jcr->crypto.pki_session_encoded = GetMemory(size); + jcr->impl_->crypto.pki_session_encoded = GetMemory(size); /** * Encode session data */ - if (!CryptoSessionEncode(jcr->crypto.pki_session, - (uint8_t*)jcr->crypto.pki_session_encoded, + if (!CryptoSessionEncode(jcr->impl_->crypto.pki_session, + (uint8_t*)jcr->impl_->crypto.pki_session_encoded, &size)) { Jmsg(jcr, M_FATAL, 0, _("An error occurred while encrypting the stream.\n")); @@ -104,12 +106,12 @@ bool CryptoSessionStart(JobControlRecord* jcr, crypto_cipher_t cipher) /** * ... and store the encoded size */ - jcr->crypto.pki_session_encoded_size = size; + jcr->impl_->crypto.pki_session_encoded_size = size; /** * Allocate the encryption/decryption buffer */ - jcr->crypto.crypto_buf = GetMemory(CRYPTO_CIPHER_MAX_BLOCK_SIZE); + jcr->impl_->crypto.crypto_buf = GetMemory(CRYPTO_CIPHER_MAX_BLOCK_SIZE); } return true; @@ -117,14 +119,16 @@ bool CryptoSessionStart(JobControlRecord* jcr, crypto_cipher_t cipher) void CryptoSessionEnd(JobControlRecord* jcr) { - if (jcr->crypto.crypto_buf) { - FreePoolMemory(jcr->crypto.crypto_buf); - jcr->crypto.crypto_buf = NULL; + if (jcr->impl_->crypto.crypto_buf) { + FreePoolMemory(jcr->impl_->crypto.crypto_buf); + jcr->impl_->crypto.crypto_buf = NULL; + } + if (jcr->impl_->crypto.pki_session) { + CryptoSessionFree(jcr->impl_->crypto.pki_session); } - if (jcr->crypto.pki_session) { CryptoSessionFree(jcr->crypto.pki_session); } - if (jcr->crypto.pki_session_encoded) { - FreePoolMemory(jcr->crypto.pki_session_encoded); - jcr->crypto.pki_session_encoded = NULL; + if (jcr->impl_->crypto.pki_session_encoded) { + FreePoolMemory(jcr->impl_->crypto.pki_session_encoded); + jcr->impl_->crypto.pki_session_encoded = NULL; } } @@ -138,8 +142,8 @@ bool CryptoSessionSend(JobControlRecord* jcr, BareosSocket* sd) sd->fsend("%ld %d 0", jcr->JobFiles, STREAM_ENCRYPTED_SESSION_DATA); msgsave = sd->msg; - sd->msg = jcr->crypto.pki_session_encoded; - sd->message_length = jcr->crypto.pki_session_encoded_size; + sd->msg = jcr->impl_->crypto.pki_session_encoded; + sd->message_length = jcr->impl_->crypto.pki_session_encoded_size; jcr->JobBytes += sd->message_length; Dmsg1(100, "Send data len=%d\n", sd->message_length); @@ -167,7 +171,7 @@ bool VerifySignature(JobControlRecord* jcr, r_ctx& rctx) crypto_digest_t algorithm; SIGNATURE* sig = rctx.sig; - if (!jcr->crypto.pki_sign) { + if (!jcr->impl_->crypto.pki_sign) { /* * no signature OK */ @@ -176,7 +180,7 @@ bool VerifySignature(JobControlRecord* jcr, r_ctx& rctx) if (!sig) { if (rctx.type == FT_REGE || rctx.type == FT_REG || rctx.type == FT_RAW) { Jmsg1(jcr, M_ERROR, 0, _("Missing cryptographic signature for %s\n"), - jcr->last_fname); + jcr->impl_->last_fname); goto bail_out; } return true; @@ -185,33 +189,35 @@ bool VerifySignature(JobControlRecord* jcr, r_ctx& rctx) /* * Iterate through the trusted signers */ - foreach_alist (keypair, jcr->crypto.pki_signers) { - err = CryptoSignGetDigest(sig, jcr->crypto.pki_keypair, algorithm, &digest); + foreach_alist (keypair, jcr->impl_->crypto.pki_signers) { + err = CryptoSignGetDigest(sig, jcr->impl_->crypto.pki_keypair, algorithm, + &digest); switch (err) { case CRYPTO_ERROR_NONE: Dmsg0(50, "== Got digest\n"); /* - * We computed jcr->crypto.digest using signing_algorithm while writing - * the file. If it is not the same as the algorithm used for + * We computed jcr->impl_->crypto.digest using signing_algorithm while + * writing the file. If it is not the same as the algorithm used for * this file, punt by releasing the computed algorithm and * computing by re-reading the file. */ if (algorithm != signing_algorithm) { - if (jcr->crypto.digest) { - CryptoDigestFree(jcr->crypto.digest); - jcr->crypto.digest = NULL; + if (jcr->impl_->crypto.digest) { + CryptoDigestFree(jcr->impl_->crypto.digest); + jcr->impl_->crypto.digest = NULL; } } - if (jcr->crypto.digest) { + if (jcr->impl_->crypto.digest) { /* * Use digest computed while writing the file to verify the signature */ - if ((err = CryptoSignVerify(sig, keypair, jcr->crypto.digest)) != + if ((err = + CryptoSignVerify(sig, keypair, jcr->impl_->crypto.digest)) != CRYPTO_ERROR_NONE) { - Dmsg1(50, "Bad signature on %s\n", jcr->last_fname); + Dmsg1(50, "Bad signature on %s\n", jcr->impl_->last_fname); Jmsg2(jcr, M_ERROR, 0, _("Signature validation failed for file %s: ERR=%s\n"), - jcr->last_fname, crypto_strerror(err)); + jcr->impl_->last_fname, crypto_strerror(err)); goto bail_out; } } else { @@ -219,17 +225,17 @@ bool VerifySignature(JobControlRecord* jcr, r_ctx& rctx) * Signature found, digest allocated. Old method, * re-read the file and compute the digest */ - jcr->crypto.digest = digest; + jcr->impl_->crypto.digest = digest; /* * Checksum the entire file * Make sure we don't modify JobBytes by saving and restoring it */ saved_bytes = jcr->JobBytes; - if (FindOneFile(jcr, jcr->ff, DoFileDigest, jcr->last_fname, - (dev_t)-1, 1) != 0) { + if (FindOneFile(jcr, jcr->impl_->ff, DoFileDigest, + jcr->impl_->last_fname, (dev_t)-1, 1) != 0) { Jmsg(jcr, M_ERROR, 0, _("Digest one file failed for file: %s\n"), - jcr->last_fname); + jcr->impl_->last_fname); jcr->JobBytes = saved_bytes; goto bail_out; } @@ -240,19 +246,19 @@ bool VerifySignature(JobControlRecord* jcr, r_ctx& rctx) */ if ((err = CryptoSignVerify(sig, keypair, digest)) != CRYPTO_ERROR_NONE) { - Dmsg1(50, "Bad signature on %s\n", jcr->last_fname); + Dmsg1(50, "Bad signature on %s\n", jcr->impl_->last_fname); Jmsg2(jcr, M_ERROR, 0, _("Signature validation failed for file %s: ERR=%s\n"), - jcr->last_fname, crypto_strerror(err)); + jcr->impl_->last_fname, crypto_strerror(err)); goto bail_out; } - jcr->crypto.digest = NULL; + jcr->impl_->crypto.digest = NULL; } /* * Valid signature */ - Dmsg1(50, "Signature good on %s\n", jcr->last_fname); + Dmsg1(50, "Signature good on %s\n", jcr->impl_->last_fname); CryptoDigestFree(digest); return true; @@ -270,7 +276,7 @@ bool VerifySignature(JobControlRecord* jcr, r_ctx& rctx) * Something strange happened (that shouldn't happen!)... */ Qmsg2(jcr, M_ERROR, 0, _("Signature validation failed for %s: %s\n"), - jcr->last_fname, crypto_strerror(err)); + jcr->impl_->last_fname, crypto_strerror(err)); goto bail_out; } } @@ -279,7 +285,7 @@ bool VerifySignature(JobControlRecord* jcr, r_ctx& rctx) * No signer */ Dmsg1(50, "Could not find a valid public key for signature on %s\n", - jcr->last_fname); + jcr->impl_->last_fname); bail_out: if (digest) { CryptoDigestFree(digest); } @@ -319,7 +325,7 @@ bool FlushCipher(JobControlRecord* jcr, */ Jmsg3(jcr, M_ERROR, 0, _("Decryption error. buf_len=%d decrypt_len=%d on file %s\n"), - cipher_ctx->buf_len, decrypted_len, jcr->last_fname); + cipher_ctx->buf_len, decrypted_len, jcr->impl_->last_fname); } Dmsg2(130, "Flush decrypt len=%d buf_len=%d\n", decrypted_len, @@ -350,7 +356,8 @@ bool FlushCipher(JobControlRecord* jcr, } if (BitIsSet(FO_COMPRESS, flags)) { - if (!DecompressData(jcr, jcr->last_fname, stream, &wbuf, &wsize, false)) { + if (!DecompressData(jcr, jcr->impl_->last_fname, stream, &wbuf, &wsize, + false)) { return false; } } @@ -436,8 +443,9 @@ bool SetupEncryptionContext(b_ctx& bctx) /* * Allocate the cipher context */ - if ((bctx.cipher_ctx = crypto_cipher_new(bctx.jcr->crypto.pki_session, true, - &cipher_block_size)) == NULL) { + if ((bctx.cipher_ctx = crypto_cipher_new( + bctx.jcr->impl_->crypto.pki_session, true, &cipher_block_size)) == + NULL) { /* * Shouldn't happen! */ @@ -453,15 +461,15 @@ bool SetupEncryptionContext(b_ctx& bctx) * could be returned for the given read buffer size. * (Using the larger of either rsize or max_compress_len) */ - bctx.jcr->crypto.crypto_buf = - CheckPoolMemorySize(bctx.jcr->crypto.crypto_buf, + bctx.jcr->impl_->crypto.crypto_buf = + CheckPoolMemorySize(bctx.jcr->impl_->crypto.crypto_buf, (MAX(bctx.jcr->buf_size + (int)sizeof(uint32_t), (int32_t)bctx.max_compress_len) + cipher_block_size - 1) / cipher_block_size * cipher_block_size); bctx.wbuf = - bctx.jcr->crypto + bctx.jcr->impl_->crypto .crypto_buf; /* Encrypted, possibly compressed output here. */ } @@ -479,7 +487,7 @@ bool SetupDecryptionContext(r_ctx& rctx, RestoreCipherContext& rcctx) if (!rctx.cs) { Jmsg1(rctx.jcr, M_ERROR, 0, _("Missing encryption session data stream for %s\n"), - rctx.jcr->last_fname); + rctx.jcr->impl_->last_fname); return false; } @@ -487,7 +495,7 @@ bool SetupDecryptionContext(r_ctx& rctx, RestoreCipherContext& rcctx) NULL) { Jmsg1(rctx.jcr, M_ERROR, 0, _("Failed to initialize decryption context for %s\n"), - rctx.jcr->last_fname); + rctx.jcr->impl_->last_fname); FreeSession(rctx); return false; } @@ -530,7 +538,7 @@ bool EncryptData(b_ctx* bctx, bool* need_more_data) Dmsg1(20, "Encrypt len=%d\n", bctx->cipher_input_len); if (!CryptoCipherUpdate(bctx->cipher_ctx, packet_len, sizeof(packet_len), - (uint8_t*)bctx->jcr->crypto.crypto_buf, + (uint8_t*)bctx->jcr->impl_->crypto.crypto_buf, &initial_len)) { /* * Encryption failed. Shouldn't happen. @@ -542,10 +550,10 @@ bool EncryptData(b_ctx* bctx, bool* need_more_data) /* * Encrypt the input block */ - if (CryptoCipherUpdate(bctx->cipher_ctx, bctx->cipher_input, - bctx->cipher_input_len, - (uint8_t*)&bctx->jcr->crypto.crypto_buf[initial_len], - &bctx->encrypted_len)) { + if (CryptoCipherUpdate( + bctx->cipher_ctx, bctx->cipher_input, bctx->cipher_input_len, + (uint8_t*)&bctx->jcr->impl_->crypto.crypto_buf[initial_len], + &bctx->encrypted_len)) { if ((initial_len + bctx->encrypted_len) == 0) { /* * No full block of data available, read more data diff --git a/core/src/filed/dir_cmd.cc b/core/src/filed/dir_cmd.cc index 7a9d2785b64..b86ae1b27a7 100644 --- a/core/src/filed/dir_cmd.cc +++ b/core/src/filed/dir_cmd.cc @@ -38,6 +38,7 @@ #include "filed/evaluate_job_command.h" #include "filed/heartbeat.h" #include "filed/fileset.h" +#include "filed/jcr_private.h" #include "filed/socket_server.h" #include "filed/restore.h" #include "filed/verify.h" @@ -328,7 +329,7 @@ static inline void CleanupFileset(JobControlRecord* jcr) findIncludeExcludeItem* incexe; findFOPTS* fo; - fileset = jcr->ff->fileset; + fileset = jcr->impl_->ff->fileset; if (fileset) { /* * Delete FileSet Include lists @@ -393,7 +394,7 @@ static inline void CleanupFileset(JobControlRecord* jcr) fileset->exclude_list.destroy(); free(fileset); } - jcr->ff->fileset = nullptr; + jcr->impl_->ff->fileset = nullptr; } static inline bool AreMaxConcurrentJobsExceeded() @@ -409,27 +410,32 @@ static inline bool AreMaxConcurrentJobsExceeded() return (cnt >= me->MaxConcurrentJobs) ? true : false; } +static JobControlRecord* NewFiledJcr() +{ + JobControlRecord* jcr = new_jcr(sizeof(JobControlRecord), FiledFreeJcr); + jcr->impl_ = new JobControlRecordPrivate; + return jcr; +} + JobControlRecord* create_new_director_session(BareosSocket* dir) { - JobControlRecord* jcr; const char jobname[12] = "*Director*"; - jcr = new_jcr(sizeof(JobControlRecord), - FiledFreeJcr); /* create JobControlRecord */ + JobControlRecord* jcr{NewFiledJcr()}; jcr->dir_bsock = dir; - jcr->ff = init_find_files(); + jcr->impl_->ff = init_find_files(); jcr->start_time = time(nullptr); - jcr->RunScripts = new alist(10, not_owned_by_alist); - jcr->last_fname = GetPoolMemory(PM_FNAME); - jcr->last_fname[0] = 0; + jcr->impl_->RunScripts = new alist(10, not_owned_by_alist); + jcr->impl_->last_fname = GetPoolMemory(PM_FNAME); + jcr->impl_->last_fname[0] = 0; jcr->client_name = GetMemory(strlen(my_name) + 1); PmStrcpy(jcr->client_name, my_name); bstrncpy(jcr->Job, jobname, sizeof(jobname)); /* dummy */ - jcr->crypto.pki_sign = me->pki_sign; - jcr->crypto.pki_encrypt = me->pki_encrypt; - jcr->crypto.pki_keypair = me->pki_keypair; - jcr->crypto.pki_signers = me->pki_signers; - jcr->crypto.pki_recipients = me->pki_recipients; + jcr->impl_->crypto.pki_sign = me->pki_sign; + jcr->impl_->crypto.pki_encrypt = me->pki_encrypt; + jcr->impl_->crypto.pki_keypair = me->pki_keypair; + jcr->impl_->crypto.pki_signers = me->pki_signers; + jcr->impl_->crypto.pki_recipients = me->pki_recipients; if (dir) { dir->SetJcr(jcr); } SetJcrInThreadSpecificData(jcr); @@ -463,7 +469,7 @@ void* process_director_commands(JobControlRecord* jcr, BareosSocket* dir) for (int i = 0; cmds[i].cmd; i++) { if (bstrncmp(cmds[i].cmd, dir->msg, strlen(cmds[i].cmd))) { found = true; /* indicate command found */ - if ((!cmds[i].monitoraccess) && (jcr->director->monitor)) { + if ((!cmds[i].monitoraccess) && (jcr->impl_->director->monitor)) { Dmsg1(100, "Command \"%s\" is invalid.\n", cmds[i].cmd); dir->fsend(invalid_cmd); dir->signal(BNET_EOD); @@ -492,11 +498,12 @@ void* process_director_commands(JobControlRecord* jcr, BareosSocket* dir) /* * Run the after job */ - if (jcr->RunScripts) { - RunScripts(jcr, jcr->RunScripts, "ClientAfterJob", - (jcr->director && jcr->director->allowed_script_dirs) - ? jcr->director->allowed_script_dirs - : me->allowed_script_dirs); + if (jcr->impl_->RunScripts) { + RunScripts( + jcr, jcr->impl_->RunScripts, "ClientAfterJob", + (jcr->impl_->director && jcr->impl_->director->allowed_script_dirs) + ? jcr->impl_->director->allowed_script_dirs + : me->allowed_script_dirs); } if (jcr->JobId) { /* send EndJob if running a job */ @@ -506,8 +513,8 @@ void* process_director_commands(JobControlRecord* jcr, BareosSocket* dir) */ dir->fsend(EndJob, jcr->JobStatus, jcr->JobFiles, edit_uint64(jcr->ReadBytes, ed1), - edit_uint64(jcr->JobBytes, ed2), jcr->JobErrors, jcr->enable_vss, - jcr->crypto.pki_encrypt); + edit_uint64(jcr->JobBytes, ed2), jcr->JobErrors, + jcr->impl_->enable_vss, jcr->impl_->crypto.pki_encrypt); Dmsg1(110, "End FD msg: %s\n", dir->msg); } @@ -521,7 +528,7 @@ void* process_director_commands(JobControlRecord* jcr, BareosSocket* dir) dir->signal(BNET_TERMINATE); FreePlugins(jcr); /* release instantiated plugins */ - FreeAndNullPoolMemory(jcr->job_metadata); + FreeAndNullPoolMemory(jcr->impl_->job_metadata); /* * Clean up fileset @@ -934,15 +941,16 @@ static bool EstimateCmd(JobControlRecord* jcr) /* * See if we are allowed to run estimate cmds. */ - if (!ValidateCommand(jcr, "estimate", - (jcr->director && jcr->director->allowed_job_cmds) - ? jcr->director->allowed_job_cmds - : me->allowed_job_cmds)) { + if (!ValidateCommand( + jcr, "estimate", + (jcr->impl_->director && jcr->impl_->director->allowed_job_cmds) + ? jcr->impl_->director->allowed_job_cmds + : me->allowed_job_cmds)) { dir->fsend(_("2992 Bad estimate command.\n")); return 0; } - if (sscanf(dir->msg, Estimatecmd, &jcr->listing) != 1) { + if (sscanf(dir->msg, Estimatecmd, &jcr->impl_->listing) != 1) { PmStrcpy(jcr->errmsg, dir->msg); Jmsg(jcr, M_FATAL, 0, _("Bad estimate command: %s"), jcr->errmsg); dir->fsend(_("2992 Bad estimate command.\n")); @@ -951,7 +959,8 @@ static bool EstimateCmd(JobControlRecord* jcr) MakeEstimate(jcr); - dir->fsend(OKest, edit_uint64_with_commas(jcr->num_files_examined, ed1), + dir->fsend(OKest, + edit_uint64_with_commas(jcr->impl_->num_files_examined, ed1), edit_uint64_with_commas(jcr->JobBytes, ed2)); dir->signal(BNET_EOD); @@ -1057,9 +1066,9 @@ static bool RunbeforenowCmd(JobControlRecord* jcr) { BareosSocket* dir = jcr->dir_bsock; - RunScripts(jcr, jcr->RunScripts, "ClientBeforeJob", - (jcr->director && jcr->director->allowed_script_dirs) - ? jcr->director->allowed_script_dirs + RunScripts(jcr, jcr->impl_->RunScripts, "ClientBeforeJob", + (jcr->impl_->director && jcr->impl_->director->allowed_script_dirs) + ? jcr->impl_->director->allowed_script_dirs : me->allowed_script_dirs); if (JobCanceled(jcr)) { @@ -1104,7 +1113,7 @@ static bool RunafterCmd(JobControlRecord* jcr) script->when = SCRIPT_After; FreeMemory(cmd); - jcr->RunScripts->append(script); + jcr->impl_->RunScripts->append(script); return dir->fsend(OKRunAfter); } @@ -1119,10 +1128,11 @@ static bool RunscriptCmd(JobControlRecord* jcr) /* * See if we are allowed to run runscript cmds. */ - if (!ValidateCommand(jcr, "runscript", - (jcr->director && jcr->director->allowed_job_cmds) - ? jcr->director->allowed_job_cmds - : me->allowed_job_cmds)) { + if (!ValidateCommand( + jcr, "runscript", + (jcr->impl_->director && jcr->impl_->director->allowed_job_cmds) + ? jcr->impl_->director->allowed_job_cmds + : me->allowed_job_cmds)) { dir->fsend(FailedRunScript); return 0; } @@ -1154,7 +1164,7 @@ static bool RunscriptCmd(JobControlRecord* jcr) cmd->SetCommand(msg); cmd->Debug(); - jcr->RunScripts->append(cmd); + jcr->impl_->RunScripts->append(cmd); FreePoolMemory(msg); @@ -1301,7 +1311,7 @@ static bool RestoreObjectCmd(JobControlRecord* jcr) */ if (bstrcmp(rop.object_name, "job_metadata.xml")) { Dmsg0(100, "got job metadata\n"); - jcr->got_metadata = true; + jcr->impl_->got_metadata = true; } GeneratePluginEvent(jcr, bEventRestoreObject, (void*)&rop); @@ -1327,7 +1337,7 @@ static inline int CountIncludeListFileEntries(JobControlRecord* jcr) findFILESET* fileset; findIncludeExcludeItem* incexe; - fileset = jcr->ff->fileset; + fileset = jcr->impl_->ff->fileset; if (fileset) { for (int i = 0; i < fileset->include_list.size(); i++) { incexe = (findIncludeExcludeItem*)fileset->include_list.get(i); @@ -1363,13 +1373,13 @@ static bool FilesetCmd(JobControlRecord* jcr) if (!TermFileset(jcr)) { return false; } #if defined(WIN32_VSS) - jcr->enable_vss = + jcr->impl_->enable_vss = (vss && (CountIncludeListFileEntries(jcr) > 0)) ? true : false; #endif retval = dir->fsend(OKinc); GeneratePluginEvent(jcr, bEventEndFileSet); - CheckIncludeListShadowing(jcr, jcr->ff->fileset); + CheckIncludeListShadowing(jcr, jcr->impl_->ff->fileset); return retval; } @@ -1484,7 +1494,7 @@ static bool LevelCmd(JobControlRecord* jcr) } if (sscanf(dir->msg, "level = since_utime %s mtime_only=%d prev_job=%127s", - buf, &mtime_only, jcr->PrevJob) != 3) { + buf, &mtime_only, jcr->impl_->PrevJob) != 3) { if (sscanf(dir->msg, "level = since_utime %s mtime_only=%d", buf, &mtime_only) != 2) { goto bail_out; @@ -1492,7 +1502,8 @@ static bool LevelCmd(JobControlRecord* jcr) } since_time = str_to_uint64(buf); /* this is the since time */ - Dmsg2(100, "since_time=%lld prev_job=%s\n", since_time, jcr->PrevJob); + Dmsg2(100, "since_time=%lld prev_job=%s\n", since_time, + jcr->impl_->PrevJob); /* * Sync clocks by polling him for the time. We take 10 samples of his time * throwing out the first two. @@ -1540,9 +1551,9 @@ static bool LevelCmd(JobControlRecord* jcr) dir->signal(BNET_EOD); Dmsg2(100, "adj=%lld since_time=%lld\n", adj, since_time); - jcr->incremental = true; /* set incremental or decremental backup */ - jcr->mtime = since_time; /* set since time */ - GeneratePluginEvent(jcr, bEventSince, (void*)(time_t)jcr->mtime); + jcr->impl_->incremental = true; /* set incremental or decremental backup */ + jcr->impl_->mtime = since_time; /* set since time */ + GeneratePluginEvent(jcr, bEventSince, (void*)(time_t)jcr->impl_->mtime); } else { Jmsg1(jcr, M_FATAL, 0, _("Unknown backup level: %s\n"), level); FreeMemory(level); @@ -1574,8 +1585,8 @@ static bool SessionCmd(JobControlRecord* jcr) Dmsg1(100, "SessionCmd: %s", dir->msg); if (sscanf(dir->msg, sessioncmd, jcr->VolumeName, &jcr->VolSessionId, - &jcr->VolSessionTime, &jcr->StartFile, &jcr->EndFile, - &jcr->StartBlock, &jcr->EndBlock) != 7) { + &jcr->VolSessionTime, &jcr->impl_->StartFile, &jcr->impl_->EndFile, + &jcr->impl_->StartBlock, &jcr->impl_->EndBlock) != 7) { PmStrcpy(jcr->errmsg, dir->msg); Jmsg(jcr, M_FATAL, 0, _("Bad session command: %s"), jcr->errmsg); return false; @@ -1610,7 +1621,7 @@ static void SetStorageAuthKeyAndTlsPolicy(JobControlRecord* jcr, * restore */ Dmsg0(5, "set multi_restore=true\n"); - jcr->multi_restore = true; + jcr->impl_->multi_restore = true; free(jcr->sd_auth_key); } @@ -1657,8 +1668,8 @@ static bool StorageCmd(JobControlRecord* jcr) * TODO: see if we put limit on restore and backup... */ if (!jcr->max_bandwidth) { - if (jcr->director->max_bandwidth_per_job) { - jcr->max_bandwidth = jcr->director->max_bandwidth_per_job; + if (jcr->impl_->director->max_bandwidth_per_job) { + jcr->max_bandwidth = jcr->impl_->director->max_bandwidth_per_job; } else if (me->max_bandwidth_per_job) { jcr->max_bandwidth = me->max_bandwidth_per_job; } @@ -1724,7 +1735,7 @@ static void LogFlagStatus(JobControlRecord* jcr, int flag, const char* flag_text) { - findFILESET* fileset = jcr->ff->fileset; + findFILESET* fileset = jcr->impl_->ff->fileset; bool found = false; if (fileset) { for (int i = 0; i < fileset->include_list.size() && !found; i++) { @@ -1758,7 +1769,7 @@ static inline void ClearFlagInFileset(JobControlRecord* jcr, findFILESET* fileset; bool cleared_flag = false; - fileset = jcr->ff->fileset; + fileset = jcr->impl_->ff->fileset; if (fileset) { for (int i = 0; i < fileset->include_list.size(); i++) { findIncludeExcludeItem* incexe = @@ -1788,7 +1799,7 @@ static inline void ClearCompressionFlagInFileset(JobControlRecord* jcr) { findFILESET* fileset; - fileset = jcr->ff->fileset; + fileset = jcr->impl_->ff->fileset; if (fileset) { for (int i = 0; i < fileset->include_list.size(); i++) { findIncludeExcludeItem* incexe = @@ -1848,7 +1859,7 @@ static inline bool GetWantedCryptoCipher(JobControlRecord* jcr, * Walk the fileset and check for the FO_FORCE_ENCRYPT flag and any forced * crypto cipher. */ - fileset = jcr->ff->fileset; + fileset = jcr->impl_->ff->fileset; if (fileset) { for (int i = 0; i < fileset->include_list.size(); i++) { findIncludeExcludeItem* incexe = @@ -1872,7 +1883,7 @@ static inline bool GetWantedCryptoCipher(JobControlRecord* jcr, /* * See if pki_encrypt is already set for this Job. */ - if (!jcr->crypto.pki_encrypt) { + if (!jcr->impl_->crypto.pki_encrypt) { if (!me->pki_keypair_file) { Jmsg(jcr, M_FATAL, 0, _("Fileset contains cipher settings but PKI Key Pair is not " @@ -1883,8 +1894,8 @@ static inline bool GetWantedCryptoCipher(JobControlRecord* jcr, /* * Enable encryption and signing for this Job. */ - jcr->crypto.pki_sign = true; - jcr->crypto.pki_encrypt = true; + jcr->impl_->crypto.pki_sign = true; + jcr->impl_->crypto.pki_encrypt = true; } wanted_cipher = (crypto_cipher_t)fo->Encryption_cipher; @@ -1908,7 +1919,7 @@ static inline bool GetWantedCryptoCipher(JobControlRecord* jcr, * See if FO_FORCE_ENCRYPT is set and encryption is not configured for the * filed. */ - if (force_encrypt && !jcr->crypto.pki_encrypt) { + if (force_encrypt && !jcr->impl_->crypto.pki_encrypt) { Jmsg(jcr, M_FATAL, 0, _("Fileset forces encryption but encryption is not configured\n")); return false; @@ -1945,15 +1956,16 @@ static bool BackupCmd(JobControlRecord* jcr) /* * See if we are allowed to run backup cmds. */ - if (!ValidateCommand(jcr, "backup", - (jcr->director && jcr->director->allowed_job_cmds) - ? jcr->director->allowed_job_cmds - : me->allowed_job_cmds)) { + if (!ValidateCommand( + jcr, "backup", + (jcr->impl_->director && jcr->impl_->director->allowed_job_cmds) + ? jcr->impl_->director->allowed_job_cmds + : me->allowed_job_cmds)) { goto cleanup; } #if defined(WIN32_VSS) - if (jcr->enable_vss) { VSSInit(jcr); } + if (jcr->impl_->enable_vss) { VSSInit(jcr); } #endif if (sscanf(dir->msg, "backup FileIndex=%ld\n", &FileIndex) == 1) { @@ -1997,7 +2009,7 @@ static bool BackupCmd(JobControlRecord* jcr) jcr->setJobStatus(JS_Blocked); jcr->setJobType(JT_BACKUP); - Dmsg1(100, "begin backup ff=%p\n", jcr->ff); + Dmsg1(100, "begin backup ff=%p\n", jcr->impl_->ff); if (sd == nullptr) { Jmsg(jcr, M_FATAL, 0, _("Cannot contact Storage daemon\n")); @@ -2019,11 +2031,11 @@ static bool BackupCmd(JobControlRecord* jcr) */ if (BgetMsg(sd) >= 0) { Dmsg1(110, "msg); - if (sscanf(sd->msg, OK_open, &jcr->Ticket) != 1) { + if (sscanf(sd->msg, OK_open, &jcr->impl_->Ticket) != 1) { Jmsg(jcr, M_FATAL, 0, _("Bad response to append open: %s\n"), sd->msg); goto cleanup; } - Dmsg1(110, "Got Ticket=%d\n", jcr->Ticket); + Dmsg1(110, "Got Ticket=%d\n", jcr->impl_->Ticket); } else { Jmsg(jcr, M_FATAL, 0, _("Bad response from stored to open command\n")); goto cleanup; @@ -2032,7 +2044,7 @@ static bool BackupCmd(JobControlRecord* jcr) /** * Send Append data command to Storage daemon */ - sd->fsend(append_data, jcr->Ticket); + sd->fsend(append_data, jcr->impl_->Ticket); Dmsg1(110, ">stored: %s", sd->msg); /** @@ -2050,8 +2062,8 @@ static bool BackupCmd(JobControlRecord* jcr) /* * START VSS ON WIN32 */ - if (jcr->pVSSClient) { - if (jcr->pVSSClient->InitializeForBackup(jcr)) { + if (jcr->impl_->pVSSClient) { + if (jcr->impl_->pVSSClient->InitializeForBackup(jcr)) { int drive_count; char szWinDriveLetters[27]; bool onefs_disabled; @@ -2068,18 +2080,19 @@ static bool BackupCmd(JobControlRecord* jcr) */ GeneratePluginEvent(jcr, bEventVssPrepareSnapshot, szWinDriveLetters); - drive_count = get_win32_driveletters(jcr->ff->fileset, szWinDriveLetters); + drive_count = + get_win32_driveletters(jcr->impl_->ff->fileset, szWinDriveLetters); - onefs_disabled = win32_onefs_is_disabled(jcr->ff->fileset); + onefs_disabled = win32_onefs_is_disabled(jcr->impl_->ff->fileset); if (drive_count > 0) { Jmsg(jcr, M_INFO, 0, _("Generate VSS snapshots. Driver=\"%s\", Drive(s)=\"%s\"\n"), - jcr->pVSSClient->GetDriverName(), + jcr->impl_->pVSSClient->GetDriverName(), (drive_count) ? szWinDriveLetters : "None"); - if (!jcr->pVSSClient->CreateSnapshots(szWinDriveLetters, - onefs_disabled)) { + if (!jcr->impl_->pVSSClient->CreateSnapshots(szWinDriveLetters, + onefs_disabled)) { BErrNo be; Jmsg(jcr, M_FATAL, 0, _("CreateSGenerate VSS snapshots failed. ERR=%s\n"), @@ -2090,7 +2103,7 @@ static bool BackupCmd(JobControlRecord* jcr) /* * Inform about VMPs if we have them */ - jcr->pVSSClient->ShowVolumeMountPointStats(jcr); + jcr->impl_->pVSSClient->ShowVolumeMountPointStats(jcr); /* * Tell user if snapshot creation of a specific drive failed @@ -2106,10 +2119,11 @@ static bool BackupCmd(JobControlRecord* jcr) /* * Inform user about writer states */ - for (size_t i = 0; i < jcr->pVSSClient->GetWriterCount(); i++) { - if (jcr->pVSSClient->GetWriterState(i) < 1) { + for (size_t i = 0; i < jcr->impl_->pVSSClient->GetWriterCount(); + i++) { + if (jcr->impl_->pVSSClient->GetWriterState(i) < 1) { Jmsg(jcr, M_INFO, 0, _("VSS Writer (PrepareForBackup): %s\n"), - jcr->pVSSClient->GetWriterInfo(i)); + jcr->impl_->pVSSClient->GetWriterInfo(i)); } } } @@ -2125,17 +2139,18 @@ static bool BackupCmd(JobControlRecord* jcr) be.bstrerror()); } - RunScripts(jcr, jcr->RunScripts, "ClientAfterVSS", - (jcr->director && jcr->director->allowed_script_dirs) - ? jcr->director->allowed_script_dirs - : me->allowed_script_dirs); + RunScripts( + jcr, jcr->impl_->RunScripts, "ClientAfterVSS", + (jcr->impl_->director && jcr->impl_->director->allowed_script_dirs) + ? jcr->impl_->director->allowed_script_dirs + : me->allowed_script_dirs); } #endif /** * Send Files to Storage daemon */ - Dmsg1(110, "begin blast ff=%p\n", (FindFilesPacket*)jcr->ff); + Dmsg1(110, "begin blast ff=%p\n", (FindFilesPacket*)jcr->impl_->ff); if (!BlastDataToStorageDaemon(jcr, nullptr, cipher)) { jcr->setJobStatus(JS_ErrorTerminated); BnetSuppressErrorMessages(sd, 1); @@ -2158,7 +2173,7 @@ static bool BackupCmd(JobControlRecord* jcr) /** * Send Append End Data to Storage daemon */ - sd->fsend(append_end, jcr->Ticket); + sd->fsend(append_end, jcr->impl_->Ticket); /* Get end OK */ if (!response(jcr, sd, OK_end, "Append End")) { jcr->setJobStatus(JS_ErrorTerminated); @@ -2168,7 +2183,7 @@ static bool BackupCmd(JobControlRecord* jcr) /** * Send Append Close to Storage daemon */ - sd->fsend(append_close, jcr->Ticket); + sd->fsend(append_close, jcr->impl_->Ticket); while (BgetMsg(sd) >= 0) { /* stop on signal or error */ if (sscanf(sd->msg, OK_close, &SDJobStatus) == 1) { ok = 1; @@ -2187,7 +2202,7 @@ static bool BackupCmd(JobControlRecord* jcr) cleanup: #if defined(WIN32_VSS) - if (jcr->pVSSClient) { jcr->pVSSClient->DestroyWriterInfo(); } + if (jcr->impl_->pVSSClient) { jcr->impl_->pVSSClient->DestroyWriterInfo(); } #endif GeneratePluginEvent(jcr, bEventEndBackupJob); @@ -2207,10 +2222,11 @@ static bool VerifyCmd(JobControlRecord* jcr) /* * See if we are allowed to run verify cmds. */ - if (!ValidateCommand(jcr, "verify", - (jcr->director && jcr->director->allowed_job_cmds) - ? jcr->director->allowed_job_cmds - : me->allowed_job_cmds)) { + if (!ValidateCommand( + jcr, "verify", + (jcr->impl_->director && jcr->impl_->director->allowed_job_cmds) + ? jcr->impl_->director->allowed_job_cmds + : me->allowed_job_cmds)) { dir->fsend(_("2994 Bad verify command: %s\n"), dir->msg); return 0; } @@ -2256,7 +2272,7 @@ static bool VerifyCmd(JobControlRecord* jcr) /* * Send Close session command to Storage daemon */ - sd->fsend(read_close, jcr->Ticket); + sd->fsend(read_close, jcr->impl_->Ticket); Dmsg1(130, "filed>stored: %s", sd->msg); /* ****FIXME**** check response */ @@ -2336,7 +2352,7 @@ static BareosSocket* connect_to_director(JobControlRecord* jcr, director_socket->recv(); ParseOkVersion(director_socket->msg); - jcr->director = dir_res; + jcr->impl_->director = dir_res; return director_socket.release(); } @@ -2368,10 +2384,11 @@ static bool RestoreCmd(JobControlRecord* jcr) /* * See if we are allowed to run restore cmds. */ - if (!ValidateCommand(jcr, "restore", - (jcr->director && jcr->director->allowed_job_cmds) - ? jcr->director->allowed_job_cmds - : me->allowed_job_cmds)) { + if (!ValidateCommand( + jcr, "restore", + (jcr->impl_->director && jcr->impl_->director->allowed_job_cmds) + ? jcr->impl_->director->allowed_job_cmds + : me->allowed_job_cmds)) { return 0; } @@ -2405,9 +2422,9 @@ static bool RestoreCmd(JobControlRecord* jcr) /** * No need to enable VSS for restore if we do not have plugin data to restore */ - jcr->enable_vss = jcr->got_metadata; + jcr->impl_->enable_vss = jcr->impl_->got_metadata; - if (jcr->enable_vss) { VSSInit(jcr); } + if (jcr->impl_->enable_vss) { VSSInit(jcr); } #endif /* @@ -2435,7 +2452,7 @@ static bool RestoreCmd(JobControlRecord* jcr) } FreePoolMemory(args); - jcr->replace = replace; + jcr->impl_->replace = replace; jcr->prefix_links = prefix_links; dir->fsend(OKrestore); @@ -2460,8 +2477,8 @@ static bool RestoreCmd(JobControlRecord* jcr) /* * START VSS ON WIN32 */ - if (jcr->pVSSClient) { - if (!jcr->pVSSClient->InitializeForRestore(jcr)) { + if (jcr->impl_->pVSSClient) { + if (!jcr->impl_->pVSSClient->InitializeForRestore(jcr)) { BErrNo be; Jmsg(jcr, M_WARNING, 0, _("VSS was not initialized properly. VSS support is disabled. " @@ -2471,10 +2488,11 @@ static bool RestoreCmd(JobControlRecord* jcr) GeneratePluginEvent(jcr, bEventVssRestoreLoadComponentMetadata); - RunScripts(jcr, jcr->RunScripts, "ClientAfterVSS", - (jcr->director && jcr->director->allowed_script_dirs) - ? jcr->director->allowed_script_dirs - : me->allowed_script_dirs); + RunScripts( + jcr, jcr->impl_->RunScripts, "ClientAfterVSS", + (jcr->impl_->director && jcr->impl_->director->allowed_script_dirs) + ? jcr->impl_->director->allowed_script_dirs + : me->allowed_script_dirs); } #endif @@ -2490,7 +2508,7 @@ static bool RestoreCmd(JobControlRecord* jcr) /** * Send Close session command to Storage daemon */ - sd->fsend(read_close, jcr->Ticket); + sd->fsend(read_close, jcr->impl_->Ticket); Dmsg1(100, "filed>stored: %s", sd->msg); BgetMsg(sd); /* get OK */ @@ -2503,26 +2521,26 @@ static bool RestoreCmd(JobControlRecord* jcr) * STOP VSS ON WIN32 * Tell vss to close the restore session */ - if (jcr->pVSSClient) { + if (jcr->impl_->pVSSClient) { Dmsg0(100, "About to call CloseRestore\n"); GeneratePluginEvent(jcr, bEventVssCloseRestore); Dmsg0(100, "Really about to call CloseRestore\n"); - if (jcr->pVSSClient->CloseRestore()) { + if (jcr->impl_->pVSSClient->CloseRestore()) { Dmsg0(100, "CloseRestore success\n"); /* * Inform user about writer states */ - for (size_t i = 0; i < jcr->pVSSClient->GetWriterCount(); i++) { + for (size_t i = 0; i < jcr->impl_->pVSSClient->GetWriterCount(); i++) { int msg_type = M_INFO; - if (jcr->pVSSClient->GetWriterState(i) < 1) { + if (jcr->impl_->pVSSClient->GetWriterState(i) < 1) { msg_type = M_WARNING; jcr->JobErrors++; } Jmsg(jcr, msg_type, 0, _("VSS Writer (RestoreComplete): %s\n"), - jcr->pVSSClient->GetWriterInfo(i)); + jcr->impl_->pVSSClient->GetWriterInfo(i)); } } else { Dmsg1(100, "CloseRestore fail - %08x\n", errno); @@ -2537,7 +2555,7 @@ static bool RestoreCmd(JobControlRecord* jcr) Dmsg0(100, "Done in job.c\n"); - if (jcr->multi_restore) { + if (jcr->impl_->multi_restore) { Dmsg0(100, OKstoreend); dir->fsend(OKstoreend); retval = true; /* we continue the loop, waiting for next part */ @@ -2570,13 +2588,14 @@ static bool OpenSdReadSession(JobControlRecord* jcr) return false; } Dmsg4(120, "VolSessId=%ld VolsessT=%ld SF=%ld EF=%ld\n", jcr->VolSessionId, - jcr->VolSessionTime, jcr->StartFile, jcr->EndFile); + jcr->VolSessionTime, jcr->impl_->StartFile, jcr->impl_->EndFile); Dmsg2(120, "JobId=%d vol=%s\n", jcr->JobId, "DummyVolume"); /* * Open Read Session with Storage daemon */ sd->fsend(read_open, "DummyVolume", jcr->VolSessionId, jcr->VolSessionTime, - jcr->StartFile, jcr->EndFile, jcr->StartBlock, jcr->EndBlock); + jcr->impl_->StartFile, jcr->impl_->EndFile, jcr->impl_->StartBlock, + jcr->impl_->EndBlock); Dmsg1(110, ">stored: %s", sd->msg); /* @@ -2584,11 +2603,11 @@ static bool OpenSdReadSession(JobControlRecord* jcr) */ if (BgetMsg(sd) >= 0) { Dmsg1(110, "filedmsg); - if (sscanf(sd->msg, OK_open, &jcr->Ticket) != 1) { + if (sscanf(sd->msg, OK_open, &jcr->impl_->Ticket) != 1) { Jmsg(jcr, M_FATAL, 0, _("Bad response to SD read open: %s\n"), sd->msg); return false; } - Dmsg1(110, "filed: got Ticket=%d\n", jcr->Ticket); + Dmsg1(110, "filed: got Ticket=%d\n", jcr->impl_->Ticket); } else { Jmsg(jcr, M_FATAL, 0, _("Bad response from stored to read open command\n")); return false; @@ -2597,7 +2616,7 @@ static bool OpenSdReadSession(JobControlRecord* jcr) /* * Start read of data with Storage daemon */ - sd->fsend(read_data, jcr->Ticket); + sd->fsend(read_data, jcr->impl_->Ticket); Dmsg1(110, ">stored: %s", sd->msg); /* @@ -2614,9 +2633,9 @@ static bool OpenSdReadSession(JobControlRecord* jcr) static void FiledFreeJcr(JobControlRecord* jcr) { #if defined(WIN32_VSS) - if (jcr->pVSSClient) { - delete jcr->pVSSClient; - jcr->pVSSClient = nullptr; + if (jcr->impl_->pVSSClient) { + delete jcr->impl_->pVSSClient; + jcr->impl_->pVSSClient = nullptr; } #endif @@ -2632,26 +2651,31 @@ static void FiledFreeJcr(JobControlRecord* jcr) jcr->dir_bsock = nullptr; } - if (jcr->last_fname) { FreePoolMemory(jcr->last_fname); } + if (jcr->impl_->last_fname) { FreePoolMemory(jcr->impl_->last_fname); } FreeBootstrap(jcr); - FreeRunscripts(jcr->RunScripts); - delete jcr->RunScripts; - jcr->RunScripts = nullptr; + FreeRunscripts(jcr->impl_->RunScripts); + delete jcr->impl_->RunScripts; + jcr->impl_->RunScripts = nullptr; if (jcr->path_list) { FreePathList(jcr->path_list); jcr->path_list = nullptr; } - TermFindFiles(jcr->ff); - jcr->ff = nullptr; + TermFindFiles(jcr->impl_->ff); + jcr->impl_->ff = nullptr; if (jcr->JobId != 0) { WriteStateFile(me->working_directory, "bareos-fd", GetFirstPortHostOrder(me->FDaddrs)); } + if (jcr->impl_) { + delete jcr->impl_; + jcr->impl_ = nullptr; + } + return; } diff --git a/core/src/filed/estimate.cc b/core/src/filed/estimate.cc index 690f27cfe70..1395627168a 100644 --- a/core/src/filed/estimate.cc +++ b/core/src/filed/estimate.cc @@ -30,6 +30,7 @@ #include "include/bareos.h" #include "filed/filed.h" +#include "filed/jcr_private.h" #include "filed/accurate.h" namespace filedaemon { @@ -45,13 +46,15 @@ int MakeEstimate(JobControlRecord* jcr) jcr->setJobStatus(JS_Running); - SetFindOptions((FindFilesPacket*)jcr->ff, jcr->incremental, jcr->mtime); + SetFindOptions((FindFilesPacket*)jcr->impl_->ff, jcr->impl_->incremental, + jcr->impl_->mtime); /* in accurate mode, we overwrite the find_one check function */ if (jcr->accurate) { - SetFindChangedFunction((FindFilesPacket*)jcr->ff, AccurateCheckFile); + SetFindChangedFunction((FindFilesPacket*)jcr->impl_->ff, AccurateCheckFile); } - status = FindFiles(jcr, (FindFilesPacket*)jcr->ff, TallyFile, PluginEstimate); + status = FindFiles(jcr, (FindFilesPacket*)jcr->impl_->ff, TallyFile, + PluginEstimate); AccurateFree(jcr); return status; } @@ -106,9 +109,9 @@ static int TallyFile(JobControlRecord* jcr, } #endif } - jcr->num_files_examined++; + jcr->impl_->num_files_examined++; jcr->JobFiles++; /* increment number of files seen */ - if (jcr->listing) { + if (jcr->impl_->listing) { memcpy(&attr.statp, &ff_pkt->statp, sizeof(struct stat)); attr.type = ff_pkt->type; attr.ofname = (POOLMEM*)ff_pkt->fname; diff --git a/core/src/filed/fd_plugins.cc b/core/src/filed/fd_plugins.cc index bcab309f629..a1cada963ae 100644 --- a/core/src/filed/fd_plugins.cc +++ b/core/src/filed/fd_plugins.cc @@ -34,6 +34,7 @@ #include "filed/heartbeat.h" #include "filed/fileset.h" #include "filed/heartbeat.h" +#include "filed/jcr_private.h" #include "findlib/attribs.h" #include "findlib/find.h" #include "findlib/find_one.h" @@ -742,8 +743,8 @@ int PluginSave(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool top_level) goto bail_out; } - jcr->plugin_sp = &sp; - ff_pkt = jcr->ff; + jcr->impl_->plugin_sp = &sp; + ff_pkt = jcr->impl_->ff; /* * Save original flags. @@ -1009,13 +1010,13 @@ int PluginEstimate(JobControlRecord* jcr, default: break; } - jcr->num_files_examined++; + jcr->impl_->num_files_examined++; if (sp.type != FT_LNKSAVED && S_ISREG(sp.statp.st_mode)) { if (sp.statp.st_size > 0) { jcr->JobBytes += sp.statp.st_size; } } - if (jcr->listing) { + if (jcr->impl_->listing) { memcpy(&attr.statp, &sp.statp, sizeof(struct stat)); attr.type = sp.type; attr.ofname = (POOLMEM*)sp.fname; @@ -1057,7 +1058,7 @@ bool SendPluginName(JobControlRecord* jcr, BareosSocket* sd, bool start) { int status; int index = jcr->JobFiles; - struct save_pkt* sp = (struct save_pkt*)jcr->plugin_sp; + struct save_pkt* sp = (struct save_pkt*)jcr->impl_->plugin_sp; if (!sp) { Jmsg0(jcr, M_FATAL, 0, _("Plugin save packet not found.\n")); @@ -1257,7 +1258,7 @@ int PluginCreateFile(JobControlRecord* jcr, rp.olname = attr->olname; rp.where = jcr->where; rp.RegexWhere = jcr->RegexWhere; - rp.replace = jcr->replace; + rp.replace = jcr->impl_->replace; rp.create_status = CF_ERROR; Dmsg4(debuglevel, @@ -1355,7 +1356,7 @@ bool PluginSetAttributes(JobControlRecord* jcr, rp.olname = attr->olname; rp.where = jcr->where; rp.RegexWhere = jcr->RegexWhere; - rp.replace = jcr->replace; + rp.replace = jcr->impl_->replace; rp.create_status = CF_ERROR; PlugFunc(plugin)->setFileAttributes(jcr->plugin_ctx, &rp); @@ -2107,7 +2108,7 @@ static bRC bareosGetValue(bpContext* ctx, bVariable var, void* value) NPRT(*((char**)value))); break; case bVarPrevJobName: - *((char**)value) = jcr->PrevJob; + *((char**)value) = jcr->impl_->PrevJob; Dmsg1(debuglevel, "fd-plugin: return bVarPrevJobName=%s\n", NPRT(*((char**)value))); break; @@ -2117,9 +2118,9 @@ static bRC bareosGetValue(bpContext* ctx, bVariable var, void* value) jcr->JobStatus); break; case bVarSinceTime: - *((int*)value) = (int)jcr->mtime; + *((int*)value) = (int)jcr->impl_->mtime; Dmsg1(debuglevel, "fd-plugin: return bVarSinceTime=%d\n", - (int)jcr->mtime); + (int)jcr->impl_->mtime); break; case bVarAccurate: *((int*)value) = (int)jcr->accurate; @@ -2130,8 +2131,8 @@ static bRC bareosGetValue(bpContext* ctx, bVariable var, void* value) break; /* a write only variable, ignore read request */ case bVarVssClient: #ifdef HAVE_WIN32 - if (jcr->pVSSClient) { - *(void**)value = jcr->pVSSClient; + if (jcr->impl_->pVSSClient) { + *(void**)value = jcr->impl_->pVSSClient; Dmsg1(debuglevel, "fd-plugin: return bVarVssClient=%p\n", *(void**)value); break; @@ -2339,7 +2340,7 @@ static bRC bareosAddExclude(bpContext* ctx, const char* fname) */ if (!old) { return bRC_Error; } - if (!bctx->exclude) { bctx->exclude = new_exclude(jcr->ff->fileset); } + if (!bctx->exclude) { bctx->exclude = new_exclude(jcr->impl_->ff->fileset); } /* * Set the Exclude context @@ -2444,7 +2445,7 @@ static bRC bareosNewOptions(bpContext* ctx) b_plugin_ctx* bctx; if (!IsCtxGood(ctx, jcr, bctx)) { return bRC_Error; } - (void)NewOptions(jcr->ff, jcr->ff->fileset->incexe); + (void)NewOptions(jcr->impl_->ff, jcr->impl_->ff->fileset->incexe); return bRC_OK; } @@ -2455,7 +2456,7 @@ static bRC bareosNewInclude(bpContext* ctx) b_plugin_ctx* bctx; if (!IsCtxGood(ctx, jcr, bctx)) { return bRC_Error; } - (void)new_include(jcr->ff->fileset); + (void)new_include(jcr->impl_->ff->fileset); return bRC_OK; } @@ -2467,8 +2468,8 @@ static bRC bareosNewPreInclude(bpContext* ctx) if (!IsCtxGood(ctx, jcr, bctx)) { return bRC_Error; } - bctx->include = new_preinclude(jcr->ff->fileset); - NewOptions(jcr->ff, bctx->include); + bctx->include = new_preinclude(jcr->impl_->ff->fileset); + NewOptions(jcr->impl_->ff, bctx->include); SetIncexe(jcr, bctx->include); return bRC_OK; @@ -2488,7 +2489,7 @@ static bRC bareosCheckChanges(bpContext* ctx, struct save_pkt* sp) if (!sp) { goto bail_out; } - ff_pkt = jcr->ff; + ff_pkt = jcr->impl_->ff; /* * Copy fname and link because SaveFile() zaps them. * This avoids zaping the plugin's strings. @@ -2538,7 +2539,7 @@ static bRC bareosAcceptFile(bpContext* ctx, struct save_pkt* sp) if (!IsCtxGood(ctx, jcr, bctx)) { goto bail_out; } if (!sp) { goto bail_out; } - ff_pkt = jcr->ff; + ff_pkt = jcr->impl_->ff; ff_pkt->fname = sp->fname; memcpy(&ff_pkt->statp, &sp->statp, sizeof(ff_pkt->statp)); diff --git a/core/src/filed/fileset.cc b/core/src/filed/fileset.cc index 2ba249954a1..962a3a0c1f0 100644 --- a/core/src/filed/fileset.cc +++ b/core/src/filed/fileset.cc @@ -32,6 +32,7 @@ #include "include/bareos.h" #include "filed/filed.h" #include "filed/filed_globals.h" +#include "filed/jcr_private.h" #include "findlib/match.h" #include "lib/berrno.h" #include "lib/edit.h" @@ -61,10 +62,10 @@ extern "C" char* job_code_callback_filed(JobControlRecord* jcr, switch (param[0]) { case 'D': - if (jcr->director) { return jcr->director->resource_name_; } + if (jcr->impl_->director) { return jcr->impl_->director->resource_name_; } break; case 'm': - return edit_uint64(jcr->mtime, str); + return edit_uint64(jcr->impl_->mtime, str); } return NULL; @@ -75,8 +76,8 @@ bool InitFileset(JobControlRecord* jcr) FindFilesPacket* ff; findFILESET* fileset; - if (!jcr->ff) { return false; } - ff = jcr->ff; + if (!jcr->impl_->ff) { return false; } + ff = jcr->impl_->ff; if (ff->fileset) { return false; } fileset = (findFILESET*)malloc(sizeof(findFILESET)); *fileset = findFILESET{}; @@ -113,7 +114,7 @@ static void append_file(JobControlRecord* jcr, */ void AddFileToFileset(JobControlRecord* jcr, const char* fname, bool IsFile) { - findFILESET* fileset = jcr->ff->fileset; + findFILESET* fileset = jcr->impl_->ff->fileset; char* p; Bpipe* bpipe; POOLMEM* fn; @@ -173,14 +174,16 @@ void AddFileToFileset(JobControlRecord* jcr, const char* fname, bool IsFile) findIncludeExcludeItem* get_incexe(JobControlRecord* jcr) { - if (jcr->ff && jcr->ff->fileset) { return jcr->ff->fileset->incexe; } + if (jcr->impl_->ff && jcr->impl_->ff->fileset) { + return jcr->impl_->ff->fileset->incexe; + } return NULL; } void SetIncexe(JobControlRecord* jcr, findIncludeExcludeItem* incexe) { - findFILESET* fileset = jcr->ff->fileset; + findFILESET* fileset = jcr->impl_->ff->fileset; fileset->incexe = incexe; } @@ -189,7 +192,7 @@ void SetIncexe(JobControlRecord* jcr, findIncludeExcludeItem* incexe) */ int AddRegexToFileset(JobControlRecord* jcr, const char* item, int type) { - findFOPTS* current_opts = start_options(jcr->ff); + findFOPTS* current_opts = start_options(jcr->impl_->ff); regex_t* preg; int rc; char prbuf[500]; @@ -225,7 +228,7 @@ int AddRegexToFileset(JobControlRecord* jcr, const char* item, int type) */ int AddWildToFileset(JobControlRecord* jcr, const char* item, int type) { - findFOPTS* current_opts = start_options(jcr->ff); + findFOPTS* current_opts = start_options(jcr->impl_->ff); if (type == ' ') { current_opts->wild.append(strdup(item)); @@ -247,7 +250,7 @@ int AddWildToFileset(JobControlRecord* jcr, const char* item, int type) */ int AddOptionsToFileset(JobControlRecord* jcr, const char* item) { - findFOPTS* current_opts = start_options(jcr->ff); + findFOPTS* current_opts = start_options(jcr->impl_->ff); SetOptions(current_opts, item); @@ -256,7 +259,7 @@ int AddOptionsToFileset(JobControlRecord* jcr, const char* item) void AddFileset(JobControlRecord* jcr, const char* item) { - FindFilesPacket* ff = jcr->ff; + FindFilesPacket* ff = jcr->impl_->ff; findFILESET* fileset = ff->fileset; int code, subcode; int state = fileset->state; @@ -297,10 +300,10 @@ void AddFileset(JobControlRecord* jcr, const char* item) } switch (code) { case 'I': - (void)new_include(jcr->ff->fileset); + (void)new_include(jcr->impl_->ff->fileset); break; case 'E': - (void)new_exclude(jcr->ff->fileset); + (void)new_exclude(jcr->impl_->ff->fileset); break; case 'N': /* Null */ state = state_none; @@ -367,18 +370,18 @@ bool TermFileset(JobControlRecord* jcr) { findFILESET* fileset; - fileset = jcr->ff->fileset; + fileset = jcr->impl_->ff->fileset; #ifdef HAVE_WIN32 /* * Expand the fileset to include all drive letters when the fileset includes a * File = / entry. */ - if (!expand_win32_fileset(jcr->ff->fileset)) { return false; } + if (!expand_win32_fileset(jcr->impl_->ff->fileset)) { return false; } /* * Exclude entries in NotToBackup registry key */ - if (!exclude_win32_not_to_backup_registry_entries(jcr, jcr->ff)) { + if (!exclude_win32_not_to_backup_registry_entries(jcr, jcr->impl_->ff)) { return false; } #endif @@ -399,7 +402,7 @@ bool TermFileset(JobControlRecord* jcr) } } - return jcr->ff->fileset->state != state_error; + return jcr->impl_->ff->fileset->state != state_error; } /** diff --git a/core/src/filed/heartbeat.cc b/core/src/filed/heartbeat.cc index c9ab082d4ef..9f08a3c7fec 100644 --- a/core/src/filed/heartbeat.cc +++ b/core/src/filed/heartbeat.cc @@ -32,6 +32,7 @@ #include "include/bareos.h" #include "filed/filed.h" +#include "filed/jcr_private.h" #include "filed/filed_globals.h" #include "lib/bnet.h" #include "lib/bsock.h" @@ -66,9 +67,9 @@ extern "C" void* sd_heartbeat_thread(void* arg) sd.reset(jcr->store_bsock->clone()); dir.reset(jcr->dir_bsock->clone()); - jcr->hb_bsock = sd; - jcr->hb_started = true; - jcr->hb_dir_bsock = dir; + jcr->impl_->hb_bsock = sd; + jcr->impl_->hb_started = true; + jcr->impl_->hb_dir_bsock = dir; dir->suppress_error_msgs_ = true; sd->suppress_error_msgs_ = true; @@ -103,9 +104,9 @@ extern "C" void* sd_heartbeat_thread(void* arg) sd->close(); dir->close(); - jcr->hb_bsock.reset(); - jcr->hb_started = false; - jcr->hb_dir_bsock = NULL; + jcr->impl_->hb_bsock.reset(); + jcr->impl_->hb_started = false; + jcr->impl_->hb_dir_bsock = NULL; return NULL; } @@ -119,10 +120,11 @@ void StartHeartbeatMonitor(JobControlRecord* jcr) * make debugging impossible. */ if (!no_signals) { - jcr->hb_bsock = NULL; - jcr->hb_started = false; - jcr->hb_dir_bsock = NULL; - pthread_create(&jcr->heartbeat_id, NULL, sd_heartbeat_thread, (void*)jcr); + jcr->impl_->hb_bsock = NULL; + jcr->impl_->hb_started = false; + jcr->impl_->hb_dir_bsock = NULL; + pthread_create(&jcr->impl_->heartbeat_id, NULL, sd_heartbeat_thread, + (void*)jcr); } } @@ -132,23 +134,24 @@ void StopHeartbeatMonitor(JobControlRecord* jcr) int cnt = 0; if (no_signals) { return; } /* Wait max 10 secs for heartbeat thread to start */ - while (!jcr->hb_started && cnt++ < 200) { + while (!jcr->impl_->hb_started && cnt++ < 200) { Bmicrosleep(0, 50000); /* wait for start */ } - if (jcr->hb_started) { - jcr->hb_bsock->SetTimedOut(); /* set timed_out to Terminate read */ - jcr->hb_bsock->SetTerminated(); /* set to Terminate read */ + if (jcr->impl_->hb_started) { + jcr->impl_->hb_bsock->SetTimedOut(); /* set timed_out to Terminate read */ + jcr->impl_->hb_bsock->SetTerminated(); /* set to Terminate read */ } - if (jcr->hb_dir_bsock) { - jcr->hb_dir_bsock->SetTimedOut(); /* set timed_out to Terminate read */ - jcr->hb_dir_bsock->SetTerminated(); /* set to Terminate read */ + if (jcr->impl_->hb_dir_bsock) { + jcr->impl_->hb_dir_bsock + ->SetTimedOut(); /* set timed_out to Terminate read */ + jcr->impl_->hb_dir_bsock->SetTerminated(); /* set to Terminate read */ } - if (jcr->hb_started) { + if (jcr->impl_->hb_started) { Dmsg0(100, "Send kill to heartbeat id\n"); - pthread_kill(jcr->heartbeat_id, + pthread_kill(jcr->impl_->heartbeat_id, TIMEOUT_SIGNAL); /* make heartbeat thread go away */ Bmicrosleep(0, 50000); } @@ -157,20 +160,20 @@ void StopHeartbeatMonitor(JobControlRecord* jcr) /* * Wait max 100 secs for heartbeat thread to stop */ - while (jcr->hb_started && cnt++ < 200) { - pthread_kill(jcr->heartbeat_id, + while (jcr->impl_->hb_started && cnt++ < 200) { + pthread_kill(jcr->impl_->heartbeat_id, TIMEOUT_SIGNAL); /* make heartbeat thread go away */ Bmicrosleep(0, 500000); } - if (jcr->hb_bsock) { - // delete jcr->hb_bsock; - jcr->hb_bsock.reset(); + if (jcr->impl_->hb_bsock) { + // delete jcr->impl_->hb_bsock; + jcr->impl_->hb_bsock.reset(); } - if (jcr->hb_dir_bsock) { - // delete jcr->hb_dir_bsock; - jcr->hb_dir_bsock.reset(); + if (jcr->impl_->hb_dir_bsock) { + // delete jcr->impl_->hb_dir_bsock; + jcr->impl_->hb_dir_bsock.reset(); } } @@ -192,8 +195,8 @@ extern "C" void* dir_heartbeat_thread(void* arg) */ dir = jcr->dir_bsock->clone(); - jcr->hb_bsock.reset(dir); - jcr->hb_started = true; + jcr->impl_->hb_bsock.reset(dir); + jcr->impl_->hb_started = true; dir->suppress_error_msgs_ = true; while (!dir->IsStop()) { @@ -209,8 +212,8 @@ extern "C" void* dir_heartbeat_thread(void* arg) Bmicrosleep(next, 0); } dir->close(); - jcr->hb_bsock.reset(); - jcr->hb_started = false; + jcr->impl_->hb_bsock.reset(); + jcr->impl_->hb_started = false; return NULL; } @@ -221,7 +224,8 @@ void StartDirHeartbeat(JobControlRecord* jcr) { if (me->heartbeat_interval) { jcr->dir_bsock->SetLocking(); - pthread_create(&jcr->heartbeat_id, NULL, dir_heartbeat_thread, (void*)jcr); + pthread_create(&jcr->impl_->heartbeat_id, NULL, dir_heartbeat_thread, + (void*)jcr); } } diff --git a/core/src/filed/jcr_private.h b/core/src/filed/jcr_private.h new file mode 100644 index 00000000000..efef6f77224 --- /dev/null +++ b/core/src/filed/jcr_private.h @@ -0,0 +1,88 @@ +/* + BAREOS® - Backup Archiving REcovery Open Sourced + + Copyright (C) 2000-2012 Free Software Foundation Europe e.V. + Copyright (C) 2011-2012 Planets Communications B.V. + Copyright (C) 2013-2019 Bareos GmbH & Co. KG + + This program is Free Software; you can redistribute it and/or + modify it under the terms of version three of the GNU Affero General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#ifndef BAREOS_SRC_FILED_JCR_H_ +#define BAREOS_SRC_FILED_JCR_H_ + +#include "include/bareos.h" + +struct acl_data_t; +struct xattr_data_t; + +/* clang-format off */ +struct CryptoContext { + bool pki_sign = false; /**< Enable PKI Signatures? */ + bool pki_encrypt = false; /**< Enable PKI Encryption? */ + DIGEST* digest = nullptr; /**< Last file's digest context */ + X509_KEYPAIR* pki_keypair = nullptr; /**< Encryption key pair */ + alist* pki_signers = nullptr; /**< Trusted Signers */ + alist* pki_recipients = nullptr; /**< Trusted Recipients */ + CRYPTO_SESSION* pki_session = nullptr; /**< PKE Public Keys + Symmetric Session Keys */ + POOLMEM* crypto_buf = nullptr; /**< Encryption/Decryption buffer */ + POOLMEM* pki_session_encoded = nullptr; /**< Cached DER-encoded copy of pki_session */ + int32_t pki_session_encoded_size = 0; /**< Size of DER-encoded pki_session */ +}; +/* clang-format on */ + +struct JobControlRecordPrivate { + uint32_t num_files_examined = 0; /**< Files examined this job */ + POOLMEM* last_fname = nullptr; /**< Last file saved/verified */ + POOLMEM* job_metadata = nullptr; /**< VSS job metadata */ + acl_data_t* acl_data = nullptr; /**< ACLs for backup/restore */ + xattr_data_t* xattr_data = + nullptr; /**< Extended Attributes for backup/restore */ + int32_t last_type = 0; /**< Type of last file saved/verified */ + bool incremental = false; /**< Set if incremental for SINCE */ + utime_t mtime = 0; /**< Begin time for SINCE */ + int listing = 0; /**< Job listing in estimate */ + int32_t Ticket = 0; /**< Ticket */ + char* big_buf = nullptr; /**< I/O buffer */ + int32_t replace = 0; /**< Replace options */ + FindFilesPacket* ff = nullptr; /**< Find Files packet */ + char PrevJob[MAX_NAME_LENGTH]{ + 0}; /**< Previous job name assiciated with since time */ + uint32_t ExpectedFiles = 0; /**< Expected restore files */ + uint32_t StartFile = 0; + uint32_t EndFile = 0; + uint32_t StartBlock = 0; + uint32_t EndBlock = 0; + pthread_t heartbeat_id = 0; /**< Id of heartbeat thread */ + volatile bool hb_started = false; /**< Heartbeat running */ + std::shared_ptr hb_bsock; /**< Duped SD socket */ + std::shared_ptr hb_dir_bsock; /**< Duped DIR socket */ + alist* RunScripts = nullptr; /**< Commands to run before and after job */ + CryptoContext crypto; /**< Crypto ctx */ + filedaemon::DirectorResource* director = nullptr; /**< Director resource */ + bool enable_vss = false; /**< VSS used by FD */ + bool got_metadata = false; /**< Set when found job_metadata */ + bool multi_restore = false; /**< Dir can do multiple storage restore */ + filedaemon::BareosAccurateFilelist* file_list = + nullptr; /**< Previous file list (accurate mode) */ + uint64_t base_size = 0; /**< Compute space saved with base job */ + filedaemon::save_pkt* plugin_sp = nullptr; /**< Plugin save packet */ +#ifdef HAVE_WIN32 + VSSClient* pVSSClient = nullptr; /**< VSS Client Instance */ +#endif +}; + +#endif // BAREOS_SRC_FILED_JCR_H_ diff --git a/core/src/filed/restore.cc b/core/src/filed/restore.cc index a67e026151f..1bb553c586c 100644 --- a/core/src/filed/restore.cc +++ b/core/src/filed/restore.cc @@ -31,6 +31,7 @@ #include "include/bareos.h" #include "filed/filed.h" #include "filed/filed_globals.h" +#include "filed/jcr_private.h" #include "filed/compression.h" #include "filed/crypto.h" #include "filed/restore.h" @@ -135,7 +136,8 @@ static int BcloseChksize(JobControlRecord* jcr, Qmsg3(jcr, M_WARNING, 0, _("Size of data or stream of %s not correct. Original %s, restored " "%s.\n"), - jcr->last_fname, edit_uint64(osize, ec1), edit_uint64(fsize, ec2)); + jcr->impl_->last_fname, edit_uint64(osize, ec1), + edit_uint64(fsize, ec2)); return -1; } return 0; @@ -153,16 +155,16 @@ static inline bool RestoreFinderinfo(JobControlRecord* jcr, attrList.commonattr = ATTR_CMN_FNDRINFO; Dmsg0(130, "Restoring Finder Info\n"); - SetBit(FO_HFSPLUS, jcr->ff->flags); + SetBit(FO_HFSPLUS, jcr->impl_->ff->flags); if (buflen != 32) { Jmsg(jcr, M_WARNING, 0, _("Invalid length of Finder Info (got %d, not 32)\n"), buflen); return false; } - if (setattrlist(jcr->last_fname, &attrList, buf, buflen, 0) != 0) { + if (setattrlist(jcr->impl_->last_fname, &attrList, buf, buflen, 0) != 0) { Jmsg(jcr, M_WARNING, 0, _("Could not set Finder Info on %s\n"), - jcr->last_fname); + jcr->impl_->last_fname); return false; } @@ -221,14 +223,14 @@ static inline bool do_reStoreAcl(JobControlRecord* jcr, { bacl_exit_code retval; - jcr->acl_data->last_fname = jcr->last_fname; + jcr->impl_->acl_data->last_fname = jcr->impl_->last_fname; switch (stream) { case STREAM_ACL_PLUGIN: - retval = plugin_parse_acl_streams(jcr, jcr->acl_data, stream, content, - content_length); + retval = plugin_parse_acl_streams(jcr, jcr->impl_->acl_data, stream, + content, content_length); break; default: - retval = parse_acl_streams(jcr, jcr->acl_data, stream, content, + retval = parse_acl_streams(jcr, jcr->impl_->acl_data, stream, content, content_length); break; } @@ -242,10 +244,11 @@ static inline bool do_reStoreAcl(JobControlRecord* jcr, * ACL_REPORT_ERR_MAX_PER_JOB print the error message set by the lower * level routine in jcr->errmsg. */ - if (jcr->acl_data->u.parse->nr_errors < ACL_REPORT_ERR_MAX_PER_JOB) { + if (jcr->impl_->acl_data->u.parse->nr_errors < + ACL_REPORT_ERR_MAX_PER_JOB) { Jmsg(jcr, M_WARNING, 0, "%s", jcr->errmsg); } - jcr->acl_data->u.parse->nr_errors++; + jcr->impl_->acl_data->u.parse->nr_errors++; break; case bacl_exit_ok: break; @@ -265,14 +268,14 @@ static inline bool do_restore_xattr(JobControlRecord* jcr, { BxattrExitCode retval; - jcr->xattr_data->last_fname = jcr->last_fname; + jcr->impl_->xattr_data->last_fname = jcr->impl_->last_fname; switch (stream) { case STREAM_XATTR_PLUGIN: - retval = PluginParseXattrStreams(jcr, jcr->xattr_data, stream, content, - content_length); + retval = PluginParseXattrStreams(jcr, jcr->impl_->xattr_data, stream, + content, content_length); break; default: - retval = ParseXattrStreams(jcr, jcr->xattr_data, stream, content, + retval = ParseXattrStreams(jcr, jcr->impl_->xattr_data, stream, content, content_length); break; } @@ -285,7 +288,7 @@ static inline bool do_restore_xattr(JobControlRecord* jcr, break; case BxattrExitCode::kError: Jmsg(jcr, M_ERROR, 0, "%s", jcr->errmsg); - jcr->xattr_data->u.parse->nr_errors++; + jcr->impl_->xattr_data->u.parse->nr_errors++; break; case BxattrExitCode::kSuccess: break; @@ -487,18 +490,18 @@ void DoRestore(JobControlRecord* jcr) binit(&rctx.forkbfd); attr = rctx.attr = new_attr(jcr); if (have_acl) { - jcr->acl_data = (acl_data_t*)malloc(sizeof(acl_data_t)); - memset(jcr->acl_data, 0, sizeof(acl_data_t)); - jcr->acl_data->u.parse = + jcr->impl_->acl_data = (acl_data_t*)malloc(sizeof(acl_data_t)); + memset(jcr->impl_->acl_data, 0, sizeof(acl_data_t)); + jcr->impl_->acl_data->u.parse = (acl_parse_data_t*)malloc(sizeof(acl_parse_data_t)); - memset(jcr->acl_data->u.parse, 0, sizeof(acl_parse_data_t)); + memset(jcr->impl_->acl_data->u.parse, 0, sizeof(acl_parse_data_t)); } if (have_xattr) { - jcr->xattr_data = (xattr_data_t*)malloc(sizeof(xattr_data_t)); - memset(jcr->xattr_data, 0, sizeof(xattr_data_t)); - jcr->xattr_data->u.parse = + jcr->impl_->xattr_data = (xattr_data_t*)malloc(sizeof(xattr_data_t)); + memset(jcr->impl_->xattr_data, 0, sizeof(xattr_data_t)); + jcr->impl_->xattr_data->u.parse = (xattr_parse_data_t*)malloc(sizeof(xattr_parse_data_t)); - memset(jcr->xattr_data->u.parse, 0, sizeof(xattr_parse_data_t)); + memset(jcr->impl_->xattr_data->u.parse, 0, sizeof(xattr_parse_data_t)); } while (BgetMsg(sd) >= 0 && !JobCanceled(jcr)) { @@ -607,20 +610,20 @@ void DoRestore(JobControlRecord* jcr) * Try to actually create the file, which returns a status telling * us if we need to extract or not. */ - jcr->num_files_examined++; + jcr->impl_->num_files_examined++; rctx.extract = false; status = CF_CORE; /* By default, let Bareos's core handle it */ if (jcr->IsPlugin()) { - status = PluginCreateFile(jcr, attr, &rctx.bfd, jcr->replace); + status = PluginCreateFile(jcr, attr, &rctx.bfd, jcr->impl_->replace); } if (status == CF_CORE) { - status = CreateFile(jcr, attr, &rctx.bfd, jcr->replace); + status = CreateFile(jcr, attr, &rctx.bfd, jcr->impl_->replace); } jcr->lock(); - PmStrcpy(jcr->last_fname, attr->ofname); - jcr->last_type = attr->type; + PmStrcpy(jcr->impl_->last_fname, attr->ofname); + jcr->impl_->last_type = attr->type; jcr->unlock(); Dmsg2(130, "Outfile=%s CreateFile status=%d\n", attr->ofname, status); switch (status) { @@ -695,7 +698,7 @@ void DoRestore(JobControlRecord* jcr) /* * Do we have any keys at all? */ - if (!jcr->crypto.pki_recipients) { + if (!jcr->impl_->crypto.pki_recipients) { Jmsg(jcr, M_ERROR, 0, _("No private decryption keys have been defined to decrypt " "encrypted backup data.\n")); @@ -704,9 +707,11 @@ void DoRestore(JobControlRecord* jcr) break; } - if (jcr->crypto.digest) { CryptoDigestFree(jcr->crypto.digest); } - jcr->crypto.digest = crypto_digest_new(jcr, signing_algorithm); - if (!jcr->crypto.digest) { + if (jcr->impl_->crypto.digest) { + CryptoDigestFree(jcr->impl_->crypto.digest); + } + jcr->impl_->crypto.digest = crypto_digest_new(jcr, signing_algorithm); + if (!jcr->impl_->crypto.digest) { Jmsg0(jcr, M_FATAL, 0, _("Could not create digest.\n")); rctx.extract = false; bclose(&rctx.bfd); @@ -716,9 +721,9 @@ void DoRestore(JobControlRecord* jcr) /* * Decode and save session keys. */ - cryptoerr = CryptoSessionDecode((uint8_t*)sd->msg, - (uint32_t)sd->message_length, - jcr->crypto.pki_recipients, &rctx.cs); + cryptoerr = CryptoSessionDecode( + (uint8_t*)sd->msg, (uint32_t)sd->message_length, + jcr->impl_->crypto.pki_recipients, &rctx.cs); switch (cryptoerr) { case CRYPTO_ERROR_NONE: /* @@ -873,7 +878,7 @@ void DoRestore(JobControlRecord* jcr) case STREAM_MACOS_FORK_DATA: if (have_darwin_os) { ClearAllBits(FO_MAX, rctx.fork_flags); - SetBit(FO_HFSPLUS, jcr->ff->flags); + SetBit(FO_HFSPLUS, jcr->impl_->ff->flags); if (rctx.stream == STREAM_ENCRYPTED_MACOS_FORK_DATA) { SetBit(FO_ENCRYPT, rctx.fork_flags); @@ -888,10 +893,11 @@ void DoRestore(JobControlRecord* jcr) if (rctx.extract) { if (rctx.prev_stream != rctx.stream) { - if (BopenRsrc(&rctx.forkbfd, jcr->last_fname, + if (BopenRsrc(&rctx.forkbfd, jcr->impl_->last_fname, O_WRONLY | O_TRUNC | O_BINARY, 0) < 0) { Jmsg(jcr, M_WARNING, 0, - _("Cannot open resource fork for %s.\n"), jcr->last_fname); + _("Cannot open resource fork for %s.\n"), + jcr->impl_->last_fname); rctx.extract = false; continue; } @@ -951,8 +957,8 @@ void DoRestore(JobControlRecord* jcr) * b) and it is not a directory (they are never "extracted") * c) or the file name is empty */ - if ((!rctx.extract && jcr->last_type != FT_DIREND) || - (*jcr->last_fname == 0)) { + if ((!rctx.extract && jcr->impl_->last_type != FT_DIREND) || + (*jcr->impl_->last_fname == 0)) { break; } if (have_acl) { @@ -960,7 +966,7 @@ void DoRestore(JobControlRecord* jcr) * For anything that is not a directory we delay * the restore of acls till a later stage. */ - if (jcr->last_type != FT_DIREND) { + if (jcr->impl_->last_type != FT_DIREND) { PushDelayedDataStream(rctx, sd); } else { if (!do_reStoreAcl(jcr, rctx.stream, sd->msg, sd->message_length)) { @@ -989,8 +995,8 @@ void DoRestore(JobControlRecord* jcr) * b) and it is not a directory (they are never "extracted") * c) or the file name is empty */ - if ((!rctx.extract && jcr->last_type != FT_DIREND) || - (*jcr->last_fname == 0)) { + if ((!rctx.extract && jcr->impl_->last_type != FT_DIREND) || + (*jcr->impl_->last_fname == 0)) { break; } if (have_xattr) { @@ -998,7 +1004,7 @@ void DoRestore(JobControlRecord* jcr) * For anything that is not a directory we delay * the restore of xattr till a later stage. */ - if (jcr->last_type != FT_DIREND) { + if (jcr->impl_->last_type != FT_DIREND) { PushDelayedDataStream(rctx, sd); } else { if (!do_restore_xattr(jcr, rctx.stream, sd->msg, @@ -1018,8 +1024,8 @@ void DoRestore(JobControlRecord* jcr) * b) and it is not a directory (they are never "extracted") * c) or the file name is empty */ - if ((!rctx.extract && jcr->last_type != FT_DIREND) || - (*jcr->last_fname == 0)) { + if ((!rctx.extract && jcr->impl_->last_type != FT_DIREND) || + (*jcr->impl_->last_fname == 0)) { break; } if (have_xattr) { @@ -1050,7 +1056,7 @@ void DoRestore(JobControlRecord* jcr) (uint32_t)sd->message_length)) == NULL) { Jmsg1(jcr, M_ERROR, 0, _("Failed to decode message signature for %s\n"), - jcr->last_fname); + jcr->impl_->last_fname); } break; @@ -1115,15 +1121,15 @@ void DoRestore(JobControlRecord* jcr) */ Dmsg2(10, "End Do Restore. Files=%d Bytes=%s\n", jcr->JobFiles, edit_uint64(jcr->JobBytes, ec1)); - if (have_acl && jcr->acl_data->u.parse->nr_errors > 0) { + if (have_acl && jcr->impl_->acl_data->u.parse->nr_errors > 0) { Jmsg(jcr, M_WARNING, 0, _("Encountered %ld acl errors while doing restore\n"), - jcr->acl_data->u.parse->nr_errors); + jcr->impl_->acl_data->u.parse->nr_errors); } - if (have_xattr && jcr->xattr_data->u.parse->nr_errors > 0) { + if (have_xattr && jcr->impl_->xattr_data->u.parse->nr_errors > 0) { Jmsg(jcr, M_WARNING, 0, _("Encountered %ld xattr errors while doing restore\n"), - jcr->xattr_data->u.parse->nr_errors); + jcr->impl_->xattr_data->u.parse->nr_errors); } if (non_support_data > 1 || non_support_attr > 1) { Jmsg(jcr, M_WARNING, 0, @@ -1157,9 +1163,9 @@ void DoRestore(JobControlRecord* jcr) */ FreeSignature(rctx); FreeSession(rctx); - if (jcr->crypto.digest) { - CryptoDigestFree(jcr->crypto.digest); - jcr->crypto.digest = NULL; + if (jcr->impl_->crypto.digest) { + CryptoDigestFree(jcr->impl_->crypto.digest); + jcr->impl_->crypto.digest = NULL; } /* @@ -1187,16 +1193,16 @@ void DoRestore(JobControlRecord* jcr) rctx.fork_cipher_ctx.buf = NULL; } - if (have_acl && jcr->acl_data) { - free(jcr->acl_data->u.parse); - free(jcr->acl_data); - jcr->acl_data = NULL; + if (have_acl && jcr->impl_->acl_data) { + free(jcr->impl_->acl_data->u.parse); + free(jcr->impl_->acl_data); + jcr->impl_->acl_data = NULL; } - if (have_xattr && jcr->xattr_data) { - free(jcr->xattr_data->u.parse); - free(jcr->xattr_data); - jcr->xattr_data = NULL; + if (have_xattr && jcr->impl_->xattr_data) { + free(jcr->impl_->xattr_data->u.parse); + free(jcr->impl_->xattr_data); + jcr->impl_->xattr_data = NULL; } /* @@ -1217,7 +1223,7 @@ void DoRestore(JobControlRecord* jcr) int DoFileDigest(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool top_level) { Dmsg1(50, "DoFileDigest jcr=%p\n", jcr); - return (DigestFile(jcr, ff_pkt, jcr->crypto.digest)); + return (DigestFile(jcr, ff_pkt, jcr->impl_->crypto.digest)); } bool SparseData(JobControlRecord* jcr, @@ -1237,7 +1243,7 @@ bool SparseData(JobControlRecord* jcr, if (blseek(bfd, (boffset_t)*addr, SEEK_SET) < 0) { BErrNo be; Jmsg3(jcr, M_ERROR, 0, _("Seek to %s error on %s: ERR=%s\n"), - edit_uint64(*addr, ec1), jcr->last_fname, + edit_uint64(*addr, ec1), jcr->impl_->last_fname, be.bstrerror(bfd->BErrNo)); return false; } @@ -1253,8 +1259,8 @@ bool StoreData(JobControlRecord* jcr, const int32_t length, bool win32_decomp) { - if (jcr->crypto.digest) { - CryptoDigestUpdate(jcr->crypto.digest, (uint8_t*)data, length); + if (jcr->impl_->crypto.digest) { + CryptoDigestUpdate(jcr->impl_->crypto.digest, (uint8_t*)data, length); } if (win32_decomp) { @@ -1262,7 +1268,7 @@ bool StoreData(JobControlRecord* jcr, BErrNo be; Jmsg2(jcr, M_ERROR, 0, _("Write error in Win32 Block Decomposition on %s: %s\n"), - jcr->last_fname, be.bstrerror(bfd->BErrNo)); + jcr->impl_->last_fname, be.bstrerror(bfd->BErrNo)); return false; } #ifdef HAVE_WIN32 @@ -1271,22 +1277,22 @@ bool StoreData(JobControlRecord* jcr, if (win32_send_to_copy_thread(jcr, bfd, data, length) != (ssize_t)length) { BErrNo be; - Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: %s\n"), jcr->last_fname, - be.bstrerror(bfd->BErrNo)); + Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: %s\n"), + jcr->impl_->last_fname, be.bstrerror(bfd->BErrNo)); return false; } } else { if (bwrite(bfd, data, length) != (ssize_t)length) { BErrNo be; - Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: %s\n"), jcr->last_fname, - be.bstrerror(bfd->BErrNo)); + Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: %s\n"), + jcr->impl_->last_fname, be.bstrerror(bfd->BErrNo)); } } } #else } else if (bwrite(bfd, data, length) != (ssize_t)length) { BErrNo be; - Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: %s\n"), jcr->last_fname, + Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: %s\n"), jcr->impl_->last_fname, be.bstrerror(bfd->BErrNo)); return false; } @@ -1330,7 +1336,8 @@ int32_t ExtractData(JobControlRecord* jcr, } if (BitIsSet(FO_COMPRESS, flags)) { - if (!DecompressData(jcr, jcr->last_fname, stream, &wbuf, &wsize, false)) { + if (!DecompressData(jcr, jcr->impl_->last_fname, stream, &wbuf, &wsize, + false)) { goto bail_out; } } @@ -1418,7 +1425,7 @@ static bool ClosePreviousStream(JobControlRecord* jcr, r_ctx& rctx) */ FreeSignature(rctx); FreeSession(rctx); - ClearAllBits(FO_MAX, rctx.jcr->ff->flags); + ClearAllBits(FO_MAX, rctx.jcr->impl_->ff->flags); Dmsg0(130, "Stop extracting.\n"); } else if (IsBopen(&rctx.bfd)) { Jmsg0(rctx.jcr, M_ERROR, 0, diff --git a/core/src/filed/sd_cmds.cc b/core/src/filed/sd_cmds.cc index 3fbf4b1fc4c..af780068c13 100644 --- a/core/src/filed/sd_cmds.cc +++ b/core/src/filed/sd_cmds.cc @@ -29,6 +29,7 @@ #include "include/bareos.h" #include "filed/filed.h" #include "filed/filed_globals.h" +#include "filed/jcr_private.h" #include "filed/authenticate.h" #include "lib/bnet.h" #include "lib/bsock.h" @@ -96,8 +97,8 @@ void* handle_stored_connection(BareosSocket* sd) } if (!jcr->max_bandwidth) { - if (jcr->director->max_bandwidth_per_job) { - jcr->max_bandwidth = jcr->director->max_bandwidth_per_job; + if (jcr->impl_->director->max_bandwidth_per_job) { + jcr->max_bandwidth = jcr->impl_->director->max_bandwidth_per_job; } else if (me->max_bandwidth_per_job) { jcr->max_bandwidth = me->max_bandwidth_per_job; } diff --git a/core/src/filed/status.cc b/core/src/filed/status.cc index 361b62ac582..9d611aeff35 100644 --- a/core/src/filed/status.cc +++ b/core/src/filed/status.cc @@ -32,6 +32,7 @@ #include "include/bareos.h" #include "filed/filed.h" #include "filed/filed_globals.h" +#include "filed/jcr_private.h" #include "lib/status.h" #include "lib/bsock.h" #include "lib/edit.h" @@ -181,7 +182,9 @@ static void ListRunningJobsPlain(StatusPacket* sp) #ifdef WIN32_VSS len = Mmsg( msg, _(" %s%s %s Job started: %s\n"), - (njcr->pVSSClient && njcr->pVSSClient->IsInitialized()) ? "VSS " : "", + (njcr->impl_->pVSSClient && njcr->impl_->pVSSClient->IsInitialized()) + ? "VSS " + : "", JobLevelToString(njcr->getJobLevel()), job_type_to_str(njcr->getJobType()), dt); #else @@ -189,9 +192,9 @@ static void ListRunningJobsPlain(StatusPacket* sp) JobLevelToString(njcr->getJobLevel()), job_type_to_str(njcr->getJobType()), dt); #endif - } else if ((njcr->JobId == 0) && (njcr->director)) { + } else if ((njcr->JobId == 0) && (njcr->impl_->director)) { len = Mmsg(msg, _("%s (director) connected at: %s\n"), - njcr->director->resource_name_, dt); + njcr->impl_->director->resource_name_, dt); } else { /* * This should only occur shortly, until the JobControlRecord values are @@ -213,11 +216,11 @@ static void ListRunningJobsPlain(StatusPacket* sp) edit_uint64_with_commas(njcr->max_bandwidth, b4)); sendit(msg, len, sp); len = Mmsg(msg, _(" Files Examined=%s\n"), - edit_uint64_with_commas(njcr->num_files_examined, b1)); + edit_uint64_with_commas(njcr->impl_->num_files_examined, b1)); sendit(msg, len, sp); if (njcr->JobFiles > 0) { njcr->lock(); - len = Mmsg(msg, _(" Processing file: %s\n"), njcr->last_fname); + len = Mmsg(msg, _(" Processing file: %s\n"), njcr->impl_->last_fname); njcr->unlock(); sendit(msg, len, sp); } @@ -261,10 +264,12 @@ static void ListRunningJobsApi(StatusPacket* sp) len = Mmsg(msg, "JobId=%d\n Job=%s\n", njcr->JobId, njcr->Job); sendit(msg, len, sp); #ifdef WIN32_VSS - len = - Mmsg(msg, " VSS=%d\n Level=%c\n JobType=%c\n JobStarted=%s\n", - (njcr->pVSSClient && njcr->pVSSClient->IsInitialized()) ? 1 : 0, - njcr->getJobLevel(), njcr->getJobType(), dt); + len = Mmsg( + msg, " VSS=%d\n Level=%c\n JobType=%c\n JobStarted=%s\n", + (njcr->impl_->pVSSClient && njcr->impl_->pVSSClient->IsInitialized()) + ? 1 + : 0, + njcr->getJobLevel(), njcr->getJobType(), dt); #else len = Mmsg(msg, " VSS=%d\n Level=%c\n JobType=%c\n JobStarted=%s\n", 0, njcr->getJobLevel(), njcr->getJobType(), dt); @@ -283,11 +288,11 @@ static void ListRunningJobsApi(StatusPacket* sp) edit_int64(njcr->max_bandwidth, b4)); sendit(msg, len, sp); len = Mmsg(msg, " Files Examined=%s\n", - edit_uint64(njcr->num_files_examined, b1)); + edit_uint64(njcr->impl_->num_files_examined, b1)); sendit(msg, len, sp); if (njcr->JobFiles > 0) { njcr->lock(); - len = Mmsg(msg, " Processing file=%s\n", njcr->last_fname); + len = Mmsg(msg, " Processing file=%s\n", njcr->impl_->last_fname); njcr->unlock(); sendit(msg, len, sp); } diff --git a/core/src/filed/verify.cc b/core/src/filed/verify.cc index 7b1b3559e22..5379754dba3 100644 --- a/core/src/filed/verify.cc +++ b/core/src/filed/verify.cc @@ -29,6 +29,7 @@ #include "include/bareos.h" #include "filed/filed.h" +#include "filed/jcr_private.h" #include "findlib/find.h" #include "findlib/attribs.h" #include "lib/attribs.h" @@ -65,19 +66,20 @@ void DoVerify(JobControlRecord* jcr) { jcr->setJobStatus(JS_Running); jcr->buf_size = DEFAULT_NETWORK_BUFFER_SIZE; - if ((jcr->big_buf = (char*)malloc(jcr->buf_size)) == NULL) { + if ((jcr->impl_->big_buf = (char*)malloc(jcr->buf_size)) == NULL) { Jmsg1(jcr, M_ABORT, 0, _("Cannot malloc %d network read buffer\n"), DEFAULT_NETWORK_BUFFER_SIZE); } - SetFindOptions((FindFilesPacket*)jcr->ff, jcr->incremental, jcr->mtime); + SetFindOptions((FindFilesPacket*)jcr->impl_->ff, jcr->impl_->incremental, + jcr->impl_->mtime); Dmsg0(10, "Start find files\n"); /* Subroutine VerifyFile() is called for each file */ - FindFiles(jcr, (FindFilesPacket*)jcr->ff, VerifyFile, NULL); + FindFiles(jcr, (FindFilesPacket*)jcr->impl_->ff, VerifyFile, NULL); Dmsg0(10, "End find files\n"); - if (jcr->big_buf) { - free(jcr->big_buf); - jcr->big_buf = NULL; + if (jcr->impl_->big_buf) { + free(jcr->impl_->big_buf); + jcr->impl_->big_buf = NULL; } jcr->setJobStatus(JS_Terminated); } @@ -98,7 +100,7 @@ static int VerifyFile(JobControlRecord* jcr, if (JobCanceled(jcr)) { return 0; } dir = jcr->dir_bsock; - jcr->num_files_examined++; /* bump total file count */ + jcr->impl_->num_files_examined++; /* bump total file count */ switch (ff_pkt->type) { case FT_LNKSAVED: /* Hard linked, file already saved */ @@ -114,8 +116,8 @@ static int VerifyFile(JobControlRecord* jcr, Dmsg2(30, "FT_LNK saving: %s -> %s\n", ff_pkt->fname, ff_pkt->link); break; case FT_DIRBEGIN: - jcr->num_files_examined--; /* correct file count */ - return 1; /* ignored */ + jcr->impl_->num_files_examined--; /* correct file count */ + return 1; /* ignored */ case FT_REPARSE: case FT_JUNCTION: case FT_DIREND: @@ -199,7 +201,7 @@ static int VerifyFile(JobControlRecord* jcr, jcr->lock(); jcr->JobFiles++; /* increment number of files sent */ - PmStrcpy(jcr->last_fname, ff_pkt->fname); + PmStrcpy(jcr->impl_->last_fname, ff_pkt->fname); jcr->unlock(); /* @@ -341,7 +343,7 @@ static int ReadDigest(BareosWinFilePacket* bfd, char buf[DEFAULT_NETWORK_BUFFER_SIZE]; int64_t n; int64_t bufsiz = (int64_t)sizeof(buf); - FindFilesPacket* ff_pkt = (FindFilesPacket*)jcr->ff; + FindFilesPacket* ff_pkt = (FindFilesPacket*)jcr->impl_->ff; uint64_t fileAddr = 0; /* file address */ @@ -371,10 +373,10 @@ static int ReadDigest(BareosWinFilePacket* bfd, if (n < 0) { BErrNo be; be.SetErrno(bfd->BErrNo); - Dmsg2(100, "Error reading file %s: ERR=%s\n", jcr->last_fname, + Dmsg2(100, "Error reading file %s: ERR=%s\n", jcr->impl_->last_fname, be.bstrerror()); - Jmsg(jcr, M_ERROR, 1, _("Error reading file %s: ERR=%s\n"), jcr->last_fname, - be.bstrerror()); + Jmsg(jcr, M_ERROR, 1, _("Error reading file %s: ERR=%s\n"), + jcr->impl_->last_fname, be.bstrerror()); jcr->JobErrors++; return -1; } diff --git a/core/src/filed/verify_vol.cc b/core/src/filed/verify_vol.cc index 5d2bf5eac7c..aa1249e9490 100644 --- a/core/src/filed/verify_vol.cc +++ b/core/src/filed/verify_vol.cc @@ -31,6 +31,7 @@ #include "include/bareos.h" #include "filed/filed.h" #include "filed/filed_globals.h" +#include "filed/jcr_private.h" #include "lib/bsock.h" #include "lib/bget_msg.h" #include "lib/bnet.h" @@ -172,8 +173,8 @@ void DoVerifyVolume(JobControlRecord* jcr) } jcr->lock(); jcr->JobFiles++; - jcr->num_files_examined++; - PmStrcpy(jcr->last_fname, fname); /* last file examined */ + jcr->impl_->num_files_examined++; + PmStrcpy(jcr->impl_->last_fname, fname); /* last file examined */ jcr->unlock(); /* @@ -255,7 +256,7 @@ void DoVerifyVolume(JobControlRecord* jcr) case STREAM_RESTORE_OBJECT: jcr->lock(); jcr->JobFiles++; - jcr->num_files_examined++; + jcr->impl_->num_files_examined++; jcr->unlock(); Dmsg2(400, "send inx=%d STREAM_RESTORE_OBJECT-%d\n", jcr->JobFiles, diff --git a/core/src/include/jcr.h b/core/src/include/jcr.h index 281f997bddc..3fdfa0629e8 100644 --- a/core/src/include/jcr.h +++ b/core/src/include/jcr.h @@ -227,25 +227,7 @@ struct bpContext; struct CopyThreadContext; #endif -#ifdef FILE_DAEMON -struct acl_data_t; -struct xattr_data_t; - -/* clang-format off */ -struct CryptoContext { - bool pki_sign = false; /**< Enable PKI Signatures? */ - bool pki_encrypt = false; /**< Enable PKI Encryption? */ - DIGEST* digest = nullptr; /**< Last file's digest context */ - X509_KEYPAIR* pki_keypair = nullptr; /**< Encryption key pair */ - alist* pki_signers = nullptr; /**< Trusted Signers */ - alist* pki_recipients = nullptr; /**< Trusted Recipients */ - CRYPTO_SESSION* pki_session = nullptr; /**< PKE Public Keys + Symmetric Session Keys */ - POOLMEM* crypto_buf = nullptr; /**< Encryption/Decryption buffer */ - POOLMEM* pki_session_encoded = nullptr; /**< Cached DER-encoded copy of pki_session */ - int32_t pki_session_encoded_size = 0; /**< Size of DER-encoded pki_session */ -}; -/* clang-format on */ -#endif +struct JobControlRecordPrivate; /* clang-format off */ #ifdef DIRECTOR_DAEMON @@ -547,46 +529,7 @@ class JobControlRecord { directordaemon::ClientConnectionHandshakeMode::kUndefined; #endif /* DIRECTOR_DAEMON */ -#ifdef FILE_DAEMON - /* - * File Daemon specific part of JobControlRecord - */ - uint32_t num_files_examined = 0; /**< Files examined this job */ - POOLMEM* last_fname = nullptr; /**< Last file saved/verified */ - POOLMEM* job_metadata = nullptr; /**< VSS job metadata */ - acl_data_t* acl_data = nullptr; /**< ACLs for backup/restore */ - xattr_data_t* xattr_data = nullptr; /**< Extended Attributes for backup/restore */ - int32_t last_type = 0; /**< Type of last file saved/verified */ - bool incremental = false; /**< Set if incremental for SINCE */ - utime_t mtime = 0; /**< Begin time for SINCE */ - int listing = 0; /**< Job listing in estimate */ - int32_t Ticket = 0; /**< Ticket */ - char* big_buf = nullptr; /**< I/O buffer */ - int32_t replace = 0; /**< Replace options */ - FindFilesPacket* ff = nullptr; /**< Find Files packet */ - char PrevJob[MAX_NAME_LENGTH]{0}; /**< Previous job name assiciated with since time */ - uint32_t ExpectedFiles = 0; /**< Expected restore files */ - uint32_t StartFile = 0; - uint32_t EndFile = 0; - uint32_t StartBlock = 0; - uint32_t EndBlock = 0; - pthread_t heartbeat_id = 0; /**< Id of heartbeat thread */ - volatile bool hb_started = false; /**< Heartbeat running */ - std::shared_ptr hb_bsock; /**< Duped SD socket */ - std::shared_ptr hb_dir_bsock; /**< Duped DIR socket */ - alist* RunScripts = nullptr; /**< Commands to run before and after job */ - CryptoContext crypto; /**< Crypto ctx */ - filedaemon::DirectorResource* director = nullptr; /**< Director resource */ - bool enable_vss = false; /**< VSS used by FD */ - bool got_metadata = false; /**< Set when found job_metadata */ - bool multi_restore = false; /**< Dir can do multiple storage restore */ - filedaemon::BareosAccurateFilelist* file_list = nullptr; /**< Previous file list (accurate mode) */ - uint64_t base_size = 0; /**< Compute space saved with base job */ - filedaemon::save_pkt* plugin_sp = nullptr; /**< Plugin save packet */ -#ifdef HAVE_WIN32 - VSSClient* pVSSClient = nullptr; /**< VSS Client Instance */ -#endif -#endif /* FILE_DAEMON */ + JobControlRecordPrivate* impl_; #ifdef STORAGE_DAEMON /* diff --git a/core/src/win32/filed/vss.cc b/core/src/win32/filed/vss.cc index 2f6b522bad5..041d62ba69c 100644 --- a/core/src/win32/filed/vss.cc +++ b/core/src/win32/filed/vss.cc @@ -33,6 +33,7 @@ #include "include/bareos.h" #include "filed/filed.h" +#include "filed/jcr_private.h" #include "lib/thread_specific_data.h" #include "ms_atl.h" @@ -55,8 +56,9 @@ static bool VSSPathConvert(const char* szFilePath, { JobControlRecord* jcr = GetJcrFromThreadSpecificData(); - if (jcr && jcr->pVSSClient) { - return jcr->pVSSClient->GetShadowPath(szFilePath, szShadowPath, nBuflen); + if (jcr && jcr->impl_->pVSSClient) { + return jcr->impl_->pVSSClient->GetShadowPath(szFilePath, szShadowPath, + nBuflen); } return false; @@ -68,8 +70,9 @@ static bool VSSPathConvertW(const wchar_t* szFilePath, { JobControlRecord* jcr = GetJcrFromThreadSpecificData(); - if (jcr && jcr->pVSSClient) { - return jcr->pVSSClient->GetShadowPathW(szFilePath, szShadowPath, nBuflen); + if (jcr && jcr->impl_->pVSSClient) { + return jcr->impl_->pVSSClient->GetShadowPathW(szFilePath, szShadowPath, + nBuflen); } return false; @@ -83,17 +86,17 @@ void VSSInit(JobControlRecord* jcr) if (g_MajorVersion == 5) { switch (g_MinorVersion) { case 1: - jcr->pVSSClient = new VSSClientXP(); + jcr->impl_->pVSSClient = new VSSClientXP(); break; case 2: - jcr->pVSSClient = new VSSClient2003(); + jcr->impl_->pVSSClient = new VSSClient2003(); break; } /* * Vista or Longhorn or later */ } else if (g_MajorVersion >= 6) { - jcr->pVSSClient = new VSSClientVista(); + jcr->impl_->pVSSClient = new VSSClientVista(); } /* @@ -209,14 +212,11 @@ bool VSSClient::GetShadowPathW(const wchar_t* szFilePath, return false; } -size_t VSSClient::GetWriterCount() const -{ - return writer_info_.size(); -} +size_t VSSClient::GetWriterCount() const { return writer_info_.size(); } const char* VSSClient::GetWriterInfo(size_t nIndex) const { - if ( nIndex < writer_info_.size() ) { + if (nIndex < writer_info_.size()) { return writer_info_[nIndex].info_text_.c_str(); } return nullptr; @@ -224,9 +224,7 @@ const char* VSSClient::GetWriterInfo(size_t nIndex) const int VSSClient::GetWriterState(size_t nIndex) const { - if ( nIndex < writer_info_.size() ) { - return writer_info_[nIndex].state_; - } + if (nIndex < writer_info_.size()) { return writer_info_[nIndex].state_; } return 0; } @@ -241,8 +239,5 @@ void VSSClient::AppendWriterInfo(int nState, const char* pszInfo) /* * Note, this is called at the end of every job, so release all items */ -void VSSClient::DestroyWriterInfo() -{ - writer_info_.clear(); -} +void VSSClient::DestroyWriterInfo() { writer_info_.clear(); } #endif From e2057b5e41b0187df19bbd1710d3f128c8472ce7 Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Mon, 4 Nov 2019 18:16:57 +0100 Subject: [PATCH 02/23] dird: move daemon private data to separate file --- core/src/dird/admin.cc | 17 +- core/src/dird/archive.cc | 17 +- core/src/dird/authenticate.cc | 15 +- core/src/dird/autoprune.cc | 13 +- core/src/dird/backup.cc | 266 ++++---- core/src/dird/bsr.cc | 17 +- core/src/dird/catreq.cc | 38 +- core/src/dird/consolidate.cc | 70 ++- core/src/dird/dir_plugins.cc | 61 +- core/src/dird/dird_conf.cc | 19 +- core/src/dird/expand.cc | 23 +- core/src/dird/fd_cmds.cc | 164 ++--- core/src/dird/getmsg.cc | 5 +- core/src/dird/inc_conf.cc | 5 +- core/src/dird/jcr_private.h | 156 +++++ core/src/dird/job.cc | 571 ++++++++++-------- core/src/dird/job.h | 1 + core/src/dird/jobq.cc | 242 ++++---- core/src/dird/migrate.cc | 438 +++++++------- core/src/dird/msgchan.cc | 94 +-- core/src/dird/ndmp_dma_backup_NDMP_BAREOS.cc | 53 +- core/src/dird/ndmp_dma_backup_NDMP_NATIVE.cc | 56 +- core/src/dird/ndmp_dma_backup_common.cc | 31 +- core/src/dird/ndmp_dma_generic.cc | 48 +- core/src/dird/ndmp_dma_restore_NDMP_BAREOS.cc | 71 +-- core/src/dird/ndmp_dma_restore_NDMP_NATIVE.cc | 22 +- core/src/dird/ndmp_dma_restore_common.cc | 15 +- core/src/dird/ndmp_dma_storage.cc | 9 +- core/src/dird/newvol.cc | 5 +- core/src/dird/next_vol.cc | 23 +- core/src/dird/quota.cc | 161 ++--- core/src/dird/recycle.cc | 5 +- core/src/dird/restore.cc | 111 ++-- core/src/dird/scheduler.cc | 40 +- core/src/dird/sd_cmds.cc | 68 ++- core/src/dird/stats.cc | 23 +- core/src/dird/storage.cc | 244 ++++---- core/src/dird/testfind.cc | 8 +- core/src/dird/ua_cmds.cc | 44 +- core/src/dird/ua_db.cc | 3 +- core/src/dird/ua_dotcmds.cc | 2 +- core/src/dird/ua_label.cc | 25 +- core/src/dird/ua_output.cc | 34 +- core/src/dird/ua_purge.cc | 5 +- core/src/dird/ua_restore.cc | 3 +- core/src/dird/ua_run.cc | 475 ++++++++------- core/src/dird/ua_select.cc | 18 +- core/src/dird/ua_server.cc | 7 +- core/src/dird/ua_status.cc | 35 +- core/src/dird/ua_update.cc | 3 +- core/src/dird/vbackup.cc | 146 ++--- core/src/dird/verify.cc | 160 ++--- core/src/filed/jcr_private.h | 5 +- core/src/include/jcr.h | 139 ----- 54 files changed, 2325 insertions(+), 2004 deletions(-) create mode 100644 core/src/dird/jcr_private.h diff --git a/core/src/dird/admin.cc b/core/src/dird/admin.cc index 7282f234586..75bcd0022d9 100644 --- a/core/src/dird/admin.cc +++ b/core/src/dird/admin.cc @@ -32,6 +32,7 @@ #include "include/bareos.h" #include "dird.h" #include "dird/admin.h" +#include "dird/jcr_private.h" #include "dird/job.h" #include "dird/storage.h" @@ -53,9 +54,9 @@ bool DoAdminInit(JobControlRecord* jcr) */ bool do_admin(JobControlRecord* jcr) { - jcr->jr.JobId = jcr->JobId; + jcr->impl_->jr.JobId = jcr->JobId; - jcr->fname = (char*)GetPoolMemory(PM_FNAME); + jcr->impl_->fname = (char*)GetPoolMemory(PM_FNAME); /* * Print Job Start message @@ -83,7 +84,7 @@ void AdminCleanup(JobControlRecord* jcr, int TermCode) UpdateJobEnd(jcr, TermCode); - if (!jcr->db->GetJobRecord(jcr, &jcr->jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Job record for Job report: ERR=%s"), jcr->db->strerror()); @@ -108,9 +109,9 @@ void AdminCleanup(JobControlRecord* jcr, int TermCode) sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus); break; } - bstrftimes(schedt, sizeof(schedt), jcr->jr.SchedTime); - bstrftimes(sdt, sizeof(sdt), jcr->jr.StartTime); - bstrftimes(edt, sizeof(edt), jcr->jr.EndTime); + bstrftimes(schedt, sizeof(schedt), jcr->impl_->jr.SchedTime); + bstrftimes(sdt, sizeof(sdt), jcr->impl_->jr.StartTime); + bstrftimes(edt, sizeof(edt), jcr->impl_->jr.EndTime); Jmsg(jcr, msg_type, 0, _("BAREOS " VERSION " (" LSMDATE "): %s\n" @@ -121,8 +122,8 @@ void AdminCleanup(JobControlRecord* jcr, int TermCode) " End time: %s\n" " Bareos binary info: %s\n" " Termination: %s\n\n"), - edt, jcr->jr.JobId, jcr->jr.Job, schedt, sdt, edt, BAREOS_JOBLOG_MESSAGE, - TermMsg); + edt, jcr->impl_->jr.JobId, jcr->impl_->jr.Job, schedt, sdt, edt, + BAREOS_JOBLOG_MESSAGE, TermMsg); Dmsg0(debuglevel, "Leave AdminCleanup()\n"); } diff --git a/core/src/dird/archive.cc b/core/src/dird/archive.cc index 565f6550689..49efd80926d 100644 --- a/core/src/dird/archive.cc +++ b/core/src/dird/archive.cc @@ -32,6 +32,7 @@ #include "dird.h" #include "dird/archive.h" #include "dird/job.h" +#include "dird/jcr_private.h" #include "dird/storage.h" namespace directordaemon { @@ -52,9 +53,9 @@ bool DoArchiveInit(JobControlRecord* jcr) */ bool DoArchive(JobControlRecord* jcr) { - jcr->jr.JobId = jcr->JobId; + jcr->impl_->jr.JobId = jcr->JobId; - jcr->fname = (char*)GetPoolMemory(PM_FNAME); + jcr->impl_->fname = (char*)GetPoolMemory(PM_FNAME); /* * Print Job Start message @@ -82,7 +83,7 @@ void ArchiveCleanup(JobControlRecord* jcr, int TermCode) UpdateJobEnd(jcr, TermCode); - if (!jcr->db->GetJobRecord(jcr, &jcr->jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Job record for Job report: ERR=%s"), jcr->db->strerror()); @@ -108,9 +109,9 @@ void ArchiveCleanup(JobControlRecord* jcr, int TermCode) break; } - bstrftimes(schedt, sizeof(schedt), jcr->jr.SchedTime); - bstrftimes(sdt, sizeof(sdt), jcr->jr.StartTime); - bstrftimes(edt, sizeof(edt), jcr->jr.EndTime); + bstrftimes(schedt, sizeof(schedt), jcr->impl_->jr.SchedTime); + bstrftimes(sdt, sizeof(sdt), jcr->impl_->jr.StartTime); + bstrftimes(edt, sizeof(edt), jcr->impl_->jr.EndTime); Jmsg(jcr, msg_type, 0, _("BAREOS " VERSION " (" LSMDATE "): %s\n" @@ -121,8 +122,8 @@ void ArchiveCleanup(JobControlRecord* jcr, int TermCode) " End time: %s\n" " Bareos binary info: %s\n" " Termination: %s\n\n"), - edt, jcr->jr.JobId, jcr->jr.Job, schedt, sdt, edt, BAREOS_JOBLOG_MESSAGE, - TermMsg); + edt, jcr->impl_->jr.JobId, jcr->impl_->jr.Job, schedt, sdt, edt, + BAREOS_JOBLOG_MESSAGE, TermMsg); Dmsg0(debuglevel, "Leave ArchiveCleanup()\n"); } diff --git a/core/src/dird/authenticate.cc b/core/src/dird/authenticate.cc index 6f9f641ed7a..af402dbfa1c 100644 --- a/core/src/dird/authenticate.cc +++ b/core/src/dird/authenticate.cc @@ -39,6 +39,7 @@ #include "dird/fd_cmds.h" #include "dird/client_connection_handshake_mode.h" #include "dird/dird_globals.h" +#include "dird/jcr_private.h" #include "lib/bnet.h" #include "lib/qualified_resource_name_type_converter.h" #include "lib/bstringlist.h" @@ -72,8 +73,7 @@ bool AuthenticateWithStorageDaemon(BareosSocket* sd, bstrncpy(dirname, me->resource_name_, sizeof(dirname)); BashSpaces(dirname); - sd->InitBnetDump( - my_config->CreateOwnQualifiedNameForNetworkDump()); + sd->InitBnetDump(my_config->CreateOwnQualifiedNameForNetworkDump()); if (!sd->fsend(hello, dirname)) { Dmsg1(debuglevel, _("Error sending Hello to Storage daemon. ERR=%s\n"), BnetStrerror(sd)); @@ -126,9 +126,9 @@ bool AuthenticateWithFileDaemon(JobControlRecord* jcr) if (jcr->authenticated) { return true; } BareosSocket* fd = jcr->file_bsock; - ClientResource* client = jcr->res.client; + ClientResource* client = jcr->impl_->res.client; - if (jcr->connection_handshake_try_ == + if (jcr->impl_->connection_handshake_try_ == ClientConnectionHandshakeMode::kTlsFirst) { std::string qualified_resource_name; if (!my_config->GetQualifiedResourceNameTypeConverter()->ResourceToString( @@ -151,8 +151,7 @@ bool AuthenticateWithFileDaemon(JobControlRecord* jcr) bstrncpy(dirname, me->resource_name_, sizeof(dirname)); BashSpaces(dirname); - fd->InitBnetDump( - my_config->CreateOwnQualifiedNameForNetworkDump()); + fd->InitBnetDump(my_config->CreateOwnQualifiedNameForNetworkDump()); if (!fd->fsend(hello, dirname)) { Jmsg(jcr, M_FATAL, 0, _("Error sending Hello to File daemon at \"%s:%d\". ERR=%s\n"), @@ -193,9 +192,9 @@ bool AuthenticateWithFileDaemon(JobControlRecord* jcr) } Dmsg1(110, "msg); - jcr->FDVersion = 0; + jcr->impl_->FDVersion = 0; if (!bstrncmp(fd->msg, FDOKhello, sizeof(FDOKhello)) && - sscanf(fd->msg, FDOKnewHello, &jcr->FDVersion) != 1) { + sscanf(fd->msg, FDOKnewHello, &jcr->impl_->FDVersion) != 1) { Dmsg0(debuglevel, _("File daemon rejected Hello command\n")); Jmsg(jcr, M_FATAL, 0, _("File daemon at \"%s:%d\" rejected Hello command\n"), fd->host(), diff --git a/core/src/dird/autoprune.cc b/core/src/dird/autoprune.cc index e5e1ec16f2c..a3f9ea2c96f 100644 --- a/core/src/dird/autoprune.cc +++ b/core/src/dird/autoprune.cc @@ -30,6 +30,7 @@ #include "include/bareos.h" #include "dird.h" +#include "dird/jcr_private.h" #include "dird/next_vol.h" #include "dird/ua_server.h" #include "dird/ua_prune.h" @@ -50,14 +51,14 @@ void DoAutoprune(JobControlRecord* jcr) PoolResource* pool; bool pruned; - if (!jcr->res.client) { /* temp -- remove me */ + if (!jcr->impl_->res.client) { /* temp -- remove me */ return; } ua = new_ua_context(jcr); - job = jcr->res.job; - client = jcr->res.client; - pool = jcr->res.pool; + job = jcr->impl_->res.job; + client = jcr->impl_->res.client; + pool = jcr->impl_->res.pool; if (job->PruneJobs || client->AutoPrune) { PruneJobs(ua, client, pool, jcr->getJobType()); @@ -93,8 +94,8 @@ void PruneVolumes(JobControlRecord* jcr, PoolMem query(PM_MESSAGE); char ed1[50], ed2[100], ed3[50]; - Dmsg1(100, "Prune volumes PoolId=%d\n", jcr->jr.PoolId); - if (!jcr->res.job->PruneVolumes && !jcr->res.pool->AutoPrune) { + Dmsg1(100, "Prune volumes PoolId=%d\n", jcr->impl_->jr.PoolId); + if (!jcr->impl_->res.job->PruneVolumes && !jcr->impl_->res.pool->AutoPrune) { Dmsg0(100, "AutoPrune not set in Pool.\n"); return; } diff --git a/core/src/dird/backup.cc b/core/src/dird/backup.cc index 8d503e0f489..c518e64642c 100644 --- a/core/src/dird/backup.cc +++ b/core/src/dird/backup.cc @@ -41,6 +41,7 @@ #include "dird/fd_cmds.h" #include "dird/getmsg.h" #include "dird/inc_conf.h" +#include "dird/jcr_private.h" #include "dird/job.h" #include "dird/msgchan.h" #include "dird/quota.h" @@ -72,14 +73,15 @@ static char EndJob[] = static inline bool ValidateClient(JobControlRecord* jcr) { - switch (jcr->res.client->Protocol) { + switch (jcr->impl_->res.client->Protocol) { case APT_NATIVE: return true; default: - Jmsg(jcr, M_FATAL, 0, - _("Client %s has illegal backup protocol %s for Native backup\n"), - jcr->res.client->resource_name_, - AuthenticationProtocolTypeToString(jcr->res.client->Protocol)); + Jmsg( + jcr, M_FATAL, 0, + _("Client %s has illegal backup protocol %s for Native backup\n"), + jcr->impl_->res.client->resource_name_, + AuthenticationProtocolTypeToString(jcr->impl_->res.client->Protocol)); return false; } } @@ -130,7 +132,7 @@ static inline bool ValidateStorage(JobControlRecord* jcr) { StorageResource* store = nullptr; - foreach_alist (store, jcr->res.write_storage_list) { + foreach_alist (store, jcr->impl_->res.write_storage_list) { switch (store->Protocol) { case APT_NATIVE: continue; @@ -155,14 +157,15 @@ bool DoNativeBackupInit(JobControlRecord* jcr) if (!AllowDuplicateJob(jcr)) { return false; } - jcr->jr.PoolId = GetOrCreatePoolRecord(jcr, jcr->res.pool->resource_name_); - if (jcr->jr.PoolId == 0) { return false; } + jcr->impl_->jr.PoolId = + GetOrCreatePoolRecord(jcr, jcr->impl_->res.pool->resource_name_); + if (jcr->impl_->jr.PoolId == 0) { return false; } /* * If pool storage specified, use it instead of job storage */ - CopyWstorage(jcr, jcr->res.pool->storage, _("Pool resource")); - if (!jcr->res.write_storage_list) { + CopyWstorage(jcr, jcr->impl_->res.pool->storage, _("Pool resource")); + if (!jcr->impl_->res.write_storage_list) { Jmsg(jcr, M_FATAL, 0, _("No Storage specification found in Job or Pool.\n")); return false; @@ -188,11 +191,13 @@ static bool GetBaseJobids(JobControlRecord* jcr, db_list_ctx* jobids) JobId_t id; char str_jobid[50]; - if (!jcr->res.job->base) { return false; /* no base job, stop accurate */ } + if (!jcr->impl_->res.job->base) { + return false; /* no base job, stop accurate */ + } - jr.StartTime = jcr->jr.StartTime; + jr.StartTime = jcr->impl_->jr.StartTime; - foreach_alist (job, jcr->res.job->base) { + foreach_alist (job, jcr->impl_->res.job->base) { bstrncpy(jr.Name, job->resource_name_, sizeof(jr.Name)); jcr->db->GetBaseJobid(jcr, &jr, &id); @@ -222,7 +227,7 @@ static int AccurateListHandler(void* ctx, int num_fields, char** row) } /* sending with checksum */ - if (jcr->use_accurate_chksum && num_fields == 9 && + if (jcr->impl_->use_accurate_chksum && num_fields == 9 && row[6][0] && /* skip checksum = '0' */ row[6][1]) { jcr->file_bsock->fsend("%s%s%c%s%c%s%c%s", row[0], row[1], 0, row[4], 0, @@ -246,9 +251,9 @@ static bool IsChecksumNeededByFileset(JobControlRecord* jcr) bool in_block = false; bool have_basejob_option = false; - if (!jcr->res.job || !jcr->res.job->fileset) { return false; } + if (!jcr->impl_->res.job || !jcr->impl_->res.job->fileset) { return false; } - fs = jcr->res.job->fileset; + fs = jcr->impl_->res.job->fileset; for (std::size_t i = 0; i < fs->include_items.size(); i++) { inc = fs->include_items[i]; @@ -325,7 +330,7 @@ bool SendAccurateCurrentFiles(JobControlRecord* jcr) /* * For Incr/Diff level, we search for older jobs */ - jcr->db->AccurateGetJobids(jcr, &jcr->jr, &jobids); + jcr->db->AccurateGetJobids(jcr, &jcr->impl_->jr, &jobids); /* * We are in Incr/Diff, but no Full to build the accurate list... @@ -339,7 +344,7 @@ bool SendAccurateCurrentFiles(JobControlRecord* jcr) /* * Don't send and store the checksum if fileset doesn't require it */ - jcr->use_accurate_chksum = IsChecksumNeededByFileset(jcr); + jcr->impl_->use_accurate_chksum = IsChecksumNeededByFileset(jcr); if (jcr->JobId) { /* display the message only for real jobs */ Jmsg(jcr, M_INFO, 0, _("Sending Accurate information.\n")); } @@ -359,7 +364,7 @@ bool SendAccurateCurrentFiles(JobControlRecord* jcr) jcr->db->strerror()); return false; } - if (!jcr->db->GetBaseFileList(jcr, jcr->use_accurate_chksum, + if (!jcr->db->GetBaseFileList(jcr, jcr->impl_->use_accurate_chksum, AccurateListHandler, (void*)jcr)) { Jmsg(jcr, M_FATAL, 0, "error in jcr->db->GetBaseFileList:%s\n", jcr->db->strerror()); @@ -371,9 +376,9 @@ bool SendAccurateCurrentFiles(JobControlRecord* jcr) return false; /* Fail */ } - jcr->db_batch->GetFileList(jcr, jobids.list, jcr->use_accurate_chksum, - false /* no delta */, AccurateListHandler, - (void*)jcr); + jcr->db_batch->GetFileList( + jcr, jobids.list, jcr->impl_->use_accurate_chksum, false /* no delta */, + AccurateListHandler, (void*)jcr); } jcr->file_bsock->signal(BNET_EOD); @@ -402,8 +407,9 @@ bool DoNativeBackup(JobControlRecord* jcr) edit_uint64(jcr->JobId, ed1), jcr->Job); jcr->setJobStatus(JS_Running); - Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->jr.JobId, jcr->jr.JobLevel); - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->jr)) { + Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->impl_->jr.JobId, + jcr->impl_->jr.JobLevel); + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); return false; } @@ -439,7 +445,7 @@ bool DoNativeBackup(JobControlRecord* jcr) /* * Now start a job with the Storage daemon */ - if (!StartStorageDaemonJob(jcr, NULL, jcr->res.write_storage_list)) { + if (!StartStorageDaemonJob(jcr, NULL, jcr->impl_->res.write_storage_list)) { return false; } @@ -447,7 +453,7 @@ bool DoNativeBackup(JobControlRecord* jcr) * When the client is not in passive mode we can put the SD in * listen mode for the FD connection. */ - jcr->passive_client = jcr->res.client->passive; + jcr->passive_client = jcr->impl_->res.client->passive; if (!jcr->passive_client) { /* * Start the job prior to starting the message thread below @@ -478,11 +484,11 @@ bool DoNativeBackup(JobControlRecord* jcr) /* * Check if the file daemon supports passive client mode. */ - if (jcr->passive_client && jcr->FDVersion < FD_VERSION_51) { + if (jcr->passive_client && jcr->impl_->FDVersion < FD_VERSION_51) { Jmsg(jcr, M_FATAL, 0, _("Client \"%s\" doesn't support passive client mode. " "Please upgrade your client or disable compat mode.\n"), - jcr->res.client->resource_name_); + jcr->impl_->res.client->resource_name_); goto close_fd; } @@ -502,18 +508,18 @@ bool DoNativeBackup(JobControlRecord* jcr) Dmsg1(500, "Unexpected %s secure erase\n", "client"); } - if (jcr->res.job->max_bandwidth > 0) { - jcr->max_bandwidth = jcr->res.job->max_bandwidth; - } else if (jcr->res.client->max_bandwidth > 0) { - jcr->max_bandwidth = jcr->res.client->max_bandwidth; + if (jcr->impl_->res.job->max_bandwidth > 0) { + jcr->max_bandwidth = jcr->impl_->res.job->max_bandwidth; + } else if (jcr->impl_->res.client->max_bandwidth > 0) { + jcr->max_bandwidth = jcr->impl_->res.client->max_bandwidth; } if (jcr->max_bandwidth > 0) { SendBwlimitToFd(jcr, jcr->Job); /* Old clients don't have this command */ } - client = jcr->res.client; - store = jcr->res.write_storage; + client = jcr->impl_->res.client; + store = jcr->impl_->res.write_storage; char* connection_target_address; /* @@ -530,7 +536,7 @@ bool DoNativeBackup(JobControlRecord* jcr) */ TlsPolicy tls_policy; - if (jcr->res.client->connection_successful_handshake_ != + if (jcr->impl_->res.client->connection_successful_handshake_ != ClientConnectionHandshakeMode::kTlsFirst) { tls_policy = store->GetPolicy(); } else { @@ -552,7 +558,7 @@ bool DoNativeBackup(JobControlRecord* jcr) } else { /* passive client */ TlsPolicy tls_policy; - if (jcr->res.client->connection_successful_handshake_ != + if (jcr->impl_->res.client->connection_successful_handshake_ != ClientConnectionHandshakeMode::kTlsFirst) { tls_policy = client->GetPolicy(); } else { @@ -612,8 +618,8 @@ bool DoNativeBackup(JobControlRecord* jcr) * is after the start of this run. */ jcr->start_time = time(NULL); - jcr->jr.StartTime = jcr->start_time; - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->jr)) { + jcr->impl_->jr.StartTime = jcr->start_time; + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); } @@ -701,10 +707,10 @@ int WaitForJobTermination(JobControlRecord* jcr, int timeout) */ while ((n = BgetDirmsg(fd)) >= 0) { if (!fd_ok && - sscanf(fd->msg, EndJob, &jcr->FDJobStatus, &JobFiles, &ReadBytes, - &JobBytes, &JobErrors, &VSS, &Encrypt) == 7) { + sscanf(fd->msg, EndJob, &jcr->impl_->FDJobStatus, &JobFiles, + &ReadBytes, &JobBytes, &JobErrors, &VSS, &Encrypt) == 7) { fd_ok = true; - jcr->setJobStatus(jcr->FDJobStatus); + jcr->setJobStatus(jcr->impl_->FDJobStatus); Dmsg1(100, "FDStatus=%c\n", (char)jcr->JobStatus); } else { Jmsg(jcr, M_WARNING, 0, _("Unexpected Client Job message: %s\n"), @@ -718,7 +724,7 @@ int WaitForJobTermination(JobControlRecord* jcr, int timeout) int i = 0; Jmsg(jcr, M_FATAL, 0, _("Network error with FD during %s: ERR=%s\n"), job_type_to_str(jcr->getJobType()), fd->bstrerror()); - while (i++ < 10 && jcr->res.job->RescheduleIncompleteJobs && + while (i++ < 10 && jcr->impl_->res.job->RescheduleIncompleteJobs && jcr->IsCanceled()) { Bmicrosleep(3, 0); } @@ -731,11 +737,12 @@ int WaitForJobTermination(JobControlRecord* jcr, int timeout) * the SD despool. */ Dmsg5(100, "cancel=%d fd_ok=%d FDJS=%d JS=%d SDJS=%d\n", jcr->IsCanceled(), - fd_ok, jcr->FDJobStatus, jcr->JobStatus, jcr->SDJobStatus); + fd_ok, jcr->impl_->FDJobStatus, jcr->JobStatus, + jcr->impl_->SDJobStatus); if (jcr->IsCanceled() || - (!jcr->res.job->RescheduleIncompleteJobs && !fd_ok)) { - Dmsg4(100, "fd_ok=%d FDJS=%d JS=%d SDJS=%d\n", fd_ok, jcr->FDJobStatus, - jcr->JobStatus, jcr->SDJobStatus); + (!jcr->impl_->res.job->RescheduleIncompleteJobs && !fd_ok)) { + Dmsg4(100, "fd_ok=%d FDJS=%d JS=%d SDJS=%d\n", fd_ok, + jcr->impl_->FDJobStatus, jcr->JobStatus, jcr->impl_->SDJobStatus); CancelStorageDaemonJob(jcr); } @@ -753,24 +760,27 @@ int WaitForJobTermination(JobControlRecord* jcr, int timeout) jcr->ReadBytes = ReadBytes; jcr->JobBytes = JobBytes; jcr->JobWarnings = JobWarnings; - jcr->VSS = VSS; - jcr->Encrypt = Encrypt; + jcr->impl_->VSS = VSS; + jcr->impl_->Encrypt = Encrypt; } else { Jmsg(jcr, M_FATAL, 0, _("No Job status returned from FD.\n")); } - // Dmsg4(100, "fd_ok=%d FDJS=%d JS=%d SDJS=%d\n", fd_ok, jcr->FDJobStatus, - // jcr->JobStatus, jcr->SDJobStatus); + // Dmsg4(100, "fd_ok=%d FDJS=%d JS=%d SDJS=%d\n", fd_ok, + // jcr->impl_->FDJobStatus, + // jcr->JobStatus, jcr->impl_->SDJobStatus); /* * Return the first error status we find Dir, FD, or SD */ if (!fd_ok || IsBnetError(fd)) { /* if fd not set, that use !fd_ok */ - jcr->FDJobStatus = JS_ErrorTerminated; + jcr->impl_->FDJobStatus = JS_ErrorTerminated; } if (jcr->JobStatus != JS_Terminated) { return jcr->JobStatus; } - if (jcr->FDJobStatus != JS_Terminated) { return jcr->FDJobStatus; } - return jcr->SDJobStatus; + if (jcr->impl_->FDJobStatus != JS_Terminated) { + return jcr->impl_->FDJobStatus; + } + return jcr->impl_->SDJobStatus; } /* @@ -786,20 +796,20 @@ void NativeBackupCleanup(JobControlRecord* jcr, int TermCode) Dmsg2(100, "Enter backup_cleanup %d %c\n", TermCode, TermCode); if (jcr->is_JobStatus(JS_Terminated) && - (jcr->JobErrors || jcr->SDErrors || jcr->JobWarnings)) { + (jcr->JobErrors || jcr->impl_->SDErrors || jcr->JobWarnings)) { TermCode = JS_Warnings; } UpdateJobEnd(jcr, TermCode); - if (!jcr->db->GetJobRecord(jcr, &jcr->jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Job record for Job report: ERR=%s"), jcr->db->strerror()); jcr->setJobStatus(JS_ErrorTerminated); } - bstrncpy(cr.Name, jcr->res.client->resource_name_, sizeof(cr.Name)); + bstrncpy(cr.Name, jcr->impl_->res.client->resource_name_, sizeof(cr.Name)); if (!jcr->db->GetClientRecord(jcr, &cr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Client record for Job report: ERR=%s"), @@ -824,14 +834,18 @@ void NativeBackupCleanup(JobControlRecord* jcr, int TermCode) msg_type = M_ERROR; /* Generate error message */ if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->SD_msg_chan_started) { pthread_cancel(jcr->SD_msg_chan); } + if (jcr->impl_->SD_msg_chan_started) { + pthread_cancel(jcr->impl_->SD_msg_chan); + } } break; case JS_Canceled: TermMsg = _("Backup Canceled"); if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->SD_msg_chan_started) { pthread_cancel(jcr->SD_msg_chan); } + if (jcr->impl_->SD_msg_chan_started) { + pthread_cancel(jcr->impl_->SD_msg_chan); + } } break; default: @@ -850,8 +864,8 @@ void UpdateBootstrapFile(JobControlRecord* jcr) /* * Now update the bootstrap file if any */ - if (jcr->IsTerminatedOk() && jcr->jr.JobBytes && - jcr->res.job->WriteBootstrap) { + if (jcr->IsTerminatedOk() && jcr->impl_->jr.JobBytes && + jcr->impl_->res.job->WriteBootstrap) { FILE* fd; int VolCount; int got_pipe = 0; @@ -860,7 +874,7 @@ void UpdateBootstrapFile(JobControlRecord* jcr) char edt[50], ed1[50], ed2[50]; POOLMEM* fname = GetPoolMemory(PM_FNAME); - fname = edit_job_codes(jcr, fname, jcr->res.job->WriteBootstrap, ""); + fname = edit_job_codes(jcr, fname, jcr->impl_->res.job->WriteBootstrap, ""); if (*fname == '|') { got_pipe = 1; bpipe = OpenBpipe(fname + 1, 0, "w"); /* skip first char "|" */ @@ -876,12 +890,14 @@ void UpdateBootstrapFile(JobControlRecord* jcr) _("Could not get Job Volume Parameters to " "update Bootstrap file. ERR=%s\n"), jcr->db->strerror()); - if (jcr->SDJobFiles != 0) { jcr->setJobStatus(JS_ErrorTerminated); } + if (jcr->impl_->SDJobFiles != 0) { + jcr->setJobStatus(JS_ErrorTerminated); + } } /* Start output with when and who wrote it */ bstrftimes(edt, sizeof(edt), time(NULL)); - fprintf(fd, "# %s - %s - %s%s\n", edt, jcr->jr.Job, - JobLevelToString(jcr->getJobLevel()), jcr->since); + fprintf(fd, "# %s - %s - %s%s\n", edt, jcr->impl_->jr.Job, + JobLevelToString(jcr->getJobLevel()), jcr->impl_->since); for (int i = 0; i < VolCount; i++) { /* Write the record */ fprintf(fd, "Volume=\"%s\"\n", VolParams[i].VolumeName); @@ -941,28 +957,28 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty secure_erase_status, compress_algo_list; - bstrftimes(schedt, sizeof(schedt), jcr->jr.SchedTime); - bstrftimes(sdt, sizeof(sdt), jcr->jr.StartTime); - bstrftimes(edt, sizeof(edt), jcr->jr.EndTime); - RunTime = jcr->jr.EndTime - jcr->jr.StartTime; + bstrftimes(schedt, sizeof(schedt), jcr->impl_->jr.SchedTime); + bstrftimes(sdt, sizeof(sdt), jcr->impl_->jr.StartTime); + bstrftimes(edt, sizeof(edt), jcr->impl_->jr.EndTime); + RunTime = jcr->impl_->jr.EndTime - jcr->impl_->jr.StartTime; bstrftimes(gdt, sizeof(gdt), - jcr->res.client->GraceTime + - jcr->res.client->SoftQuotaGracePeriod); + jcr->impl_->res.client->GraceTime + + jcr->impl_->res.client->SoftQuotaGracePeriod); if (RunTime <= 0) { kbps = 0; } else { - kbps = ((double)jcr->jr.JobBytes) / (1000.0 * (double)RunTime); + kbps = ((double)jcr->impl_->jr.JobBytes) / (1000.0 * (double)RunTime); } - if (!jcr->db->GetJobVolumeNames(jcr, jcr->jr.JobId, jcr->VolumeName)) { + if (!jcr->db->GetJobVolumeNames(jcr, jcr->impl_->jr.JobId, jcr->VolumeName)) { /* * Note, if the job has erred, most likely it did not write any * tape, so suppress this "error" message since in that case * it is normal. Or look at it the other way, only for a * normal exit should we complain about this error. */ - if (jcr->IsTerminatedOk() && jcr->jr.JobBytes) { + if (jcr->IsTerminatedOk() && jcr->impl_->jr.JobBytes) { Jmsg(jcr, M_ERROR, 0, "%s", jcr->db->strerror()); } jcr->VolumeName[0] = 0; /* none */ @@ -997,36 +1013,36 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty } } - JobstatusToAscii(jcr->FDJobStatus, fd_term_msg, sizeof(fd_term_msg)); - JobstatusToAscii(jcr->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); + JobstatusToAscii(jcr->impl_->FDJobStatus, fd_term_msg, sizeof(fd_term_msg)); + JobstatusToAscii(jcr->impl_->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); switch (jcr->getJobProtocol()) { case PT_NDMP_BAREOS: Mmsg(level_info, _( " Backup Level: %s%s\n"), - JobLevelToString(jcr->getJobLevel()), jcr->since); + JobLevelToString(jcr->getJobLevel()), jcr->impl_->since); Mmsg(statistics, _( " NDMP Files Written: %s\n" " SD Files Written: %s\n" " NDMP Bytes Written: %s (%sB)\n" " SD Bytes Written: %s (%sB)\n"), - edit_uint64_with_commas(jcr->jr.JobFiles, ec1), - edit_uint64_with_commas(jcr->SDJobFiles, ec2), - edit_uint64_with_commas(jcr->jr.JobBytes, ec3), - edit_uint64_with_suffix(jcr->jr.JobBytes, ec4), - edit_uint64_with_commas(jcr->SDJobBytes, ec5), - edit_uint64_with_suffix(jcr->SDJobBytes, ec6)); + edit_uint64_with_commas(jcr->impl_->jr.JobFiles, ec1), + edit_uint64_with_commas(jcr->impl_->SDJobFiles, ec2), + edit_uint64_with_commas(jcr->impl_->jr.JobBytes, ec3), + edit_uint64_with_suffix(jcr->impl_->jr.JobBytes, ec4), + edit_uint64_with_commas(jcr->impl_->SDJobBytes, ec5), + edit_uint64_with_suffix(jcr->impl_->SDJobBytes, ec6)); break; case PT_NDMP_NATIVE: Mmsg(level_info, _( " Backup Level: %s%s\n"), - JobLevelToString(jcr->getJobLevel()), jcr->since); + JobLevelToString(jcr->getJobLevel()), jcr->impl_->since); Mmsg(statistics, _( " NDMP Files Written: %s\n" " NDMP Bytes Written: %s (%sB)\n"), - edit_uint64_with_commas(jcr->jr.JobFiles, ec1), - edit_uint64_with_commas(jcr->jr.JobBytes, ec3), - edit_uint64_with_suffix(jcr->jr.JobBytes, ec4)); + edit_uint64_with_commas(jcr->impl_->jr.JobFiles, ec1), + edit_uint64_with_commas(jcr->impl_->jr.JobBytes, ec3), + edit_uint64_with_suffix(jcr->impl_->jr.JobBytes, ec4)); break; default: if (jcr->is_JobLevel(L_VIRTUAL_FULL)) { @@ -1035,32 +1051,32 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty Mmsg(statistics, _( " SD Files Written: %s\n" " SD Bytes Written: %s (%sB)\n"), - edit_uint64_with_commas(jcr->SDJobFiles, ec2), - edit_uint64_with_commas(jcr->SDJobBytes, ec5), - edit_uint64_with_suffix(jcr->SDJobBytes, ec6)); + edit_uint64_with_commas(jcr->impl_->SDJobFiles, ec2), + edit_uint64_with_commas(jcr->impl_->SDJobBytes, ec5), + edit_uint64_with_suffix(jcr->impl_->SDJobBytes, ec6)); } else { Mmsg(level_info, _( " Backup Level: %s%s\n"), - JobLevelToString(jcr->getJobLevel()), jcr->since); + JobLevelToString(jcr->getJobLevel()), jcr->impl_->since); Mmsg(statistics, _( " FD Files Written: %s\n" " SD Files Written: %s\n" " FD Bytes Written: %s (%sB)\n" " SD Bytes Written: %s (%sB)\n"), - edit_uint64_with_commas(jcr->jr.JobFiles, ec1), - edit_uint64_with_commas(jcr->SDJobFiles, ec2), - edit_uint64_with_commas(jcr->jr.JobBytes, ec3), - edit_uint64_with_suffix(jcr->jr.JobBytes, ec4), - edit_uint64_with_commas(jcr->SDJobBytes, ec5), - edit_uint64_with_suffix(jcr->SDJobBytes, ec6)); + edit_uint64_with_commas(jcr->impl_->jr.JobFiles, ec1), + edit_uint64_with_commas(jcr->impl_->SDJobFiles, ec2), + edit_uint64_with_commas(jcr->impl_->jr.JobBytes, ec3), + edit_uint64_with_suffix(jcr->impl_->jr.JobBytes, ec4), + edit_uint64_with_commas(jcr->impl_->SDJobBytes, ec5), + edit_uint64_with_suffix(jcr->impl_->SDJobBytes, ec6)); } break; } - if (jcr->HasQuota) { - if (jcr->res.client->GraceTime != 0) { - bstrftimes(gdt, sizeof(gdt), jcr->res.client->GraceTime + - jcr->res.client->SoftQuotaGracePeriod); + if (jcr->impl_->HasQuota) { + if (jcr->impl_->res.client->GraceTime != 0) { + bstrftimes(gdt, sizeof(gdt), jcr->impl_->res.client->GraceTime + + jcr->impl_->res.client->SoftQuotaGracePeriod); } else { bstrncpy(gdt, "Soft Quota not exceeded", sizeof(gdt)); } @@ -1070,14 +1086,14 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty " Soft Quota: %s (%sB)\n" " Hard Quota: %s (%sB)\n" " Grace Expiry Date: %s\n"), - edit_uint64_with_commas(jcr->jr.JobSumTotalBytes+jcr->SDJobBytes, ec1), - edit_uint64_with_suffix(jcr->jr.JobSumTotalBytes+jcr->SDJobBytes, ec2), - edit_uint64_with_commas(jcr->res.client->QuotaLimit, ec3), - edit_uint64_with_suffix(jcr->res.client->QuotaLimit, ec4), - edit_uint64_with_commas(jcr->res.client->SoftQuota, ec5), - edit_uint64_with_suffix(jcr->res.client->SoftQuota, ec6), - edit_uint64_with_commas(jcr->res.client->HardQuota, ec7), - edit_uint64_with_suffix(jcr->res.client->HardQuota, ec8), + edit_uint64_with_commas(jcr->impl_->jr.JobSumTotalBytes+jcr->impl_->SDJobBytes, ec1), + edit_uint64_with_suffix(jcr->impl_->jr.JobSumTotalBytes+jcr->impl_->SDJobBytes, ec2), + edit_uint64_with_commas(jcr->impl_->res.client->QuotaLimit, ec3), + edit_uint64_with_suffix(jcr->impl_->res.client->QuotaLimit, ec4), + edit_uint64_with_commas(jcr->impl_->res.client->SoftQuota, ec5), + edit_uint64_with_suffix(jcr->impl_->res.client->SoftQuota, ec6), + edit_uint64_with_commas(jcr->impl_->res.client->HardQuota, ec7), + edit_uint64_with_suffix(jcr->impl_->res.client->HardQuota, ec8), gdt); } @@ -1091,7 +1107,7 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty " SD Errors: %d\n" " SD termination status: %s\n" " Accurate: %s\n"), - jcr->SDErrors, + jcr->impl_->SDErrors, sd_term_msg, jcr->accurate ? _("yes") : _("no")); } else { @@ -1107,8 +1123,8 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty jcr->nb_base_files, jcr->nb_base_files_used, jcr->nb_base_files_used * 100.0 / jcr->nb_base_files, - jcr->VSS ? _("yes") : _("no"), - jcr->Encrypt ? _("yes") : _("no"), + jcr->impl_->VSS ? _("yes") : _("no"), + jcr->impl_->Encrypt ? _("yes") : _("no"), jcr->accurate ? _("yes") : _("no")); } else { Mmsg(client_options, _( @@ -1118,8 +1134,8 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty " Accurate: %s\n"), compress, compress_algo_list.c_str(), - jcr->VSS ? _("yes") : _("no"), - jcr->Encrypt ? _("yes") : _("no"), + jcr->impl_->VSS ? _("yes") : _("no"), + jcr->impl_->Encrypt ? _("yes") : _("no"), jcr->accurate ? _("yes") : _("no")); } @@ -1129,7 +1145,7 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty " FD termination status: %s\n" " SD termination status: %s\n"), jcr->JobErrors, - jcr->SDErrors, + jcr->impl_->SDErrors, fd_term_msg, sd_term_msg); @@ -1137,12 +1153,12 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty Mmsg(temp," Dir Secure Erase Cmd: %s\n", me->secure_erase_cmdline); PmStrcat(secure_erase_status, temp.c_str()); } - if (!bstrcmp(jcr->FDSecureEraseCmd, "*None*")) { - Mmsg(temp, " FD Secure Erase Cmd: %s\n", jcr->FDSecureEraseCmd); + if (!bstrcmp(jcr->impl_->FDSecureEraseCmd, "*None*")) { + Mmsg(temp, " FD Secure Erase Cmd: %s\n", jcr->impl_->FDSecureEraseCmd); PmStrcat(secure_erase_status, temp.c_str()); } - if (!bstrcmp(jcr->SDSecureEraseCmd, "*None*")) { - Mmsg(temp, " SD Secure Erase Cmd: %s\n", jcr->SDSecureEraseCmd); + if (!bstrcmp(jcr->impl_->SDSecureEraseCmd, "*None*")) { + Mmsg(temp, " SD Secure Erase Cmd: %s\n", jcr->impl_->SDSecureEraseCmd); PmStrcat(secure_erase_status, temp.c_str()); } } @@ -1180,14 +1196,14 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty " Termination: %s\n\n"), BAREOS, my_name, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER, - jcr->jr.JobId, - jcr->jr.Job, + jcr->impl_->jr.JobId, + jcr->impl_->jr.Job, level_info.c_str(), - jcr->res.client->resource_name_, cr->Uname, - jcr->res.fileset->resource_name_, jcr->FSCreateTime, - jcr->res.pool->resource_name_, jcr->res.pool_source, - jcr->res.catalog->resource_name_, jcr->res.catalog_source, - jcr->res.write_storage->resource_name_, jcr->res.wstore_source, + jcr->impl_->res.client->resource_name_, cr->Uname, + jcr->impl_->res.fileset->resource_name_, jcr->impl_->FSCreateTime, + jcr->impl_->res.pool->resource_name_, jcr->impl_->res.pool_source, + jcr->impl_->res.catalog->resource_name_, jcr->impl_->res.catalog_source, + jcr->impl_->res.write_storage->resource_name_, jcr->impl_->res.wstore_source, schedt, sdt, edt, diff --git a/core/src/dird/bsr.cc b/core/src/dird/bsr.cc index 3f609711065..de15c7721ed 100644 --- a/core/src/dird/bsr.cc +++ b/core/src/dird/bsr.cc @@ -31,6 +31,7 @@ #include "include/bareos.h" #include "dird.h" #include "dird/dird_globals.h" +#include "dird/jcr_private.h" #include "dird/ua_input.h" #include "dird/ua_restore.h" #include "dird/ua_server.h" @@ -252,13 +253,13 @@ static void MakeUniqueRestoreFilename(UaContext* ua, PoolMem& fname) int i = FindArgWithValue(ua, "bootstrap"); if (i >= 0) { Mmsg(fname, "%s", ua->argv[i]); - jcr->unlink_bsr = false; + jcr->impl_->unlink_bsr = false; } else { P(mutex); uniq++; V(mutex); Mmsg(fname, "%s/%s.restore.%u.bsr", working_directory, my_name, uniq); - jcr->unlink_bsr = true; + jcr->impl_->unlink_bsr = true; } if (jcr->RestoreBootstrap) { free(jcr->RestoreBootstrap); } jcr->RestoreBootstrap = strdup(fname.c_str()); @@ -602,7 +603,7 @@ bool OpenBootstrapFile(JobControlRecord* jcr, bootstrap_info& info) info.ua = NULL; if (!jcr->RestoreBootstrap) { return false; } - bstrncpy(info.storage, jcr->res.read_storage->resource_name_, + bstrncpy(info.storage, jcr->impl_->res.read_storage->resource_name_, MAX_NAME_LENGTH); bs = fopen(jcr->RestoreBootstrap, "rb"); @@ -642,7 +643,7 @@ static inline bool IsOnSameStorage(JobControlRecord* jcr, char* new_one) /* * With old FD, we send the whole bootstrap to the storage */ - if (jcr->FDVersion < FD_VERSION_2) { return true; } + if (jcr->impl_->FDVersion < FD_VERSION_2) { return true; } /* * We are in init loop ? shoudn't fail here @@ -652,7 +653,9 @@ static inline bool IsOnSameStorage(JobControlRecord* jcr, char* new_one) /* * Same name */ - if (bstrcmp(new_one, jcr->res.read_storage->resource_name_)) { return true; } + if (bstrcmp(new_one, jcr->impl_->res.read_storage->resource_name_)) { + return true; + } new_store = (StorageResource*)my_config->GetResWithName(R_STORAGE, new_one); if (!new_store) { @@ -665,8 +668,8 @@ static inline bool IsOnSameStorage(JobControlRecord* jcr, char* new_one) * If Port and Hostname/IP are same, we are talking to the same * Storage Daemon */ - if (jcr->res.read_storage->SDport != new_store->SDport || - !bstrcmp(jcr->res.read_storage->address, new_store->address)) { + if (jcr->impl_->res.read_storage->SDport != new_store->SDport || + !bstrcmp(jcr->impl_->res.read_storage->address, new_store->address)) { return false; } diff --git a/core/src/dird/catreq.cc b/core/src/dird/catreq.cc index 7a9d7c93b5c..114aa1f272b 100644 --- a/core/src/dird/catreq.cc +++ b/core/src/dird/catreq.cc @@ -37,6 +37,7 @@ #include "include/bareos.h" #include "dird.h" #include "dird/next_vol.h" +#include "dird/jcr_private.h" #include "dird/sd_cmds.h" #include "findlib/find.h" #include "lib/berrno.h" @@ -88,7 +89,7 @@ static int SendVolumeInfoToStorageDaemon(JobControlRecord* jcr, int status; char ed1[50], ed2[50], ed3[50], ed4[50], ed5[50], ed6[50]; - jcr->MediaId = mr->MediaId; + jcr->impl_->MediaId = mr->MediaId; PmStrcpy(jcr->VolumeName, mr->VolumeName); BashSpaces(mr->VolumeName); status = sd->fsend( @@ -145,7 +146,7 @@ void CatalogRequest(JobControlRecord* jcr, BareosSocket* bs) ok = jcr->db->GetPoolRecord(jcr, &pr); if (ok) { mr.PoolId = pr.PoolId; - SetStorageidInMr(jcr->res.write_storage, &mr); + SetStorageidInMr(jcr->impl_->res.write_storage, &mr); mr.ScratchPoolId = pr.ScratchPoolId; ok = FindNextVolumeForAppend(jcr, &mr, index, unwanted_volumes.c_str(), fnv_create_vol, fnv_prune); @@ -186,9 +187,10 @@ void CatalogRequest(JobControlRecord* jcr, BareosSocket* bs) * Pool matches, and it is either Append or Recycle * and Media Type matches and Pool allows any volume. */ - if (mr.PoolId != jcr->jr.PoolId) { + if (mr.PoolId != jcr->impl_->jr.PoolId) { reason = _("not in Pool"); - } else if (!bstrcmp(mr.MediaType, jcr->res.write_storage->media_type)) { + } else if (!bstrcmp(mr.MediaType, + jcr->impl_->res.write_storage->media_type)) { reason = _("not correct MediaType"); } else { /* @@ -295,13 +297,13 @@ void CatalogRequest(JobControlRecord* jcr, BareosSocket* bs) * However, do so only if we are writing the tape, i.e. * the number of VolWrites has increased. */ - if (jcr->res.write_storage && sdmr.VolWrites > mr.VolWrites) { + if (jcr->impl_->res.write_storage && sdmr.VolWrites > mr.VolWrites) { Dmsg2(050, "Update StorageId old=%d new=%d\n", mr.StorageId, - jcr->res.write_storage->StorageId); + jcr->impl_->res.write_storage->StorageId); /* * Update StorageId after write */ - SetStorageidInMr(jcr->res.write_storage, &mr); + SetStorageidInMr(jcr->impl_->res.write_storage, &mr); } else { /* * Nothing written, reset same StorageId @@ -354,8 +356,8 @@ void CatalogRequest(JobControlRecord* jcr, BareosSocket* bs) /* * Request to create a JobMedia record */ - if (jcr->mig_jcr) { - jm.JobId = jcr->mig_jcr->JobId; + if (jcr->impl_->mig_jcr) { + jm.JobId = jcr->impl_->mig_jcr->JobId; } else { jm.JobId = jcr->JobId; } @@ -466,7 +468,8 @@ static void UpdateAttribute(JobControlRecord* jcr, Dmsg5(400, "UpdCat VolSessId=%d VolSessT=%d FI=%d Strm=%d reclen=%d\n", VolSessionId, VolSessionTime, FileIndex, Stream, reclen); - jcr->SDJobBytes += reclen; /* update number of bytes transferred for quotas */ + jcr->impl_->SDJobBytes += + reclen; /* update number of bytes transferred for quotas */ /* * Depending on the stream we are handling dispatch. @@ -522,8 +525,8 @@ static void UpdateAttribute(JobControlRecord* jcr, } ar->Stream = Stream; ar->link = NULL; - if (jcr->mig_jcr) { - ar->JobId = jcr->mig_jcr->JobId; + if (jcr->impl_->mig_jcr) { + ar->JobId = jcr->impl_->mig_jcr->JobId; } else { ar->JobId = jcr->JobId; } @@ -549,8 +552,8 @@ static void UpdateAttribute(JobControlRecord* jcr, ro.Stream = Stream; ro.FileIndex = FileIndex; - if (jcr->mig_jcr) { - ro.JobId = jcr->mig_jcr->JobId; + if (jcr->impl_->mig_jcr) { + ro.JobId = jcr->impl_->mig_jcr->JobId; } else { ro.JobId = jcr->JobId; } @@ -676,7 +679,9 @@ static void UpdateAttribute(JobControlRecord* jcr, */ void CatalogUpdate(JobControlRecord* jcr, BareosSocket* bs) { - if (!jcr->res.pool->catalog_files) { return; /* user disabled cataloging */ } + if (!jcr->impl_->res.pool->catalog_files) { + return; /* user disabled cataloging */ + } if (jcr->IsJobCanceled()) { goto bail_out; } @@ -712,7 +717,8 @@ bool DespoolAttributesFromFile(JobControlRecord* jcr, const char* file) Dmsg0(100, "Begin DespoolAttributesFromFile\n"); - if (jcr->IsJobCanceled() || !jcr->res.pool->catalog_files || !jcr->db) { + if (jcr->IsJobCanceled() || !jcr->impl_->res.pool->catalog_files || + !jcr->db) { goto bail_out; /* user disabled cataloging */ } diff --git a/core/src/dird/consolidate.cc b/core/src/dird/consolidate.cc index 12589fa97c8..d73d90d865f 100644 --- a/core/src/dird/consolidate.cc +++ b/core/src/dird/consolidate.cc @@ -33,6 +33,7 @@ #include "include/bareos.h" #include "dird.h" #include "dird/consolidate.h" +#include "dird/jcr_private.h" #include "dird/job.h" #include "dird/storage.h" #include "dird/ua_input.h" @@ -55,7 +56,7 @@ bool DoConsolidateInit(JobControlRecord* jcr) /** * Start a Virtual(Full) Job that creates a new virtual backup - * containing the jobids given in jcr->vf_jobids + * containing the jobids given in jcr->impl_->vf_jobids */ static inline void StartNewConsolidationJob(JobControlRecord* jcr, char* jobname) @@ -67,7 +68,7 @@ static inline void StartNewConsolidationJob(JobControlRecord* jcr, ua = new_ua_context(jcr); ua->batch = true; Mmsg(ua->cmd, "run job=\"%s\" jobid=%s level=VirtualFull %s", jobname, - jcr->vf_jobids, jcr->accurate ? "accurate=yes" : "accurate=no"); + jcr->impl_->vf_jobids, jcr->accurate ? "accurate=yes" : "accurate=no"); Dmsg1(debuglevel, "=============== consolidate cmd=%s\n", ua->cmd); ParseUaArgs(ua); /* parse command */ @@ -101,15 +102,15 @@ bool DoConsolidate(JobControlRecord* jcr) int32_t fullconsolidations_started = 0; int32_t max_full_consolidations = 0; - tmpjob = jcr->res.job; /* Memorize job */ + tmpjob = jcr->impl_->res.job; /* Memorize job */ /* * Get Value for MaxFullConsolidations from Consolidation job */ - max_full_consolidations = jcr->res.job->MaxFullConsolidations; + max_full_consolidations = jcr->impl_->res.job->MaxFullConsolidations; - jcr->jr.JobId = jcr->JobId; - jcr->fname = (char*)GetPoolMemory(PM_FNAME); + jcr->impl_->jr.JobId = jcr->JobId; + jcr->impl_->fname = (char*)GetPoolMemory(PM_FNAME); /* * Print Job Start message @@ -132,12 +133,12 @@ bool DoConsolidate(JobControlRecord* jcr) /* * Fake always incremental job as job of current jcr. */ - jcr->res.job = job; - jcr->res.fileset = job->fileset; - jcr->res.client = job->client; - jcr->jr.JobLevel = L_INCREMENTAL; - jcr->jr.limit = 0; - jcr->jr.StartTime = 0; + jcr->impl_->res.job = job; + jcr->impl_->res.fileset = job->fileset; + jcr->impl_->res.client = job->client; + jcr->impl_->jr.JobLevel = L_INCREMENTAL; + jcr->impl_->jr.limit = 0; + jcr->impl_->jr.StartTime = 0; if (!GetOrCreateFilesetRecord(jcr)) { Jmsg(jcr, M_FATAL, 0, _("JobId=%d no FileSet\n"), (int)jcr->JobId); @@ -154,7 +155,7 @@ bool DoConsolidate(JobControlRecord* jcr) /* * First determine the number of total incrementals */ - jcr->db->AccurateGetJobids(jcr, &jcr->jr, &jobids_ctx); + jcr->db->AccurateGetJobids(jcr, &jcr->impl_->jr, &jobids_ctx); incrementals_total = jobids_ctx.count - 1; Dmsg1(10, "unlimited jobids list: %s.\n", jobids_ctx.list); @@ -166,18 +167,19 @@ bool DoConsolidate(JobControlRecord* jcr) if (job->AlwaysIncrementalJobRetention) { char sdt[50]; - jcr->jr.StartTime = now - job->AlwaysIncrementalJobRetention; - bstrftimes(sdt, sizeof(sdt), jcr->jr.StartTime); + jcr->impl_->jr.StartTime = now - job->AlwaysIncrementalJobRetention; + bstrftimes(sdt, sizeof(sdt), jcr->impl_->jr.StartTime); Jmsg(jcr, M_INFO, 0, _("%s: considering jobs older than %s for consolidation.\n"), job->resource_name_, sdt); Dmsg4(10, _("%s: considering jobs with ClientId %d and FilesetId %d older " "than %s for consolidation.\n"), - job->resource_name_, jcr->jr.ClientId, jcr->jr.FileSetId, sdt); + job->resource_name_, jcr->impl_->jr.ClientId, + jcr->impl_->jr.FileSetId, sdt); } - jcr->db->AccurateGetJobids(jcr, &jcr->jr, &jobids_ctx); + jcr->db->AccurateGetJobids(jcr, &jcr->impl_->jr, &jobids_ctx); Dmsg1(10, "consolidate candidates: %s.\n", jobids_ctx.list); /** @@ -201,12 +203,12 @@ bool DoConsolidate(JobControlRecord* jcr) Dmsg2(10, "Incrementals found/required. (%d/%d).\n", incrementals_total, job->AlwaysIncrementalKeepNumber); if ((max_incrementals_to_consolidate + 1) > 1) { - jcr->jr.limit = max_incrementals_to_consolidate + 1; + jcr->impl_->jr.limit = max_incrementals_to_consolidate + 1; Dmsg3(10, "total: %d, to_consolidate: %d, limit: %d.\n", incrementals_total, max_incrementals_to_consolidate, - jcr->jr.limit); + jcr->impl_->jr.limit); jobids_ctx.reset(); - jcr->db->AccurateGetJobids(jcr, &jcr->jr, &jobids_ctx); + jcr->db->AccurateGetJobids(jcr, &jcr->impl_->jr, &jobids_ctx); incrementals_to_consolidate = jobids_ctx.count - 1; Dmsg2(10, "%d consolidate ids after limit: %s.\n", jobids_ctx.count, jobids_ctx.list); @@ -255,18 +257,18 @@ bool DoConsolidate(JobControlRecord* jcr) /** * Get db record of oldest jobid and check its age */ - jcr->previous_jr = JobDbRecord{}; - jcr->previous_jr.JobId = str_to_int64(jobids); + jcr->impl_->previous_jr = JobDbRecord{}; + jcr->impl_->previous_jr.JobId = str_to_int64(jobids); Dmsg1(10, "Previous JobId=%s\n", jobids); - if (!jcr->db->GetJobRecord(jcr, &jcr->previous_jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->previous_jr)) { Jmsg(jcr, M_FATAL, 0, _("Error getting Job record for first Job: ERR=%s"), jcr->db->strerror()); goto bail_out; } - starttime = jcr->previous_jr.JobTDate; + starttime = jcr->impl_->previous_jr.JobTDate; oldest_allowed_starttime = now - job->AlwaysIncrementalMaxFullAge; bstrftimes(sdt_allowed, sizeof(sdt_allowed), oldest_allowed_starttime); bstrftimes(sdt_starttime, sizeof(sdt_starttime), starttime); @@ -308,8 +310,10 @@ bool DoConsolidate(JobControlRecord* jcr) /** * Set the virtualfull jobids to be consolidated */ - if (!jcr->vf_jobids) { jcr->vf_jobids = GetPoolMemory(PM_MESSAGE); } - PmStrcpy(jcr->vf_jobids, p); + if (!jcr->impl_->vf_jobids) { + jcr->impl_->vf_jobids = GetPoolMemory(PM_MESSAGE); + } + PmStrcpy(jcr->impl_->vf_jobids, p); Jmsg(jcr, M_INFO, 0, _("%s: Start new consolidation\n"), job->resource_name_); @@ -321,7 +325,7 @@ bool DoConsolidate(JobControlRecord* jcr) /** * Restore original job back to jcr. */ - jcr->res.job = tmpjob; + jcr->impl_->res.job = tmpjob; jcr->setJobStatus(JS_Terminated); ConsolidateCleanup(jcr, JS_Terminated); @@ -344,7 +348,7 @@ void ConsolidateCleanup(JobControlRecord* jcr, int TermCode) UpdateJobEnd(jcr, TermCode); - if (!jcr->db->GetJobRecord(jcr, &jcr->jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Job record for Job report: ERR=%s"), jcr->db->strerror()); @@ -369,9 +373,9 @@ void ConsolidateCleanup(JobControlRecord* jcr, int TermCode) sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus); break; } - bstrftimes(schedt, sizeof(schedt), jcr->jr.SchedTime); - bstrftimes(sdt, sizeof(sdt), jcr->jr.StartTime); - bstrftimes(edt, sizeof(edt), jcr->jr.EndTime); + bstrftimes(schedt, sizeof(schedt), jcr->impl_->jr.SchedTime); + bstrftimes(sdt, sizeof(sdt), jcr->impl_->jr.StartTime); + bstrftimes(edt, sizeof(edt), jcr->impl_->jr.EndTime); Jmsg(jcr, msg_type, 0, _("BAREOS " VERSION " (" LSMDATE "): %s\n" @@ -382,8 +386,8 @@ void ConsolidateCleanup(JobControlRecord* jcr, int TermCode) " End time: %s\n" " Bareos binary info: %s\n" " Termination: %s\n\n"), - edt, jcr->jr.JobId, jcr->jr.Job, schedt, sdt, edt, BAREOS_JOBLOG_MESSAGE, - TermMsg); + edt, jcr->impl_->jr.JobId, jcr->impl_->jr.Job, schedt, sdt, edt, + BAREOS_JOBLOG_MESSAGE, TermMsg); Dmsg0(debuglevel, "Leave ConsolidateCleanup()\n"); } diff --git a/core/src/dird/dir_plugins.cc b/core/src/dird/dir_plugins.cc index a73106ed73c..cd3cad29b98 100644 --- a/core/src/dird/dir_plugins.cc +++ b/core/src/dird/dir_plugins.cc @@ -29,6 +29,7 @@ #include "include/bareos.h" #include "dird.h" #include "dird/dird_globals.h" +#include "dird/jcr_private.h" #include "dir_plugins.h" #include "lib/edit.h" @@ -403,7 +404,7 @@ static inline bpContext* instantiate_plugin(JobControlRecord* jcr, /** * Send a bDirEventNewPluginOptions event to all plugins configured in - * jcr->res.Job.DirPluginOptions + * jcr->impl_->res.Job.DirPluginOptions */ void DispatchNewPluginOptions(JobControlRecord* jcr) { @@ -419,12 +420,13 @@ void DispatchNewPluginOptions(JobControlRecord* jcr) if (!dird_plugin_list || dird_plugin_list->empty()) { return; } - if (jcr->res.job && jcr->res.job->DirPluginOptions && - jcr->res.job->DirPluginOptions->size()) { + if (jcr->impl_->res.job && jcr->impl_->res.job->DirPluginOptions && + jcr->impl_->res.job->DirPluginOptions->size()) { eventType = bDirEventNewPluginOptions; event.eventType = eventType; - foreach_alist_index (i, plugin_options, jcr->res.job->DirPluginOptions) { + foreach_alist_index (i, plugin_options, + jcr->impl_->res.job->DirPluginOptions) { /* * Make a private copy of plugin options. */ @@ -589,7 +591,7 @@ static bRC bareosGetValue(bpContext* ctx, brDirVariable var, void* value) NPRT(*((char**)value))); break; case bDirVarJob: - *((char**)value) = jcr->res.job->resource_name_; + *((char**)value) = jcr->impl_->res.job->resource_name_; Dmsg1(debuglevel, "dir-plugin: return bDirVarJob=%s\n", NPRT(*((char**)value))); break; @@ -604,29 +606,30 @@ static bRC bareosGetValue(bpContext* ctx, brDirVariable var, void* value) jcr->getJobType()); break; case bDirVarClient: - *((char**)value) = jcr->res.client->resource_name_; + *((char**)value) = jcr->impl_->res.client->resource_name_; Dmsg1(debuglevel, "dir-plugin: return bDirVarClient=%s\n", NPRT(*((char**)value))); break; case bDirVarNumVols: { PoolDbRecord pr; - bstrncpy(pr.Name, jcr->res.pool->resource_name_, sizeof(pr.Name)); + bstrncpy(pr.Name, jcr->impl_->res.pool->resource_name_, + sizeof(pr.Name)); if (!jcr->db->GetPoolRecord(jcr, &pr)) { retval = bRC_Error; } *((int*)value) = pr.NumVols; Dmsg1(debuglevel, "dir-plugin: return bDirVarNumVols=%d\n", pr.NumVols); break; } case bDirVarPool: - *((char**)value) = jcr->res.pool->resource_name_; + *((char**)value) = jcr->impl_->res.pool->resource_name_; Dmsg1(debuglevel, "dir-plugin: return bDirVarPool=%s\n", NPRT(*((char**)value))); break; case bDirVarStorage: - if (jcr->res.write_storage) { - *((char**)value) = jcr->res.write_storage->resource_name_; - } else if (jcr->res.read_storage) { - *((char**)value) = jcr->res.read_storage->resource_name_; + if (jcr->impl_->res.write_storage) { + *((char**)value) = jcr->impl_->res.write_storage->resource_name_; + } else if (jcr->impl_->res.read_storage) { + *((char**)value) = jcr->impl_->res.read_storage->resource_name_; } else { *((char**)value) = NULL; retval = bRC_Error; @@ -635,8 +638,8 @@ static bRC bareosGetValue(bpContext* ctx, brDirVariable var, void* value) NPRT(*((char**)value))); break; case bDirVarWriteStorage: - if (jcr->res.write_storage) { - *((char**)value) = jcr->res.write_storage->resource_name_; + if (jcr->impl_->res.write_storage) { + *((char**)value) = jcr->impl_->res.write_storage->resource_name_; } else { *((char**)value) = NULL; retval = bRC_Error; @@ -645,8 +648,8 @@ static bRC bareosGetValue(bpContext* ctx, brDirVariable var, void* value) NPRT(*((char**)value))); break; case bDirVarReadStorage: - if (jcr->res.read_storage) { - *((char**)value) = jcr->res.read_storage->resource_name_; + if (jcr->impl_->res.read_storage) { + *((char**)value) = jcr->impl_->res.read_storage->resource_name_; } else { *((char**)value) = NULL; retval = bRC_Error; @@ -655,15 +658,15 @@ static bRC bareosGetValue(bpContext* ctx, brDirVariable var, void* value) NPRT(*((char**)value))); break; case bDirVarCatalog: - *((char**)value) = jcr->res.catalog->resource_name_; + *((char**)value) = jcr->impl_->res.catalog->resource_name_; Dmsg1(debuglevel, "dir-plugin: return bDirVarCatalog=%s\n", NPRT(*((char**)value))); break; case bDirVarMediaType: - if (jcr->res.write_storage) { - *((char**)value) = jcr->res.write_storage->media_type; - } else if (jcr->res.read_storage) { - *((char**)value) = jcr->res.read_storage->media_type; + if (jcr->impl_->res.write_storage) { + *((char**)value) = jcr->impl_->res.write_storage->media_type; + } else if (jcr->impl_->res.read_storage) { + *((char**)value) = jcr->impl_->res.read_storage->media_type; } else { *((char**)value) = NULL; retval = bRC_Error; @@ -700,24 +703,24 @@ static bRC bareosGetValue(bpContext* ctx, brDirVariable var, void* value) jcr->JobFiles); break; case bDirVarSDJobFiles: - *((int*)value) = jcr->SDJobFiles; + *((int*)value) = jcr->impl_->SDJobFiles; Dmsg1(debuglevel, "dir-plugin: return bDirVarSDFiles=%d\n", - jcr->SDJobFiles); + jcr->impl_->SDJobFiles); break; case bDirVarSDErrors: - *((int*)value) = jcr->SDErrors; + *((int*)value) = jcr->impl_->SDErrors; Dmsg1(debuglevel, "dir-plugin: return bDirVarSDErrors=%d\n", - jcr->SDErrors); + jcr->impl_->SDErrors); break; case bDirVarFDJobStatus: - *((int*)value) = jcr->FDJobStatus; + *((int*)value) = jcr->impl_->FDJobStatus; Dmsg1(debuglevel, "dir-plugin: return bDirVarFDJobStatus=%c\n", - jcr->FDJobStatus); + jcr->impl_->FDJobStatus); break; case bDirVarSDJobStatus: - *((int*)value) = jcr->SDJobStatus; + *((int*)value) = jcr->impl_->SDJobStatus; Dmsg1(debuglevel, "dir-plugin: return bDirVarSDJobStatus=%c\n", - jcr->SDJobStatus); + jcr->impl_->SDJobStatus); break; case bDirVarLastRate: *((int*)value) = jcr->LastRate; diff --git a/core/src/dird/dird_conf.cc b/core/src/dird/dird_conf.cc index 426a9b860bb..d4191f0d961 100644 --- a/core/src/dird/dird_conf.cc +++ b/core/src/dird/dird_conf.cc @@ -51,6 +51,7 @@ #include "dird.h" #include "dird/inc_conf.h" #include "dird/dird_globals.h" +#include "dird/jcr_private.h" #include "lib/berrno.h" #include "lib/breg.h" #include "lib/tls_conf.h" @@ -3301,23 +3302,25 @@ extern "C" char* job_code_callback_director(JobControlRecord* jcr, switch (param[0]) { case 'f': - if (jcr->res.fileset) { return jcr->res.fileset->resource_name_; } + if (jcr->impl_->res.fileset) { + return jcr->impl_->res.fileset->resource_name_; + } break; case 'h': - if (jcr->res.client) { return jcr->res.client->address; } + if (jcr->impl_->res.client) { return jcr->impl_->res.client->address; } break; case 'p': - if (jcr->res.pool) { return jcr->res.pool->resource_name_; } + if (jcr->impl_->res.pool) { return jcr->impl_->res.pool->resource_name_; } break; case 'w': - if (jcr->res.write_storage) { - return jcr->res.write_storage->resource_name_; + if (jcr->impl_->res.write_storage) { + return jcr->impl_->res.write_storage->resource_name_; } break; case 'x': - return jcr->spool_data ? yes : no; + return jcr->impl_->spool_data ? yes : no; case 'C': - return jcr->cloned ? yes : no; + return jcr->impl_->cloned ? yes : no; case 'D': return my_name; case 'V': @@ -3326,7 +3329,7 @@ extern "C" char* job_code_callback_director(JobControlRecord* jcr, * If this is a migration/copy we need the volume name from the * mig_jcr. */ - if (jcr->mig_jcr) { jcr = jcr->mig_jcr; } + if (jcr->impl_->mig_jcr) { jcr = jcr->impl_->mig_jcr; } if (jcr->VolumeName) { return jcr->VolumeName; diff --git a/core/src/dird/expand.cc b/core/src/dird/expand.cc index 93ca3a598e4..95e4095cad8 100644 --- a/core/src/dird/expand.cc +++ b/core/src/dird/expand.cc @@ -32,6 +32,7 @@ #include "include/bareos.h" #include "dird.h" #include "dird/dird_globals.h" +#include "dird/jcr_private.h" #include "lib/parse_conf.h" #include "lib/util.h" #include "lib/output_formatter.h" @@ -93,7 +94,7 @@ static int job_item(JobControlRecord* jcr, switch (code) { case 1: /* Job */ - str = jcr->res.job->resource_name_; + str = jcr->impl_->res.job->resource_name_; break; case 2: /* Director's name */ str = my_name; @@ -109,31 +110,31 @@ static int job_item(JobControlRecord* jcr, str = buf; break; case 6: /* Client */ - str = jcr->res.client->resource_name_; + str = jcr->impl_->res.client->resource_name_; if (!str) { str = " "; } break; case 7: /* NumVols */ - Bsnprintf(buf, sizeof(buf), "%d", jcr->NumVols); + Bsnprintf(buf, sizeof(buf), "%d", jcr->impl_->NumVols); str = buf; break; case 8: /* Pool */ - str = jcr->res.pool->resource_name_; + str = jcr->impl_->res.pool->resource_name_; break; case 9: /* Storage */ - if (jcr->res.write_storage) { - str = jcr->res.write_storage->resource_name_; + if (jcr->impl_->res.write_storage) { + str = jcr->impl_->res.write_storage->resource_name_; } else { - str = jcr->res.read_storage->resource_name_; + str = jcr->impl_->res.read_storage->resource_name_; } break; case 10: /* Catalog */ - str = jcr->res.catalog->resource_name_; + str = jcr->impl_->res.catalog->resource_name_; break; case 11: /* MediaType */ - if (jcr->res.write_storage) { - str = jcr->res.write_storage->media_type; + if (jcr->impl_->res.write_storage) { + str = jcr->impl_->res.write_storage->media_type; } else { - str = jcr->res.read_storage->media_type; + str = jcr->impl_->res.read_storage->media_type; } break; case 12: /* JobName */ diff --git a/core/src/dird/fd_cmds.cc b/core/src/dird/fd_cmds.cc index fff6cf20b96..d3047d80a7a 100644 --- a/core/src/dird/fd_cmds.cc +++ b/core/src/dird/fd_cmds.cc @@ -37,10 +37,12 @@ #include "include/bareos.h" #include "dird.h" #include "dird/dird_globals.h" +#include "dird/jcr_private.h" #include "findlib/find.h" #include "dird/authenticate.h" #include "dird/fd_cmds.h" #include "dird/getmsg.h" +#include "dird/jcr_private.h" #include "dird/msgchan.h" #include "lib/berrno.h" #include "lib/bsock_tcp.h" @@ -123,22 +125,22 @@ static bool connect_outbound_to_file_daemon(JobControlRecord* jcr, if (!IsConnectingToClientAllowed(jcr)) { Dmsg1(120, "connecting to client \"%s\" is not allowed.\n", - jcr->res.client->resource_name_); + jcr->impl_->res.client->resource_name_); return false; } fd = new BareosSocketTCP; if (me->nokeepalive) { fd->ClearKeepalive(); } - heart_beat = get_heartbeat_interval(jcr->res.client); + heart_beat = get_heartbeat_interval(jcr->impl_->res.client); char name[MAX_NAME_LENGTH + 100]; bstrncpy(name, _("Client: "), sizeof(name)); - bstrncat(name, jcr->res.client->resource_name_, sizeof(name)); + bstrncat(name, jcr->impl_->res.client->resource_name_, sizeof(name)); fd->SetSourceAddress(me->DIRsrc_addr); if (!fd->connect(jcr, retry_interval, max_retry_time, heart_beat, name, - jcr->res.client->address, NULL, jcr->res.client->FDport, - verbose)) { + jcr->impl_->res.client->address, NULL, + jcr->impl_->res.client->FDport, verbose)) { delete fd; fd = NULL; jcr->setJobStatus(JS_ErrorTerminated); @@ -156,9 +158,9 @@ static void OutputMessageForConnectionTry(JobControlRecord* jcr, UaContext* ua) { std::string m; - if (jcr->res.client->connection_successful_handshake_ == + if (jcr->impl_->res.client->connection_successful_handshake_ == ClientConnectionHandshakeMode::kUndefined || - jcr->res.client->connection_successful_handshake_ == + jcr->impl_->res.client->connection_successful_handshake_ == ClientConnectionHandshakeMode::kFailed) { m = "Probing client protocol... (result will be saved until config reload)"; } else { @@ -186,12 +188,12 @@ static void SendInfoChosenCipher(JobControlRecord* jcr, UaContext* ua) static void SendInfoSuccess(JobControlRecord* jcr, UaContext* ua) { std::string m; - if (jcr->res.client->connection_successful_handshake_ == + if (jcr->impl_->res.client->connection_successful_handshake_ == ClientConnectionHandshakeMode::kUndefined) { m += "\r\v"; } bool add_newline_in_joblog = false; - switch (jcr->connection_handshake_try_) { + switch (jcr->impl_->connection_handshake_try_) { case ClientConnectionHandshakeMode::kTlsFirst: m += " Handshake: Immediate TLS,"; break; @@ -232,21 +234,22 @@ bool ConnectToFileDaemon(JobControlRecord* jcr, * in case there is a client that cannot do Tls immediately then * fall back to cleartext md5-handshake */ OutputMessageForConnectionTry(jcr, ua); - if (jcr->res.client->connection_successful_handshake_ == + if (jcr->impl_->res.client->connection_successful_handshake_ == ClientConnectionHandshakeMode::kUndefined || - jcr->res.client->connection_successful_handshake_ == + jcr->impl_->res.client->connection_successful_handshake_ == ClientConnectionHandshakeMode::kFailed) { - if (jcr->res.client->IsTlsConfigured()) { - jcr->connection_handshake_try_ = ClientConnectionHandshakeMode::kTlsFirst; + if (jcr->impl_->res.client->IsTlsConfigured()) { + jcr->impl_->connection_handshake_try_ = + ClientConnectionHandshakeMode::kTlsFirst; } else { - jcr->connection_handshake_try_ = + jcr->impl_->connection_handshake_try_ = ClientConnectionHandshakeMode::kCleartextFirst; } jcr->is_passive_client_connection_probing = true; } else { /* if there is a stored mode from a previous connection then use this */ - jcr->connection_handshake_try_ = - jcr->res.client->connection_successful_handshake_; + jcr->impl_->connection_handshake_try_ = + jcr->impl_->res.client->connection_successful_handshake_; jcr->is_passive_client_connection_probing = false; } @@ -272,14 +275,14 @@ bool ConnectToFileDaemon(JobControlRecord* jcr, SendInfoSuccess(jcr, ua); SendInfoChosenCipher(jcr, ua); jcr->is_passive_client_connection_probing = false; - jcr->res.client->connection_successful_handshake_ = - jcr->connection_handshake_try_; + jcr->impl_->res.client->connection_successful_handshake_ = + jcr->impl_->connection_handshake_try_; } else { /* authentication failed due to * - tls mismatch or * - if an old client cannot do tls- before md5-handshake * */ - switch (jcr->connection_handshake_try_) { + switch (jcr->impl_->connection_handshake_try_) { case ClientConnectionHandshakeMode::kTlsFirst: if (jcr->file_bsock) { jcr->file_bsock->close(); @@ -287,11 +290,11 @@ bool ConnectToFileDaemon(JobControlRecord* jcr, jcr->file_bsock = nullptr; } jcr->resetJobStatus(JS_Running); - jcr->connection_handshake_try_ = + jcr->impl_->connection_handshake_try_ = ClientConnectionHandshakeMode::kCleartextFirst; break; case ClientConnectionHandshakeMode::kCleartextFirst: - jcr->connection_handshake_try_ = + jcr->impl_->connection_handshake_try_ = ClientConnectionHandshakeMode::kFailed; break; case ClientConnectionHandshakeMode::kFailed: @@ -302,11 +305,11 @@ bool ConnectToFileDaemon(JobControlRecord* jcr, } } else { Jmsg(jcr, M_FATAL, 0, "\nFailed to connect to client \"%s\".\n", - jcr->res.client->resource_name_); + jcr->impl_->res.client->resource_name_); } connect_tries--; } while (!tcp_connect_failed && connect_tries && !success && - jcr->connection_handshake_try_ != + jcr->impl_->connection_handshake_try_ != ClientConnectionHandshakeMode::kFailed); if (!success) { jcr->setJobStatus(JS_ErrorTerminated); } @@ -320,7 +323,7 @@ int SendJobInfoToFileDaemon(JobControlRecord* jcr) if (jcr->sd_auth_key == NULL) { jcr->sd_auth_key = strdup("dummy"); } - if (jcr->res.client->connection_successful_handshake_ == + if (jcr->impl_->res.client->connection_successful_handshake_ == ClientConnectionHandshakeMode::kTlsFirst) { /* client protocol onwards Bareos 18.2 */ TlsPolicy tls_policy = kBnetTlsUnknown; @@ -333,10 +336,10 @@ int SendJobInfoToFileDaemon(JobControlRecord* jcr) break; default: StorageResource* storage = nullptr; - if (jcr->res.write_storage) { - storage = jcr->res.write_storage; - } else if (jcr->res.read_storage) { - storage = jcr->res.read_storage; + if (jcr->impl_->res.write_storage) { + storage = jcr->impl_->res.write_storage; + } else if (jcr->impl_->res.read_storage) { + storage = jcr->impl_->res.read_storage; } else { Jmsg(jcr, M_FATAL, 0, _("No read or write storage defined\n")); jcr->setJobStatus(JS_ErrorTerminated); @@ -352,16 +355,16 @@ int SendJobInfoToFileDaemon(JobControlRecord* jcr) fd->fsend(jobcmdssl, edit_int64(jcr->JobId, ed1), jcr->Job, jcr->VolSessionId, jcr->VolSessionTime, jcr->sd_auth_key, tls_policy); - } else { /* jcr->res.client->connection_successful_handshake_ != + } else { /* jcr->impl_->res.client->connection_successful_handshake_ != ClientConnectionHandshakeMode::kTlsFirst */ /* client protocol before Bareos 18.2 */ char ed1[30]; fd->fsend(jobcmd, edit_int64(jcr->JobId, ed1), jcr->Job, jcr->VolSessionId, jcr->VolSessionTime, jcr->sd_auth_key); - } /* if (jcr->res.client->connection_successful_handshake_ == + } /* if (jcr->impl_->res.client->connection_successful_handshake_ == ClientConnectionHandshakeMode::kTlsFirst) */ - if (!jcr->keep_sd_auth_key && !bstrcmp(jcr->sd_auth_key, "dummy")) { + if (!jcr->impl_->keep_sd_auth_key && !bstrcmp(jcr->sd_auth_key, "dummy")) { memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key)); } @@ -370,16 +373,17 @@ int SendJobInfoToFileDaemon(JobControlRecord* jcr) Dmsg1(110, "msg); if (!bstrncmp(fd->msg, OKjob, strlen(OKjob))) { Jmsg(jcr, M_FATAL, 0, _("File daemon \"%s\" rejected Job command: %s\n"), - jcr->res.client->resource_name_, fd->msg); + jcr->impl_->res.client->resource_name_, fd->msg); jcr->setJobStatus(JS_ErrorTerminated); return 0; } else if (jcr->db) { ClientDbRecord cr; - bstrncpy(cr.Name, jcr->res.client->resource_name_, sizeof(cr.Name)); - cr.AutoPrune = jcr->res.client->AutoPrune; - cr.FileRetention = jcr->res.client->FileRetention; - cr.JobRetention = jcr->res.client->JobRetention; + bstrncpy(cr.Name, jcr->impl_->res.client->resource_name_, + sizeof(cr.Name)); + cr.AutoPrune = jcr->impl_->res.client->AutoPrune; + cr.FileRetention = jcr->impl_->res.client->FileRetention; + cr.JobRetention = jcr->impl_->res.client->JobRetention; bstrncpy(cr.Uname, fd->msg + strlen(OKjob) + 1, sizeof(cr.Uname)); if (!jcr->db->UpdateClientRecord(jcr, &cr)) { Jmsg(jcr, M_WARNING, 0, _("Error updating Client record. ERR=%s\n"), @@ -404,8 +408,8 @@ bool SendPreviousRestoreObjects(JobControlRecord* jcr) switch (JobLevel) { case L_DIFFERENTIAL: case L_INCREMENTAL: - if (jcr->previous_jr.JobId > 0) { - if (!SendRestoreObjects(jcr, jcr->previous_jr.JobId, false)) { + if (jcr->impl_->previous_jr.JobId > 0) { + if (!SendRestoreObjects(jcr, jcr->impl_->previous_jr.JobId, false)) { return false; } } @@ -421,7 +425,7 @@ bool SendBwlimitToFd(JobControlRecord* jcr, const char* Job) { BareosSocket* fd = jcr->file_bsock; - if (jcr->FDVersion >= FD_VERSION_4) { + if (jcr->impl_->FDVersion >= FD_VERSION_4) { fd->fsend(bandwidthcmd, jcr->max_bandwidth, Job); if (!response(jcr, fd, OKBandwidth, "Bandwidth", DISPLAY_ERROR)) { jcr->max_bandwidth = 0; /* can't set bandwidth limit */ @@ -437,27 +441,29 @@ bool SendSecureEraseReqToFd(JobControlRecord* jcr) int32_t n; BareosSocket* fd = jcr->file_bsock; - if (!jcr->FDSecureEraseCmd) { - jcr->FDSecureEraseCmd = GetPoolMemory(PM_NAME); + if (!jcr->impl_->FDSecureEraseCmd) { + jcr->impl_->FDSecureEraseCmd = GetPoolMemory(PM_NAME); } - if (jcr->FDVersion > FD_VERSION_53) { + if (jcr->impl_->FDVersion > FD_VERSION_53) { fd->fsend(getSecureEraseCmd); while ((n = BgetDirmsg(fd)) >= 0) { - jcr->FDSecureEraseCmd = - CheckPoolMemorySize(jcr->FDSecureEraseCmd, fd->message_length); - if (sscanf(fd->msg, OKgetSecureEraseCmd, jcr->FDSecureEraseCmd) == 1) { - Dmsg1(400, "Got FD Secure Erase Cmd: %s\n", jcr->FDSecureEraseCmd); + jcr->impl_->FDSecureEraseCmd = + CheckPoolMemorySize(jcr->impl_->FDSecureEraseCmd, fd->message_length); + if (sscanf(fd->msg, OKgetSecureEraseCmd, jcr->impl_->FDSecureEraseCmd) == + 1) { + Dmsg1(400, "Got FD Secure Erase Cmd: %s\n", + jcr->impl_->FDSecureEraseCmd); break; } else { Jmsg(jcr, M_WARNING, 0, _("Unexpected Client Secure Erase Cmd: %s\n"), fd->msg); - PmStrcpy(jcr->FDSecureEraseCmd, "*None*"); + PmStrcpy(jcr->impl_->FDSecureEraseCmd, "*None*"); return false; } } } else { - PmStrcpy(jcr->FDSecureEraseCmd, "*None*"); + PmStrcpy(jcr->impl_->FDSecureEraseCmd, "*None*"); } return true; @@ -471,7 +477,7 @@ static void SendSinceTime(JobControlRecord* jcr) stime = StrToUtime(jcr->stime); fd->fsend(levelcmd, "", NT_("since_utime "), edit_uint64(stime, ed1), 0, - NT_("prev_job="), jcr->PrevJob); + NT_("prev_job="), jcr->impl_->PrevJob); while (BgetDirmsg(fd) >= 0) { /* allow him to poll us to sync clocks */ Jmsg(jcr, M_INFO, 0, "%s\n", fd->msg); @@ -532,9 +538,9 @@ bool SendLevelCommand(JobControlRecord* jcr) */ static bool SendFileset(JobControlRecord* jcr) { - FilesetResource* fileset = jcr->res.fileset; + FilesetResource* fileset = jcr->impl_->res.fileset; BareosSocket* fd = jcr->file_bsock; - StorageResource* store = jcr->res.write_storage; + StorageResource* store = jcr->impl_->res.write_storage; int num; bool include = true; @@ -777,8 +783,8 @@ static bool SendListItem(JobControlRecord* jcr, bool SendIncludeList(JobControlRecord* jcr) { BareosSocket* fd = jcr->file_bsock; - if (jcr->res.fileset->new_include) { - fd->fsend(filesetcmd, jcr->res.fileset->enable_vss ? " vss=1" : ""); + if (jcr->impl_->res.fileset->new_include) { + fd->fsend(filesetcmd, jcr->impl_->res.fileset->enable_vss ? " vss=1" : ""); return SendFileset(jcr); } return true; @@ -826,18 +832,18 @@ int SendRunscriptsCommands(JobControlRecord* jcr) /* * See if there are any runscripts that need to be ran on the client. */ - if (!HaveClientRunscripts(jcr->res.job->RunScripts)) { return 1; } + if (!HaveClientRunscripts(jcr->impl_->res.job->RunScripts)) { return 1; } Dmsg0(120, "dird: sending runscripts to fd\n"); msg = GetPoolMemory(PM_FNAME); ehost = GetPoolMemory(PM_FNAME); - foreach_alist (cmd, jcr->res.job->RunScripts) { + foreach_alist (cmd, jcr->impl_->res.job->RunScripts) { if (!cmd->target.empty()) { ehost = edit_job_codes(jcr, ehost, cmd->target.c_str(), ""); Dmsg2(200, "dird: runscript %s -> %s\n", cmd->target.c_str(), ehost); - if (bstrcmp(ehost, jcr->res.client->resource_name_)) { + if (bstrcmp(ehost, jcr->impl_->res.client->resource_name_)) { PmStrcpy(msg, cmd->command.c_str()); BashSpaces(msg); @@ -911,15 +917,16 @@ static int RestoreObjectHandler(void* ctx, int num_fields, char** row) /* * Old File Daemon doesn't handle restore objects */ - if (jcr->FDVersion < FD_VERSION_3) { + if (jcr->impl_->FDVersion < FD_VERSION_3) { Jmsg(jcr, M_WARNING, 0, _("Client \"%s\" may not be used to restore " "this job. Please upgrade your client.\n"), - jcr->res.client->resource_name_); + jcr->impl_->res.client->resource_name_); return 1; } - if (jcr->FDVersion < FD_VERSION_5) { /* Old version without PluginName */ + if (jcr->impl_->FDVersion < + FD_VERSION_5) { /* Old version without PluginName */ fd->fsend("restoreobject JobId=%s %s,%s,%s,%s,%s,%s\n", row[0], row[1], row[2], row[3], row[4], row[5], row[6]); } else { @@ -966,9 +973,9 @@ bool SendPluginOptions(JobControlRecord* jcr) const char* plugin_options; POOLMEM* msg; - if (jcr->plugin_options) { + if (jcr->impl_->plugin_options) { msg = GetPoolMemory(PM_FNAME); - PmStrcpy(msg, jcr->plugin_options); + PmStrcpy(msg, jcr->impl_->plugin_options); BashSpaces(msg); fd->fsend(pluginoptionscmd, msg); @@ -979,10 +986,11 @@ bool SendPluginOptions(JobControlRecord* jcr) return false; } } - if (jcr->res.job && jcr->res.job->FdPluginOptions && - jcr->res.job->FdPluginOptions->size()) { + if (jcr->impl_->res.job && jcr->impl_->res.job->FdPluginOptions && + jcr->impl_->res.job->FdPluginOptions->size()) { Dmsg2(200, "dird: sendpluginoptions found FdPluginOptions in res.job"); - foreach_alist_index (i, plugin_options, jcr->res.job->FdPluginOptions) { + foreach_alist_index (i, plugin_options, + jcr->impl_->res.job->FdPluginOptions) { PmStrcpy(cur_plugin_options, plugin_options); BashSpaces(cur_plugin_options.c_str()); @@ -1085,8 +1093,8 @@ int GetAttributesAndPutInCatalog(JobControlRecord* jcr) PoolMem digest(PM_MESSAGE); fd = jcr->file_bsock; - jcr->jr.FirstIndex = 1; - jcr->FileIndex = 0; + jcr->impl_->jr.FirstIndex = 1; + jcr->impl_->FileIndex = 0; /* * Start transaction allocates jcr->attr and jcr->ar if needed @@ -1140,14 +1148,15 @@ int GetAttributesAndPutInCatalog(JobControlRecord* jcr) /* * Any cached attr is flushed so we can reuse jcr->attr and jcr->ar */ - fn = jcr->fname = CheckPoolMemorySize(jcr->fname, fd->message_length); + fn = jcr->impl_->fname = + CheckPoolMemorySize(jcr->impl_->fname, fd->message_length); while (*p != 0) { *fn++ = *p++; /* copy filename */ } *fn = *p++; /* term filename and point p to attribs */ PmStrcpy(jcr->attr, p); /* save attributes */ jcr->JobFiles++; - jcr->FileIndex = file_index; + jcr->impl_->FileIndex = file_index; ar->attr = jcr->attr; - ar->fname = jcr->fname; + ar->fname = jcr->impl_->fname; ar->FileIndex = file_index; ar->Stream = stream; ar->link = NULL; @@ -1159,7 +1168,8 @@ int GetAttributesAndPutInCatalog(JobControlRecord* jcr) ar->DeltaSeq = 0; jcr->cached_attribute = true; - Dmsg2(debuglevel, "dirdfname); + Dmsg2(debuglevel, "dirdimpl_->fname); Dmsg1(debuglevel, "dirdattr); jcr->FileId = ar->FileId; } else if (CryptoDigestStreamType(stream) != CRYPTO_DIGEST_NONE) { @@ -1171,9 +1181,9 @@ int GetAttributesAndPutInCatalog(JobControlRecord* jcr) * it (or not) When we get a new STREAM_UNIX_ATTRIBUTES, we known that we * can add file to the catalog At the end, we have to add the last file */ - if (jcr->FileIndex != (uint32_t)file_index) { + if (jcr->impl_->FileIndex != (uint32_t)file_index) { Jmsg3(jcr, M_ERROR, 0, _("%s index %d not same as attributes %d\n"), - stream_to_ascii(stream), file_index, jcr->FileIndex); + stream_to_ascii(stream), file_index, jcr->impl_->FileIndex); continue; } @@ -1185,8 +1195,8 @@ int GetAttributesAndPutInCatalog(JobControlRecord* jcr) Dmsg4(debuglevel, "stream=%d DigestLen=%d Digest=%s type=%d\n", stream, strlen(digest.c_str()), digest.c_str(), ar->DigestType); } - jcr->jr.JobFiles = jcr->JobFiles = file_index; - jcr->jr.LastIndex = file_index; + jcr->impl_->jr.JobFiles = jcr->JobFiles = file_index; + jcr->impl_->jr.LastIndex = file_index; } if (IsBnetError(fd)) { @@ -1218,7 +1228,7 @@ bool CancelFileDaemonJob(UaContext* ua, JobControlRecord* jcr) { BareosSocket* fd; - ua->jcr->res.client = jcr->res.client; + ua->jcr->impl_->res.client = jcr->impl_->res.client; if (!ConnectToFileDaemon(ua->jcr, 10, me->FDConnectTimeout, true, ua)) { ua->ErrorMsg(_("\nFailed to connect to File daemon.\n")); return false; @@ -1246,7 +1256,7 @@ void DoNativeClientStatus(UaContext* ua, ClientResource* client, char* cmd) /* * Connect to File daemon */ - ua->jcr->res.client = client; + ua->jcr->impl_->res.client = client; /* * Try to connect for 15 seconds @@ -1295,7 +1305,7 @@ void DoClientResolve(UaContext* ua, ClientResource* client) /* * Connect to File daemon */ - ua->jcr->res.client = client; + ua->jcr->impl_->res.client = client; /* * Try to connect for 15 seconds diff --git a/core/src/dird/getmsg.cc b/core/src/dird/getmsg.cc index d5cd3506662..1887dfbd198 100644 --- a/core/src/dird/getmsg.cc +++ b/core/src/dird/getmsg.cc @@ -45,6 +45,7 @@ #include "include/bareos.h" #include "dird.h" #include "dird/catreq.h" +#include "dird/jcr_private.h" #include "dird/msgchan.h" #include "lib/bnet.h" #include "lib/edit.h" @@ -86,12 +87,12 @@ static void SetJcrSdJobStatus(JobControlRecord* jcr, int SDJobStatus) Dmsg0(800, "Setting wait_time\n"); jcr->wait_time = time(NULL); } - jcr->SDJobStatus = SDJobStatus; + jcr->impl_->SDJobStatus = SDJobStatus; /* * Some SD Job status setting are propagated to the controlling Job. */ - switch (jcr->SDJobStatus) { + switch (jcr->impl_->SDJobStatus) { case JS_Incomplete: jcr->setJobStatus(JS_Incomplete); break; diff --git a/core/src/dird/inc_conf.cc b/core/src/dird/inc_conf.cc index 36e323d533d..75f24e28932 100644 --- a/core/src/dird/inc_conf.cc +++ b/core/src/dird/inc_conf.cc @@ -32,6 +32,7 @@ #include "include/bareos.h" #include "dird.h" #include "dird/dird_globals.h" +#include "dird/jcr_private.h" #include "findlib/match.h" #include "lib/parse_conf.h" @@ -308,9 +309,9 @@ void FindUsedCompressalgos(PoolMem* compressalgos, JobControlRecord* jcr) FilesetResource* fs; struct s_fs_opt* fs_opt; - if (!jcr->res.job || !jcr->res.job->fileset) { return; } + if (!jcr->impl_->res.job || !jcr->impl_->res.job->fileset) { return; } - fs = jcr->res.job->fileset; + fs = jcr->impl_->res.job->fileset; for (std::size_t i = 0; i < fs->include_items.size(); i++) { inc = fs->include_items[i]; diff --git a/core/src/dird/jcr_private.h b/core/src/dird/jcr_private.h new file mode 100644 index 00000000000..1a8d2bb8127 --- /dev/null +++ b/core/src/dird/jcr_private.h @@ -0,0 +1,156 @@ +/* + BAREOS® - Backup Archiving REcovery Open Sourced + + Copyright (C) 2000-2012 Free Software Foundation Europe e.V. + Copyright (C) 2011-2012 Planets Communications B.V. + Copyright (C) 2013-2019 Bareos GmbH & Co. KG + + This program is Free Software; you can redistribute it and/or + modify it under the terms of version three of the GNU Affero General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#ifndef BAREOS_SRC_DIRD_JCR_PRIVATE_H_ +#define BAREOS_SRC_DIRD_JCR_PRIVATE_H_ + +namespace directordaemon { +class JobResource; +class StorageResource; +class ClientResource; +class PoolResource; +class FilesetResource; +class CatalogResource; +} // namespace directordaemon + +#define JobWaiting(jcr) \ + (jcr->job_started && \ + (jcr->JobStatus == JS_WaitFD || jcr->JobStatus == JS_WaitSD || \ + jcr->JobStatus == JS_WaitMedia || jcr->JobStatus == JS_WaitMount || \ + jcr->JobStatus == JS_WaitStoreRes || jcr->JobStatus == JS_WaitJobRes || \ + jcr->JobStatus == JS_WaitClientRes || jcr->JobStatus == JS_WaitMaxJobs || \ + jcr->JobStatus == JS_WaitPriority || \ + jcr->impl_->SDJobStatus == JS_WaitMedia || \ + jcr->impl_->SDJobStatus == JS_WaitMount || \ + jcr->impl_->SDJobStatus == JS_WaitDevice || \ + jcr->impl_->SDJobStatus == JS_WaitMaxJobs)) + +/* clang-format off */ +struct Resources { + directordaemon::JobResource* job = nullptr; /**< Job resource */ + directordaemon::JobResource* verify_job = nullptr; /**< Job resource of verify previous job */ + directordaemon::JobResource* previous_job = nullptr; /**< Job resource of migration previous job */ + directordaemon::StorageResource* read_storage = nullptr; /**< Selected read storage */ + directordaemon::StorageResource* write_storage = nullptr; /**< Selected write storage */ + directordaemon::StorageResource* paired_read_write_storage = nullptr; /*< Selected paired storage (savedwrite_storage or read_storage)*/ + directordaemon::ClientResource* client = nullptr; /**< Client resource */ + directordaemon::PoolResource* pool = nullptr; /**< Pool resource = write for migration */ + directordaemon::PoolResource* rpool = nullptr; /**< Read pool. Used only in migration */ + directordaemon::PoolResource* full_pool = nullptr; /**< Full backup pool resource */ + directordaemon::PoolResource* vfull_pool = nullptr; /**< Virtual Full backup pool resource */ + directordaemon::PoolResource* inc_pool = nullptr; /**< Incremental backup pool resource */ + directordaemon::PoolResource* diff_pool = nullptr; /**< Differential backup pool resource */ + directordaemon::PoolResource* next_pool = nullptr; /**< Next Pool used for migration/copy and virtual backup */ + directordaemon::FilesetResource* fileset = nullptr; /**< FileSet resource */ + directordaemon::CatalogResource* catalog = nullptr; /**< Catalog resource */ + MessagesResource* messages = nullptr; /**< Default message handler */ + POOLMEM* pool_source = nullptr; /**< Where pool came from */ + POOLMEM* npool_source = nullptr; /**< Where next pool came from */ + POOLMEM* rpool_source = nullptr; /**< Where migrate read pool came from */ + POOLMEM* rstore_source = nullptr; /**< Where read storage came from */ + POOLMEM* wstore_source = nullptr; /**< Where write storage came from */ + POOLMEM* catalog_source = nullptr; /**< Where catalog came from */ + alist* read_storage_list = nullptr; /**< Read storage possibilities */ + alist* write_storage_list = nullptr; /**< Write storage possibilities */ + alist* paired_read_write_storage_list = nullptr; /**< Paired storage possibilities + * (saved write_storage_list or read_storage_list) */ + bool run_pool_override = false; /**< Pool override was given on run cmdline */ + bool run_full_pool_override = false; /**< Full pool override was given on run cmdline */ + bool run_vfull_pool_override = false; /**< Virtual Full pool override was given on run cmdline */ + bool run_inc_pool_override = false; /**< Incremental pool override was given on run cmdline */ + bool run_diff_pool_override = false; /**< Differential pool override was given on run cmdline */ + bool run_next_pool_override = false; /**< Next pool override was given on run cmdline */ +}; + +struct JobControlRecordPrivate { + JobControlRecordPrivate() { + RestoreJobId = 0; MigrateJobId = 0; VerifyJobId = 0; + } + pthread_t SD_msg_chan = 0; /**< Message channel thread id */ + bool SD_msg_chan_started = false; /**< Message channel thread started */ + pthread_cond_t term_wait = PTHREAD_COND_INITIALIZER; /**< Wait for job termination */ + pthread_cond_t nextrun_ready = PTHREAD_COND_INITIALIZER; /**< Wait for job next run to become ready */ + Resources res; /**< Resources assigned */ + TREE_ROOT* restore_tree_root = nullptr; /**< Selected files to restore (some protocols need this info) */ + storagedaemon::BootStrapRecord* bsr = nullptr; /**< Bootstrap record -- has everything */ + char* backup_format = nullptr; /**< Backup format used when doing a NDMP backup */ + char* plugin_options = nullptr; /**< User set options for plugin */ + uint32_t SDJobFiles = 0; /**< Number of files written, this job */ + uint64_t SDJobBytes = 0; /**< Number of bytes processed this job */ + uint32_t SDErrors = 0; /**< Number of non-fatal errors */ + volatile int32_t SDJobStatus = 0; /**< Storage Job Status */ + volatile int32_t FDJobStatus = 0; /**< File daemon Job Status */ + uint32_t DumpLevel = 0; /**< Dump level when doing a NDMP backup */ + uint32_t ExpectedFiles = 0; /**< Expected restore files */ + uint32_t MediaId = 0; /**< DB record IDs associated with this job */ + uint32_t FileIndex = 0; /**< Last FileIndex processed */ + utime_t MaxRunSchedTime = 0; /**< Max run time in seconds from Initial Scheduled time */ + JobDbRecord jr; /**< Job DB record for current job */ + JobDbRecord previous_jr; /**< Previous job database record */ + JobControlRecord* mig_jcr = nullptr; /**< JobControlRecord for migration/copy job */ + char FSCreateTime[MAX_TIME_LENGTH]{0}; /**< FileSet CreateTime as returned from DB */ + char since[MAX_TIME_LENGTH]{0}; /**< Since time */ + char PrevJob[MAX_NAME_LENGTH]{0}; /**< Previous job name assiciated with since time */ + union { + JobId_t RestoreJobId; /**< Restore JobId specified by UA */ + JobId_t MigrateJobId; /**< Migration JobId specified by UA */ + JobId_t VerifyJobId; /**< Verify JobId specified by UA */ + }; + POOLMEM* fname = nullptr; /**< Name to put into catalog */ + POOLMEM* client_uname = nullptr; /**< Client uname */ + POOLMEM* FDSecureEraseCmd = nullptr; /**< Report: Secure Erase Command */ + POOLMEM* SDSecureEraseCmd = nullptr; /**< Report: Secure Erase Command */ + POOLMEM* vf_jobids = nullptr; /**< JobIds to use for Virtual Full */ + uint32_t replace = 0; /**< Replace option */ + int32_t NumVols = 0; /**< Number of Volume used in pool */ + int32_t reschedule_count = 0; /**< Number of times rescheduled */ + int32_t FDVersion = 0; /**< File daemon version number */ + int64_t spool_size = 0; /**< Spool size for this job */ + volatile bool sd_msg_thread_done = false; /**< Set when Storage message thread done */ + bool IgnoreDuplicateJobChecking = false; /**< Set in migration jobs */ + bool IgnoreLevelPoolOverides = false; /**< Set if a cmdline pool was specified */ + bool IgnoreClientConcurrency = false; /**< Set in migration jobs */ + bool IgnoreStorageConcurrency = false; /**< Set in migration jobs */ + bool spool_data = false; /**< Spool data in SD */ + bool acquired_resource_locks = false; /**< Set if resource locks acquired */ + bool term_wait_inited = false; /**< Set when cond var inited */ + bool nextrun_ready_inited = false; /**< Set when cond var inited */ + bool fn_printed = false; /**< Printed filename */ + bool needs_sd = false; /**< Set if SD needed by Job */ + bool cloned = false; /**< Set if cloned */ + bool unlink_bsr = false; /**< Unlink bsr file created */ + bool VSS = false; /**< VSS used by FD */ + bool Encrypt = false; /**< Encryption used by FD */ + bool no_maxtime = false; /**< Don't check Max*Time for this JobControlRecord */ + bool keep_sd_auth_key = false; /**< Clear or not the SD auth key after connection*/ + bool use_accurate_chksum = false; /**< Use or not checksum option in accurate code */ + bool sd_canceled = false; /**< Set if SD canceled */ + bool remote_replicate = false; /**< Replicate data to remote SD */ + bool HasQuota = false; /**< Client has quota limits */ + bool HasSelectedJobs = false; /**< Migration/Copy Job did actually select some JobIds */ + directordaemon::ClientConnectionHandshakeMode connection_handshake_try_ = + directordaemon::ClientConnectionHandshakeMode::kUndefined; +}; +/* clang-format on */ + +#endif // BAREOS_SRC_DIRD_JCR_PRIVATE_H_ diff --git a/core/src/dird/job.cc b/core/src/dird/job.cc index 1998d59322c..5274bdf472e 100644 --- a/core/src/dird/job.cc +++ b/core/src/dird/job.cc @@ -38,6 +38,7 @@ #include "dird/consolidate.h" #include "dird/fd_cmds.h" #include "dird/job.h" +#include "dird/jcr_private.h" #include "dird/migration.h" #include "dird/pthread_detach_if_not_detached.h" #include "dird/restore.h" @@ -145,7 +146,7 @@ bool SetupJob(JobControlRecord* jcr, bool suppress_output) * See if we should suppress all output. */ if (!suppress_output) { - InitMsg(jcr, jcr->res.messages, job_code_callback_director); + InitMsg(jcr, jcr->impl_->res.messages, job_code_callback_director); } else { jcr->suppress_output = true; } @@ -153,19 +154,19 @@ bool SetupJob(JobControlRecord* jcr, bool suppress_output) /* * Initialize termination condition variable */ - if ((errstat = pthread_cond_init(&jcr->term_wait, NULL)) != 0) { + if ((errstat = pthread_cond_init(&jcr->impl_->term_wait, NULL)) != 0) { BErrNo be; Jmsg1(jcr, M_FATAL, 0, _("Unable to init job cond variable: ERR=%s\n"), be.bstrerror(errstat)); jcr->unlock(); goto bail_out; } - jcr->term_wait_inited = true; + jcr->impl_->term_wait_inited = true; /* * Initialize nextrun ready condition variable */ - if ((errstat = pthread_cond_init(&jcr->nextrun_ready, NULL)) != 0) { + if ((errstat = pthread_cond_init(&jcr->impl_->nextrun_ready, NULL)) != 0) { BErrNo be; Jmsg1(jcr, M_FATAL, 0, _("Unable to init job nextrun cond variable: ERR=%s\n"), @@ -173,9 +174,9 @@ bool SetupJob(JobControlRecord* jcr, bool suppress_output) jcr->unlock(); goto bail_out; } - jcr->nextrun_ready_inited = true; + jcr->impl_->nextrun_ready_inited = true; - CreateUniqueJobName(jcr, jcr->res.job->resource_name_); + CreateUniqueJobName(jcr, jcr->impl_->res.job->resource_name_); jcr->setJobStatus(JS_Created); jcr->unlock(); @@ -184,34 +185,37 @@ bool SetupJob(JobControlRecord* jcr, bool suppress_output) */ Dmsg0(100, "Open database\n"); jcr->db = DbSqlGetPooledConnection( - jcr, jcr->res.catalog->db_driver, jcr->res.catalog->db_name, - jcr->res.catalog->db_user, jcr->res.catalog->db_password.value, - jcr->res.catalog->db_address, jcr->res.catalog->db_port, - jcr->res.catalog->db_socket, jcr->res.catalog->mult_db_connections, - jcr->res.catalog->disable_batch_insert, jcr->res.catalog->try_reconnect, - jcr->res.catalog->exit_on_fatal); + jcr, jcr->impl_->res.catalog->db_driver, jcr->impl_->res.catalog->db_name, + jcr->impl_->res.catalog->db_user, + jcr->impl_->res.catalog->db_password.value, + jcr->impl_->res.catalog->db_address, jcr->impl_->res.catalog->db_port, + jcr->impl_->res.catalog->db_socket, + jcr->impl_->res.catalog->mult_db_connections, + jcr->impl_->res.catalog->disable_batch_insert, + jcr->impl_->res.catalog->try_reconnect, + jcr->impl_->res.catalog->exit_on_fatal); if (jcr->db == NULL) { Jmsg(jcr, M_FATAL, 0, _("Could not open database \"%s\".\n"), - jcr->res.catalog->db_name); + jcr->impl_->res.catalog->db_name); goto bail_out; } Dmsg0(150, "DB opened\n"); - if (!jcr->fname) { jcr->fname = GetPoolMemory(PM_FNAME); } + if (!jcr->impl_->fname) { jcr->impl_->fname = GetPoolMemory(PM_FNAME); } - if (!jcr->res.pool_source) { - jcr->res.pool_source = GetPoolMemory(PM_MESSAGE); - PmStrcpy(jcr->res.pool_source, _("unknown source")); + if (!jcr->impl_->res.pool_source) { + jcr->impl_->res.pool_source = GetPoolMemory(PM_MESSAGE); + PmStrcpy(jcr->impl_->res.pool_source, _("unknown source")); } - if (!jcr->res.npool_source) { - jcr->res.npool_source = GetPoolMemory(PM_MESSAGE); - PmStrcpy(jcr->res.npool_source, _("unknown source")); + if (!jcr->impl_->res.npool_source) { + jcr->impl_->res.npool_source = GetPoolMemory(PM_MESSAGE); + PmStrcpy(jcr->impl_->res.npool_source, _("unknown source")); } if (jcr->JobReads()) { - if (!jcr->res.rpool_source) { - jcr->res.rpool_source = GetPoolMemory(PM_MESSAGE); - PmStrcpy(jcr->res.rpool_source, _("unknown source")); + if (!jcr->impl_->res.rpool_source) { + jcr->impl_->res.rpool_source = GetPoolMemory(PM_MESSAGE); + PmStrcpy(jcr->impl_->res.rpool_source, _("unknown source")); } } @@ -220,18 +224,18 @@ bool SetupJob(JobControlRecord* jcr, bool suppress_output) */ InitJcrJobRecord(jcr); - if (jcr->res.client) { + if (jcr->impl_->res.client) { if (!GetOrCreateClientRecord(jcr)) { goto bail_out; } } - if (!jcr->db->CreateJobRecord(jcr, &jcr->jr)) { + if (!jcr->db->CreateJobRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); goto bail_out; } - jcr->JobId = jcr->jr.JobId; + jcr->JobId = jcr->impl_->jr.JobId; Dmsg4(100, "Created job record JobId=%d Name=%s Type=%c Level=%c\n", - jcr->JobId, jcr->Job, jcr->jr.JobType, jcr->jr.JobLevel); + jcr->JobId, jcr->Job, jcr->impl_->jr.JobType, jcr->impl_->jr.JobLevel); NewPlugins(jcr); /* instantiate plugins for this jcr */ DispatchNewPluginOptions(jcr); @@ -239,11 +243,12 @@ bool SetupJob(JobControlRecord* jcr, bool suppress_output) if (JobCanceled(jcr)) { goto bail_out; } - if (jcr->JobReads() && !jcr->res.read_storage_list) { - if (jcr->res.job->storage) { - CopyRwstorage(jcr, jcr->res.job->storage, _("Job resource")); + if (jcr->JobReads() && !jcr->impl_->res.read_storage_list) { + if (jcr->impl_->res.job->storage) { + CopyRwstorage(jcr, jcr->impl_->res.job->storage, _("Job resource")); } else { - CopyRwstorage(jcr, jcr->res.job->pool->storage, _("Pool resource")); + CopyRwstorage(jcr, jcr->impl_->res.job->pool->storage, + _("Pool resource")); } } @@ -323,9 +328,9 @@ bool SetupJob(JobControlRecord* jcr, bool suppress_output) * Any non NDMP restore is not interested at the items * that were selected for restore so drop them now. */ - if (jcr->restore_tree_root) { - FreeTree(jcr->restore_tree_root); - jcr->restore_tree_root = NULL; + if (jcr->impl_->restore_tree_root) { + FreeTree(jcr->impl_->restore_tree_root); + jcr->impl_->restore_tree_root = NULL; } if (!DoNativeRestoreInit(jcr)) { NativeRestoreCleanup(jcr, JS_ErrorTerminated); @@ -397,7 +402,7 @@ bool IsConnectingToClientAllowed(ClientResource* res) bool IsConnectingToClientAllowed(JobControlRecord* jcr) { - return IsConnectingToClientAllowed(jcr->res.client); + return IsConnectingToClientAllowed(jcr->impl_->res.client); } bool IsConnectFromClientAllowed(ClientResource* res) @@ -407,7 +412,7 @@ bool IsConnectFromClientAllowed(ClientResource* res) bool IsConnectFromClientAllowed(JobControlRecord* jcr) { - return IsConnectFromClientAllowed(jcr->res.client); + return IsConnectFromClientAllowed(jcr->impl_->res.client); } bool UseWaitingClient(JobControlRecord* jcr, int timeout) @@ -418,16 +423,17 @@ bool UseWaitingClient(JobControlRecord* jcr, int timeout) if (!IsConnectFromClientAllowed(jcr)) { Dmsg1(120, "Client Initiated Connection from \"%s\" is not allowed.\n", - jcr->res.client->resource_name_); + jcr->impl_->res.client->resource_name_); } else { - connection = connections->remove(jcr->res.client->resource_name_, timeout); + connection = + connections->remove(jcr->impl_->res.client->resource_name_, timeout); if (connection) { jcr->file_bsock = connection->bsock(); - jcr->FDVersion = connection->protocol_version(); + jcr->impl_->FDVersion = connection->protocol_version(); jcr->authenticated = connection->authenticated(); delete (connection); Jmsg(jcr, M_INFO, 0, _("Using Client Initiated Connection (%s).\n"), - jcr->res.client->resource_name_); + jcr->impl_->res.client->resource_name_); result = true; } } @@ -458,15 +464,15 @@ static void* job_thread(void* arg) Dmsg0(200, "=====Start Job=========\n"); jcr->setJobStatus(JS_Running); /* this will be set only if no error */ jcr->start_time = time(NULL); /* set the real start time */ - jcr->jr.StartTime = jcr->start_time; + jcr->impl_->jr.StartTime = jcr->start_time; /* * Let the statistics subsystem know a new Job was started. */ stats_job_started(); - if (jcr->res.job->MaxStartDelay != 0 && - jcr->res.job->MaxStartDelay < + if (jcr->impl_->res.job->MaxStartDelay != 0 && + jcr->impl_->res.job->MaxStartDelay < (utime_t)(jcr->start_time - jcr->sched_time)) { jcr->setJobStatus(JS_Canceled); Jmsg(jcr, M_FATAL, 0, @@ -482,19 +488,19 @@ static void* job_thread(void* arg) /* * TODO : check if it is used somewhere */ - if (jcr->res.job->RunScripts == NULL) { + if (jcr->impl_->res.job->RunScripts == NULL) { Dmsg0(200, "Warning, job->RunScripts is empty\n"); - jcr->res.job->RunScripts = new alist(10, not_owned_by_alist); + jcr->impl_->res.job->RunScripts = new alist(10, not_owned_by_alist); } - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->jr)) { + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); } /* * Run any script BeforeJob on dird */ - RunScripts(jcr, jcr->res.job->RunScripts, "BeforeJob"); + RunScripts(jcr, jcr->impl_->res.job->RunScripts, "BeforeJob"); /* * We re-update the job start record so that the start time is set after the @@ -506,8 +512,8 @@ static void* job_thread(void* arg) * because in that case, their date is after the start of this run. */ jcr->start_time = time(NULL); - jcr->jr.StartTime = jcr->start_time; - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->jr)) { + jcr->impl_->jr.StartTime = jcr->start_time; + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); } @@ -669,7 +675,7 @@ static void* job_thread(void* arg) me->subscriptions_used, me->subscriptions); } - RunScripts(jcr, jcr->res.job->RunScripts, "AfterJob"); + RunScripts(jcr, jcr->impl_->res.job->RunScripts, "AfterJob"); /* * Send off any queued messages @@ -685,10 +691,10 @@ static void* job_thread(void* arg) void SdMsgThreadSendSignal(JobControlRecord* jcr, int sig) { jcr->lock(); - if (!jcr->sd_msg_thread_done && jcr->SD_msg_chan_started && - !pthread_equal(jcr->SD_msg_chan, pthread_self())) { + if (!jcr->impl_->sd_msg_thread_done && jcr->impl_->SD_msg_chan_started && + !pthread_equal(jcr->impl_->SD_msg_chan, pthread_self())) { Dmsg1(800, "Send kill to SD msg chan jid=%d\n", jcr->JobId); - pthread_kill(jcr->SD_msg_chan, sig); + pthread_kill(jcr->impl_->SD_msg_chan, sig); } jcr->unlock(); } @@ -738,14 +744,14 @@ bool CancelJob(UaContext* ua, JobControlRecord* jcr) /* * Cancel second Storage daemon for SD-SD replication. */ - if (jcr->mig_jcr && jcr->mig_jcr->store_bsock) { - if (!CancelStorageDaemonJob(ua, jcr->mig_jcr)) { return false; } + if (jcr->impl_->mig_jcr && jcr->impl_->mig_jcr->store_bsock) { + if (!CancelStorageDaemonJob(ua, jcr->impl_->mig_jcr)) { return false; } } break; } - RunScripts(jcr, jcr->res.job->RunScripts, "AfterJob"); + RunScripts(jcr, jcr->impl_->res.job->RunScripts, "AfterJob"); return true; } @@ -768,7 +774,7 @@ static void JobMonitorWatchdog(watchdog_t* self) foreach_jcr (jcr) { bool cancel = false; - if (jcr->JobId == 0 || JobCanceled(jcr) || jcr->no_maxtime) { + if (jcr->JobId == 0 || JobCanceled(jcr) || jcr->impl_->no_maxtime) { Dmsg2(800, "Skipping JobControlRecord=%p Job=%s\n", jcr, jcr->Job); continue; } @@ -812,7 +818,7 @@ static void JobMonitorWatchdog(watchdog_t* self) static bool JobCheckMaxwaittime(JobControlRecord* jcr) { bool cancel = false; - JobResource* job = jcr->res.job; + JobResource* job = jcr->impl_->res.job; utime_t current = 0; if (!JobWaiting(jcr)) { return false; } @@ -836,7 +842,7 @@ static bool JobCheckMaxwaittime(JobControlRecord* jcr) static bool JobCheckMaxruntime(JobControlRecord* jcr) { bool cancel = false; - JobResource* job = jcr->res.job; + JobResource* job = jcr->impl_->res.job; utime_t run_time; if (JobCanceled(jcr) || !jcr->job_started) { return false; } @@ -875,10 +881,10 @@ static bool JobCheckMaxruntime(JobControlRecord* jcr) */ static bool JobCheckMaxrunschedtime(JobControlRecord* jcr) { - if (jcr->MaxRunSchedTime == 0 || JobCanceled(jcr)) { return false; } - if ((watchdog_time - jcr->initial_sched_time) < jcr->MaxRunSchedTime) { + if (jcr->impl_->MaxRunSchedTime == 0 || JobCanceled(jcr)) { return false; } + if ((watchdog_time - jcr->initial_sched_time) < jcr->impl_->MaxRunSchedTime) { Dmsg3(200, "Job %p (%s) with MaxRunSchedTime %d not expired\n", jcr, - jcr->Job, jcr->MaxRunSchedTime); + jcr->Job, jcr->impl_->MaxRunSchedTime); return false; } @@ -899,7 +905,7 @@ DBId_t GetOrCreatePoolRecord(JobControlRecord* jcr, char* pool_name) while (!jcr->db->GetPoolRecord(jcr, &pr)) { /* get by Name */ /* Try to create the pool */ - if (CreatePool(jcr, jcr->db, jcr->res.pool, POOL_OP_CREATE) < 0) { + if (CreatePool(jcr, jcr->db, jcr->impl_->res.pool, POOL_OP_CREATE) < 0) { Jmsg(jcr, M_FATAL, 0, _("Pool \"%s\" not in database. ERR=%s"), pr.Name, jcr->db->strerror()); return 0; @@ -919,7 +925,7 @@ DBId_t GetOrCreatePoolRecord(JobControlRecord* jcr, char* pool_name) bool AllowDuplicateJob(JobControlRecord* jcr) { JobControlRecord* djcr; /* possible duplicate job */ - JobResource* job = jcr->res.job; + JobResource* job = jcr->impl_->res.job; bool cancel_dup = false; bool cancel_me = false; @@ -927,7 +933,7 @@ bool AllowDuplicateJob(JobControlRecord* jcr) * See if AllowDuplicateJobs is set or * if duplicate checking is disabled for this job. */ - if (job->AllowDuplicateJobs || jcr->IgnoreDuplicateJobChecking) { + if (job->AllowDuplicateJobs || jcr->impl_->IgnoreDuplicateJobChecking) { return true; } @@ -947,9 +953,9 @@ bool AllowDuplicateJob(JobControlRecord* jcr) * See if this Job has the IgnoreDuplicateJobChecking flag set, ignore it * for any checking against other jobs. */ - if (djcr->IgnoreDuplicateJobChecking) { continue; } + if (djcr->impl_->IgnoreDuplicateJobChecking) { continue; } - if (bstrcmp(job->resource_name_, djcr->res.job->resource_name_)) { + if (bstrcmp(job->resource_name_, djcr->impl_->res.job->resource_name_)) { if (job->DuplicateJobProximity > 0) { utime_t now = (utime_t)time(NULL); if ((now - djcr->start_time) > job->DuplicateJobProximity) { @@ -1061,14 +1067,14 @@ bool GetLevelSinceTime(JobControlRecord* jcr) utime_t last_diff_time; char prev_job[MAX_NAME_LENGTH]; - jcr->since[0] = 0; + jcr->impl_->since[0] = 0; /* * If job cloned and a since time already given, use it */ - if (jcr->cloned && jcr->stime && jcr->stime[0]) { - bstrncpy(jcr->since, _(", since="), sizeof(jcr->since)); - bstrncat(jcr->since, jcr->stime, sizeof(jcr->since)); + if (jcr->impl_->cloned && jcr->stime && jcr->stime[0]) { + bstrncpy(jcr->impl_->since, _(", since="), sizeof(jcr->impl_->since)); + bstrncat(jcr->impl_->since, jcr->stime, sizeof(jcr->impl_->since)); return pool_updated; } @@ -1076,7 +1082,7 @@ bool GetLevelSinceTime(JobControlRecord* jcr) * Make sure stime buffer is allocated */ if (!jcr->stime) { jcr->stime = GetPoolMemory(PM_MESSAGE); } - jcr->PrevJob[0] = 0; + jcr->impl_->PrevJob[0] = 0; jcr->stime[0] = 0; /* @@ -1093,18 +1099,19 @@ bool GetLevelSinceTime(JobControlRecord* jcr) * Look up start time of last Full job */ now = (utime_t)time(NULL); - jcr->jr.JobId = 0; /* flag to return since time */ + jcr->impl_->jr.JobId = 0; /* flag to return since time */ /* * This is probably redundant, but some of the code below * uses jcr->stime, so don't remove unless you are sure. */ - if (!jcr->db->FindJobStartTime(jcr, &jcr->jr, jcr->stime, jcr->PrevJob)) { + if (!jcr->db->FindJobStartTime(jcr, &jcr->impl_->jr, jcr->stime, + jcr->impl_->PrevJob)) { do_full = true; } - have_full = - jcr->db->FindLastJobStartTime(jcr, &jcr->jr, stime, prev_job, L_FULL); + have_full = jcr->db->FindLastJobStartTime(jcr, &jcr->impl_->jr, stime, + prev_job, L_FULL); if (have_full) { last_full_time = StrToUtime(stime); } else { @@ -1118,11 +1125,11 @@ bool GetLevelSinceTime(JobControlRecord* jcr) * Make sure the last diff is recent enough */ if (have_full && JobLevel == L_INCREMENTAL && - jcr->res.job->MaxDiffInterval > 0) { + jcr->impl_->res.job->MaxDiffInterval > 0) { /* * Lookup last diff job */ - if (jcr->db->FindLastJobStartTime(jcr, &jcr->jr, stime, prev_job, + if (jcr->db->FindLastJobStartTime(jcr, &jcr->impl_->jr, stime, prev_job, L_DIFFERENTIAL)) { last_diff_time = StrToUtime(stime); /* @@ -1141,18 +1148,21 @@ bool GetLevelSinceTime(JobControlRecord* jcr) Dmsg1(50, "No last_diff_time setting to full_time=%lld\n", last_full_time); } - do_diff = ((now - last_diff_time) >= jcr->res.job->MaxDiffInterval); + do_diff = + ((now - last_diff_time) >= jcr->impl_->res.job->MaxDiffInterval); Dmsg2(50, "do_diff=%d diffInter=%lld\n", do_diff, - jcr->res.job->MaxDiffInterval); + jcr->impl_->res.job->MaxDiffInterval); } /* * Note, do_full takes precedence over do_vfull and do_diff */ - if (have_full && jcr->res.job->MaxFullInterval > 0) { - do_full = ((now - last_full_time) >= jcr->res.job->MaxFullInterval); - } else if (have_full && jcr->res.job->MaxVFullInterval > 0) { - do_vfull = ((now - last_full_time) >= jcr->res.job->MaxVFullInterval); + if (have_full && jcr->impl_->res.job->MaxFullInterval > 0) { + do_full = + ((now - last_full_time) >= jcr->impl_->res.job->MaxFullInterval); + } else if (have_full && jcr->impl_->res.job->MaxVFullInterval > 0) { + do_vfull = + ((now - last_full_time) >= jcr->impl_->res.job->MaxVFullInterval); } FreePoolMemory(stime); @@ -1164,9 +1174,9 @@ bool GetLevelSinceTime(JobControlRecord* jcr) Jmsg(jcr, M_INFO, 0, _("No prior or suitable Full backup found in catalog. Doing FULL " "backup.\n")); - Bsnprintf(jcr->since, sizeof(jcr->since), _(" (upgraded from %s)"), - JobLevelToString(JobLevel)); - jcr->setJobLevel(jcr->jr.JobLevel = L_FULL); + Bsnprintf(jcr->impl_->since, sizeof(jcr->impl_->since), + _(" (upgraded from %s)"), JobLevelToString(JobLevel)); + jcr->setJobLevel(jcr->impl_->jr.JobLevel = L_FULL); pool_updated = true; } else if (do_vfull) { /* @@ -1177,18 +1187,19 @@ bool GetLevelSinceTime(JobControlRecord* jcr) Jmsg(jcr, M_INFO, 0, _("No prior or suitable Full backup found in catalog. Doing " "Virtual FULL backup.\n")); - Bsnprintf(jcr->since, sizeof(jcr->since), _(" (upgraded from %s)"), + Bsnprintf(jcr->impl_->since, sizeof(jcr->impl_->since), + _(" (upgraded from %s)"), JobLevelToString(jcr->getJobLevel())); - jcr->setJobLevel(jcr->jr.JobLevel = L_VIRTUAL_FULL); + jcr->setJobLevel(jcr->impl_->jr.JobLevel = L_VIRTUAL_FULL); pool_updated = true; /* * If we get upgraded to a Virtual Full we will be using a read pool so * make sure we have a rpool_source. */ - if (!jcr->res.rpool_source) { - jcr->res.rpool_source = GetPoolMemory(PM_MESSAGE); - PmStrcpy(jcr->res.rpool_source, _("unknown source")); + if (!jcr->impl_->res.rpool_source) { + jcr->impl_->res.rpool_source = GetPoolMemory(PM_MESSAGE); + PmStrcpy(jcr->impl_->res.rpool_source, _("unknown source")); } } else if (do_diff) { /* @@ -1197,39 +1208,39 @@ bool GetLevelSinceTime(JobControlRecord* jcr) Jmsg(jcr, M_INFO, 0, _("No prior or suitable Differential backup found in catalog. " "Doing Differential backup.\n")); - Bsnprintf(jcr->since, sizeof(jcr->since), _(" (upgraded from %s)"), - JobLevelToString(JobLevel)); - jcr->setJobLevel(jcr->jr.JobLevel = L_DIFFERENTIAL); + Bsnprintf(jcr->impl_->since, sizeof(jcr->impl_->since), + _(" (upgraded from %s)"), JobLevelToString(JobLevel)); + jcr->setJobLevel(jcr->impl_->jr.JobLevel = L_DIFFERENTIAL); pool_updated = true; } else { - if (jcr->res.job->rerun_failed_levels) { - if (jcr->db->FindFailedJobSince(jcr, &jcr->jr, jcr->stime, + if (jcr->impl_->res.job->rerun_failed_levels) { + if (jcr->db->FindFailedJobSince(jcr, &jcr->impl_->jr, jcr->stime, JobLevel)) { Jmsg(jcr, M_INFO, 0, _("Prior failed job found in catalog. Upgrading to %s.\n"), JobLevelToString(JobLevel)); - Bsnprintf(jcr->since, sizeof(jcr->since), _(" (upgraded from %s)"), - JobLevelToString(JobLevel)); - jcr->setJobLevel(jcr->jr.JobLevel = JobLevel); - jcr->jr.JobId = jcr->JobId; + Bsnprintf(jcr->impl_->since, sizeof(jcr->impl_->since), + _(" (upgraded from %s)"), JobLevelToString(JobLevel)); + jcr->setJobLevel(jcr->impl_->jr.JobLevel = JobLevel); + jcr->impl_->jr.JobId = jcr->JobId; pool_updated = true; break; } } - bstrncpy(jcr->since, _(", since="), sizeof(jcr->since)); - bstrncat(jcr->since, jcr->stime, sizeof(jcr->since)); + bstrncpy(jcr->impl_->since, _(", since="), sizeof(jcr->impl_->since)); + bstrncat(jcr->impl_->since, jcr->stime, sizeof(jcr->impl_->since)); } - jcr->jr.JobId = jcr->JobId; + jcr->impl_->jr.JobId = jcr->JobId; /* * Lookup the Job record of the previous Job and store it in - * jcr->previous_jr. + * jcr->impl_->previous_jr. */ - if (jcr->PrevJob[0]) { - bstrncpy(jcr->previous_jr.Job, jcr->PrevJob, - sizeof(jcr->previous_jr.Job)); - if (!jcr->db->GetJobRecord(jcr, &jcr->previous_jr)) { + if (jcr->impl_->PrevJob[0]) { + bstrncpy(jcr->impl_->previous_jr.Job, jcr->impl_->PrevJob, + sizeof(jcr->impl_->previous_jr.Job)); + if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->previous_jr)) { Jmsg(jcr, M_FATAL, 0, _("Could not get job record for previous Job. ERR=%s"), jcr->db->strerror()); @@ -1240,7 +1251,7 @@ bool GetLevelSinceTime(JobControlRecord* jcr) } Dmsg3(100, "Level=%c last start time=%s job=%s\n", JobLevel, jcr->stime, - jcr->PrevJob); + jcr->impl_->PrevJob); return pool_updated; } @@ -1254,85 +1265,89 @@ void ApplyPoolOverrides(JobControlRecord* jcr, bool force) * If a cmdline pool override is given ignore any level pool overrides. * Unless a force is given then we always apply any overrides. */ - if (!force && jcr->IgnoreLevelPoolOverides) { return; } + if (!force && jcr->impl_->IgnoreLevelPoolOverides) { return; } /* * If only a pool override and no level overrides are given in run entry * choose this pool */ - if (jcr->res.run_pool_override && !jcr->res.run_full_pool_override && - !jcr->res.run_vfull_pool_override && !jcr->res.run_inc_pool_override && - !jcr->res.run_diff_pool_override) { - PmStrcpy(jcr->res.pool_source, _("Run Pool override")); - Dmsg2(100, "Pool set to '%s' because of %s", jcr->res.pool->resource_name_, - _("Run Pool override\n")); + if (jcr->impl_->res.run_pool_override && + !jcr->impl_->res.run_full_pool_override && + !jcr->impl_->res.run_vfull_pool_override && + !jcr->impl_->res.run_inc_pool_override && + !jcr->impl_->res.run_diff_pool_override) { + PmStrcpy(jcr->impl_->res.pool_source, _("Run Pool override")); + Dmsg2(100, "Pool set to '%s' because of %s", + jcr->impl_->res.pool->resource_name_, _("Run Pool override\n")); } else { /* * Apply any level related Pool selections */ switch (jcr->getJobLevel()) { case L_FULL: - if (jcr->res.full_pool) { - jcr->res.pool = jcr->res.full_pool; + if (jcr->impl_->res.full_pool) { + jcr->impl_->res.pool = jcr->impl_->res.full_pool; pool_override = true; - if (jcr->res.run_full_pool_override) { - PmStrcpy(jcr->res.pool_source, _("Run FullPool override")); + if (jcr->impl_->res.run_full_pool_override) { + PmStrcpy(jcr->impl_->res.pool_source, _("Run FullPool override")); Dmsg2(100, "Pool set to '%s' because of %s", - jcr->res.full_pool->resource_name_, + jcr->impl_->res.full_pool->resource_name_, "Run FullPool override\n"); } else { - PmStrcpy(jcr->res.pool_source, _("Job FullPool override")); + PmStrcpy(jcr->impl_->res.pool_source, _("Job FullPool override")); Dmsg2(100, "Pool set to '%s' because of %s", - jcr->res.full_pool->resource_name_, + jcr->impl_->res.full_pool->resource_name_, "Job FullPool override\n"); } } break; case L_VIRTUAL_FULL: - if (jcr->res.vfull_pool) { - jcr->res.pool = jcr->res.vfull_pool; + if (jcr->impl_->res.vfull_pool) { + jcr->impl_->res.pool = jcr->impl_->res.vfull_pool; pool_override = true; - if (jcr->res.run_vfull_pool_override) { - PmStrcpy(jcr->res.pool_source, _("Run VFullPool override")); + if (jcr->impl_->res.run_vfull_pool_override) { + PmStrcpy(jcr->impl_->res.pool_source, _("Run VFullPool override")); Dmsg2(100, "Pool set to '%s' because of %s", - jcr->res.vfull_pool->resource_name_, + jcr->impl_->res.vfull_pool->resource_name_, "Run VFullPool override\n"); } else { - PmStrcpy(jcr->res.pool_source, _("Job VFullPool override")); + PmStrcpy(jcr->impl_->res.pool_source, _("Job VFullPool override")); Dmsg2(100, "Pool set to '%s' because of %s", - jcr->res.vfull_pool->resource_name_, + jcr->impl_->res.vfull_pool->resource_name_, "Job VFullPool override\n"); } } break; case L_INCREMENTAL: - if (jcr->res.inc_pool) { - jcr->res.pool = jcr->res.inc_pool; + if (jcr->impl_->res.inc_pool) { + jcr->impl_->res.pool = jcr->impl_->res.inc_pool; pool_override = true; - if (jcr->res.run_inc_pool_override) { - PmStrcpy(jcr->res.pool_source, _("Run IncPool override")); + if (jcr->impl_->res.run_inc_pool_override) { + PmStrcpy(jcr->impl_->res.pool_source, _("Run IncPool override")); Dmsg2(100, "Pool set to '%s' because of %s", - jcr->res.inc_pool->resource_name_, "Run IncPool override\n"); + jcr->impl_->res.inc_pool->resource_name_, + "Run IncPool override\n"); } else { - PmStrcpy(jcr->res.pool_source, _("Job IncPool override")); + PmStrcpy(jcr->impl_->res.pool_source, _("Job IncPool override")); Dmsg2(100, "Pool set to '%s' because of %s", - jcr->res.inc_pool->resource_name_, "Job IncPool override\n"); + jcr->impl_->res.inc_pool->resource_name_, + "Job IncPool override\n"); } } break; case L_DIFFERENTIAL: - if (jcr->res.diff_pool) { - jcr->res.pool = jcr->res.diff_pool; + if (jcr->impl_->res.diff_pool) { + jcr->impl_->res.pool = jcr->impl_->res.diff_pool; pool_override = true; - if (jcr->res.run_diff_pool_override) { - PmStrcpy(jcr->res.pool_source, _("Run DiffPool override")); + if (jcr->impl_->res.run_diff_pool_override) { + PmStrcpy(jcr->impl_->res.pool_source, _("Run DiffPool override")); Dmsg2(100, "Pool set to '%s' because of %s", - jcr->res.diff_pool->resource_name_, + jcr->impl_->res.diff_pool->resource_name_, "Run DiffPool override\n"); } else { - PmStrcpy(jcr->res.pool_source, _("Job DiffPool override")); + PmStrcpy(jcr->impl_->res.pool_source, _("Job DiffPool override")); Dmsg2(100, "Pool set to '%s' because of %s", - jcr->res.diff_pool->resource_name_, + jcr->impl_->res.diff_pool->resource_name_, "Job DiffPool override\n"); } } @@ -1343,9 +1358,9 @@ void ApplyPoolOverrides(JobControlRecord* jcr, bool force) /* * Update catalog if pool overridden */ - if (pool_override && jcr->res.pool->catalog) { - jcr->res.catalog = jcr->res.pool->catalog; - PmStrcpy(jcr->res.catalog_source, _("Pool resource")); + if (pool_override && jcr->impl_->res.pool->catalog) { + jcr->impl_->res.catalog = jcr->impl_->res.pool->catalog; + PmStrcpy(jcr->impl_->res.catalog_source, _("Pool resource")); } } @@ -1356,12 +1371,12 @@ bool GetOrCreateClientRecord(JobControlRecord* jcr) { ClientDbRecord cr; - bstrncpy(cr.Name, jcr->res.client->resource_name_, sizeof(cr.Name)); - cr.AutoPrune = jcr->res.client->AutoPrune; - cr.FileRetention = jcr->res.client->FileRetention; - cr.JobRetention = jcr->res.client->JobRetention; + bstrncpy(cr.Name, jcr->impl_->res.client->resource_name_, sizeof(cr.Name)); + cr.AutoPrune = jcr->impl_->res.client->AutoPrune; + cr.FileRetention = jcr->impl_->res.client->FileRetention; + cr.JobRetention = jcr->impl_->res.client->JobRetention; if (!jcr->client_name) { jcr->client_name = GetPoolMemory(PM_NAME); } - PmStrcpy(jcr->client_name, jcr->res.client->resource_name_); + PmStrcpy(jcr->client_name, jcr->impl_->res.client->resource_name_); if (!jcr->db->CreateClientRecord(jcr, &cr)) { Jmsg(jcr, M_FATAL, 0, _("Could not create Client record. ERR=%s\n"), jcr->db->strerror()); @@ -1370,25 +1385,28 @@ bool GetOrCreateClientRecord(JobControlRecord* jcr) /* * Only initialize quota when a Soft or Hard Limit is set. */ - if (jcr->res.client->HardQuota != 0 || jcr->res.client->SoftQuota != 0) { + if (jcr->impl_->res.client->HardQuota != 0 || + jcr->impl_->res.client->SoftQuota != 0) { if (!jcr->db->GetQuotaRecord(jcr, &cr)) { if (!jcr->db->CreateQuotaRecord(jcr, &cr)) { Jmsg(jcr, M_FATAL, 0, _("Could not create Quota record. ERR=%s\n"), jcr->db->strerror()); } - jcr->res.client->QuotaLimit = 0; - jcr->res.client->GraceTime = 0; + jcr->impl_->res.client->QuotaLimit = 0; + jcr->impl_->res.client->GraceTime = 0; } } - jcr->jr.ClientId = cr.ClientId; - jcr->res.client->QuotaLimit = cr.QuotaLimit; - jcr->res.client->GraceTime = cr.GraceTime; + jcr->impl_->jr.ClientId = cr.ClientId; + jcr->impl_->res.client->QuotaLimit = cr.QuotaLimit; + jcr->impl_->res.client->GraceTime = cr.GraceTime; if (cr.Uname[0]) { - if (!jcr->client_uname) { jcr->client_uname = GetPoolMemory(PM_NAME); } - PmStrcpy(jcr->client_uname, cr.Uname); + if (!jcr->impl_->client_uname) { + jcr->impl_->client_uname = GetPoolMemory(PM_NAME); + } + PmStrcpy(jcr->impl_->client_uname, cr.Uname); } - Dmsg2(100, "Created Client %s record %d\n", jcr->res.client->resource_name_, - jcr->jr.ClientId); + Dmsg2(100, "Created Client %s record %d\n", + jcr->impl_->res.client->resource_name_, jcr->impl_->jr.ClientId); return true; } @@ -1399,26 +1417,28 @@ bool GetOrCreateFilesetRecord(JobControlRecord* jcr) /* * Get or Create FileSet record */ - bstrncpy(fsr.FileSet, jcr->res.fileset->resource_name_, sizeof(fsr.FileSet)); - if (jcr->res.fileset->have_MD5) { + bstrncpy(fsr.FileSet, jcr->impl_->res.fileset->resource_name_, + sizeof(fsr.FileSet)); + if (jcr->impl_->res.fileset->have_MD5) { MD5_CTX md5c; unsigned char digest[MD5HashSize]; - memcpy(&md5c, &jcr->res.fileset->md5c, sizeof(md5c)); + memcpy(&md5c, &jcr->impl_->res.fileset->md5c, sizeof(md5c)); MD5_Final(digest, &md5c); /* * Keep the flag (last arg) set to false otherwise old FileSets will * get new MD5 sums and the user will get Full backups on everything */ BinToBase64(fsr.MD5, sizeof(fsr.MD5), (char*)digest, MD5HashSize, false); - bstrncpy(jcr->res.fileset->MD5, fsr.MD5, sizeof(jcr->res.fileset->MD5)); + bstrncpy(jcr->impl_->res.fileset->MD5, fsr.MD5, + sizeof(jcr->impl_->res.fileset->MD5)); } else { Jmsg(jcr, M_WARNING, 0, _("FileSet MD5 digest not found.\n")); } - if (!jcr->res.fileset->ignore_fs_changes || + if (!jcr->impl_->res.fileset->ignore_fs_changes || !jcr->db->GetFilesetRecord(jcr, &fsr)) { PoolMem FileSetText(PM_MESSAGE); - jcr->res.fileset->PrintConfig(FileSetText, *my_config, false, false); + jcr->impl_->res.fileset->PrintConfig(FileSetText, *my_config, false, false); fsr.FileSetText = FileSetText.c_str(); if (!jcr->db->CreateFilesetRecord(jcr, &fsr)) { @@ -1429,27 +1449,29 @@ bool GetOrCreateFilesetRecord(JobControlRecord* jcr) } } - jcr->jr.FileSetId = fsr.FileSetId; - bstrncpy(jcr->FSCreateTime, fsr.cCreateTime, sizeof(jcr->FSCreateTime)); + jcr->impl_->jr.FileSetId = fsr.FileSetId; + bstrncpy(jcr->impl_->FSCreateTime, fsr.cCreateTime, + sizeof(jcr->impl_->FSCreateTime)); - Dmsg2(119, "Created FileSet %s record %u\n", jcr->res.fileset->resource_name_, - jcr->jr.FileSetId); + Dmsg2(119, "Created FileSet %s record %u\n", + jcr->impl_->res.fileset->resource_name_, jcr->impl_->jr.FileSetId); return true; } void InitJcrJobRecord(JobControlRecord* jcr) { - jcr->jr.SchedTime = jcr->sched_time; - jcr->jr.StartTime = jcr->start_time; - jcr->jr.EndTime = 0; /* perhaps rescheduled, clear it */ - jcr->jr.JobType = jcr->getJobType(); - jcr->jr.JobLevel = jcr->getJobLevel(); - jcr->jr.JobStatus = jcr->JobStatus; - jcr->jr.JobId = jcr->JobId; - jcr->jr.JobSumTotalBytes = 18446744073709551615LLU; - bstrncpy(jcr->jr.Name, jcr->res.job->resource_name_, sizeof(jcr->jr.Name)); - bstrncpy(jcr->jr.Job, jcr->Job, sizeof(jcr->jr.Job)); + jcr->impl_->jr.SchedTime = jcr->sched_time; + jcr->impl_->jr.StartTime = jcr->start_time; + jcr->impl_->jr.EndTime = 0; /* perhaps rescheduled, clear it */ + jcr->impl_->jr.JobType = jcr->getJobType(); + jcr->impl_->jr.JobLevel = jcr->getJobLevel(); + jcr->impl_->jr.JobStatus = jcr->JobStatus; + jcr->impl_->jr.JobId = jcr->JobId; + jcr->impl_->jr.JobSumTotalBytes = 18446744073709551615LLU; + bstrncpy(jcr->impl_->jr.Name, jcr->impl_->res.job->resource_name_, + sizeof(jcr->impl_->jr.Name)); + bstrncpy(jcr->impl_->jr.Job, jcr->Job, sizeof(jcr->impl_->jr.Job)); } /** @@ -1457,18 +1479,18 @@ void InitJcrJobRecord(JobControlRecord* jcr) */ void UpdateJobEndRecord(JobControlRecord* jcr) { - jcr->jr.EndTime = time(NULL); - jcr->end_time = jcr->jr.EndTime; - jcr->jr.JobId = jcr->JobId; - jcr->jr.JobStatus = jcr->JobStatus; - jcr->jr.JobFiles = jcr->JobFiles; - jcr->jr.JobBytes = jcr->JobBytes; - jcr->jr.ReadBytes = jcr->ReadBytes; - jcr->jr.VolSessionId = jcr->VolSessionId; - jcr->jr.VolSessionTime = jcr->VolSessionTime; - jcr->jr.JobErrors = jcr->JobErrors; - jcr->jr.HasBase = jcr->HasBase; - if (!jcr->db->UpdateJobEndRecord(jcr, &jcr->jr)) { + jcr->impl_->jr.EndTime = time(NULL); + jcr->end_time = jcr->impl_->jr.EndTime; + jcr->impl_->jr.JobId = jcr->JobId; + jcr->impl_->jr.JobStatus = jcr->JobStatus; + jcr->impl_->jr.JobFiles = jcr->JobFiles; + jcr->impl_->jr.JobBytes = jcr->JobBytes; + jcr->impl_->jr.ReadBytes = jcr->ReadBytes; + jcr->impl_->jr.VolSessionId = jcr->VolSessionId; + jcr->impl_->jr.VolSessionTime = jcr->VolSessionTime; + jcr->impl_->jr.JobErrors = jcr->JobErrors; + jcr->impl_->jr.HasBase = jcr->HasBase; + if (!jcr->db->UpdateJobEndRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error updating job record. %s"), jcr->db->strerror()); } @@ -1552,14 +1574,14 @@ void DirdFreeJcrPointers(JobControlRecord* jcr) BfreeAndNull(jcr->sd_auth_key); BfreeAndNull(jcr->where); - BfreeAndNull(jcr->backup_format); + BfreeAndNull(jcr->impl_->backup_format); BfreeAndNull(jcr->RestoreBootstrap); BfreeAndNull(jcr->ar); FreeAndNullPoolMemory(jcr->JobIds); - FreeAndNullPoolMemory(jcr->client_uname); + FreeAndNullPoolMemory(jcr->impl_->client_uname); FreeAndNullPoolMemory(jcr->attr); - FreeAndNullPoolMemory(jcr->fname); + FreeAndNullPoolMemory(jcr->impl_->fname); } /** @@ -1571,21 +1593,21 @@ void DirdFreeJcr(JobControlRecord* jcr) { Dmsg0(200, "Start dird FreeJcr\n"); - if (jcr->mig_jcr) { - FreeJcr(jcr->mig_jcr); - jcr->mig_jcr = NULL; + if (jcr->impl_->mig_jcr) { + FreeJcr(jcr->impl_->mig_jcr); + jcr->impl_->mig_jcr = NULL; } DirdFreeJcrPointers(jcr); - if (jcr->term_wait_inited) { - pthread_cond_destroy(&jcr->term_wait); - jcr->term_wait_inited = false; + if (jcr->impl_->term_wait_inited) { + pthread_cond_destroy(&jcr->impl_->term_wait); + jcr->impl_->term_wait_inited = false; } - if (jcr->nextrun_ready_inited) { - pthread_cond_destroy(&jcr->nextrun_ready); - jcr->nextrun_ready_inited = false; + if (jcr->impl_->nextrun_ready_inited) { + pthread_cond_destroy(&jcr->impl_->nextrun_ready); + jcr->impl_->nextrun_ready_inited = false; } if (jcr->db_batch) { @@ -1599,24 +1621,26 @@ void DirdFreeJcr(JobControlRecord* jcr) jcr->db = NULL; } - if (jcr->restore_tree_root) { FreeTree(jcr->restore_tree_root); } + if (jcr->impl_->restore_tree_root) { + FreeTree(jcr->impl_->restore_tree_root); + } - if (jcr->bsr) { - libbareos::FreeBsr(jcr->bsr); - jcr->bsr = NULL; + if (jcr->impl_->bsr) { + libbareos::FreeBsr(jcr->impl_->bsr); + jcr->impl_->bsr = NULL; } FreeAndNullPoolMemory(jcr->stime); - FreeAndNullPoolMemory(jcr->fname); - FreeAndNullPoolMemory(jcr->res.pool_source); - FreeAndNullPoolMemory(jcr->res.npool_source); - FreeAndNullPoolMemory(jcr->res.rpool_source); - FreeAndNullPoolMemory(jcr->res.wstore_source); - FreeAndNullPoolMemory(jcr->res.rstore_source); - FreeAndNullPoolMemory(jcr->res.catalog_source); - FreeAndNullPoolMemory(jcr->FDSecureEraseCmd); - FreeAndNullPoolMemory(jcr->SDSecureEraseCmd); - FreeAndNullPoolMemory(jcr->vf_jobids); + FreeAndNullPoolMemory(jcr->impl_->fname); + FreeAndNullPoolMemory(jcr->impl_->res.pool_source); + FreeAndNullPoolMemory(jcr->impl_->res.npool_source); + FreeAndNullPoolMemory(jcr->impl_->res.rpool_source); + FreeAndNullPoolMemory(jcr->impl_->res.wstore_source); + FreeAndNullPoolMemory(jcr->impl_->res.rstore_source); + FreeAndNullPoolMemory(jcr->impl_->res.catalog_source); + FreeAndNullPoolMemory(jcr->impl_->FDSecureEraseCmd); + FreeAndNullPoolMemory(jcr->impl_->SDSecureEraseCmd); + FreeAndNullPoolMemory(jcr->impl_->vf_jobids); /* * Delete lists setup to hold storage pointers @@ -1632,6 +1656,11 @@ void DirdFreeJcr(JobControlRecord* jcr) FreePlugins(jcr); /* release instantiated plugins */ + if (jcr->impl_) { + delete jcr->impl_; + jcr->impl_ = nullptr; + } + Dmsg0(200, "End dird FreeJcr\n"); } @@ -1664,6 +1693,13 @@ void GetJobStorage(UnifiedStorageResource* store, } } +JobControlRecord* NewDirectorJcr() +{ + JobControlRecord* jcr = new_jcr(sizeof(JobControlRecord), DirdFreeJcr); + jcr->impl_ = new JobControlRecordPrivate; + return jcr; +} + /** * Set some defaults in the JobControlRecord necessary to * run. These items are pulled from the job @@ -1673,7 +1709,7 @@ void GetJobStorage(UnifiedStorageResource* store, */ void SetJcrDefaults(JobControlRecord* jcr, JobResource* job) { - jcr->res.job = job; + jcr->impl_->res.job = job; jcr->setJobType(job->JobType); jcr->setJobProtocol(job->Protocol); jcr->JobStatus = JS_Created; @@ -1690,18 +1726,18 @@ void SetJcrDefaults(JobControlRecord* jcr, JobResource* job) break; } - if (!jcr->fname) { jcr->fname = GetPoolMemory(PM_FNAME); } - if (!jcr->res.pool_source) { - jcr->res.pool_source = GetPoolMemory(PM_MESSAGE); - PmStrcpy(jcr->res.pool_source, _("unknown source")); + if (!jcr->impl_->fname) { jcr->impl_->fname = GetPoolMemory(PM_FNAME); } + if (!jcr->impl_->res.pool_source) { + jcr->impl_->res.pool_source = GetPoolMemory(PM_MESSAGE); + PmStrcpy(jcr->impl_->res.pool_source, _("unknown source")); } - if (!jcr->res.npool_source) { - jcr->res.npool_source = GetPoolMemory(PM_MESSAGE); - PmStrcpy(jcr->res.npool_source, _("unknown source")); + if (!jcr->impl_->res.npool_source) { + jcr->impl_->res.npool_source = GetPoolMemory(PM_MESSAGE); + PmStrcpy(jcr->impl_->res.npool_source, _("unknown source")); } - if (!jcr->res.catalog_source) { - jcr->res.catalog_source = GetPoolMemory(PM_MESSAGE); - PmStrcpy(jcr->res.catalog_source, _("unknown source")); + if (!jcr->impl_->res.catalog_source) { + jcr->impl_->res.catalog_source = GetPoolMemory(PM_MESSAGE); + PmStrcpy(jcr->impl_->res.catalog_source, _("unknown source")); } jcr->JobPriority = job->Priority; @@ -1714,48 +1750,48 @@ void SetJcrDefaults(JobControlRecord* jcr, JobResource* job) } else if (job->pool) { CopyRwstorage(jcr, job->pool->storage, _("Pool resource")); } - jcr->res.client = job->client; + jcr->impl_->res.client = job->client; - if (jcr->res.client) { + if (jcr->impl_->res.client) { if (!jcr->client_name) { jcr->client_name = GetPoolMemory(PM_NAME); } - PmStrcpy(jcr->client_name, jcr->res.client->resource_name_); + PmStrcpy(jcr->client_name, jcr->impl_->res.client->resource_name_); } - PmStrcpy(jcr->res.pool_source, _("Job resource")); - jcr->res.pool = job->pool; - jcr->res.full_pool = job->full_pool; - jcr->res.inc_pool = job->inc_pool; - jcr->res.diff_pool = job->diff_pool; + PmStrcpy(jcr->impl_->res.pool_source, _("Job resource")); + jcr->impl_->res.pool = job->pool; + jcr->impl_->res.full_pool = job->full_pool; + jcr->impl_->res.inc_pool = job->inc_pool; + jcr->impl_->res.diff_pool = job->diff_pool; if (job->pool && job->pool->catalog) { - jcr->res.catalog = job->pool->catalog; - PmStrcpy(jcr->res.catalog_source, _("Pool resource")); + jcr->impl_->res.catalog = job->pool->catalog; + PmStrcpy(jcr->impl_->res.catalog_source, _("Pool resource")); } else { if (job->catalog) { - jcr->res.catalog = job->catalog; - PmStrcpy(jcr->res.catalog_source, _("Job resource")); + jcr->impl_->res.catalog = job->catalog; + PmStrcpy(jcr->impl_->res.catalog_source, _("Job resource")); } else { if (job->client) { - jcr->res.catalog = job->client->catalog; - PmStrcpy(jcr->res.catalog_source, _("Client resource")); + jcr->impl_->res.catalog = job->client->catalog; + PmStrcpy(jcr->impl_->res.catalog_source, _("Client resource")); } else { - jcr->res.catalog = + jcr->impl_->res.catalog = (CatalogResource*)my_config->GetNextRes(R_CATALOG, NULL); - PmStrcpy(jcr->res.catalog_source, _("Default catalog")); + PmStrcpy(jcr->impl_->res.catalog_source, _("Default catalog")); } } } - jcr->res.fileset = job->fileset; + jcr->impl_->res.fileset = job->fileset; jcr->accurate = job->accurate; - jcr->res.messages = job->messages; - jcr->spool_data = job->spool_data; - jcr->spool_size = job->spool_size; - jcr->IgnoreDuplicateJobChecking = job->IgnoreDuplicateJobChecking; - jcr->MaxRunSchedTime = job->MaxRunSchedTime; + jcr->impl_->res.messages = job->messages; + jcr->impl_->spool_data = job->spool_data; + jcr->impl_->spool_size = job->spool_size; + jcr->impl_->IgnoreDuplicateJobChecking = job->IgnoreDuplicateJobChecking; + jcr->impl_->MaxRunSchedTime = job->MaxRunSchedTime; - if (jcr->backup_format) { free(jcr->backup_format); } - jcr->backup_format = strdup(job->backup_format); + if (jcr->impl_->backup_format) { free(jcr->impl_->backup_format); } + jcr->impl_->backup_format = strdup(job->backup_format); if (jcr->RestoreBootstrap) { free(jcr->RestoreBootstrap); @@ -1772,7 +1808,7 @@ void SetJcrDefaults(JobControlRecord* jcr, JobResource* job) /* * This can be overridden by Console program */ - jcr->res.verify_job = job->verify_job; + jcr->impl_->res.verify_job = job->verify_job; /* * If no default level given, set one @@ -1801,11 +1837,12 @@ void CreateClones(JobControlRecord* jcr) /* * Fire off any clone jobs (run directives) */ - Dmsg2(900, "cloned=%d run_cmds=%p\n", jcr->cloned, jcr->res.job->run_cmds); - if (!jcr->cloned && jcr->res.job->run_cmds) { + Dmsg2(900, "cloned=%d run_cmds=%p\n", jcr->impl_->cloned, + jcr->impl_->res.job->run_cmds); + if (!jcr->impl_->cloned && jcr->impl_->res.job->run_cmds) { char* runcmd = nullptr; JobId_t jobid; - JobResource* job = jcr->res.job; + JobResource* job = jcr->impl_->res.job; POOLMEM* cmd = GetPoolMemory(PM_FNAME); UaContext* ua = new_ua_context(jcr); @@ -1830,7 +1867,7 @@ void CreateClones(JobControlRecord* jcr) } /** - * Given: a JobId in jcr->previous_jr.JobId, + * Given: a JobId in jcr->impl_->previous_jr.JobId, * this subroutine writes a bsr file to restore that job. * Returns: -1 on error * number of files if OK @@ -1843,24 +1880,24 @@ int CreateRestoreBootstrapFile(JobControlRecord* jcr) rx.bsr = std::make_unique(); rx.JobIds = (char*)""; - rx.bsr->JobId = jcr->previous_jr.JobId; + rx.bsr->JobId = jcr->impl_->previous_jr.JobId; ua = new_ua_context(jcr); if (!AddVolumeInformationToBsr(ua, rx.bsr.get())) { files = -1; goto bail_out; } - for (uint32_t fi = 1; fi <= jcr->previous_jr.JobFiles; fi++) { + for (uint32_t fi = 1; fi <= jcr->impl_->previous_jr.JobFiles; fi++) { rx.bsr->fi->Add(fi); } - jcr->ExpectedFiles = WriteBsrFile(ua, rx); - if (jcr->ExpectedFiles == 0) { + jcr->impl_->ExpectedFiles = WriteBsrFile(ua, rx); + if (jcr->impl_->ExpectedFiles == 0) { files = 0; goto bail_out; } FreeUaContext(ua); rx.bsr.reset(nullptr); - jcr->needs_sd = true; - return jcr->ExpectedFiles; + jcr->impl_->needs_sd = true; + return jcr->impl_->ExpectedFiles; bail_out: FreeUaContext(ua); diff --git a/core/src/dird/job.h b/core/src/dird/job.h index 6bac37218ac..67b1e6f526a 100644 --- a/core/src/dird/job.h +++ b/core/src/dird/job.h @@ -29,6 +29,7 @@ namespace directordaemon { class UaContext; bool AllowDuplicateJob(JobControlRecord* jcr); +JobControlRecord* NewDirectorJcr(); void SetJcrDefaults(JobControlRecord* jcr, JobResource* job); void CreateUniqueJobName(JobControlRecord* jcr, const char* base_name); void UpdateJobEndRecord(JobControlRecord* jcr); diff --git a/core/src/dird/jobq.cc b/core/src/dird/jobq.cc index 7c7e17ea855..2cd2860b549 100644 --- a/core/src/dird/jobq.cc +++ b/core/src/dird/jobq.cc @@ -33,6 +33,7 @@ #include "include/bareos.h" #include "dird.h" +#include "dird/jcr_private.h" #include "dird/job.h" #include "dird/jobq.h" #include "dird/storage.h" @@ -213,17 +214,17 @@ int JobqAdd(jobq_t* jq, JobControlRecord* jcr) pthread_t id; wait_pkt* sched_pkt; - if (!jcr->term_wait_inited) { + if (!jcr->impl_->term_wait_inited) { /* * Initialize termination condition variable */ - if ((status = pthread_cond_init(&jcr->term_wait, NULL)) != 0) { + if ((status = pthread_cond_init(&jcr->impl_->term_wait, NULL)) != 0) { BErrNo be; Jmsg1(jcr, M_FATAL, 0, _("Unable to init job cond variable: ERR=%s\n"), be.bstrerror(status)); return status; } - jcr->term_wait_inited = true; + jcr->impl_->term_wait_inited = true; } Dmsg3(2300, "JobqAdd jobid=%d jcr=0x%x UseCount=%d\n", jcr->JobId, jcr, @@ -482,12 +483,12 @@ extern "C" void* jobq_server(void* arg) * been acquired for jobs canceled before they were put into the ready * queue. */ - if (jcr->acquired_resource_locks) { + if (jcr->impl_->acquired_resource_locks) { DecReadStore(jcr); DecWriteStore(jcr); DecClientConcurrency(jcr); DecJobConcurrency(jcr); - jcr->acquired_resource_locks = false; + jcr->impl_->acquired_resource_locks = false; } if (RescheduleJob(jcr, jq, je)) { continue; /* go look for more work */ } @@ -497,7 +498,7 @@ extern "C" void* jobq_server(void* arg) */ Dmsg2(2300, "====== Termination job=%d use_cnt=%d\n", jcr->JobId, jcr->UseCount()); - jcr->SDJobStatus = 0; + jcr->impl_->SDJobStatus = 0; V(jq->mutex); /* release internal lock */ FreeJcr(jcr); free(je); /* release job entry */ @@ -520,9 +521,10 @@ extern "C" void* jobq_server(void* arg) running_allow_mix = true; for (; re;) { - Dmsg2(2300, "JobId %d is also running with %s\n", re->jcr->JobId, - re->jcr->res.job->allow_mixed_priority ? "mix" : "no mix"); - if (!re->jcr->res.job->allow_mixed_priority) { + Dmsg2( + 2300, "JobId %d is also running with %s\n", re->jcr->JobId, + re->jcr->impl_->res.job->allow_mixed_priority ? "mix" : "no mix"); + if (!re->jcr->impl_->res.job->allow_mixed_priority) { running_allow_mix = false; break; } @@ -548,14 +550,15 @@ extern "C" void* jobq_server(void* arg) Dmsg4(2300, "Examining Job=%d JobPri=%d want Pri=%d (%s)\n", jcr->JobId, jcr->JobPriority, Priority, - jcr->res.job->allow_mixed_priority ? "mix" : "no mix"); + jcr->impl_->res.job->allow_mixed_priority ? "mix" : "no mix"); /* * Take only jobs of correct Priority */ if (!(jcr->JobPriority == Priority || (jcr->JobPriority < Priority && - jcr->res.job->allow_mixed_priority && running_allow_mix))) { + jcr->impl_->res.job->allow_mixed_priority && + running_allow_mix))) { jcr->setJobStatus(JS_WaitPriority); break; } @@ -656,18 +659,18 @@ static bool RescheduleJob(JobControlRecord* jcr, jobq_t* jq, jobq_item_t* je) /* * Basic condition is that more reschedule times remain */ - if (jcr->res.job->RescheduleTimes == 0 || - jcr->reschedule_count < jcr->res.job->RescheduleTimes) { + if (jcr->impl_->res.job->RescheduleTimes == 0 || + jcr->impl_->reschedule_count < jcr->impl_->res.job->RescheduleTimes) { resched = /* * Check for incomplete jobs */ - (jcr->res.job->RescheduleIncompleteJobs && jcr->IsIncomplete() && + (jcr->impl_->res.job->RescheduleIncompleteJobs && jcr->IsIncomplete() && jcr->is_JobType(JT_BACKUP) && !jcr->is_JobLevel(L_BASE)) || /* * Check for failed jobs */ - (jcr->res.job->RescheduleOnError && !jcr->IsTerminatedOk() && + (jcr->impl_->res.job->RescheduleOnError && !jcr->IsTerminatedOk() && !jcr->is_JobStatus(JS_Canceled) && jcr->is_JobType(JT_BACKUP)); } @@ -680,19 +683,19 @@ static bool RescheduleJob(JobControlRecord* jcr, jobq_t* jq, jobq_item_t* je) * possible. */ now = time(NULL); - jcr->reschedule_count++; - jcr->sched_time = now + jcr->res.job->RescheduleInterval; + jcr->impl_->reschedule_count++; + jcr->sched_time = now + jcr->impl_->res.job->RescheduleInterval; bstrftime(dt, sizeof(dt), now); bstrftime(dt2, sizeof(dt2), jcr->sched_time); Dmsg4(2300, "Rescheduled Job %s to re-run in %d seconds.(now=%u,then=%u)\n", - jcr->Job, (int)jcr->res.job->RescheduleInterval, now, + jcr->Job, (int)jcr->impl_->res.job->RescheduleInterval, now, jcr->sched_time); Jmsg(jcr, M_INFO, 0, _("Rescheduled Job %s at %s to re-run in %d seconds (%s).\n"), - jcr->Job, dt, (int)jcr->res.job->RescheduleInterval, dt2); + jcr->Job, dt, (int)jcr->impl_->res.job->RescheduleInterval, dt2); DirdFreeJcrPointers(jcr); /* partial cleanup old stuff */ jcr->JobStatus = -1; - jcr->SDJobStatus = 0; + jcr->impl_->SDJobStatus = 0; jcr->JobErrors = 0; if (!AllowDuplicateJob(jcr)) { return false; } @@ -704,7 +707,7 @@ static bool RescheduleJob(JobControlRecord* jcr, jobq_t* jq, jobq_item_t* je) UpdateJobEnd(jcr, JS_WaitStartTime); Dmsg2(2300, "Requeue job=%d use=%d\n", jcr->JobId, jcr->UseCount()); V(jq->mutex); - jcr->jr.RealEndTime = 0; + jcr->impl_->jr.RealEndTime = 0; JobqAdd(jq, jcr); /* queue the job to run again */ P(jq->mutex); FreeJcr(jcr); /* release jcr */ @@ -720,37 +723,43 @@ static bool RescheduleJob(JobControlRecord* jcr, jobq_t* jq, jobq_item_t* je) * appropriate fields. */ jcr->setJobStatus(JS_WaitStartTime); - njcr = new_jcr(sizeof(JobControlRecord), DirdFreeJcr); - SetJcrDefaults(njcr, jcr->res.job); - njcr->reschedule_count = jcr->reschedule_count; + njcr = NewDirectorJcr(); + SetJcrDefaults(njcr, jcr->impl_->res.job); + njcr->impl_->reschedule_count = jcr->impl_->reschedule_count; njcr->sched_time = jcr->sched_time; njcr->initial_sched_time = jcr->initial_sched_time; njcr->setJobLevel(jcr->getJobLevel()); - njcr->res.pool = jcr->res.pool; - njcr->res.run_pool_override = jcr->res.run_pool_override; - njcr->res.full_pool = jcr->res.full_pool; - njcr->res.run_full_pool_override = jcr->res.run_full_pool_override; - njcr->res.inc_pool = jcr->res.inc_pool; - njcr->res.run_inc_pool_override = jcr->res.run_inc_pool_override; - njcr->res.diff_pool = jcr->res.diff_pool; - njcr->res.run_diff_pool_override = jcr->res.run_diff_pool_override; - njcr->res.next_pool = jcr->res.next_pool; - njcr->res.run_next_pool_override = jcr->res.run_next_pool_override; + njcr->impl_->res.pool = jcr->impl_->res.pool; + njcr->impl_->res.run_pool_override = jcr->impl_->res.run_pool_override; + njcr->impl_->res.full_pool = jcr->impl_->res.full_pool; + njcr->impl_->res.run_full_pool_override = + jcr->impl_->res.run_full_pool_override; + njcr->impl_->res.inc_pool = jcr->impl_->res.inc_pool; + njcr->impl_->res.run_inc_pool_override = + jcr->impl_->res.run_inc_pool_override; + njcr->impl_->res.diff_pool = jcr->impl_->res.diff_pool; + njcr->impl_->res.run_diff_pool_override = + jcr->impl_->res.run_diff_pool_override; + njcr->impl_->res.next_pool = jcr->impl_->res.next_pool; + njcr->impl_->res.run_next_pool_override = + jcr->impl_->res.run_next_pool_override; njcr->JobStatus = -1; njcr->setJobStatus(jcr->JobStatus); - if (jcr->res.read_storage) { - CopyRstorage(njcr, jcr->res.read_storage_list, _("previous Job")); + if (jcr->impl_->res.read_storage) { + CopyRstorage(njcr, jcr->impl_->res.read_storage_list, + _("previous Job")); } else { FreeRstorage(njcr); } - if (jcr->res.write_storage) { - CopyWstorage(njcr, jcr->res.write_storage_list, _("previous Job")); + if (jcr->impl_->res.write_storage) { + CopyWstorage(njcr, jcr->impl_->res.write_storage_list, + _("previous Job")); } else { FreeWstorage(njcr); } - njcr->res.messages = jcr->res.messages; - njcr->spool_data = jcr->spool_data; + njcr->impl_->res.messages = jcr->impl_->res.messages; + njcr->impl_->spool_data = jcr->impl_->spool_data; Dmsg0(2300, "Call to run new job\n"); V(jq->mutex); RunJob(njcr); /* This creates a "new" job */ @@ -775,7 +784,7 @@ static bool AcquireResources(JobControlRecord* jcr) /* * Set that we didn't acquire any resourse locks yet. */ - jcr->acquired_resource_locks = false; + jcr->impl_->acquired_resource_locks = false; /* * Some Job Types are excluded from the client and storage concurrency @@ -789,11 +798,11 @@ static bool AcquireResources(JobControlRecord* jcr) * Migration/Copy and Consolidation jobs are not counted for client * concurrency as they do not touch the client at all */ - jcr->IgnoreClientConcurrency = true; + jcr->impl_->IgnoreClientConcurrency = true; Dmsg1(200, "Skipping migrate/copy Job %s for client concurrency\n", jcr->Job); - if (jcr->MigrateJobId == 0) { + if (jcr->impl_->MigrateJobId == 0) { /* * Migration/Copy control jobs are not counted for storage concurrency * as they do not touch the storage at all @@ -801,14 +810,14 @@ static bool AcquireResources(JobControlRecord* jcr) Dmsg1(200, "Skipping migrate/copy Control Job %s for storage concurrency\n", jcr->Job); - jcr->IgnoreStorageConcurrency = true; + jcr->impl_->IgnoreStorageConcurrency = true; } break; default: break; } - if (jcr->res.read_storage) { + if (jcr->impl_->res.read_storage) { if (!IncReadStore(jcr)) { jcr->setJobStatus(JS_WaitStoreRes); @@ -816,7 +825,7 @@ static bool AcquireResources(JobControlRecord* jcr) } } - if (jcr->res.write_storage) { + if (jcr->impl_->res.write_storage) { if (!IncWriteStore(jcr)) { DecReadStore(jcr); jcr->setJobStatus(JS_WaitStoreRes); @@ -848,21 +857,23 @@ static bool AcquireResources(JobControlRecord* jcr) return false; } - jcr->acquired_resource_locks = true; + jcr->impl_->acquired_resource_locks = true; return true; } static bool IncClientConcurrency(JobControlRecord* jcr) { - if (!jcr->res.client || jcr->IgnoreClientConcurrency) { return true; } + if (!jcr->impl_->res.client || jcr->impl_->IgnoreClientConcurrency) { + return true; + } P(mutex); - if (jcr->res.client->rcs->NumConcurrentJobs < - jcr->res.client->MaxConcurrentJobs) { - jcr->res.client->rcs->NumConcurrentJobs++; - Dmsg2(50, "Inc Client=%s rncj=%d\n", jcr->res.client->resource_name_, - jcr->res.client->rcs->NumConcurrentJobs); + if (jcr->impl_->res.client->rcs->NumConcurrentJobs < + jcr->impl_->res.client->MaxConcurrentJobs) { + jcr->impl_->res.client->rcs->NumConcurrentJobs++; + Dmsg2(50, "Inc Client=%s rncj=%d\n", jcr->impl_->res.client->resource_name_, + jcr->impl_->res.client->rcs->NumConcurrentJobs); V(mutex); return true; @@ -875,13 +886,13 @@ static bool IncClientConcurrency(JobControlRecord* jcr) static void DecClientConcurrency(JobControlRecord* jcr) { - if (jcr->IgnoreClientConcurrency) { return; } + if (jcr->impl_->IgnoreClientConcurrency) { return; } P(mutex); - if (jcr->res.client) { - jcr->res.client->rcs->NumConcurrentJobs--; - Dmsg2(50, "Dec Client=%s rncj=%d\n", jcr->res.client->resource_name_, - jcr->res.client->rcs->NumConcurrentJobs); + if (jcr->impl_->res.client) { + jcr->impl_->res.client->rcs->NumConcurrentJobs--; + Dmsg2(50, "Dec Client=%s rncj=%d\n", jcr->impl_->res.client->resource_name_, + jcr->impl_->res.client->rcs->NumConcurrentJobs); } V(mutex); } @@ -889,10 +900,11 @@ static void DecClientConcurrency(JobControlRecord* jcr) static bool IncJobConcurrency(JobControlRecord* jcr) { P(mutex); - if (jcr->res.job->rjs->NumConcurrentJobs < jcr->res.job->MaxConcurrentJobs) { - jcr->res.job->rjs->NumConcurrentJobs++; - Dmsg2(50, "Inc Job=%s rncj=%d\n", jcr->res.job->resource_name_, - jcr->res.job->rjs->NumConcurrentJobs); + if (jcr->impl_->res.job->rjs->NumConcurrentJobs < + jcr->impl_->res.job->MaxConcurrentJobs) { + jcr->impl_->res.job->rjs->NumConcurrentJobs++; + Dmsg2(50, "Inc Job=%s rncj=%d\n", jcr->impl_->res.job->resource_name_, + jcr->impl_->res.job->rjs->NumConcurrentJobs); V(mutex); return true; @@ -906,9 +918,9 @@ static bool IncJobConcurrency(JobControlRecord* jcr) static void DecJobConcurrency(JobControlRecord* jcr) { P(mutex); - jcr->res.job->rjs->NumConcurrentJobs--; - Dmsg2(50, "Dec Job=%s rncj=%d\n", jcr->res.job->resource_name_, - jcr->res.job->rjs->NumConcurrentJobs); + jcr->impl_->res.job->rjs->NumConcurrentJobs--; + Dmsg2(50, "Dec Job=%s rncj=%d\n", jcr->impl_->res.job->resource_name_, + jcr->impl_->res.job->rjs->NumConcurrentJobs); V(mutex); } @@ -918,49 +930,58 @@ static void DecJobConcurrency(JobControlRecord* jcr) */ bool IncReadStore(JobControlRecord* jcr) { - if (jcr->IgnoreStorageConcurrency) { return true; } + if (jcr->impl_->IgnoreStorageConcurrency) { return true; } P(mutex); - if (jcr->res.read_storage->runtime_storage_status->NumConcurrentJobs < - jcr->res.read_storage->MaxConcurrentJobs) { - jcr->res.read_storage->runtime_storage_status->NumConcurrentReadJobs++; - jcr->res.read_storage->runtime_storage_status->NumConcurrentJobs++; - Dmsg2(50, "Inc Rstore=%s rncj=%d\n", jcr->res.read_storage->resource_name_, - jcr->res.read_storage->runtime_storage_status->NumConcurrentJobs); + if (jcr->impl_->res.read_storage->runtime_storage_status->NumConcurrentJobs < + jcr->impl_->res.read_storage->MaxConcurrentJobs) { + jcr->impl_->res.read_storage->runtime_storage_status + ->NumConcurrentReadJobs++; + jcr->impl_->res.read_storage->runtime_storage_status->NumConcurrentJobs++; + Dmsg2(50, "Inc Rstore=%s rncj=%d\n", + jcr->impl_->res.read_storage->resource_name_, + jcr->impl_->res.read_storage->runtime_storage_status + ->NumConcurrentJobs); V(mutex); return true; } V(mutex); - Dmsg2(50, "Fail to acquire Rstore=%s rncj=%d\n", - jcr->res.read_storage->resource_name_, - jcr->res.read_storage->runtime_storage_status->NumConcurrentJobs); + Dmsg2( + 50, "Fail to acquire Rstore=%s rncj=%d\n", + jcr->impl_->res.read_storage->resource_name_, + jcr->impl_->res.read_storage->runtime_storage_status->NumConcurrentJobs); return false; } void DecReadStore(JobControlRecord* jcr) { - if (jcr->res.read_storage && !jcr->IgnoreStorageConcurrency) { + if (jcr->impl_->res.read_storage && !jcr->impl_->IgnoreStorageConcurrency) { P(mutex); - jcr->res.read_storage->runtime_storage_status->NumConcurrentReadJobs--; - jcr->res.read_storage->runtime_storage_status->NumConcurrentJobs--; - Dmsg2(50, "Dec Rstore=%s rncj=%d\n", jcr->res.read_storage->resource_name_, - jcr->res.read_storage->runtime_storage_status->NumConcurrentJobs); - - if (jcr->res.read_storage->runtime_storage_status->NumConcurrentReadJobs < - 0) { - Jmsg( - jcr, M_FATAL, 0, _("NumConcurrentReadJobs Dec Rstore=%s rncj=%d\n"), - jcr->res.read_storage->resource_name_, - jcr->res.read_storage->runtime_storage_status->NumConcurrentReadJobs); + jcr->impl_->res.read_storage->runtime_storage_status + ->NumConcurrentReadJobs--; + jcr->impl_->res.read_storage->runtime_storage_status->NumConcurrentJobs--; + Dmsg2(50, "Dec Rstore=%s rncj=%d\n", + jcr->impl_->res.read_storage->resource_name_, + jcr->impl_->res.read_storage->runtime_storage_status + ->NumConcurrentJobs); + + if (jcr->impl_->res.read_storage->runtime_storage_status + ->NumConcurrentReadJobs < 0) { + Jmsg(jcr, M_FATAL, 0, _("NumConcurrentReadJobs Dec Rstore=%s rncj=%d\n"), + jcr->impl_->res.read_storage->resource_name_, + jcr->impl_->res.read_storage->runtime_storage_status + ->NumConcurrentReadJobs); } - if (jcr->res.read_storage->runtime_storage_status->NumConcurrentJobs < 0) { + if (jcr->impl_->res.read_storage->runtime_storage_status + ->NumConcurrentJobs < 0) { Jmsg(jcr, M_FATAL, 0, _("NumConcurrentJobs Dec Rstore=%s rncj=%d\n"), - jcr->res.read_storage->resource_name_, - jcr->res.read_storage->runtime_storage_status->NumConcurrentJobs); + jcr->impl_->res.read_storage->resource_name_, + jcr->impl_->res.read_storage->runtime_storage_status + ->NumConcurrentJobs); } V(mutex); } @@ -968,39 +989,46 @@ void DecReadStore(JobControlRecord* jcr) static bool IncWriteStore(JobControlRecord* jcr) { - if (jcr->IgnoreStorageConcurrency) { return true; } + if (jcr->impl_->IgnoreStorageConcurrency) { return true; } P(mutex); - if (jcr->res.write_storage->runtime_storage_status->NumConcurrentJobs < - jcr->res.write_storage->MaxConcurrentJobs) { - jcr->res.write_storage->runtime_storage_status->NumConcurrentJobs++; - Dmsg2(50, "Inc Wstore=%s wncj=%d\n", jcr->res.write_storage->resource_name_, - jcr->res.write_storage->runtime_storage_status->NumConcurrentJobs); + if (jcr->impl_->res.write_storage->runtime_storage_status->NumConcurrentJobs < + jcr->impl_->res.write_storage->MaxConcurrentJobs) { + jcr->impl_->res.write_storage->runtime_storage_status->NumConcurrentJobs++; + Dmsg2(50, "Inc Wstore=%s wncj=%d\n", + jcr->impl_->res.write_storage->resource_name_, + jcr->impl_->res.write_storage->runtime_storage_status + ->NumConcurrentJobs); V(mutex); return true; } V(mutex); - Dmsg2(50, "Fail to acquire Wstore=%s wncj=%d\n", - jcr->res.write_storage->resource_name_, - jcr->res.write_storage->runtime_storage_status->NumConcurrentJobs); + Dmsg2( + 50, "Fail to acquire Wstore=%s wncj=%d\n", + jcr->impl_->res.write_storage->resource_name_, + jcr->impl_->res.write_storage->runtime_storage_status->NumConcurrentJobs); return false; } static void DecWriteStore(JobControlRecord* jcr) { - if (jcr->res.write_storage && !jcr->IgnoreStorageConcurrency) { + if (jcr->impl_->res.write_storage && !jcr->impl_->IgnoreStorageConcurrency) { P(mutex); - jcr->res.write_storage->runtime_storage_status->NumConcurrentJobs--; - Dmsg2(50, "Dec Wstore=%s wncj=%d\n", jcr->res.write_storage->resource_name_, - jcr->res.write_storage->runtime_storage_status->NumConcurrentJobs); - - if (jcr->res.write_storage->runtime_storage_status->NumConcurrentJobs < 0) { + jcr->impl_->res.write_storage->runtime_storage_status->NumConcurrentJobs--; + Dmsg2(50, "Dec Wstore=%s wncj=%d\n", + jcr->impl_->res.write_storage->resource_name_, + jcr->impl_->res.write_storage->runtime_storage_status + ->NumConcurrentJobs); + + if (jcr->impl_->res.write_storage->runtime_storage_status + ->NumConcurrentJobs < 0) { Jmsg(jcr, M_FATAL, 0, _("NumConcurrentJobs Dec Wstore=%s wncj=%d\n"), - jcr->res.write_storage->resource_name_, - jcr->res.write_storage->runtime_storage_status->NumConcurrentJobs); + jcr->impl_->res.write_storage->resource_name_, + jcr->impl_->res.write_storage->runtime_storage_status + ->NumConcurrentJobs); } V(mutex); } diff --git a/core/src/dird/migrate.cc b/core/src/dird/migrate.cc index 25305162bb8..467cc0ccfc5 100644 --- a/core/src/dird/migrate.cc +++ b/core/src/dird/migrate.cc @@ -42,6 +42,7 @@ #include "dird.h" #include "dird/dird_globals.h" #include "dird/backup.h" +#include "dird/jcr_private.h" #include "dird/job.h" #include "dird/migration.h" #include "dird/msgchan.h" @@ -293,7 +294,7 @@ static inline bool SetMigrationNextPool(JobControlRecord* jcr, * Get the PoolId used with the original job. Then * find the pool name from the database record. */ - pr.PoolId = jcr->jr.PoolId; + pr.PoolId = jcr->impl_->jr.PoolId; if (!jcr->db->GetPoolRecord(jcr, &pr)) { Jmsg(jcr, M_FATAL, 0, _("Pool for JobId %s not in database. ERR=%s\n"), edit_int64(pr.PoolId, ed1), jcr->db->strerror()); @@ -313,26 +314,26 @@ static inline bool SetMigrationNextPool(JobControlRecord* jcr, /* * See if there is a next pool override. */ - if (jcr->res.run_next_pool_override) { - PmStrcpy(jcr->res.npool_source, _("Run NextPool override")); - PmStrcpy(jcr->res.pool_source, _("Run NextPool override")); + if (jcr->impl_->res.run_next_pool_override) { + PmStrcpy(jcr->impl_->res.npool_source, _("Run NextPool override")); + PmStrcpy(jcr->impl_->res.pool_source, _("Run NextPool override")); storage_source = _("Storage from Run NextPool override"); } else { /* * See if there is a next pool override in the Job definition. */ - if (jcr->res.job->next_pool) { - jcr->res.next_pool = jcr->res.job->next_pool; - PmStrcpy(jcr->res.npool_source, _("Job's NextPool resource")); - PmStrcpy(jcr->res.pool_source, _("Job's NextPool resource")); + if (jcr->impl_->res.job->next_pool) { + jcr->impl_->res.next_pool = jcr->impl_->res.job->next_pool; + PmStrcpy(jcr->impl_->res.npool_source, _("Job's NextPool resource")); + PmStrcpy(jcr->impl_->res.pool_source, _("Job's NextPool resource")); storage_source = _("Storage from Job's NextPool resource"); } else { /* * Fall back to the pool's NextPool definition. */ - jcr->res.next_pool = pool->NextPool; - PmStrcpy(jcr->res.npool_source, _("Job Pool's NextPool resource")); - PmStrcpy(jcr->res.pool_source, _("Job Pool's NextPool resource")); + jcr->impl_->res.next_pool = pool->NextPool; + PmStrcpy(jcr->impl_->res.npool_source, _("Job Pool's NextPool resource")); + PmStrcpy(jcr->impl_->res.pool_source, _("Job Pool's NextPool resource")); storage_source = _("Storage from Pool's NextPool resource"); } } @@ -342,19 +343,21 @@ static inline bool SetMigrationNextPool(JobControlRecord* jcr, * record exists in the database. Note, in this case, we * will be migrating from pool to pool->NextPool. */ - if (jcr->res.next_pool) { - jcr->jr.PoolId = - GetOrCreatePoolRecord(jcr, jcr->res.next_pool->resource_name_); - if (jcr->jr.PoolId == 0) { return false; } + if (jcr->impl_->res.next_pool) { + jcr->impl_->jr.PoolId = + GetOrCreatePoolRecord(jcr, jcr->impl_->res.next_pool->resource_name_); + if (jcr->impl_->jr.PoolId == 0) { return false; } } - if (!SetMigrationWstorage(jcr, pool, jcr->res.next_pool, storage_source)) { + if (!SetMigrationWstorage(jcr, pool, jcr->impl_->res.next_pool, + storage_source)) { return false; } - jcr->res.pool = jcr->res.next_pool; + jcr->impl_->res.pool = jcr->impl_->res.next_pool; Dmsg2(dbglevel, "Write pool=%s read rpool=%s\n", - jcr->res.pool->resource_name_, jcr->res.rpool->resource_name_); + jcr->impl_->res.pool->resource_name_, + jcr->impl_->res.rpool->resource_name_); return true; } @@ -366,8 +369,8 @@ static inline bool SameStorage(JobControlRecord* jcr) { StorageResource *read_store, *write_store; - read_store = (StorageResource*)jcr->res.read_storage_list->first(); - write_store = (StorageResource*)jcr->res.write_storage_list->first(); + read_store = (StorageResource*)jcr->impl_->res.read_storage_list->first(); + write_store = (StorageResource*)jcr->impl_->res.write_storage_list->first(); if (!read_store->autochanger && !write_store->autochanger && bstrcmp(read_store->resource_name_, write_store->resource_name_)) { @@ -387,25 +390,27 @@ static inline void StartNewMigrationJob(JobControlRecord* jcr) ua = new_ua_context(jcr); ua->batch = true; Mmsg(ua->cmd, "run job=\"%s\" jobid=%s ignoreduplicatecheck=yes", - jcr->res.job->resource_name_, edit_uint64(jcr->MigrateJobId, ed1)); + jcr->impl_->res.job->resource_name_, + edit_uint64(jcr->impl_->MigrateJobId, ed1)); /* * Make sure we have something to compare against. */ - if (jcr->res.pool) { + if (jcr->impl_->res.pool) { /* * See if there was actually a pool override. */ - if (jcr->res.pool != jcr->res.job->pool) { - Mmsg(cmd, " pool=\"%s\"", jcr->res.pool->resource_name_); + if (jcr->impl_->res.pool != jcr->impl_->res.job->pool) { + Mmsg(cmd, " pool=\"%s\"", jcr->impl_->res.pool->resource_name_); PmStrcat(ua->cmd, cmd.c_str()); } /* * See if there was actually a next pool override. */ - if (jcr->res.next_pool && jcr->res.next_pool != jcr->res.pool->NextPool) { - Mmsg(cmd, " nextpool=\"%s\"", jcr->res.next_pool->resource_name_); + if (jcr->impl_->res.next_pool && + jcr->impl_->res.next_pool != jcr->impl_->res.pool->NextPool) { + Mmsg(cmd, " nextpool=\"%s\"", jcr->impl_->res.next_pool->resource_name_); PmStrcat(ua->cmd, cmd.c_str()); } } @@ -603,7 +608,7 @@ static bool find_mediaid_then_jobids(JobControlRecord* jcr, /* * Basic query for MediaId */ - Mmsg(query, query1, jcr->res.rpool->resource_name_); + Mmsg(query, query1, jcr->impl_->res.rpool->resource_name_); if (!jcr->db->SqlQuery(query.c_str(), UniqueDbidHandler, (void*)ids)) { Jmsg(jcr, M_FATAL, 0, _("SQL failed. ERR=%s\n"), jcr->db->strerror()); goto bail_out; @@ -650,8 +655,9 @@ static inline bool FindJobidsOfPoolUncopiedJobs(JobControlRecord* jcr, } Dmsg1(dbglevel, "copy selection pattern=%s\n", - jcr->res.rpool->resource_name_); - Mmsg(query, sql_jobids_of_pool_uncopied_jobs, jcr->res.rpool->resource_name_); + jcr->impl_->res.rpool->resource_name_); + Mmsg(query, sql_jobids_of_pool_uncopied_jobs, + jcr->impl_->res.rpool->resource_name_); Dmsg1(dbglevel, "get uncopied jobs query=%s\n", query.c_str()); if (!jcr->db->SqlQuery(query.c_str(), UniqueDbidHandler, (void*)ids)) { Jmsg(jcr, M_FATAL, 0, _("SQL to get uncopied jobs failed. ERR=%s\n"), @@ -680,17 +686,18 @@ static bool regex_find_jobids(JobControlRecord* jcr, PoolMem query(PM_MESSAGE); item_chain = new dlist(item, &item->link); - if (!jcr->res.job->selection_pattern) { + if (!jcr->impl_->res.job->selection_pattern) { Jmsg(jcr, M_FATAL, 0, _("No %s %s selection pattern specified.\n"), jcr->get_OperationName(), type); goto bail_out; } - Dmsg1(dbglevel, "regex-sel-pattern=%s\n", jcr->res.job->selection_pattern); + Dmsg1(dbglevel, "regex-sel-pattern=%s\n", + jcr->impl_->res.job->selection_pattern); /* * Basic query for names */ - Mmsg(query, query1, jcr->res.rpool->resource_name_); + Mmsg(query, query1, jcr->impl_->res.rpool->resource_name_); Dmsg1(dbglevel, "get name query1=%s\n", query.c_str()); if (!jcr->db->SqlQuery(query.c_str(), UniqueNameHandler, (void*)item_chain)) { Jmsg(jcr, M_FATAL, 0, _("SQL to get %s failed. ERR=%s\n"), type, @@ -700,19 +707,19 @@ static bool regex_find_jobids(JobControlRecord* jcr, Dmsg1(dbglevel, "query1 returned %d names\n", item_chain->size()); if (item_chain->size() == 0) { Jmsg(jcr, M_INFO, 0, _("Query of Pool \"%s\" returned no Jobs to %s.\n"), - jcr->res.rpool->resource_name_, jcr->get_ActionName()); + jcr->impl_->res.rpool->resource_name_, jcr->get_ActionName()); ok = true; goto bail_out; /* skip regex match */ } else { /* * Compile regex expression */ - rc = regcomp(&preg, jcr->res.job->selection_pattern, REG_EXTENDED); + rc = regcomp(&preg, jcr->impl_->res.job->selection_pattern, REG_EXTENDED); if (rc != 0) { regerror(rc, &preg, prbuf, sizeof(prbuf)); Jmsg(jcr, M_FATAL, 0, _("Could not compile regex pattern \"%s\" ERR=%s\n"), - jcr->res.job->selection_pattern, prbuf); + jcr->impl_->res.job->selection_pattern, prbuf); goto bail_out; } @@ -758,7 +765,7 @@ static bool regex_find_jobids(JobControlRecord* jcr, ids->count = 0; foreach_dlist (item, item_chain) { Dmsg2(dbglevel, "Got %s: %s\n", type, item->item); - Mmsg(query, query2, item->item, jcr->res.rpool->resource_name_); + Mmsg(query, query2, item->item, jcr->impl_->res.rpool->resource_name_); Dmsg1(dbglevel, "get id from name query2=%s\n", query.c_str()); if (!jcr->db->SqlQuery(query.c_str(), UniqueDbidHandler, (void*)ids)) { Jmsg(jcr, M_FATAL, 0, _("SQL failed. ERR=%s\n"), jcr->db->strerror()); @@ -813,7 +820,7 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr) mid.list = NULL; jids.list = NULL; - switch (jcr->res.job->selection_type) { + switch (jcr->impl_->res.job->selection_type) { case MT_JOB: if (!regex_find_jobids(jcr, &ids, sql_job, sql_jobids_from_job, "Job")) { goto bail_out; @@ -832,14 +839,14 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr) } break; case MT_SQLQUERY: - if (!jcr->res.job->selection_pattern) { + if (!jcr->impl_->res.job->selection_pattern) { Jmsg(jcr, M_FATAL, 0, _("No %s SQL selection pattern specified.\n"), jcr->get_OperationName()); goto bail_out; } - Dmsg1(dbglevel, "SQL=%s\n", jcr->res.job->selection_pattern); - if (!jcr->db->SqlQuery(jcr->res.job->selection_pattern, UniqueDbidHandler, - (void*)&ids)) { + Dmsg1(dbglevel, "SQL=%s\n", jcr->impl_->res.job->selection_pattern); + if (!jcr->db->SqlQuery(jcr->impl_->res.job->selection_pattern, + UniqueDbidHandler, (void*)&ids)) { Jmsg(jcr, M_FATAL, 0, _("SQL failed. ERR=%s\n"), jcr->db->strerror()); goto bail_out; } @@ -871,7 +878,7 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr) /* * Find count of bytes in pool */ - Mmsg(query, sql_pool_bytes, jcr->res.rpool->resource_name_); + Mmsg(query, sql_pool_bytes, jcr->impl_->res.rpool->resource_name_); if (!jcr->db->SqlQuery(query.c_str(), db_int64_handler, (void*)&ctx)) { Jmsg(jcr, M_FATAL, 0, _("SQL failed. ERR=%s\n"), jcr->db->strerror()); @@ -887,9 +894,9 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr) pool_bytes = ctx.value; Dmsg2(dbglevel, "highbytes=%lld pool=%lld\n", - jcr->res.rpool->MigrationHighBytes, pool_bytes); + jcr->impl_->res.rpool->MigrationHighBytes, pool_bytes); - if (pool_bytes < (int64_t)jcr->res.rpool->MigrationHighBytes) { + if (pool_bytes < (int64_t)jcr->impl_->res.rpool->MigrationHighBytes) { Jmsg(jcr, M_INFO, 0, _("No Volumes found to %s.\n"), jcr->get_ActionName()); retval = true; @@ -902,7 +909,7 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr) /* * Find a list of MediaIds that could be migrated */ - Mmsg(query, sql_mediaids, jcr->res.rpool->resource_name_); + Mmsg(query, sql_mediaids, jcr->impl_->res.rpool->resource_name_); Dmsg1(dbglevel, "query=%s\n", query.c_str()); if (!jcr->db->SqlQuery(query.c_str(), UniqueDbidHandler, (void*)&ids)) { @@ -956,9 +963,10 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr) Dmsg2(dbglevel, "Total %s Job bytes=%s\n", jcr->get_ActionName(), edit_int64_with_commas(ctx.value, ed1)); Dmsg2(dbglevel, "lowbytes=%s poolafter=%s\n", - edit_int64_with_commas(jcr->res.rpool->MigrationLowBytes, ed1), + edit_int64_with_commas(jcr->impl_->res.rpool->MigrationLowBytes, + ed1), edit_int64_with_commas(pool_bytes, ed2)); - if (pool_bytes <= (int64_t)jcr->res.rpool->MigrationLowBytes) { + if (pool_bytes <= (int64_t)jcr->impl_->res.rpool->MigrationLowBytes) { Dmsg0(dbglevel, "We should be done.\n"); break; } @@ -976,11 +984,11 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr) time_t ttime; char dt[MAX_TIME_LENGTH]; - ttime = time(NULL) - (time_t)jcr->res.rpool->MigrationTime; + ttime = time(NULL) - (time_t)jcr->impl_->res.rpool->MigrationTime; bstrutime(dt, sizeof(dt), ttime); ids.count = 0; - Mmsg(query, sql_pool_time, jcr->res.rpool->resource_name_, dt); + Mmsg(query, sql_pool_time, jcr->impl_->res.rpool->resource_name_, dt); Dmsg1(dbglevel, "query=%s\n", query.c_str()); if (!jcr->db->SqlQuery(query.c_str(), UniqueDbidHandler, (void*)&ids)) { @@ -1022,8 +1030,8 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr) /* * Note: to not over load the system, limit the number of new jobs started. */ - if (jcr->res.job->MaxConcurrentCopies) { - limit = jcr->res.job->MaxConcurrentCopies; + if (jcr->impl_->res.job->MaxConcurrentCopies) { + limit = jcr->impl_->res.job->MaxConcurrentCopies; apply_limit = true; } @@ -1041,7 +1049,7 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr) retval = true; goto bail_out; } - jcr->MigrateJobId = JobId; + jcr->impl_->MigrateJobId = JobId; if (apply_limit) { /* @@ -1055,7 +1063,7 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr) Dmsg0(dbglevel, "Back from StartNewMigrationJob\n"); } - jcr->HasSelectedJobs = true; + jcr->impl_->HasSelectedJobs = true; retval = true; bail_out: @@ -1089,8 +1097,9 @@ bool DoMigrationInit(JobControlRecord* jcr) if (!AllowDuplicateJob(jcr)) { return false; } - jcr->jr.PoolId = GetOrCreatePoolRecord(jcr, jcr->res.pool->resource_name_); - if (jcr->jr.PoolId == 0) { + jcr->impl_->jr.PoolId = + GetOrCreatePoolRecord(jcr, jcr->impl_->res.pool->resource_name_); + if (jcr->impl_->jr.PoolId == 0) { Dmsg1(dbglevel, "JobId=%d no PoolId\n", (int)jcr->JobId); Jmsg(jcr, M_FATAL, 0, _("Could not get or create a Pool record.\n")); return false; @@ -1102,46 +1111,50 @@ bool DoMigrationInit(JobControlRecord* jcr) * pool will be changed to point to the write pool, * which comes from pool->NextPool. */ - jcr->res.rpool = jcr->res.pool; /* save read pool */ - PmStrcpy(jcr->res.rpool_source, jcr->res.pool_source); - Dmsg2(dbglevel, "Read pool=%s (From %s)\n", jcr->res.rpool->resource_name_, - jcr->res.rpool_source); + jcr->impl_->res.rpool = jcr->impl_->res.pool; /* save read pool */ + PmStrcpy(jcr->impl_->res.rpool_source, jcr->impl_->res.pool_source); + Dmsg2(dbglevel, "Read pool=%s (From %s)\n", + jcr->impl_->res.rpool->resource_name_, jcr->impl_->res.rpool_source); /* * See if this is a control job e.g. the one that selects the Jobs to Migrate * or Copy or one of the worker Jobs that do the actual Migration or Copy. If - * jcr->MigrateJobId is set we know that its an actual Migration or Copy Job. + * jcr->impl_->MigrateJobId is set we know that its an actual Migration or + * Copy Job. */ - if (jcr->MigrateJobId != 0) { - Dmsg1(dbglevel, "At Job start previous jobid=%u\n", jcr->MigrateJobId); + if (jcr->impl_->MigrateJobId != 0) { + Dmsg1(dbglevel, "At Job start previous jobid=%u\n", + jcr->impl_->MigrateJobId); - jcr->previous_jr.JobId = jcr->MigrateJobId; - Dmsg1(dbglevel, "Previous jobid=%d\n", (int)jcr->previous_jr.JobId); + jcr->impl_->previous_jr.JobId = jcr->impl_->MigrateJobId; + Dmsg1(dbglevel, "Previous jobid=%d\n", (int)jcr->impl_->previous_jr.JobId); - if (!jcr->db->GetJobRecord(jcr, &jcr->previous_jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->previous_jr)) { Jmsg(jcr, M_FATAL, 0, _("Could not get job record for JobId %s to %s. ERR=%s"), - edit_int64(jcr->previous_jr.JobId, ed1), jcr->get_ActionName(), - jcr->db->strerror()); + edit_int64(jcr->impl_->previous_jr.JobId, ed1), + jcr->get_ActionName(), jcr->db->strerror()); return false; } Jmsg(jcr, M_INFO, 0, _("%s using JobId=%s Job=%s\n"), - jcr->get_OperationName(), edit_int64(jcr->previous_jr.JobId, ed1), - jcr->previous_jr.Job); + jcr->get_OperationName(), + edit_int64(jcr->impl_->previous_jr.JobId, ed1), + jcr->impl_->previous_jr.Job); Dmsg4(dbglevel, "%s JobId=%d using JobId=%s Job=%s\n", jcr->get_OperationName(), jcr->JobId, - edit_int64(jcr->previous_jr.JobId, ed1), jcr->previous_jr.Job); + edit_int64(jcr->impl_->previous_jr.JobId, ed1), + jcr->impl_->previous_jr.Job); if (CreateRestoreBootstrapFile(jcr) < 0) { Jmsg(jcr, M_FATAL, 0, _("Create bootstrap file failed.\n")); return false; } - if (jcr->previous_jr.JobId == 0 || jcr->ExpectedFiles == 0) { + if (jcr->impl_->previous_jr.JobId == 0 || jcr->impl_->ExpectedFiles == 0) { jcr->setJobStatus(JS_Terminated); Dmsg1(dbglevel, "JobId=%d expected files == 0\n", (int)jcr->JobId); - if (jcr->previous_jr.JobId == 0) { + if (jcr->impl_->previous_jr.JobId == 0) { Jmsg(jcr, M_INFO, 0, _("No previous Job found to %s.\n"), jcr->get_ActionName()); } else { @@ -1153,22 +1166,22 @@ bool DoMigrationInit(JobControlRecord* jcr) } Dmsg5(dbglevel, "JobId=%d: Current: Name=%s JobId=%d Type=%c Level=%c\n", - (int)jcr->JobId, jcr->jr.Name, (int)jcr->jr.JobId, jcr->jr.JobType, - jcr->jr.JobLevel); + (int)jcr->JobId, jcr->impl_->jr.Name, (int)jcr->impl_->jr.JobId, + jcr->impl_->jr.JobType, jcr->impl_->jr.JobLevel); - job = (JobResource*)my_config->GetResWithName(R_JOB, jcr->jr.Name); - prev_job = - (JobResource*)my_config->GetResWithName(R_JOB, jcr->previous_jr.Name); + job = (JobResource*)my_config->GetResWithName(R_JOB, jcr->impl_->jr.Name); + prev_job = (JobResource*)my_config->GetResWithName( + R_JOB, jcr->impl_->previous_jr.Name); if (!job) { Jmsg(jcr, M_FATAL, 0, _("Job resource not found for \"%s\".\n"), - jcr->jr.Name); + jcr->impl_->jr.Name); return false; } if (!prev_job) { Jmsg(jcr, M_FATAL, 0, _("Previous Job resource not found for \"%s\".\n"), - jcr->previous_jr.Name); + jcr->impl_->previous_jr.Name); return false; } @@ -1183,31 +1196,33 @@ bool DoMigrationInit(JobControlRecord* jcr) * If the current Job has no explicit client set use the client setting of * the previous Job. */ - if (!jcr->res.client && prev_job->client) { - jcr->res.client = prev_job->client; + if (!jcr->impl_->res.client && prev_job->client) { + jcr->impl_->res.client = prev_job->client; if (!jcr->client_name) { jcr->client_name = GetPoolMemory(PM_NAME); } - PmStrcpy(jcr->client_name, jcr->res.client->resource_name_); + PmStrcpy(jcr->client_name, jcr->impl_->res.client->resource_name_); } /* * If the current Job has no explicit fileset set use the client setting of * the previous Job. */ - if (!jcr->res.fileset) { jcr->res.fileset = prev_job->fileset; } + if (!jcr->impl_->res.fileset) { + jcr->impl_->res.fileset = prev_job->fileset; + } /* * See if spooling data is not enabled yet. If so turn on spooling if * requested in job */ - if (!jcr->spool_data) { jcr->spool_data = job->spool_data; } + if (!jcr->impl_->spool_data) { jcr->impl_->spool_data = job->spool_data; } /* * Create a migration jcr */ - mig_jcr = new_jcr(sizeof(JobControlRecord), DirdFreeJcr); - jcr->mig_jcr = mig_jcr; - memcpy(&mig_jcr->previous_jr, &jcr->previous_jr, - sizeof(mig_jcr->previous_jr)); + mig_jcr = NewDirectorJcr(); + jcr->impl_->mig_jcr = mig_jcr; + memcpy(&mig_jcr->impl_->previous_jr, &jcr->impl_->previous_jr, + sizeof(mig_jcr->impl_->previous_jr)); /* * Turn the mig_jcr into a "real" job that takes on the aspects of @@ -1225,19 +1240,19 @@ bool DoMigrationInit(JobControlRecord* jcr) /* * Don't let Watchdog checks Max*Time value on this Job */ - mig_jcr->no_maxtime = true; + mig_jcr->impl_->no_maxtime = true; /* * Don't check for duplicates on migration and copy jobs */ - mig_jcr->IgnoreDuplicateJobChecking = true; + mig_jcr->impl_->IgnoreDuplicateJobChecking = true; /* * Copy some overwrites back from the Control Job to the migration and copy * job. */ - mig_jcr->spool_data = jcr->spool_data; - mig_jcr->spool_size = jcr->spool_size; + mig_jcr->impl_->spool_data = jcr->impl_->spool_data; + mig_jcr->impl_->spool_size = jcr->impl_->spool_size; if (!SetupJob(mig_jcr, true)) { @@ -1253,13 +1268,14 @@ bool DoMigrationInit(JobControlRecord* jcr) /* * Now reset the job record from the previous job */ - memcpy(&mig_jcr->jr, &jcr->previous_jr, sizeof(mig_jcr->jr)); + memcpy(&mig_jcr->impl_->jr, &jcr->impl_->previous_jr, + sizeof(mig_jcr->impl_->jr)); /* * Update the jr to reflect the new values of PoolId and JobId. */ - mig_jcr->jr.PoolId = jcr->jr.PoolId; - mig_jcr->jr.JobId = mig_jcr->JobId; + mig_jcr->impl_->jr.PoolId = jcr->impl_->jr.PoolId; + mig_jcr->impl_->jr.JobId = mig_jcr->JobId; if (SetMigrationNextPool(jcr, &pool)) { /* @@ -1268,9 +1284,9 @@ bool DoMigrationInit(JobControlRecord* jcr) CopyRstorage(mig_jcr, pool->storage, _("Pool resource")); CopyRstorage(jcr, pool->storage, _("Pool resource")); - mig_jcr->res.pool = jcr->res.pool; - mig_jcr->res.next_pool = jcr->res.next_pool; - mig_jcr->jr.PoolId = jcr->jr.PoolId; + mig_jcr->impl_->res.pool = jcr->impl_->res.pool; + mig_jcr->impl_->res.next_pool = jcr->impl_->res.next_pool; + mig_jcr->impl_->jr.PoolId = jcr->impl_->jr.PoolId; } /* @@ -1278,7 +1294,7 @@ bool DoMigrationInit(JobControlRecord* jcr) * This only happens when the original pool used doesn't have an explicit * storage. */ - if (!jcr->res.read_storage_list) { + if (!jcr->impl_->res.read_storage_list) { CopyRstorage(jcr, prev_job->storage, _("previous Job")); } @@ -1288,18 +1304,18 @@ bool DoMigrationInit(JobControlRecord* jcr) * otherwise we open a connection to the reading SD and a second * one to the writing SD. */ - jcr->remote_replicate = - !IsSameStorageDaemon(jcr->res.read_storage, jcr->res.write_storage); + jcr->impl_->remote_replicate = !IsSameStorageDaemon( + jcr->impl_->res.read_storage, jcr->impl_->res.write_storage); /* * set the JobLevel to what the original job was */ - mig_jcr->setJobLevel(mig_jcr->previous_jr.JobLevel); + mig_jcr->setJobLevel(mig_jcr->impl_->previous_jr.JobLevel); Dmsg4(dbglevel, "mig_jcr: Name=%s JobId=%d Type=%c Level=%c\n", - mig_jcr->jr.Name, (int)mig_jcr->jr.JobId, mig_jcr->jr.JobType, - mig_jcr->jr.JobLevel); + mig_jcr->impl_->jr.Name, (int)mig_jcr->impl_->jr.JobId, + mig_jcr->impl_->jr.JobType, mig_jcr->impl_->jr.JobLevel); } return true; @@ -1337,19 +1353,19 @@ static inline bool DoActualMigration(JobControlRecord* jcr) { char ed1[100]; bool retval = false; - JobControlRecord* mig_jcr = jcr->mig_jcr; + JobControlRecord* mig_jcr = jcr->impl_->mig_jcr; ASSERT(mig_jcr); /* * Make sure this job was not already migrated */ - if (jcr->previous_jr.JobType != JT_BACKUP && - jcr->previous_jr.JobType != JT_JOB_COPY) { + if (jcr->impl_->previous_jr.JobType != JT_BACKUP && + jcr->impl_->previous_jr.JobType != JT_JOB_COPY) { Jmsg(jcr, M_INFO, 0, _("JobId %s already %s probably by another Job. %s stopped.\n"), - edit_int64(jcr->previous_jr.JobId, ed1), jcr->get_ActionName(true), - jcr->get_OperationName()); + edit_int64(jcr->impl_->previous_jr.JobId, ed1), + jcr->get_ActionName(true), jcr->get_OperationName()); jcr->setJobStatus(JS_Terminated); MigrationCleanup(jcr, jcr->JobStatus); return true; @@ -1358,7 +1374,8 @@ static inline bool DoActualMigration(JobControlRecord* jcr) if (SameStorage(jcr)) { Jmsg(jcr, M_FATAL, 0, _("JobId %s cannot %s using the same read and write storage.\n"), - edit_int64(jcr->previous_jr.JobId, ed1), jcr->get_OperationName()); + edit_int64(jcr->impl_->previous_jr.JobId, ed1), + jcr->get_OperationName()); jcr->setJobStatus(JS_Terminated); MigrationCleanup(jcr, jcr->JobStatus); return true; @@ -1376,12 +1393,13 @@ static inline bool DoActualMigration(JobControlRecord* jcr) */ if (HasPairedStorage(jcr)) { SetPairedStorage(jcr); } - Dmsg2( - dbglevel, "Read store=%s, write store=%s\n", - ((StorageResource*)jcr->res.read_storage_list->first())->resource_name_, - ((StorageResource*)jcr->res.write_storage_list->first())->resource_name_); + Dmsg2(dbglevel, "Read store=%s, write store=%s\n", + ((StorageResource*)jcr->impl_->res.read_storage_list->first()) + ->resource_name_, + ((StorageResource*)jcr->impl_->res.write_storage_list->first()) + ->resource_name_); - if (jcr->remote_replicate) { + if (jcr->impl_->remote_replicate) { alist* write_storage_list; /* @@ -1391,12 +1409,12 @@ static inline bool DoActualMigration(JobControlRecord* jcr) * - Writing Storage Daemon bandwidth limiting * - Reading Storage Daemon bandwidth limiting */ - if (jcr->res.job->max_bandwidth > 0) { - jcr->max_bandwidth = jcr->res.job->max_bandwidth; - } else if (jcr->res.write_storage->max_bandwidth > 0) { - jcr->max_bandwidth = jcr->res.write_storage->max_bandwidth; - } else if (jcr->res.read_storage->max_bandwidth > 0) { - jcr->max_bandwidth = jcr->res.read_storage->max_bandwidth; + if (jcr->impl_->res.job->max_bandwidth > 0) { + jcr->max_bandwidth = jcr->impl_->res.job->max_bandwidth; + } else if (jcr->impl_->res.write_storage->max_bandwidth > 0) { + jcr->max_bandwidth = jcr->impl_->res.write_storage->max_bandwidth; + } else if (jcr->impl_->res.read_storage->max_bandwidth > 0) { + jcr->max_bandwidth = jcr->impl_->res.read_storage->max_bandwidth; } /* @@ -1409,15 +1427,15 @@ static inline bool DoActualMigration(JobControlRecord* jcr) * the jcr is connected to the reading storage daemon and the * mig_jcr to the writing storage daemon. */ - mig_jcr->res.write_storage = jcr->res.write_storage; - jcr->res.write_storage = NULL; + mig_jcr->impl_->res.write_storage = jcr->impl_->res.write_storage; + jcr->impl_->res.write_storage = NULL; /* * Swap the write_storage_list between the jcr and the mig_jcr. */ - write_storage_list = mig_jcr->res.write_storage_list; - mig_jcr->res.write_storage_list = jcr->res.write_storage_list; - jcr->res.write_storage_list = write_storage_list; + write_storage_list = mig_jcr->impl_->res.write_storage_list; + mig_jcr->impl_->res.write_storage_list = jcr->impl_->res.write_storage_list; + jcr->impl_->res.write_storage_list = write_storage_list; /* * Start conversation with Reading Storage daemon @@ -1443,7 +1461,7 @@ static inline bool DoActualMigration(JobControlRecord* jcr) /* * Now start a job with the Reading Storage daemon */ - if (!StartStorageDaemonJob(jcr, jcr->res.read_storage_list, NULL, + if (!StartStorageDaemonJob(jcr, jcr->impl_->res.read_storage_list, NULL, /* send_bsr */ true)) { goto bail_out; } @@ -1454,7 +1472,8 @@ static inline bool DoActualMigration(JobControlRecord* jcr) * Now start a job with the Writing Storage daemon */ - if (!StartStorageDaemonJob(mig_jcr, NULL, mig_jcr->res.write_storage_list, + if (!StartStorageDaemonJob(mig_jcr, NULL, + mig_jcr->impl_->res.write_storage_list, /* send_bsr */ false)) { goto bail_out; } @@ -1481,8 +1500,8 @@ static inline bool DoActualMigration(JobControlRecord* jcr) /* * Now start a job with the Storage daemon */ - if (!StartStorageDaemonJob(jcr, jcr->res.read_storage_list, - jcr->res.write_storage_list, + if (!StartStorageDaemonJob(jcr, jcr->impl_->res.read_storage_list, + jcr->impl_->res.write_storage_list, /* send_bsr */ true)) { FreePairedStorage(jcr); return false; @@ -1502,14 +1521,14 @@ static inline bool DoActualMigration(JobControlRecord* jcr) * is after the start of this run. */ jcr->start_time = time(NULL); - jcr->jr.StartTime = jcr->start_time; - jcr->jr.JobTDate = jcr->start_time; + jcr->impl_->jr.StartTime = jcr->start_time; + jcr->impl_->jr.JobTDate = jcr->start_time; jcr->setJobStatus(JS_Running); /* * Update job start record for this migration control job */ - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->jr)) { + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); goto bail_out; } @@ -1520,30 +1539,30 @@ static inline bool DoActualMigration(JobControlRecord* jcr) jcr->setJobStarted(); mig_jcr->start_time = time(NULL); - mig_jcr->jr.StartTime = mig_jcr->start_time; - mig_jcr->jr.JobTDate = mig_jcr->start_time; + mig_jcr->impl_->jr.StartTime = mig_jcr->start_time; + mig_jcr->impl_->jr.JobTDate = mig_jcr->start_time; mig_jcr->setJobStatus(JS_Running); /* * Update job start record for the real migration backup job */ - if (!mig_jcr->db->UpdateJobStartRecord(mig_jcr, &mig_jcr->jr)) { + if (!mig_jcr->db->UpdateJobStartRecord(mig_jcr, &mig_jcr->impl_->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", mig_jcr->db->strerror()); goto bail_out; } Dmsg4(dbglevel, "mig_jcr: Name=%s JobId=%d Type=%c Level=%c\n", - mig_jcr->jr.Name, (int)mig_jcr->jr.JobId, mig_jcr->jr.JobType, - mig_jcr->jr.JobLevel); + mig_jcr->impl_->jr.Name, (int)mig_jcr->impl_->jr.JobId, + mig_jcr->impl_->jr.JobType, mig_jcr->impl_->jr.JobLevel); /* * If we are connected to two different SDs tell the writing one * to be ready to receive the data and tell the reading one * to replicate to the other. */ - if (jcr->remote_replicate) { - StorageResource* write_storage = mig_jcr->res.write_storage; - StorageResource* read_storage = jcr->res.read_storage; + if (jcr->impl_->remote_replicate) { + StorageResource* write_storage = mig_jcr->impl_->res.write_storage; + StorageResource* read_storage = jcr->impl_->res.read_storage; PoolMem command(PM_MESSAGE); uint32_t tls_need = 0; @@ -1608,27 +1627,27 @@ static inline bool DoActualMigration(JobControlRecord* jcr) * mig_jcr->JobFiles/ReadBytes/JobBytes/JobErrors when replicating to * a remote storage daemon. */ - if (jcr->remote_replicate) { + if (jcr->impl_->remote_replicate) { WaitForStorageDaemonTermination(jcr); WaitForStorageDaemonTermination(mig_jcr); - jcr->setJobStatus(jcr->SDJobStatus); + jcr->setJobStatus(jcr->impl_->SDJobStatus); mig_jcr->db_batch->WriteBatchFileRecords(mig_jcr); } else { WaitForStorageDaemonTermination(jcr); - jcr->setJobStatus(jcr->SDJobStatus); + jcr->setJobStatus(jcr->impl_->SDJobStatus); jcr->db_batch->WriteBatchFileRecords(jcr); } bail_out: - if (jcr->remote_replicate && mig_jcr) { + if (jcr->impl_->remote_replicate && mig_jcr) { alist* write_storage_list; /* * Swap the write_storage_list between the jcr and the mig_jcr. */ - write_storage_list = mig_jcr->res.write_storage_list; - mig_jcr->res.write_storage_list = jcr->res.write_storage_list; - jcr->res.write_storage_list = write_storage_list; + write_storage_list = mig_jcr->impl_->res.write_storage_list; + mig_jcr->impl_->res.write_storage_list = jcr->impl_->res.write_storage_list; + jcr->impl_->res.write_storage_list = write_storage_list; /* * Undo the clear of the write_storage in the jcr and assign the mig_jcr @@ -1638,8 +1657,8 @@ static inline bool DoActualMigration(JobControlRecord* jcr) * the ConnectToStorageDaemon function will do the right thing e.g. connect * the jcrs in the way we want them to. */ - jcr->res.write_storage = mig_jcr->res.write_storage; - mig_jcr->res.write_storage = NULL; + jcr->impl_->res.write_storage = mig_jcr->impl_->res.write_storage; + mig_jcr->impl_->res.write_storage = NULL; } FreePairedStorage(jcr); @@ -1676,9 +1695,9 @@ bool DoMigration(JobControlRecord* jcr) /* * See if this is a control job e.g. the one that selects the Jobs to Migrate * or Copy or one of the worker Jobs that do the actual Migration or Copy. If - * jcr->MigrateJobId is unset we know that its the control job. + * jcr->impl_->MigrateJobId is unset we know that its the control job. */ - if (jcr->MigrateJobId == 0) { + if (jcr->impl_->MigrateJobId == 0) { return DoMigrationSelection(jcr); } else { return DoActualMigration(jcr); @@ -1692,7 +1711,7 @@ static inline void GenerateMigrateSummary(JobControlRecord* jcr, { double kbps; utime_t RunTime; - JobControlRecord* mig_jcr = jcr->mig_jcr; + JobControlRecord* mig_jcr = jcr->impl_->mig_jcr; char term_code[100], sd_term_msg[100]; char sdt[MAX_TIME_LENGTH], edt[MAX_TIME_LENGTH]; char ec1[30], ec2[30], ec3[30], ec4[30], ec5[30], elapsed[50]; @@ -1700,19 +1719,19 @@ static inline void GenerateMigrateSummary(JobControlRecord* jcr, Bsnprintf(term_code, sizeof(term_code), TermMsg, jcr->get_OperationName(), jcr->get_ActionName()); - bstrftimes(sdt, sizeof(sdt), jcr->jr.StartTime); - bstrftimes(edt, sizeof(edt), jcr->jr.EndTime); - RunTime = jcr->jr.EndTime - jcr->jr.StartTime; + bstrftimes(sdt, sizeof(sdt), jcr->impl_->jr.StartTime); + bstrftimes(edt, sizeof(edt), jcr->impl_->jr.EndTime); + RunTime = jcr->impl_->jr.EndTime - jcr->impl_->jr.StartTime; - JobstatusToAscii(jcr->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); - if (jcr->previous_jr.JobId != 0) { + JobstatusToAscii(jcr->impl_->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); + if (jcr->impl_->previous_jr.JobId != 0) { /* * Copy/Migrate worker Job. */ if (RunTime <= 0) { kbps = 0; } else { - kbps = (double)jcr->SDJobBytes / (1000 * RunTime); + kbps = (double)jcr->impl_->SDJobBytes / (1000 * RunTime); } Jmsg(jcr, msg_type, 0, @@ -1748,31 +1767,38 @@ static inline void GenerateMigrateSummary(JobControlRecord* jcr, " Bareos binary info: %s\n" " Termination: %s\n\n"), BAREOS, my_name, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER, - edit_uint64(jcr->previous_jr.JobId, ec6), jcr->previous_jr.Job, - mig_jcr ? edit_uint64(mig_jcr->jr.JobId, ec7) : _("*None*"), - edit_uint64(jcr->jr.JobId, ec8), jcr->jr.Job, + edit_uint64(jcr->impl_->previous_jr.JobId, ec6), + jcr->impl_->previous_jr.Job, + mig_jcr ? edit_uint64(mig_jcr->impl_->jr.JobId, ec7) : _("*None*"), + edit_uint64(jcr->impl_->jr.JobId, ec8), jcr->impl_->jr.Job, JobLevelToString(jcr->getJobLevel()), - jcr->res.client ? jcr->res.client->resource_name_ : _("*None*"), - jcr->res.fileset ? jcr->res.fileset->resource_name_ : _("*None*"), - jcr->res.rpool->resource_name_, jcr->res.rpool_source, - jcr->res.read_storage ? jcr->res.read_storage->resource_name_ - : _("*None*"), - NPRT(jcr->res.rstore_source), jcr->res.pool->resource_name_, - jcr->res.pool_source, - jcr->res.write_storage ? jcr->res.write_storage->resource_name_ + jcr->impl_->res.client ? jcr->impl_->res.client->resource_name_ : _("*None*"), - NPRT(jcr->res.wstore_source), - jcr->res.next_pool ? jcr->res.next_pool->resource_name_ : _("*None*"), - NPRT(jcr->res.npool_source), jcr->res.catalog->resource_name_, - jcr->res.catalog_source, sdt, edt, + jcr->impl_->res.fileset ? jcr->impl_->res.fileset->resource_name_ + : _("*None*"), + jcr->impl_->res.rpool->resource_name_, jcr->impl_->res.rpool_source, + jcr->impl_->res.read_storage + ? jcr->impl_->res.read_storage->resource_name_ + : _("*None*"), + NPRT(jcr->impl_->res.rstore_source), + jcr->impl_->res.pool->resource_name_, jcr->impl_->res.pool_source, + jcr->impl_->res.write_storage + ? jcr->impl_->res.write_storage->resource_name_ + : _("*None*"), + NPRT(jcr->impl_->res.wstore_source), + jcr->impl_->res.next_pool ? jcr->impl_->res.next_pool->resource_name_ + : _("*None*"), + NPRT(jcr->impl_->res.npool_source), + jcr->impl_->res.catalog->resource_name_, + jcr->impl_->res.catalog_source, sdt, edt, edit_utime(RunTime, elapsed, sizeof(elapsed)), jcr->JobPriority, - edit_uint64_with_commas(jcr->SDJobFiles, ec1), - edit_uint64_with_commas(jcr->SDJobBytes, ec2), - edit_uint64_with_suffix(jcr->SDJobBytes, ec3), (float)kbps, + edit_uint64_with_commas(jcr->impl_->SDJobFiles, ec1), + edit_uint64_with_commas(jcr->impl_->SDJobBytes, ec2), + edit_uint64_with_suffix(jcr->impl_->SDJobBytes, ec3), (float)kbps, mig_jcr ? mig_jcr->VolumeName : _("*None*"), jcr->VolSessionId, jcr->VolSessionTime, edit_uint64_with_commas(mr->VolBytes, ec4), - edit_uint64_with_suffix(mr->VolBytes, ec5), jcr->SDErrors, sd_term_msg, - BAREOS_JOBLOG_MESSAGE, term_code); + edit_uint64_with_suffix(mr->VolBytes, ec5), jcr->impl_->SDErrors, + sd_term_msg, BAREOS_JOBLOG_MESSAGE, term_code); } else { /* * Copy/Migrate selection only Job. @@ -1790,8 +1816,9 @@ static inline void GenerateMigrateSummary(JobControlRecord* jcr, " Bareos binary info: %s\n" " Termination: %s\n\n"), BAREOS, my_name, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER, - edit_uint64(jcr->jr.JobId, ec8), jcr->jr.Job, - jcr->res.catalog->resource_name_, jcr->res.catalog_source, sdt, edt, + edit_uint64(jcr->impl_->jr.JobId, ec8), jcr->impl_->jr.Job, + jcr->impl_->res.catalog->resource_name_, + jcr->impl_->res.catalog_source, sdt, edt, edit_utime(RunTime, elapsed, sizeof(elapsed)), jcr->JobPriority, BAREOS_JOBLOG_MESSAGE, term_code); } @@ -1806,7 +1833,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) const char* TermMsg; int msg_type = M_INFO; MediaDbRecord mr; - JobControlRecord* mig_jcr = jcr->mig_jcr; + JobControlRecord* mig_jcr = jcr->impl_->mig_jcr; PoolMem query(PM_MESSAGE); Dmsg2(100, "Enter migrate_cleanup %d %c\n", TermCode, TermCode); @@ -1819,27 +1846,28 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) if (mig_jcr) { char old_jobid[50], new_jobid[50]; - edit_uint64(jcr->previous_jr.JobId, old_jobid); - edit_uint64(mig_jcr->jr.JobId, new_jobid); + edit_uint64(jcr->impl_->previous_jr.JobId, old_jobid); + edit_uint64(mig_jcr->impl_->jr.JobId, new_jobid); /* * See if we used a remote SD if so the mig_jcr contains * the jobfiles and jobbytes and the new volsessionid * and volsessiontime as the writing SD generates this info. */ - if (jcr->remote_replicate) { - mig_jcr->JobFiles = jcr->JobFiles = mig_jcr->SDJobFiles; - mig_jcr->JobBytes = jcr->JobBytes = mig_jcr->SDJobBytes; + if (jcr->impl_->remote_replicate) { + mig_jcr->JobFiles = jcr->JobFiles = mig_jcr->impl_->SDJobFiles; + mig_jcr->JobBytes = jcr->JobBytes = mig_jcr->impl_->SDJobBytes; } else { - mig_jcr->JobFiles = jcr->JobFiles = jcr->SDJobFiles; - mig_jcr->JobBytes = jcr->JobBytes = jcr->SDJobBytes; + mig_jcr->JobFiles = jcr->JobFiles = jcr->impl_->SDJobFiles; + mig_jcr->JobBytes = jcr->JobBytes = jcr->impl_->SDJobBytes; mig_jcr->VolSessionId = jcr->VolSessionId; mig_jcr->VolSessionTime = jcr->VolSessionTime; } - mig_jcr->jr.RealEndTime = 0; - mig_jcr->jr.PriorJobId = jcr->previous_jr.JobId; + mig_jcr->impl_->jr.RealEndTime = 0; + mig_jcr->impl_->jr.PriorJobId = jcr->impl_->previous_jr.JobId; - if (jcr->is_JobStatus(JS_Terminated) && (jcr->JobErrors || jcr->SDErrors)) { + if (jcr->is_JobStatus(JS_Terminated) && + (jcr->JobErrors || jcr->impl_->SDErrors)) { TermCode = JS_Warnings; } @@ -1851,8 +1879,8 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) Mmsg(query, "UPDATE Job SET StartTime='%s',EndTime='%s'," "JobTDate=%s WHERE JobId=%s", - jcr->previous_jr.cStartTime, jcr->previous_jr.cEndTime, - edit_uint64(jcr->previous_jr.JobTDate, ec1), new_jobid); + jcr->impl_->previous_jr.cStartTime, jcr->impl_->previous_jr.cEndTime, + edit_uint64(jcr->impl_->previous_jr.JobTDate, ec1), new_jobid); jcr->db->SqlQuery(query.c_str()); if (jcr->IsTerminatedOk()) { @@ -1885,7 +1913,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) * storage daemon we need to add data normally send to the director * via the FHDB interface here. */ - switch (jcr->res.client->Protocol) { + switch (jcr->impl_->res.client->Protocol) { case APT_NDMPV2: case APT_NDMPV3: case APT_NDMPV4: @@ -1898,7 +1926,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) } ua = new_ua_context(jcr); - if (jcr->res.job->PurgeMigrateJob) { + if (jcr->impl_->res.job->PurgeMigrateJob) { /* * Purge old Job record */ @@ -1932,7 +1960,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) * storage daemon we need to add data normally send to the director * via the FHDB interface here. */ - switch (jcr->res.client->Protocol) { + switch (jcr->impl_->res.client->Protocol) { case APT_NDMPV2: case APT_NDMPV3: case APT_NDMPV4: @@ -1953,7 +1981,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) } } - if (!jcr->db->GetJobRecord(jcr, &jcr->jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Job record for Job report: ERR=%s"), jcr->db->strerror()); @@ -1962,7 +1990,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) UpdateBootstrapFile(mig_jcr); - if (!mig_jcr->db->GetJobVolumeNames(mig_jcr, mig_jcr->jr.JobId, + if (!mig_jcr->db->GetJobVolumeNames(mig_jcr, mig_jcr->impl_->jr.JobId, mig_jcr->VolumeName)) { /* * Note, if the job has failed, most likely it did not write any @@ -1970,7 +1998,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) * it is normal. Or look at it the other way, only for a * normal exit should we complain about this error. */ - if (jcr->IsTerminatedOk() && jcr->jr.JobBytes) { + if (jcr->IsTerminatedOk() && jcr->impl_->jr.JobBytes) { Jmsg(jcr, M_ERROR, 0, "%s", mig_jcr->db->strerror()); } mig_jcr->VolumeName[0] = 0; /* none */ @@ -2025,7 +2053,9 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) */ if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->SD_msg_chan_started) { pthread_cancel(jcr->SD_msg_chan); } + if (jcr->impl_->SD_msg_chan_started) { + pthread_cancel(jcr->impl_->SD_msg_chan); + } } /* @@ -2033,8 +2063,8 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) */ if (mig_jcr->store_bsock) { mig_jcr->store_bsock->signal(BNET_TERMINATE); - if (mig_jcr->SD_msg_chan_started) { - pthread_cancel(mig_jcr->SD_msg_chan); + if (mig_jcr->impl_->SD_msg_chan_started) { + pthread_cancel(mig_jcr->impl_->SD_msg_chan); } } break; @@ -2042,7 +2072,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) TermMsg = _("Inappropriate %s term code"); break; } - } else if (jcr->HasSelectedJobs) { + } else if (jcr->impl_->HasSelectedJobs) { switch (jcr->JobStatus) { case JS_Terminated: TermMsg = _("%s OK"); diff --git a/core/src/dird/msgchan.cc b/core/src/dird/msgchan.cc index 3deb6af92de..177b9012636 100644 --- a/core/src/dird/msgchan.cc +++ b/core/src/dird/msgchan.cc @@ -39,6 +39,7 @@ #include "dird.h" #include "dird/getmsg.h" #include "dird/job.h" +#include "dird/jcr_private.h" #include "dird/msgchan.h" #include "dird/quota.h" #include "dird/sd_cmds.h" @@ -110,9 +111,9 @@ static inline bool SendBootstrapFileToSd(JobControlRecord* jcr, while (fgets(buf, sizeof(buf), bs)) { sd->fsend("%s", buf); } sd->signal(BNET_EOD); fclose(bs); - if (jcr->unlink_bsr) { + if (jcr->impl_->unlink_bsr) { SecureErase(jcr, jcr->RestoreBootstrap); - jcr->unlink_bsr = false; + jcr->impl_->unlink_bsr = false; } return true; } @@ -150,31 +151,32 @@ bool StartStorageDaemonJob(JobControlRecord* jcr, /* * Now send JobId and permissions, and get back the authorization key. */ - PmStrcpy(job_name, jcr->res.job->resource_name_); + PmStrcpy(job_name, jcr->impl_->res.job->resource_name_); BashSpaces(job_name); - if (jcr->res.client) { - PmStrcpy(client_name, jcr->res.client->resource_name_); + if (jcr->impl_->res.client) { + PmStrcpy(client_name, jcr->impl_->res.client->resource_name_); } else { PmStrcpy(client_name, "**None**"); } BashSpaces(client_name); - if (jcr->res.fileset) { - PmStrcpy(fileset_name, jcr->res.fileset->resource_name_); + if (jcr->impl_->res.fileset) { + PmStrcpy(fileset_name, jcr->impl_->res.fileset->resource_name_); } else { PmStrcpy(fileset_name, "**None**"); } BashSpaces(fileset_name); - PmStrcpy(backup_format, jcr->backup_format); + PmStrcpy(backup_format, jcr->impl_->backup_format); BashSpaces(backup_format); - if (jcr->res.fileset && jcr->res.fileset->MD5[0] == 0) { - bstrncpy(jcr->res.fileset->MD5, "**Dummy**", sizeof(jcr->res.fileset->MD5)); - fileset_md5 = jcr->res.fileset->MD5; - } else if (jcr->res.fileset) { - fileset_md5 = jcr->res.fileset->MD5; + if (jcr->impl_->res.fileset && jcr->impl_->res.fileset->MD5[0] == 0) { + bstrncpy(jcr->impl_->res.fileset->MD5, "**Dummy**", + sizeof(jcr->impl_->res.fileset->MD5)); + fileset_md5 = jcr->impl_->res.fileset->MD5; + } else if (jcr->impl_->res.fileset) { + fileset_md5 = jcr->impl_->res.fileset->MD5; } else { fileset_md5 = "**Dummy**"; } @@ -185,7 +187,7 @@ bool StartStorageDaemonJob(JobControlRecord* jcr, * If we do not cancel it the SD will not accept a new connection * for the same jobid. */ - if (jcr->reschedule_count) { + if (jcr->impl_->reschedule_count) { sd->fsend("cancel Job=%s\n", jcr->Job); while (sd->recv() >= 0) { continue; } } @@ -198,12 +200,12 @@ bool StartStorageDaemonJob(JobControlRecord* jcr, sd->fsend(jobcmd, edit_int64(jcr->JobId, ed1), jcr->Job, job_name.c_str(), client_name.c_str(), jcr->getJobType(), jcr->getJobLevel(), - fileset_name.c_str(), !jcr->res.pool->catalog_files, - jcr->res.job->SpoolAttributes, fileset_md5, jcr->spool_data, - jcr->res.job->PreferMountedVolumes, - edit_int64(jcr->spool_size, ed2), jcr->rerunning, jcr->VolSessionId, - jcr->VolSessionTime, remainingquota, jcr->getJobProtocol(), - backup_format.c_str()); + fileset_name.c_str(), !jcr->impl_->res.pool->catalog_files, + jcr->impl_->res.job->SpoolAttributes, fileset_md5, + jcr->impl_->spool_data, jcr->impl_->res.job->PreferMountedVolumes, + edit_int64(jcr->impl_->spool_size, ed2), jcr->rerunning, + jcr->VolSessionId, jcr->VolSessionTime, remainingquota, + jcr->getJobProtocol(), backup_format.c_str()); Dmsg1(100, ">stored: %s", sd->msg); if (BgetDirmsg(sd) > 0) { @@ -253,11 +255,11 @@ bool StartStorageDaemonJob(JobControlRecord* jcr, /* For the moment, only migrate, copy and vbackup have rpool */ if (jcr->is_JobType(JT_MIGRATE) || jcr->is_JobType(JT_COPY) || (jcr->is_JobType(JT_BACKUP) && jcr->is_JobLevel(L_VIRTUAL_FULL))) { - PmStrcpy(pool_type, jcr->res.rpool->pool_type); - PmStrcpy(pool_name, jcr->res.rpool->resource_name_); + PmStrcpy(pool_type, jcr->impl_->res.rpool->pool_type); + PmStrcpy(pool_name, jcr->impl_->res.rpool->resource_name_); } else { - PmStrcpy(pool_type, jcr->res.pool->pool_type); - PmStrcpy(pool_name, jcr->res.pool->resource_name_); + PmStrcpy(pool_type, jcr->impl_->res.pool->pool_type); + PmStrcpy(pool_name, jcr->impl_->res.pool->resource_name_); } BashSpaces(pool_type); BashSpaces(pool_name); @@ -296,8 +298,8 @@ bool StartStorageDaemonJob(JobControlRecord* jcr, /* Do write side of storage daemon */ if (ok && write_storage) { - PmStrcpy(pool_type, jcr->res.pool->pool_type); - PmStrcpy(pool_name, jcr->res.pool->resource_name_); + PmStrcpy(pool_type, jcr->impl_->res.pool->pool_type); + PmStrcpy(pool_name, jcr->impl_->res.pool->resource_name_); BashSpaces(pool_type); BashSpaces(pool_name); foreach_alist (storage, write_storage) { @@ -360,8 +362,8 @@ bool StartStorageDaemonMessageThread(JobControlRecord* jcr) pthread_t thid; jcr->IncUseCount(); /* mark in use by msg thread */ - jcr->sd_msg_thread_done = false; - jcr->SD_msg_chan_started = false; + jcr->impl_->sd_msg_thread_done = false; + jcr->impl_->SD_msg_chan_started = false; Dmsg0(100, "Start SD msg_thread.\n"); if ((status = pthread_create(&thid, NULL, msg_thread, (void*)jcr)) != 0) { BErrNo be; @@ -369,9 +371,9 @@ bool StartStorageDaemonMessageThread(JobControlRecord* jcr) be.bstrerror(status)); } /* Wait for thread to start */ - while (!jcr->SD_msg_chan_started) { + while (!jcr->impl_->SD_msg_chan_started) { Bmicrosleep(0, 50); - if (JobCanceled(jcr) || jcr->sd_msg_thread_done) { return false; } + if (JobCanceled(jcr) || jcr->impl_->sd_msg_thread_done) { return false; } } Dmsg1(100, "SD msg_thread started. use=%d\n", jcr->UseCount()); return true; @@ -383,11 +385,13 @@ extern "C" void MsgThreadCleanup(void* arg) jcr->db->EndTransaction(jcr); /* Terminate any open transaction */ jcr->lock(); - jcr->sd_msg_thread_done = true; - jcr->SD_msg_chan_started = false; + jcr->impl_->sd_msg_thread_done = true; + jcr->impl_->SD_msg_chan_started = false; jcr->unlock(); - pthread_cond_broadcast(&jcr->nextrun_ready); /* wakeup any waiting threads */ - pthread_cond_broadcast(&jcr->term_wait); /* wakeup any waiting threads */ + pthread_cond_broadcast( + &jcr->impl_->nextrun_ready); /* wakeup any waiting threads */ + pthread_cond_broadcast( + &jcr->impl_->term_wait); /* wakeup any waiting threads */ Dmsg2(100, "=== End msg_thread. JobId=%d usecnt=%d\n", jcr->JobId, jcr->UseCount()); jcr->db->ThreadCleanup(); /* remove thread specific data */ @@ -411,8 +415,8 @@ extern "C" void* msg_thread(void* arg) pthread_detach(pthread_self()); SetJcrInThreadSpecificData(jcr); - jcr->SD_msg_chan = pthread_self(); - jcr->SD_msg_chan_started = true; + jcr->impl_->SD_msg_chan = pthread_self(); + jcr->impl_->SD_msg_chan_started = true; pthread_cleanup_push(MsgThreadCleanup, arg); sd = jcr->store_bsock; @@ -431,7 +435,7 @@ extern "C" void* msg_thread(void* arg) if (jcr->sd_auth_key) { free(jcr->sd_auth_key); } jcr->sd_auth_key = strdup(auth_key); pthread_cond_broadcast( - &jcr->nextrun_ready); /* wakeup any waiting threads */ + &jcr->impl_->nextrun_ready); /* wakeup any waiting threads */ continue; } @@ -446,10 +450,10 @@ extern "C" void* msg_thread(void* arg) */ if (sscanf(sd->msg, Job_end, Job, &JobStatus, &JobFiles, &JobBytes, &JobErrors) == 5) { - jcr->SDJobStatus = JobStatus; /* termination status */ - jcr->SDJobFiles = JobFiles; - jcr->SDJobBytes = JobBytes; - jcr->SDErrors = JobErrors; + jcr->impl_->SDJobStatus = JobStatus; /* termination status */ + jcr->impl_->SDJobFiles = JobFiles; + jcr->impl_->SDJobBytes = JobBytes; + jcr->impl_->SDErrors = JobErrors; break; } Dmsg1(400, "end loop use=%d\n", jcr->UseCount()); @@ -463,7 +467,7 @@ extern "C" void* msg_thread(void* arg) */ Qmsg(jcr, M_FATAL, 0, _("Director's comm line to SD dropped.\n")); } - if (IsBnetError(sd)) { jcr->SDJobStatus = JS_ErrorTerminated; } + if (IsBnetError(sd)) { jcr->impl_->SDJobStatus = JS_ErrorTerminated; } pthread_cleanup_pop(1); /* remove and execute the handler */ return NULL; } @@ -472,7 +476,7 @@ void WaitForStorageDaemonTermination(JobControlRecord* jcr) { int cancel_count = 0; /* Now wait for Storage daemon to Terminate our message thread */ - while (!jcr->sd_msg_thread_done) { + while (!jcr->impl_->sd_msg_thread_done) { struct timeval tv; struct timezone tz; struct timespec timeout; @@ -482,10 +486,10 @@ void WaitForStorageDaemonTermination(JobControlRecord* jcr) timeout.tv_sec = tv.tv_sec + 5; /* wait 5 seconds */ Dmsg0(400, "I'm waiting for message thread termination.\n"); P(mutex); - pthread_cond_timedwait(&jcr->term_wait, &mutex, &timeout); + pthread_cond_timedwait(&jcr->impl_->term_wait, &mutex, &timeout); V(mutex); if (jcr->IsCanceled()) { - if (jcr->SD_msg_chan_started) { + if (jcr->impl_->SD_msg_chan_started) { jcr->store_bsock->SetTimedOut(); jcr->store_bsock->SetTerminated(); SdMsgThreadSendSignal(jcr, TIMEOUT_SIGNAL); diff --git a/core/src/dird/ndmp_dma_backup_NDMP_BAREOS.cc b/core/src/dird/ndmp_dma_backup_NDMP_BAREOS.cc index b4e6a14e9ef..2e67d4ff9f4 100644 --- a/core/src/dird/ndmp_dma_backup_NDMP_BAREOS.cc +++ b/core/src/dird/ndmp_dma_backup_NDMP_BAREOS.cc @@ -30,6 +30,7 @@ #include "include/bareos.h" #include "dird.h" #include "dird/dird_globals.h" +#include "dird/jcr_private.h" #include "dird/job.h" #include "dird/msgchan.h" #include "dird/quota.h" @@ -108,8 +109,8 @@ static inline bool extract_post_backup_stats(JobControlRecord* jcr, */ ndm_ee = sess->control_acb->job.result_env_tab.head; while (ndm_ee) { - if (!jcr->db->CreateNdmpEnvironmentString(jcr, &jcr->jr, ndm_ee->pval.name, - ndm_ee->pval.value)) { + if (!jcr->db->CreateNdmpEnvironmentString( + jcr, &jcr->impl_->jr, ndm_ee->pval.name, ndm_ee->pval.value)) { break; } ndm_ee = ndm_ee->next; @@ -120,7 +121,7 @@ static inline bool extract_post_backup_stats(JobControlRecord* jcr, * level. */ if (nbf_options && nbf_options->uses_level) { - jcr->db->UpdateNdmpLevelMapping(jcr, &jcr->jr, filesystem, + jcr->db->UpdateNdmpLevelMapping(jcr, &jcr->impl_->jr, filesystem, sess->control_acb->job.bu_level); } @@ -136,12 +137,13 @@ bool DoNdmpBackupInit(JobControlRecord* jcr) if (!AllowDuplicateJob(jcr)) { return false; } - jcr->jr.PoolId = GetOrCreatePoolRecord(jcr, jcr->res.pool->resource_name_); - if (jcr->jr.PoolId == 0) { return false; } + jcr->impl_->jr.PoolId = + GetOrCreatePoolRecord(jcr, jcr->impl_->res.pool->resource_name_); + if (jcr->impl_->jr.PoolId == 0) { return false; } jcr->start_time = time(NULL); - jcr->jr.StartTime = jcr->start_time; - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->jr)) { + jcr->impl_->jr.StartTime = jcr->start_time; + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); return false; } @@ -149,9 +151,9 @@ bool DoNdmpBackupInit(JobControlRecord* jcr) /* * If pool storage specified, use it instead of job storage */ - CopyWstorage(jcr, jcr->res.pool->storage, _("Pool resource")); + CopyWstorage(jcr, jcr->impl_->res.pool->storage, _("Pool resource")); - if (!jcr->res.write_storage_list) { + if (!jcr->impl_->res.write_storage_list) { Jmsg(jcr, M_FATAL, 0, _("No Storage specification found in Job or Pool.\n")); return false; @@ -196,7 +198,8 @@ bool DoNdmpBackup(JobControlRecord* jcr) bool retval = false; int NdmpLoglevel; - NdmpLoglevel = std::max(jcr->res.client->ndmp_loglevel, me->ndmp_loglevel); + NdmpLoglevel = + std::max(jcr->impl_->res.client->ndmp_loglevel, me->ndmp_loglevel); /* * Print Job Start message @@ -205,8 +208,9 @@ bool DoNdmpBackup(JobControlRecord* jcr) edit_uint64(jcr->JobId, ed1), jcr->Job); jcr->setJobStatus(JS_Running); - Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->jr.JobId, jcr->jr.JobLevel); - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->jr)) { + Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->impl_->jr.JobId, + jcr->impl_->jr.JobLevel); + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); return false; } @@ -231,7 +235,7 @@ bool DoNdmpBackup(JobControlRecord* jcr) * data mover which moves the data from the NDMP DATA AGENT to the NDMP * TAPE AGENT. */ - if (jcr->res.write_storage->paired_storage) { + if (jcr->impl_->res.write_storage->paired_storage) { SetPairedStorage(jcr); jcr->setJobStatus(JS_WaitSD); @@ -242,7 +246,7 @@ bool DoNdmpBackup(JobControlRecord* jcr) /* * Now start a job with the Storage daemon */ - if (!StartStorageDaemonJob(jcr, NULL, jcr->res.write_storage_list)) { + if (!StartStorageDaemonJob(jcr, NULL, jcr->impl_->res.write_storage_list)) { return false; } @@ -269,9 +273,9 @@ bool DoNdmpBackup(JobControlRecord* jcr) * and reuse the job definition for each separate sub-backup we perform as * part of the whole job. We only free the env_table between every sub-backup. */ - if (!NdmpBuildClientJob(jcr, jcr->res.client, - jcr->res.paired_read_write_storage, NDM_JOB_OP_BACKUP, - &ndmp_job)) { + if (!NdmpBuildClientJob(jcr, jcr->impl_->res.client, + jcr->impl_->res.paired_read_write_storage, + NDM_JOB_OP_BACKUP, &ndmp_job)) { goto bail_out; } @@ -283,7 +287,7 @@ bool DoNdmpBackup(JobControlRecord* jcr) * included fileset. */ cnt = 0; - fileset = jcr->res.fileset; + fileset = jcr->impl_->res.fileset; for (i = 0; i < fileset->include_items.size(); i++) { @@ -308,7 +312,7 @@ bool DoNdmpBackup(JobControlRecord* jcr) if (jcr->store_bsock && cnt > 0) { jcr->store_bsock->fsend("nextrun"); P(mutex); - pthread_cond_wait(&jcr->nextrun_ready, &mutex); + pthread_cond_wait(&jcr->impl_->nextrun_ready, &mutex); V(mutex); } @@ -329,8 +333,8 @@ bool DoNdmpBackup(JobControlRecord* jcr) nis->filesystem = item; nis->FileIndex = cnt + 1; nis->jcr = jcr; - nis->save_filehist = jcr->res.job->SaveFileHist; - nis->filehist_size = jcr->res.job->FileHistSize; + nis->save_filehist = jcr->impl_->res.job->SaveFileHist; + nis->filehist_size = jcr->impl_->res.job->FileHistSize; ndmp_sess.param->log.ctx = nis; ndmp_sess.param->log_tag = strdup("DIR-NDMP"); @@ -365,8 +369,9 @@ bool DoNdmpBackup(JobControlRecord* jcr) * the individual file records to it. So we allocate it here once so its * available during the whole NDMP session. */ - if (Bstrcasecmp(jcr->backup_format, "dump")) { - Mmsg(virtual_filename, "/@NDMP%s%%%d", nis->filesystem, jcr->DumpLevel); + if (Bstrcasecmp(jcr->impl_->backup_format, "dump")) { + Mmsg(virtual_filename, "/@NDMP%s%%%d", nis->filesystem, + jcr->impl_->DumpLevel); } else { Mmsg(virtual_filename, "/@NDMP%s", nis->filesystem); } @@ -400,7 +405,7 @@ bool DoNdmpBackup(JobControlRecord* jcr) /* * See if there were any errors during the backup. */ - jcr->jr.FileIndex = cnt + 1; + jcr->impl_->jr.FileIndex = cnt + 1; if (!extract_post_backup_stats(jcr, item, &ndmp_sess)) { goto cleanup; } UnregisterCallbackHooks(&ndmp_sess.control_acb->job.index_log); diff --git a/core/src/dird/ndmp_dma_backup_NDMP_NATIVE.cc b/core/src/dird/ndmp_dma_backup_NDMP_NATIVE.cc index c8b3f308b13..6ada0f9ed8d 100644 --- a/core/src/dird/ndmp_dma_backup_NDMP_NATIVE.cc +++ b/core/src/dird/ndmp_dma_backup_NDMP_NATIVE.cc @@ -28,6 +28,7 @@ #include "include/bareos.h" #include "dird.h" +#include "dird/jcr_private.h" #include "dird/dird_globals.h" #include "dird/job.h" #include "dird/next_vol.h" @@ -90,12 +91,12 @@ int NdmpLoadNext(struct ndm_session* sess) bool prune = false; struct ndmmedia* media; int index = 1; - StorageResource* store = jcr->res.write_storage; + StorageResource* store = jcr->impl_->res.write_storage; /* * get the poolid for pool name */ - mr.PoolId = jcr->jr.PoolId; + mr.PoolId = jcr->impl_->jr.PoolId; if (FindNextVolumeForAppend(jcr, &mr, index, unwanted_volumes, create, @@ -181,7 +182,8 @@ bool DoNdmpBackupNdmpNative(JobControlRecord* jcr) char* item; - ndmp_log_level = std::max(jcr->res.client->ndmp_loglevel, me->ndmp_loglevel); + ndmp_log_level = + std::max(jcr->impl_->res.client->ndmp_loglevel, me->ndmp_loglevel); struct ndmca_media_callbacks media_callbacks; @@ -201,21 +203,23 @@ bool DoNdmpBackupNdmpNative(JobControlRecord* jcr) edit_uint64(jcr->JobId, ed1), jcr->Job); jcr->setJobStatus(JS_Running); - Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->jr.JobId, jcr->jr.JobLevel); - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->jr)) { + Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->impl_->jr.JobId, + jcr->impl_->jr.JobLevel); + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); return false; } status = 0; - StorageResource* store = jcr->res.write_storage; + StorageResource* store = jcr->impl_->res.write_storage; PoolMem virtual_filename(PM_FNAME); IncludeExcludeItem* ie; - if (!NdmpBuildClientAndStorageJob(jcr, jcr->res.write_storage, - jcr->res.client, true, /* init_tape */ - true, /* init_robot */ + if (!NdmpBuildClientAndStorageJob(jcr, jcr->impl_->res.write_storage, + jcr->impl_->res.client, + true, /* init_tape */ + true, /* init_robot */ NDM_JOB_OP_BACKUP, &ndmp_job)) { goto bail_out; } @@ -234,7 +238,7 @@ bool DoNdmpBackupNdmpNative(JobControlRecord* jcr) * Only one include set of the fileset is allowed in NATIVE mode as * in NDMP also per job only one filesystem can be backed up */ - fileset = jcr->res.fileset; + fileset = jcr->impl_->res.fileset; if (fileset->include_items.size() > 1) { Jmsg(jcr, M_ERROR, 0, @@ -273,8 +277,8 @@ bool DoNdmpBackupNdmpNative(JobControlRecord* jcr) nis->filesystem = item; nis->FileIndex = 1; nis->jcr = jcr; - nis->save_filehist = jcr->res.job->SaveFileHist; - nis->filehist_size = jcr->res.job->FileHistSize; + nis->save_filehist = jcr->impl_->res.job->SaveFileHist; + nis->filehist_size = jcr->impl_->res.job->FileHistSize; ndmp_sess.param->log.ctx = nis; ndmp_sess.param->log_tag = strdup("DIR-NDMP"); @@ -311,8 +315,9 @@ bool DoNdmpBackupNdmpNative(JobControlRecord* jcr) * individual file records to it. So we allocate it here once so its available * during the whole NDMP session. */ - if (Bstrcasecmp(jcr->backup_format, "dump")) { - Mmsg(virtual_filename, "/@NDMP%s%%%d", nis->filesystem, jcr->DumpLevel); + if (Bstrcasecmp(jcr->impl_->backup_format, "dump")) { + Mmsg(virtual_filename, "/@NDMP%s%%%d", nis->filesystem, + jcr->impl_->DumpLevel); } else { Mmsg(virtual_filename, "/@NDMP%s", nis->filesystem); } @@ -353,7 +358,7 @@ bool DoNdmpBackupNdmpNative(JobControlRecord* jcr) /* * See if there were any errors during the backup. */ - jcr->jr.FileIndex = 1; + jcr->impl_->jr.FileIndex = 1; if (!extract_post_backup_stats_ndmp_native(jcr, item, &ndmp_sess)) { goto cleanup; } @@ -467,12 +472,13 @@ bool DoNdmpBackupInitNdmpNative(JobControlRecord* jcr) if (!AllowDuplicateJob(jcr)) { return false; } - jcr->jr.PoolId = GetOrCreatePoolRecord(jcr, jcr->res.pool->resource_name_); - if (jcr->jr.PoolId == 0) { return false; } + jcr->impl_->jr.PoolId = + GetOrCreatePoolRecord(jcr, jcr->impl_->res.pool->resource_name_); + if (jcr->impl_->jr.PoolId == 0) { return false; } jcr->start_time = time(NULL); - jcr->jr.StartTime = jcr->start_time; - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->jr)) { + jcr->impl_->jr.StartTime = jcr->start_time; + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); return false; } @@ -480,9 +486,9 @@ bool DoNdmpBackupInitNdmpNative(JobControlRecord* jcr) /* * If pool storage specified, use it instead of job storage */ - CopyWstorage(jcr, jcr->res.pool->storage, _("Pool resource")); + CopyWstorage(jcr, jcr->impl_->res.pool->storage, _("Pool resource")); - if (!jcr->res.write_storage_list) { + if (!jcr->impl_->res.write_storage_list) { Jmsg(jcr, M_FATAL, 0, _("No Storage specification found in Job or Pool.\n")); return false; @@ -532,7 +538,7 @@ static inline bool extract_post_backup_stats_ndmp_native( */ media->slot_addr = GetBareosSlotNumberByElementAddress( - &jcr->res.write_storage->runtime_storage_status->storage_mapping, + &jcr->impl_->res.write_storage->runtime_storage_status->storage_mapping, slot_type_t::kSlotTypeStorage, media->slot_addr); #if 0 Jmsg(jcr, M_INFO, 0, _("Physical Slot is %d\n"), media->slot_addr); @@ -580,8 +586,8 @@ static inline bool extract_post_backup_stats_ndmp_native( */ ndm_ee = sess->control_acb->job.result_env_tab.head; while (ndm_ee) { - if (!jcr->db->CreateNdmpEnvironmentString(jcr, &jcr->jr, ndm_ee->pval.name, - ndm_ee->pval.value)) { + if (!jcr->db->CreateNdmpEnvironmentString( + jcr, &jcr->impl_->jr, ndm_ee->pval.name, ndm_ee->pval.value)) { break; } ndm_ee = ndm_ee->next; @@ -592,7 +598,7 @@ static inline bool extract_post_backup_stats_ndmp_native( * level. */ if (nbf_options && nbf_options->uses_level) { - jcr->db->UpdateNdmpLevelMapping(jcr, &jcr->jr, filesystem, + jcr->db->UpdateNdmpLevelMapping(jcr, &jcr->impl_->jr, filesystem, sess->control_acb->job.bu_level); } diff --git a/core/src/dird/ndmp_dma_backup_common.cc b/core/src/dird/ndmp_dma_backup_common.cc index 86dc7550472..34a4508f6ee 100644 --- a/core/src/dird/ndmp_dma_backup_common.cc +++ b/core/src/dird/ndmp_dma_backup_common.cc @@ -28,6 +28,7 @@ #include "include/bareos.h" #include "dird.h" #include "dird/backup.h" +#include "dird/jcr_private.h" #include "dird/job.h" #include "dird/ndmp_dma_backup_common.h" #include "lib/edit.h" @@ -96,8 +97,8 @@ bool FillBackupEnvironment(JobControlRecord* jcr, /* * Set the dump level for the backup. */ - jcr->DumpLevel = NativeToNdmpLevel(jcr, filesystem); - job->bu_level = jcr->DumpLevel; + jcr->impl_->DumpLevel = NativeToNdmpLevel(jcr, filesystem); + job->bu_level = jcr->impl_->DumpLevel; if (job->bu_level == -1) { return false; } pv.name = ndmp_env_keywords[NDMP_ENV_KW_LEVEL]; @@ -188,7 +189,7 @@ bool FillBackupEnvironment(JobControlRecord* jcr, if (jcr->store_bsock) { if (nbf_options && nbf_options->uses_level) { Mmsg(tape_device, "%s@%s%%%d", jcr->sd_auth_key, filesystem, - jcr->DumpLevel); + jcr->impl_->DumpLevel); } else { Mmsg(tape_device, "%s@%s", jcr->sd_auth_key, filesystem); } @@ -206,7 +207,7 @@ int NativeToNdmpLevel(JobControlRecord* jcr, char* filesystem) { int level = -1; - if (!jcr->db->CreateNdmpLevelMapping(jcr, &jcr->jr, filesystem)) { + if (!jcr->db->CreateNdmpLevelMapping(jcr, &jcr->impl_->jr, filesystem)) { return -1; } @@ -218,7 +219,7 @@ int NativeToNdmpLevel(JobControlRecord* jcr, char* filesystem) level = 1; break; case L_INCREMENTAL: - level = jcr->db->GetNdmpLevelMapping(jcr, &jcr->jr, filesystem); + level = jcr->db->GetNdmpLevelMapping(jcr, &jcr->impl_->jr, filesystem); break; default: Jmsg(jcr, M_FATAL, 0, _("Illegal Job Level %c for NDMP Job\n"), @@ -247,7 +248,7 @@ void RegisterCallbackHooks(struct ndmlog* ixlog) #ifdef HAVE_LMDB NIS* nis = (NIS*)ixlog->ctx; - if (nis->jcr->res.client->ndmp_use_lmdb) { + if (nis->jcr->impl_->res.client->ndmp_use_lmdb) { NdmpFhdbLmdbRegister(ixlog); } else { NdmpFhdbMemRegister(ixlog); @@ -262,7 +263,7 @@ void UnregisterCallbackHooks(struct ndmlog* ixlog) #ifdef HAVE_LMDB NIS* nis = (NIS*)ixlog->ctx; - if (nis->jcr->res.client->ndmp_use_lmdb) { + if (nis->jcr->impl_->res.client->ndmp_use_lmdb) { NdmpFhdbLmdbUnregister(ixlog); } else { NdmpFhdbMemUnregister(ixlog); @@ -277,7 +278,7 @@ void ProcessFhdb(struct ndmlog* ixlog) #ifdef HAVE_LMDB NIS* nis = (NIS*)ixlog->ctx; - if (nis->jcr->res.client->ndmp_use_lmdb) { + if (nis->jcr->impl_->res.client->ndmp_use_lmdb) { NdmpFhdbLmdbProcessDb(ixlog); } else { NdmpFhdbMemProcessDb(ixlog); @@ -300,20 +301,20 @@ void NdmpBackupCleanup(JobControlRecord* jcr, int TermCode) Dmsg2(100, "Enter NdmpBackupCleanup %d %c\n", TermCode, TermCode); if (jcr->is_JobStatus(JS_Terminated) && - (jcr->JobErrors || jcr->SDErrors || jcr->JobWarnings)) { + (jcr->JobErrors || jcr->impl_->SDErrors || jcr->JobWarnings)) { TermCode = JS_Warnings; } UpdateJobEnd(jcr, TermCode); - if (!jcr->db->GetJobRecord(jcr, &jcr->jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Job record for Job report: ERR=%s"), jcr->db->strerror()); jcr->setJobStatus(JS_ErrorTerminated); } - bstrncpy(cr.Name, jcr->res.client->resource_name_, sizeof(cr.Name)); + bstrncpy(cr.Name, jcr->impl_->res.client->resource_name_, sizeof(cr.Name)); if (!jcr->db->GetClientRecord(jcr, &cr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Client record for Job report: ERR=%s"), @@ -335,14 +336,18 @@ void NdmpBackupCleanup(JobControlRecord* jcr, int TermCode) msg_type = M_ERROR; /* Generate error message */ if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->SD_msg_chan_started) { pthread_cancel(jcr->SD_msg_chan); } + if (jcr->impl_->SD_msg_chan_started) { + pthread_cancel(jcr->impl_->SD_msg_chan); + } } break; case JS_Canceled: TermMsg = _("Backup Canceled"); if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->SD_msg_chan_started) { pthread_cancel(jcr->SD_msg_chan); } + if (jcr->impl_->SD_msg_chan_started) { + pthread_cancel(jcr->impl_->SD_msg_chan); + } } break; default: diff --git a/core/src/dird/ndmp_dma_generic.cc b/core/src/dird/ndmp_dma_generic.cc index 0c8ca56970a..7ffc105713e 100644 --- a/core/src/dird/ndmp_dma_generic.cc +++ b/core/src/dird/ndmp_dma_generic.cc @@ -29,6 +29,7 @@ #include "include/bareos.h" #include "dird.h" +#include "dird/jcr_private.h" #include "dird/dird_globals.h" #if HAVE_NDMP @@ -90,24 +91,25 @@ ndmp_backup_format_option* ndmp_lookup_backup_format_options( */ bool NdmpValidateClient(JobControlRecord* jcr) { - switch (jcr->res.client->Protocol) { + switch (jcr->impl_->res.client->Protocol) { case APT_NDMPV2: case APT_NDMPV3: case APT_NDMPV4: - if (jcr->res.client->password_.encoding != p_encoding_clear) { + if (jcr->impl_->res.client->password_.encoding != p_encoding_clear) { Jmsg(jcr, M_FATAL, 0, _("Client %s, has incompatible password encoding for running NDMP " "backup.\n"), - jcr->res.client->resource_name_); + jcr->impl_->res.client->resource_name_); return false; } break; default: - Jmsg(jcr, M_FATAL, 0, - _("Client %s, with backup protocol %s not compatible for running " - "NDMP backup.\n"), - jcr->res.client->resource_name_, - AuthenticationProtocolTypeToString(jcr->res.client->Protocol)); + Jmsg( + jcr, M_FATAL, 0, + _("Client %s, with backup protocol %s not compatible for running " + "NDMP backup.\n"), + jcr->impl_->res.client->resource_name_, + AuthenticationProtocolTypeToString(jcr->impl_->res.client->Protocol)); return false; } @@ -132,7 +134,8 @@ static inline bool NdmpValidateStorage(JobControlRecord* jcr, default: Jmsg(jcr, M_FATAL, 0, _("Storage %s has illegal backup protocol %s for NDMP backup\n"), - store->resource_name_, AuthenticationProtocolTypeToString(store->Protocol)); + store->resource_name_, + AuthenticationProtocolTypeToString(store->Protocol)); return false; } @@ -143,12 +146,12 @@ bool NdmpValidateStorage(JobControlRecord* jcr) { StorageResource* store = nullptr; - if (jcr->res.write_storage_list) { - foreach_alist (store, jcr->res.write_storage_list) { + if (jcr->impl_->res.write_storage_list) { + foreach_alist (store, jcr->impl_->res.write_storage_list) { if (!NdmpValidateStorage(jcr, store)) { return false; } } } else { - foreach_alist (store, jcr->res.read_storage_list) { + foreach_alist (store, jcr->impl_->res.read_storage_list) { if (!NdmpValidateStorage(jcr, store)) { return false; } } } @@ -324,7 +327,7 @@ bool NdmpBuildClientJob(JobControlRecord* jcr, memset(job, 0, sizeof(struct ndm_job_param)); job->operation = operation; - job->bu_type = jcr->backup_format; + job->bu_type = jcr->impl_->backup_format; /* * For NDMP the backupformat is a prerequite abort the backup job when @@ -355,31 +358,32 @@ bool NdmpBuildClientJob(JobControlRecord* jcr, goto bail_out; } - if (Bstrcasecmp(jcr->backup_format, "smtape")) { + if (Bstrcasecmp(jcr->impl_->backup_format, "smtape")) { /* * SMTAPE only wants certain blocksizes. */ - if (jcr->res.client->ndmp_blocksize < SMTAPE_MIN_BLOCKSIZE || - jcr->res.client->ndmp_blocksize > SMTAPE_MAX_BLOCKSIZE) { + if (jcr->impl_->res.client->ndmp_blocksize < SMTAPE_MIN_BLOCKSIZE || + jcr->impl_->res.client->ndmp_blocksize > SMTAPE_MAX_BLOCKSIZE) { Jmsg(jcr, M_FATAL, 0, _("For SMTAPE NDMP jobs the NDMP blocksize needs to be between %d " "and %d, but is set to %d\n"), SMTAPE_MIN_BLOCKSIZE, SMTAPE_MAX_BLOCKSIZE, - jcr->res.client->ndmp_blocksize); + jcr->impl_->res.client->ndmp_blocksize); goto bail_out; } - if ((jcr->res.client->ndmp_blocksize % SMTAPE_BLOCKSIZE_INCREMENTS) != 0) { + if ((jcr->impl_->res.client->ndmp_blocksize % + SMTAPE_BLOCKSIZE_INCREMENTS) != 0) { Jmsg(jcr, M_FATAL, 0, _("For SMTAPE NDMP jobs the NDMP blocksize needs to be in " "increments of %d bytes, but is set to %d\n"), - SMTAPE_BLOCKSIZE_INCREMENTS, jcr->res.client->ndmp_blocksize); + SMTAPE_BLOCKSIZE_INCREMENTS, jcr->impl_->res.client->ndmp_blocksize); goto bail_out; } - job->record_size = jcr->res.client->ndmp_blocksize; + job->record_size = jcr->impl_->res.client->ndmp_blocksize; } else { - job->record_size = jcr->res.client->ndmp_blocksize; + job->record_size = jcr->impl_->res.client->ndmp_blocksize; } return true; @@ -399,7 +403,7 @@ bool NdmpBuildStorageJob(JobControlRecord* jcr, memset(job, 0, sizeof(struct ndm_job_param)); job->operation = operation; - job->bu_type = jcr->backup_format; + job->bu_type = jcr->impl_->backup_format; if (!fill_ndmp_agent_config(jcr, &job->data_agent, store->Protocol, store->AuthType, store->address, store->SDport, diff --git a/core/src/dird/ndmp_dma_restore_NDMP_BAREOS.cc b/core/src/dird/ndmp_dma_restore_NDMP_BAREOS.cc index 50bcab5c658..8609034d778 100644 --- a/core/src/dird/ndmp_dma_restore_NDMP_BAREOS.cc +++ b/core/src/dird/ndmp_dma_restore_NDMP_BAREOS.cc @@ -31,6 +31,7 @@ #include "dird.h" #include "dird/dird_globals.h" #include "dird/getmsg.h" +#include "dird/jcr_private.h" #include "dird/msgchan.h" #include "dird/sd_cmds.h" #include "dird/storage.h" @@ -70,7 +71,7 @@ static inline char* lookup_fileindex(JobControlRecord* jcr, int32_t FileIndex) TREE_NODE *node, *parent; PoolMem restore_pathname, tmp; - node = FirstTreeNode(jcr->restore_tree_root); + node = FirstTreeNode(jcr->impl_->restore_tree_root); while (node) { /* * See if this is the wanted FileIndex. @@ -111,7 +112,7 @@ static inline int set_files_to_restore(JobControlRecord* jcr, TREE_NODE *node, *parent; PoolMem restore_pathname, tmp; - node = FirstTreeNode(jcr->restore_tree_root); + node = FirstTreeNode(jcr->impl_->restore_tree_root); while (node) { /* * See if this is the wanted FileIndex and the user asked to extract it. @@ -252,7 +253,7 @@ static inline bool fill_restore_environment(JobControlRecord* jcr, /* * Lookup any meta tags that need to be added. */ - fileset = jcr->res.fileset; + fileset = jcr->impl_->res.fileset; for (IncludeExcludeItem* ie : fileset->include_items) { /* * Loop over each file = entry of the fileset. @@ -283,7 +284,7 @@ static inline bool fill_restore_environment(JobControlRecord* jcr, if (jcr->where) { restore_prefix = jcr->where; } else { - restore_prefix = jcr->res.job->RestoreWhere; + restore_prefix = jcr->impl_->res.job->RestoreWhere; } if (!restore_prefix) { return false; } @@ -362,7 +363,7 @@ bool DoNdmpRestoreInit(JobControlRecord* jcr) { FreeWstorage(jcr); /* we don't write */ - if (!jcr->restore_tree_root) { + if (!jcr->impl_->restore_tree_root) { Jmsg(jcr, M_FATAL, 0, _("Cannot NDMP restore without a file selection.\n")); return false; } @@ -379,10 +380,10 @@ static inline int NdmpWaitForJobTermination(JobControlRecord* jcr) * so that we let the SD despool. */ Dmsg4(100, "cancel=%d FDJS=%d JS=%d SDJS=%d\n", jcr->IsCanceled(), - jcr->FDJobStatus, jcr->JobStatus, jcr->SDJobStatus); - if (jcr->IsCanceled() || (!jcr->res.job->RescheduleIncompleteJobs)) { - Dmsg3(100, "FDJS=%d JS=%d SDJS=%d\n", jcr->FDJobStatus, jcr->JobStatus, - jcr->SDJobStatus); + jcr->impl_->FDJobStatus, jcr->JobStatus, jcr->impl_->SDJobStatus); + if (jcr->IsCanceled() || (!jcr->impl_->res.job->RescheduleIncompleteJobs)) { + Dmsg3(100, "FDJS=%d JS=%d SDJS=%d\n", jcr->impl_->FDJobStatus, + jcr->JobStatus, jcr->impl_->SDJobStatus); CancelStorageDaemonJob(jcr); } @@ -391,10 +392,12 @@ static inline int NdmpWaitForJobTermination(JobControlRecord* jcr) */ WaitForStorageDaemonTermination(jcr); - jcr->FDJobStatus = JS_Terminated; + jcr->impl_->FDJobStatus = JS_Terminated; if (jcr->JobStatus != JS_Terminated) { return jcr->JobStatus; } - if (jcr->FDJobStatus != JS_Terminated) { return jcr->FDJobStatus; } - return jcr->SDJobStatus; + if (jcr->impl_->FDJobStatus != JS_Terminated) { + return jcr->impl_->FDJobStatus; + } + return jcr->impl_->SDJobStatus; } /** @@ -422,8 +425,8 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr) bool retval = false; int NdmpLoglevel; - if (jcr->res.client->ndmp_loglevel > me->ndmp_loglevel) { - NdmpLoglevel = jcr->res.client->ndmp_loglevel; + if (jcr->impl_->res.client->ndmp_loglevel > me->ndmp_loglevel) { + NdmpLoglevel = jcr->impl_->res.client->ndmp_loglevel; } else { NdmpLoglevel = me->ndmp_loglevel; } @@ -431,8 +434,8 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr) /* * We first parse the BootStrapRecord ourself so we know what to restore. */ - jcr->bsr = libbareos::parse_bsr(jcr, jcr->RestoreBootstrap); - if (!jcr->bsr) { + jcr->impl_->bsr = libbareos::parse_bsr(jcr, jcr->RestoreBootstrap); + if (!jcr->impl_->bsr) { Jmsg(jcr, M_FATAL, 0, _("Error parsing bootstrap file.\n")); goto bail_out; } @@ -441,11 +444,11 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr) * Setup all paired read storage. */ SetPairedStorage(jcr); - if (!jcr->res.paired_read_write_storage) { + if (!jcr->impl_->res.paired_read_write_storage) { Jmsg(jcr, M_FATAL, 0, _("Read storage %s doesn't point to storage definition with paired " "storage option.\n"), - jcr->res.read_storage->resource_name_); + jcr->impl_->res.read_storage->resource_name_); goto bail_out; } @@ -460,7 +463,7 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr) /* * Read the bootstrap file */ - bsr = jcr->bsr; + bsr = jcr->impl_->bsr; while (!feof(info.bs)) { if (!SelectNextRstore(jcr, info)) { goto cleanup; } @@ -470,8 +473,8 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr) * we perform as part of the whole job. We only free the env_table between * every sub-restore. */ - if (!NdmpBuildClientJob(jcr, jcr->res.client, - jcr->res.paired_read_write_storage, + if (!NdmpBuildClientJob(jcr, jcr->impl_->res.client, + jcr->impl_->res.paired_read_write_storage, NDM_JOB_OP_EXTRACT, &ndmp_job)) { goto cleanup; } @@ -496,7 +499,7 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr) /* * Now start a job with the Storage daemon */ - if (!StartStorageDaemonJob(jcr, jcr->res.read_storage_list, NULL)) { + if (!StartStorageDaemonJob(jcr, jcr->impl_->res.read_storage_list, NULL)) { goto cleanup; } @@ -533,13 +536,13 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr) bool first_run = true; bool next_sessid = true; bool next_fi = true; - int first_fi = jcr->bsr->FileIndex->findex; - int last_fi = jcr->bsr->FileIndex->findex2; - VolumeSessionInfo current_session{jcr->bsr->sessid->sessid, - jcr->bsr->sesstime->sesstime}; + int first_fi = jcr->impl_->bsr->FileIndex->findex; + int last_fi = jcr->impl_->bsr->FileIndex->findex2; + VolumeSessionInfo current_session{jcr->impl_->bsr->sessid->sessid, + jcr->impl_->bsr->sesstime->sesstime}; cnt = 0; - for (bsr = jcr->bsr; bsr; bsr = bsr->next) { + for (bsr = jcr->impl_->bsr; bsr; bsr = bsr->next) { if (current_session.id != bsr->sessid->sessid) { current_session = {bsr->sessid->sessid, bsr->sesstime->sesstime}; first_run = true; @@ -589,7 +592,7 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr) if (jcr->store_bsock && cnt > 0) { jcr->store_bsock->fsend("nextrun"); P(mutex); - pthread_cond_wait(&jcr->nextrun_ready, &mutex); + pthread_cond_wait(&jcr->impl_->nextrun_ready, &mutex); V(mutex); } @@ -620,7 +623,7 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr) /* * Copy the actual job to perform. */ - jcr->jr.FileIndex = current_fi; + jcr->impl_->jr.FileIndex = current_fi; memcpy(&ndmp_sess.control_acb->job, &ndmp_job, sizeof(struct ndm_job_param)); @@ -759,8 +762,8 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr) CloseBootstrapFile(info); bail_out: - FreeTree(jcr->restore_tree_root); - jcr->restore_tree_root = NULL; + FreeTree(jcr->impl_->restore_tree_root); + jcr->impl_->restore_tree_root = NULL; return retval; } @@ -772,14 +775,14 @@ bool DoNdmpRestore(JobControlRecord* jcr) { int status; - jcr->jr.JobLevel = L_FULL; /* Full restore */ - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->jr)) { + jcr->impl_->jr.JobLevel = L_FULL; /* Full restore */ + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); goto bail_out; } Dmsg0(20, "Updated job start record\n"); - Dmsg1(20, "RestoreJobId=%d\n", jcr->res.job->RestoreJobId); + Dmsg1(20, "RestoreJobId=%d\n", jcr->impl_->res.job->RestoreJobId); /* * Validate the Job to have a NDMP client. diff --git a/core/src/dird/ndmp_dma_restore_NDMP_NATIVE.cc b/core/src/dird/ndmp_dma_restore_NDMP_NATIVE.cc index f37b7685b02..6d97c1ff03c 100644 --- a/core/src/dird/ndmp_dma_restore_NDMP_NATIVE.cc +++ b/core/src/dird/ndmp_dma_restore_NDMP_NATIVE.cc @@ -41,6 +41,7 @@ #include "ndmp/ndmagents.h" #include "dird/ndmp_dma_storage.h" #include "ndmp_dma_priv.h" +#include "dird/jcr_private.h" #include "dird/ndmp_dma_restore_common.h" #include "dird/ndmp_dma_generic.h" @@ -107,7 +108,7 @@ static inline bool fill_restore_environment_ndmp_native( if (jcr->where) { restore_prefix = jcr->where; } else { - restore_prefix = jcr->res.job->RestoreWhere; + restore_prefix = jcr->impl_->res.job->RestoreWhere; } if (!restore_prefix) { return false; } @@ -176,7 +177,7 @@ int SetFilesToRestoreNdmpNative(JobControlRecord* jcr, TREE_NODE *node, *parent; PoolMem restore_pathname, tmp; - node = FirstTreeNode(jcr->restore_tree_root); + node = FirstTreeNode(jcr->impl_->restore_tree_root); while (node) { /* * node->extract_dir means that only the directory should be selected for @@ -253,16 +254,17 @@ static bool DoNdmpNativeRestore(JobControlRecord* jcr) slot_number_t ndmp_slot; StorageResource* store = NULL; - store = jcr->res.read_storage; + store = jcr->impl_->res.read_storage; memset(&ndmp_sess, 0, sizeof(ndmp_sess)); nis = (NIS*)malloc(sizeof(NIS)); memset(nis, 0, sizeof(NIS)); - NdmpLoglevel = std::max(jcr->res.client->ndmp_loglevel, me->ndmp_loglevel); + NdmpLoglevel = + std::max(jcr->impl_->res.client->ndmp_loglevel, me->ndmp_loglevel); - if (!NdmpBuildClientAndStorageJob(jcr, store, jcr->res.client, + if (!NdmpBuildClientAndStorageJob(jcr, store, jcr->impl_->res.client, true, /* init_tape */ true, /* init_robot */ NDM_JOB_OP_EXTRACT, &ndmp_job)) { @@ -449,8 +451,8 @@ static bool DoNdmpNativeRestore(JobControlRecord* jcr) cleanup: free(nis); - FreeTree(jcr->restore_tree_root); - jcr->restore_tree_root = NULL; + FreeTree(jcr->impl_->restore_tree_root); + jcr->impl_->restore_tree_root = NULL; return retval; } @@ -461,14 +463,14 @@ bool DoNdmpRestoreNdmpNative(JobControlRecord* jcr) { int status; - jcr->jr.JobLevel = L_FULL; /* Full restore */ - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->jr)) { + jcr->impl_->jr.JobLevel = L_FULL; /* Full restore */ + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); goto bail_out; } Dmsg0(20, "Updated job start record\n"); - Dmsg1(20, "RestoreJobId=%d\n", jcr->res.job->RestoreJobId); + Dmsg1(20, "RestoreJobId=%d\n", jcr->impl_->res.job->RestoreJobId); /* * Validate the Job to have a NDMP client. diff --git a/core/src/dird/ndmp_dma_restore_common.cc b/core/src/dird/ndmp_dma_restore_common.cc index 15f782a7338..4624dbf200b 100644 --- a/core/src/dird/ndmp_dma_restore_common.cc +++ b/core/src/dird/ndmp_dma_restore_common.cc @@ -30,6 +30,7 @@ #include "include/bareos.h" #include "dird.h" +#include "dird/jcr_private.h" #include "dird/job.h" #include "dird/restore.h" @@ -188,16 +189,16 @@ void NdmpRestoreCleanup(JobControlRecord* jcr, int TermCode) Dmsg0(20, "In NdmpRestoreCleanup\n"); UpdateJobEnd(jcr, TermCode); - if (jcr->unlink_bsr && jcr->RestoreBootstrap) { + if (jcr->impl_->unlink_bsr && jcr->RestoreBootstrap) { SecureErase(jcr, jcr->RestoreBootstrap); - jcr->unlink_bsr = false; + jcr->impl_->unlink_bsr = false; } if (JobCanceled(jcr)) { CancelStorageDaemonJob(jcr); } switch (TermCode) { case JS_Terminated: - if (jcr->ExpectedFiles > jcr->jr.JobFiles) { + if (jcr->impl_->ExpectedFiles > jcr->impl_->jr.JobFiles) { TermMsg = _("Restore OK -- warning file count mismatch"); } else { TermMsg = _("Restore OK"); @@ -212,14 +213,18 @@ void NdmpRestoreCleanup(JobControlRecord* jcr, int TermCode) msg_type = M_ERROR; /* Generate error message */ if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->SD_msg_chan_started) { pthread_cancel(jcr->SD_msg_chan); } + if (jcr->impl_->SD_msg_chan_started) { + pthread_cancel(jcr->impl_->SD_msg_chan); + } } break; case JS_Canceled: TermMsg = _("Restore Canceled"); if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->SD_msg_chan_started) { pthread_cancel(jcr->SD_msg_chan); } + if (jcr->impl_->SD_msg_chan_started) { + pthread_cancel(jcr->impl_->SD_msg_chan); + } } break; default: diff --git a/core/src/dird/ndmp_dma_storage.cc b/core/src/dird/ndmp_dma_storage.cc index abbd9af7bb4..d4b876f1570 100644 --- a/core/src/dird/ndmp_dma_storage.cc +++ b/core/src/dird/ndmp_dma_storage.cc @@ -30,6 +30,7 @@ #include "include/bareos.h" #include "dird.h" #include "dird/dird_globals.h" +#include "dird/jcr_private.h" #include "dird/sd_cmds.h" #include "dird/storage.h" #include "dird/ndmp_slot2elemaddr.h" @@ -71,10 +72,10 @@ int get_tape_info_cb(struct ndm_session* sess, } if (jcr->is_JobType(JT_BACKUP)) { - store = jcr->res.write_storage; + store = jcr->impl_->res.write_storage; } else if (jcr->is_JobType(JT_RESTORE)) { - store = jcr->res.read_storage; + store = jcr->impl_->res.read_storage; } else { return -1; @@ -187,7 +188,7 @@ void DoNdmpNativeStorageStatus(UaContext* ua, StorageResource* store, char* cmd) { struct ndm_job_param ndmp_job; - ua->jcr->res.write_storage = store; + ua->jcr->impl_->res.write_storage = store; if (!NdmpBuildStorageJob(ua->jcr, store, true, /* Query Tape Agent */ true, /* Query Robot Agent */ @@ -1140,7 +1141,7 @@ bool ndmp_native_setup_robot_and_tape_for_native_backup_job( * unload tape if tape is in drive */ ndmp_job.auto_remedy = 1; - ndmp_job.record_size = jcr->res.client->ndmp_blocksize; + ndmp_job.record_size = jcr->impl_->res.client->ndmp_blocksize; Jmsg(jcr, M_INFO, 0, _("Using Data host %s\n"), ndmp_job.data_agent.host); Jmsg(jcr, M_INFO, 0, _("Using Tape host:device:address %s:%s:@%d\n"), diff --git a/core/src/dird/newvol.cc b/core/src/dird/newvol.cc index 24e5734dd7b..d3a87deabe3 100644 --- a/core/src/dird/newvol.cc +++ b/core/src/dird/newvol.cc @@ -38,6 +38,7 @@ #include "include/bareos.h" #include "dird.h" #include "dird/expand.h" +#include "dird/jcr_private.h" #include "dird/next_vol.h" #include "cats/sql.h" #include "dird/ua_db.h" @@ -77,7 +78,7 @@ bool newVolume(JobControlRecord* jcr, MediaDbRecord* mr, StorageResource* store) *mr = MediaDbRecord{}; SetPoolDbrDefaultsInMediaDbr(mr, &pr); jcr->VolumeName[0] = 0; - bstrncpy(mr->MediaType, jcr->res.write_storage->media_type, + bstrncpy(mr->MediaType, jcr->impl_->res.write_storage->media_type, sizeof(mr->MediaType)); GeneratePluginEvent(jcr, bDirEventNewVolume); /* return void... */ if (jcr->VolumeName[0] && IsVolumeNameLegal(NULL, jcr->VolumeName)) { @@ -180,7 +181,7 @@ static bool PerformFullNameSubstitution(JobControlRecord* jcr, bool ok = false; POOLMEM* label = GetPoolMemory(PM_FNAME); - jcr->NumVols = pr->NumVols; + jcr->impl_->NumVols = pr->NumVols; if (VariableExpansion(jcr, pr->LabelFormat, label)) { bstrncpy(mr->VolumeName, label, sizeof(mr->VolumeName)); ok = true; diff --git a/core/src/dird/next_vol.cc b/core/src/dird/next_vol.cc index 298b56d0e56..fae7b9690ee 100644 --- a/core/src/dird/next_vol.cc +++ b/core/src/dird/next_vol.cc @@ -34,6 +34,7 @@ #include "dird.h" #include "dird/autoprune.h" #include "dird/autorecycle.h" +#include "dird/jcr_private.h" #include "dird/next_vol.h" #include "dird/newvol.h" #include "dird/ua_db.h" @@ -77,7 +78,7 @@ int FindNextVolumeForAppend(JobControlRecord* jcr, int retry = 0; bool ok; bool InChanger; - StorageResource* store = jcr->res.write_storage; + StorageResource* store = jcr->impl_->res.write_storage; bstrncpy(mr->MediaType, store->media_type, sizeof(mr->MediaType)); Dmsg3(debuglevel, @@ -171,12 +172,12 @@ int FindNextVolumeForAppend(JobControlRecord* jcr, /* * Look at more drastic ways to find an Appendable Volume */ - if (!ok && (jcr->res.pool->purge_oldest_volume || - jcr->res.pool->recycle_oldest_volume)) { + if (!ok && (jcr->impl_->res.pool->purge_oldest_volume || + jcr->impl_->res.pool->recycle_oldest_volume)) { Dmsg2(debuglevel, "No next volume found. PurgeOldest=%d\n RecyleOldest=%d", - jcr->res.pool->purge_oldest_volume, - jcr->res.pool->recycle_oldest_volume); + jcr->impl_->res.pool->purge_oldest_volume, + jcr->impl_->res.pool->recycle_oldest_volume); /* * Find oldest volume to recycle @@ -192,11 +193,11 @@ int FindNextVolumeForAppend(JobControlRecord* jcr, * 7. Try to purging oldest volume only if not UA calling us. */ ua = new_ua_context(jcr); - if (jcr->res.pool->purge_oldest_volume && create) { + if (jcr->impl_->res.pool->purge_oldest_volume && create) { Jmsg(jcr, M_INFO, 0, _("Purging oldest volume \"%s\"\n"), mr->VolumeName); ok = PurgeJobsFromVolume(ua, mr); - } else if (jcr->res.pool->recycle_oldest_volume) { + } else if (jcr->impl_->res.pool->recycle_oldest_volume) { /* * 8. Try recycling the oldest volume */ @@ -263,7 +264,7 @@ bool HasVolumeExpired(JobControlRecord* jcr, MediaDbRecord* mr) edit_uint64_with_commas(mr->MaxVolBytes, ed1), mr->VolumeName); bstrncpy(mr->VolStatus, "Full", sizeof(mr->VolStatus)); expired = true; - } else if (mr->VolBytes > 0 && jcr->res.pool->use_volume_once) { + } else if (mr->VolBytes > 0 && jcr->impl_->res.pool->use_volume_once) { /* * Volume should only be used once */ @@ -396,7 +397,7 @@ void CheckIfVolumeValidOrRecyclable(JobControlRecord* jcr, * try to catch close calls ... */ if ((mr->LastWritten + mr->VolRetention - 60) < (utime_t)time(NULL) && - jcr->res.pool->recycle_current_volume && + jcr->impl_->res.pool->recycle_current_volume && (bstrcmp(mr->VolStatus, "Full") || bstrcmp(mr->VolStatus, "Used"))) { /* * Attempt prune of current volume to see if we can recycle it for use. @@ -485,7 +486,7 @@ bool GetScratchVolume(JobControlRecord* jcr, * add a Volume. */ PoolDbRecord pr; - bstrncpy(pr.Name, jcr->res.pool->resource_name_, sizeof(pr.Name)); + bstrncpy(pr.Name, jcr->impl_->res.pool->resource_name_, sizeof(pr.Name)); if (!jcr->db->GetPoolRecord(jcr, &pr)) { Jmsg(jcr, M_WARNING, 0, _("Unable to get Pool record: ERR=%s"), @@ -499,7 +500,7 @@ bool GetScratchVolume(JobControlRecord* jcr, if (pr.MaxVols > 0 && pr.NumVols >= pr.MaxVols) { Jmsg(jcr, M_WARNING, 0, _("Unable add Scratch Volume, Pool \"%s\" full MaxVols=%d\n"), - jcr->res.pool->resource_name_, pr.MaxVols); + jcr->impl_->res.pool->resource_name_, pr.MaxVols); goto bail_out; } diff --git a/core/src/dird/quota.cc b/core/src/dird/quota.cc index bfb798b16e2..ce6e42c85f0 100644 --- a/core/src/dird/quota.cc +++ b/core/src/dird/quota.cc @@ -30,6 +30,7 @@ #include "include/bareos.h" #include "dird.h" +#include "dird/jcr_private.h" namespace directordaemon { @@ -47,39 +48,47 @@ uint64_t FetchRemainingQuotas(JobControlRecord* jcr) /* * Quotas not being used ? */ - if (!jcr->HasQuota) { return 0; } + if (!jcr->impl_->HasQuota) { return 0; } Dmsg2(debuglevel, "JobSumTotalBytes for JobId %d is %llu\n", jcr->JobId, - jcr->jr.JobSumTotalBytes); + jcr->impl_->jr.JobSumTotalBytes); Dmsg1(debuglevel, "Fetching remaining quotas for JobId %d\n", jcr->JobId); /* * If strict quotas on and grace exceeded, enforce the softquota */ - if (jcr->res.client->StrictQuotas && jcr->res.client->SoftQuota && - jcr->res.client->GraceTime > 0 && - (now - (uint64_t)jcr->res.client->GraceTime) > - (uint64_t)jcr->res.client->SoftQuotaGracePeriod && - jcr->res.client->SoftQuotaGracePeriod > 0) { - remaining = jcr->res.client->SoftQuota - jcr->jr.JobSumTotalBytes; - } else if (!jcr->res.client->StrictQuotas && jcr->res.client->SoftQuota && - jcr->res.client->GraceTime > 0 && - jcr->res.client->SoftQuotaGracePeriod > 0 && - (now - (uint64_t)jcr->res.client->GraceTime) > - (uint64_t)jcr->res.client->SoftQuotaGracePeriod) { + if (jcr->impl_->res.client->StrictQuotas && + jcr->impl_->res.client->SoftQuota && + jcr->impl_->res.client->GraceTime > 0 && + (now - (uint64_t)jcr->impl_->res.client->GraceTime) > + (uint64_t)jcr->impl_->res.client->SoftQuotaGracePeriod && + jcr->impl_->res.client->SoftQuotaGracePeriod > 0) { + remaining = + jcr->impl_->res.client->SoftQuota - jcr->impl_->jr.JobSumTotalBytes; + } else if (!jcr->impl_->res.client->StrictQuotas && + jcr->impl_->res.client->SoftQuota && + jcr->impl_->res.client->GraceTime > 0 && + jcr->impl_->res.client->SoftQuotaGracePeriod > 0 && + (now - (uint64_t)jcr->impl_->res.client->GraceTime) > + (uint64_t)jcr->impl_->res.client->SoftQuotaGracePeriod) { /* * If strict quotas turned off and grace exceeded use the last known limit */ - if (jcr->res.client->QuotaLimit > jcr->res.client->SoftQuota) { - remaining = jcr->res.client->QuotaLimit - jcr->jr.JobSumTotalBytes; + if (jcr->impl_->res.client->QuotaLimit > + jcr->impl_->res.client->SoftQuota) { + remaining = + jcr->impl_->res.client->QuotaLimit - jcr->impl_->jr.JobSumTotalBytes; } else { - remaining = jcr->res.client->SoftQuota - jcr->jr.JobSumTotalBytes; + remaining = + jcr->impl_->res.client->SoftQuota - jcr->impl_->jr.JobSumTotalBytes; } - } else if (jcr->jr.JobSumTotalBytes < jcr->res.client->HardQuota) { + } else if (jcr->impl_->jr.JobSumTotalBytes < + jcr->impl_->res.client->HardQuota) { /* * If within the hardquota. */ - remaining = jcr->res.client->HardQuota - jcr->jr.JobSumTotalBytes; + remaining = + jcr->impl_->res.client->HardQuota - jcr->impl_->jr.JobSumTotalBytes; } else { /* * If just over quota return 0. This shouldnt happen because quotas @@ -90,8 +99,8 @@ uint64_t FetchRemainingQuotas(JobControlRecord* jcr) Dmsg4(debuglevel, "Quota for %s is %llu. Remainder is %llu, QuotaLimit: %llu\n", - jcr->jr.Name, jcr->jr.JobSumTotalBytes, remaining, - jcr->res.client->QuotaLimit); + jcr->impl_->jr.Name, jcr->impl_->jr.JobSumTotalBytes, remaining, + jcr->impl_->res.client->QuotaLimit); return remaining; } @@ -112,35 +121,35 @@ bool CheckHardquotas(JobControlRecord* jcr) /* * Do not check if hardquota is not set */ - if (jcr->res.client->HardQuota == 0) { goto bail_out; } + if (jcr->impl_->res.client->HardQuota == 0) { goto bail_out; } Dmsg1(debuglevel, "Checking hard quotas for JobId %d\n", jcr->JobId); - if (!jcr->HasQuota) { - if (jcr->res.client->QuotaIncludeFailedJobs) { - if (!jcr->db->get_quota_jobbytes(jcr, &jcr->jr, - jcr->res.client->JobRetention)) { + if (!jcr->impl_->HasQuota) { + if (jcr->impl_->res.client->QuotaIncludeFailedJobs) { + if (!jcr->db->get_quota_jobbytes(jcr, &jcr->impl_->jr, + jcr->impl_->res.client->JobRetention)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Quota value: ERR=%s"), jcr->db->strerror()); goto bail_out; } } else { if (!jcr->db->get_quota_jobbytes_nofailed( - jcr, &jcr->jr, jcr->res.client->JobRetention)) { + jcr, &jcr->impl_->jr, jcr->impl_->res.client->JobRetention)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Quota value: ERR=%s"), jcr->db->strerror()); goto bail_out; } } - jcr->HasQuota = true; + jcr->impl_->HasQuota = true; } - if (jcr->jr.JobSumTotalBytes > jcr->res.client->HardQuota) { + if (jcr->impl_->jr.JobSumTotalBytes > jcr->impl_->res.client->HardQuota) { retval = true; goto bail_out; } - Dmsg2(debuglevel, "Quota for JobID: %d is %llu\n", jcr->jr.JobId, - jcr->jr.JobSumTotalBytes); + Dmsg2(debuglevel, "Quota for JobID: %d is %llu\n", jcr->impl_->jr.JobId, + jcr->impl_->jr.JobSumTotalBytes); bail_out: return retval; @@ -170,13 +179,13 @@ bool CheckSoftquotas(JobControlRecord* jcr) /* * Do not check if the softquota is not set */ - if (jcr->res.client->SoftQuota == 0) { goto bail_out; } + if (jcr->impl_->res.client->SoftQuota == 0) { goto bail_out; } Dmsg1(debuglevel, "Checking soft quotas for JobId %d\n", jcr->JobId); - if (!jcr->HasQuota) { - if (jcr->res.client->QuotaIncludeFailedJobs) { - if (!jcr->db->get_quota_jobbytes(jcr, &jcr->jr, - jcr->res.client->JobRetention)) { + if (!jcr->impl_->HasQuota) { + if (jcr->impl_->res.client->QuotaIncludeFailedJobs) { + if (!jcr->db->get_quota_jobbytes(jcr, &jcr->impl_->jr, + jcr->impl_->res.client->JobRetention)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Quota value: ERR=%s"), jcr->db->strerror()); goto bail_out; @@ -184,70 +193,70 @@ bool CheckSoftquotas(JobControlRecord* jcr) Dmsg0(debuglevel, "Quota Includes Failed Jobs\n"); } else { if (!jcr->db->get_quota_jobbytes_nofailed( - jcr, &jcr->jr, jcr->res.client->JobRetention)) { + jcr, &jcr->impl_->jr, jcr->impl_->res.client->JobRetention)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Quota value: ERR=%s"), jcr->db->strerror()); goto bail_out; } Jmsg(jcr, M_INFO, 0, _("Quota does NOT include Failed Jobs\n")); } - jcr->HasQuota = true; + jcr->impl_->HasQuota = true; } - Dmsg2(debuglevel, "Quota for %s is %llu\n", jcr->jr.Name, - jcr->jr.JobSumTotalBytes); - Dmsg2(debuglevel, "QuotaLimit for %s is %llu\n", jcr->jr.Name, - jcr->res.client->QuotaLimit); - Dmsg2(debuglevel, "HardQuota for %s is %llu\n", jcr->jr.Name, - jcr->res.client->HardQuota); - Dmsg2(debuglevel, "SoftQuota for %s is %llu\n", jcr->jr.Name, - jcr->res.client->SoftQuota); - Dmsg2(debuglevel, "SoftQuota Grace Period for %s is %d\n", jcr->jr.Name, - jcr->res.client->SoftQuotaGracePeriod); - Dmsg2(debuglevel, "SoftQuota Grace Time for %s is %d\n", jcr->jr.Name, - jcr->res.client->GraceTime); + Dmsg2(debuglevel, "Quota for %s is %llu\n", jcr->impl_->jr.Name, + jcr->impl_->jr.JobSumTotalBytes); + Dmsg2(debuglevel, "QuotaLimit for %s is %llu\n", jcr->impl_->jr.Name, + jcr->impl_->res.client->QuotaLimit); + Dmsg2(debuglevel, "HardQuota for %s is %llu\n", jcr->impl_->jr.Name, + jcr->impl_->res.client->HardQuota); + Dmsg2(debuglevel, "SoftQuota for %s is %llu\n", jcr->impl_->jr.Name, + jcr->impl_->res.client->SoftQuota); + Dmsg2(debuglevel, "SoftQuota Grace Period for %s is %d\n", + jcr->impl_->jr.Name, jcr->impl_->res.client->SoftQuotaGracePeriod); + Dmsg2(debuglevel, "SoftQuota Grace Time for %s is %d\n", jcr->impl_->jr.Name, + jcr->impl_->res.client->GraceTime); - if ((jcr->jr.JobSumTotalBytes + jcr->SDJobBytes) > - jcr->res.client->SoftQuota) { + if ((jcr->impl_->jr.JobSumTotalBytes + jcr->impl_->SDJobBytes) > + jcr->impl_->res.client->SoftQuota) { /* * Only warn once about softquotas in the job * Check if gracetime has been set */ - if (jcr->res.client->GraceTime == 0 && - jcr->res.client->SoftQuotaGracePeriod) { + if (jcr->impl_->res.client->GraceTime == 0 && + jcr->impl_->res.client->SoftQuotaGracePeriod) { Dmsg1(debuglevel, "UpdateQuotaGracetime: %d\n", now); - if (!jcr->db->UpdateQuotaGracetime(jcr, &jcr->jr)) { + if (!jcr->db->UpdateQuotaGracetime(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error setting Quota gracetime: ERR=%s"), jcr->db->strerror()); } else { Jmsg(jcr, M_ERROR, 0, _("Softquota Exceeded, Grace Period starts now.\n")); } - jcr->res.client->GraceTime = now; + jcr->impl_->res.client->GraceTime = now; goto bail_out; - } else if (jcr->res.client->SoftQuotaGracePeriod && - (now - (uint64_t)jcr->res.client->GraceTime) < - (uint64_t)jcr->res.client->SoftQuotaGracePeriod) { + } else if (jcr->impl_->res.client->SoftQuotaGracePeriod && + (now - (uint64_t)jcr->impl_->res.client->GraceTime) < + (uint64_t)jcr->impl_->res.client->SoftQuotaGracePeriod) { Jmsg(jcr, M_ERROR, 0, _("Softquota Exceeded, will be enforced after Grace Period " "expires.\n")); - } else if (jcr->res.client->SoftQuotaGracePeriod && - (now - (uint64_t)jcr->res.client->GraceTime) > - (uint64_t)jcr->res.client->SoftQuotaGracePeriod) { + } else if (jcr->impl_->res.client->SoftQuotaGracePeriod && + (now - (uint64_t)jcr->impl_->res.client->GraceTime) > + (uint64_t)jcr->impl_->res.client->SoftQuotaGracePeriod) { /* * If gracetime has expired update else check more if not set softlimit * yet then set and bail out. */ - if (jcr->res.client->QuotaLimit < 1) { - if (!jcr->db->UpdateQuotaSoftlimit(jcr, &jcr->jr)) { + if (jcr->impl_->res.client->QuotaLimit < 1) { + if (!jcr->db->UpdateQuotaSoftlimit(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error setting Quota Softlimit: ERR=%s"), jcr->db->strerror()); } Jmsg(jcr, M_WARNING, 0, _("Softquota Exceeded and Grace Period expired.\n")); Jmsg(jcr, M_INFO, 0, _("Setting Burst Quota to %d Bytes.\n"), - jcr->jr.JobSumTotalBytes); - jcr->res.client->QuotaLimit = jcr->jr.JobSumTotalBytes; + jcr->impl_->jr.JobSumTotalBytes); + jcr->impl_->res.client->QuotaLimit = jcr->impl_->jr.JobSumTotalBytes; retval = true; goto bail_out; } else { @@ -255,31 +264,33 @@ bool CheckSoftquotas(JobControlRecord* jcr) * If gracetime has expired update else check more if not set softlimit * yet then set and bail out. */ - if (jcr->res.client->QuotaLimit < 1) { - if (!jcr->db->UpdateQuotaSoftlimit(jcr, &jcr->jr)) { + if (jcr->impl_->res.client->QuotaLimit < 1) { + if (!jcr->db->UpdateQuotaSoftlimit(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error setting Quota Softlimit: ERR=%s"), jcr->db->strerror()); } Jmsg(jcr, M_WARNING, 0, _("Soft Quota exceeded and Grace Period expired.\n")); Jmsg(jcr, M_INFO, 0, _("Setting Burst Quota to %d Bytes.\n"), - jcr->jr.JobSumTotalBytes); - jcr->res.client->QuotaLimit = jcr->jr.JobSumTotalBytes; + jcr->impl_->jr.JobSumTotalBytes); + jcr->impl_->res.client->QuotaLimit = jcr->impl_->jr.JobSumTotalBytes; retval = true; goto bail_out; } else { /* * If we use strict quotas enforce the pure soft quota limit. */ - if (jcr->res.client->StrictQuotas) { - if (jcr->jr.JobSumTotalBytes > jcr->res.client->SoftQuota) { + if (jcr->impl_->res.client->StrictQuotas) { + if (jcr->impl_->jr.JobSumTotalBytes > + jcr->impl_->res.client->SoftQuota) { Dmsg0(debuglevel, "Soft Quota exceeded, enforcing Strict Quota Limit.\n"); retval = true; goto bail_out; } } else { - if (jcr->jr.JobSumTotalBytes >= jcr->res.client->QuotaLimit) { + if (jcr->impl_->jr.JobSumTotalBytes >= + jcr->impl_->res.client->QuotaLimit) { /* * If strict quotas turned off use the last known limit */ @@ -292,17 +303,17 @@ bool CheckSoftquotas(JobControlRecord* jcr) } } } - } else if (jcr->res.client->GraceTime != 0) { + } else if (jcr->impl_->res.client->GraceTime != 0) { /* * Reset softquota */ ClientDbRecord cr; - cr.ClientId = jcr->jr.ClientId; + cr.ClientId = jcr->impl_->jr.ClientId; if (!jcr->db->ResetQuotaRecord(jcr, &cr)) { Jmsg(jcr, M_WARNING, 0, _("Error setting Quota gracetime: ERR=%s\n"), jcr->db->strerror()); } else { - jcr->res.client->GraceTime = 0; + jcr->impl_->res.client->GraceTime = 0; Jmsg(jcr, M_INFO, 0, _("Soft Quota reset, Grace Period ends now.\n")); } } diff --git a/core/src/dird/recycle.cc b/core/src/dird/recycle.cc index 31ec7dbb215..bcf02f1467a 100644 --- a/core/src/dird/recycle.cc +++ b/core/src/dird/recycle.cc @@ -31,6 +31,7 @@ #include "include/bareos.h" #include "dird.h" #include "dird/autorecycle.h" +#include "dird/jcr_private.h" #include "dird/next_vol.h" namespace directordaemon { @@ -46,8 +47,8 @@ bool FindRecycledVolume(JobControlRecord* jcr, bstrncpy(mr->VolStatus, "Recycle", sizeof(mr->VolStatus)); SetStorageidInMr(store, mr); if (jcr->db->FindNextVolume(jcr, 1, InChanger, mr, unwanted_volumes)) { - jcr->MediaId = mr->MediaId; - Dmsg1(20, "Find_next_vol MediaId=%u\n", jcr->MediaId); + jcr->impl_->MediaId = mr->MediaId; + Dmsg1(20, "Find_next_vol MediaId=%u\n", jcr->impl_->MediaId); PmStrcpy(jcr->VolumeName, mr->VolumeName); SetStorageidInMr(store, mr); diff --git a/core/src/dird/restore.cc b/core/src/dird/restore.cc index 581d962d14d..4a18b3c69c2 100644 --- a/core/src/dird/restore.cc +++ b/core/src/dird/restore.cc @@ -46,6 +46,7 @@ #include "dird/backup.h" #include "dird/fd_cmds.h" #include "dird/getmsg.h" +#include "dird/jcr_private.h" #include "dird/job.h" #include "dird/msgchan.h" #include "dird/restore.h" @@ -82,10 +83,10 @@ static void BuildRestoreCommand(JobControlRecord* jcr, PoolMem& ret) /* * Build the restore command */ - if (jcr->replace != 0) { - replace = jcr->replace; - } else if (jcr->res.job->replace != 0) { - replace = jcr->res.job->replace; + if (jcr->impl_->replace != 0) { + replace = jcr->impl_->replace; + } else if (jcr->impl_->res.job->replace != 0) { + replace = jcr->impl_->res.job->replace; } else { replace = REPLACE_ALWAYS; /* always replace */ } @@ -93,21 +94,21 @@ static void BuildRestoreCommand(JobControlRecord* jcr, PoolMem& ret) if (jcr->RegexWhere) { where = jcr->RegexWhere; /* override */ cmd = restorecmdR; - } else if (jcr->res.job->RegexWhere) { - where = jcr->res.job->RegexWhere; /* no override take from job */ + } else if (jcr->impl_->res.job->RegexWhere) { + where = jcr->impl_->res.job->RegexWhere; /* no override take from job */ cmd = restorecmdR; } else if (jcr->where) { where = jcr->where; /* override */ cmd = restorecmd; - } else if (jcr->res.job->RestoreWhere) { - where = jcr->res.job->RestoreWhere; /* no override take from job */ + } else if (jcr->impl_->res.job->RestoreWhere) { + where = jcr->impl_->res.job->RestoreWhere; /* no override take from job */ cmd = restorecmd; } else { /* nothing was specified */ where = ∅ /* use default */ cmd = restorecmd; } - jcr->prefix_links = jcr->res.job->PrefixLinks; + jcr->prefix_links = jcr->impl_->res.job->PrefixLinks; BashSpaces(where); Mmsg(ret, cmd, replace, jcr->prefix_links, where); @@ -135,7 +136,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) PoolMem RestoreCmd(PM_MESSAGE); char* connection_target_address; - client = jcr->res.client; + client = jcr->impl_->res.client; /* * This command is used for each part */ @@ -152,7 +153,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) jcr->passive_client = client->passive; while (!feof(info.bs)) { if (!SelectNextRstore(jcr, info)) { goto bail_out; } - store = jcr->res.read_storage; + store = jcr->impl_->res.read_storage; /** * Open a message channel connection with the Storage @@ -174,7 +175,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) /* * Now start a job with the Storage daemon */ - if (!StartStorageDaemonJob(jcr, jcr->res.read_storage_list, NULL)) { + if (!StartStorageDaemonJob(jcr, jcr->impl_->res.read_storage_list, NULL)) { goto bail_out; } @@ -183,7 +184,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) * Start conversation with File daemon */ jcr->setJobStatus(JS_WaitFD); - jcr->keep_sd_auth_key = true; /* don't clear the sd_auth_key now */ + jcr->impl_->keep_sd_auth_key = true; /* don't clear the sd_auth_key now */ if (!ConnectToFileDaemon(jcr, 10, me->FDConnectTimeout, true)) { goto bail_out; @@ -198,11 +199,11 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) /* * Check if the file daemon supports passive client mode. */ - if (jcr->passive_client && jcr->FDVersion < FD_VERSION_51) { + if (jcr->passive_client && jcr->impl_->FDVersion < FD_VERSION_51) { Jmsg(jcr, M_FATAL, 0, _("Client \"%s\" doesn't support passive client mode. " "Please upgrade your client or disable compat mode.\n"), - jcr->res.client->resource_name_); + jcr->impl_->res.client->resource_name_); goto bail_out; } } @@ -247,7 +248,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) */ TlsPolicy tls_policy; - if (jcr->res.client->connection_successful_handshake_ != + if (jcr->impl_->res.client->connection_successful_handshake_ != ClientConnectionHandshakeMode::kTlsFirst) { tls_policy = store->GetPolicy(); } else { @@ -283,7 +284,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) TlsPolicy tls_policy; - if (jcr->res.client->connection_successful_handshake_ != + if (jcr->impl_->res.client->connection_successful_handshake_ != ClientConnectionHandshakeMode::kTlsFirst) { tls_policy = client->GetPolicy(); } else { @@ -332,7 +333,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) /* * Only FD version 52 and later understand the sending of plugin options. */ - if (jcr->FDVersion >= FD_VERSION_52) { + if (jcr->impl_->FDVersion >= FD_VERSION_52) { if (!SendPluginOptions(jcr)) { Dmsg0(000, "FAIL: Send plugin options\n"); goto bail_out; @@ -342,11 +343,11 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) * Plugin options specified and not a FD that understands the new * protocol keyword. */ - if (jcr->plugin_options) { + if (jcr->impl_->plugin_options) { Jmsg(jcr, M_FATAL, 0, _("Client \"%s\" doesn't support plugin option passing. " "Please upgrade your client or disable compat mode.\n"), - jcr->res.client->resource_name_); + jcr->impl_->res.client->resource_name_); goto bail_out; } } @@ -363,8 +364,8 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) goto bail_out; } - if (jcr->FDVersion < FD_VERSION_2) { /* Old FD */ - break; /* we do only one loop */ + if (jcr->impl_->FDVersion < FD_VERSION_2) { /* Old FD */ + break; /* we do only one loop */ } else { if (!response(jcr, fd, OKstoreend, "Store end", DISPLAY_ERROR)) { goto bail_out; @@ -373,7 +374,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) } } /* the whole boostrap has been send */ - if (fd && jcr->FDVersion >= FD_VERSION_2) { fd->fsend("endrestore"); } + if (fd && jcr->impl_->FDVersion >= FD_VERSION_2) { fd->fsend("endrestore"); } CloseBootstrapFile(info); return true; @@ -413,14 +414,14 @@ bool DoNativeRestore(JobControlRecord* jcr) { int status; - jcr->jr.JobLevel = L_FULL; /* Full restore */ - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->jr)) { + jcr->impl_->jr.JobLevel = L_FULL; /* Full restore */ + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); goto bail_out; } Dmsg0(20, "Updated job start record\n"); - Dmsg1(20, "RestoreJobId=%d\n", jcr->res.job->RestoreJobId); + Dmsg1(20, "RestoreJobId=%d\n", jcr->impl_->res.job->RestoreJobId); if (!jcr->RestoreBootstrap) { Jmsg(jcr, M_FATAL, 0, @@ -464,16 +465,16 @@ void NativeRestoreCleanup(JobControlRecord* jcr, int TermCode) Dmsg0(20, "In NativeRestoreCleanup\n"); UpdateJobEnd(jcr, TermCode); - if (jcr->unlink_bsr && jcr->RestoreBootstrap) { + if (jcr->impl_->unlink_bsr && jcr->RestoreBootstrap) { SecureErase(jcr, jcr->RestoreBootstrap); - jcr->unlink_bsr = false; + jcr->impl_->unlink_bsr = false; } if (JobCanceled(jcr)) { CancelStorageDaemonJob(jcr); } switch (TermCode) { case JS_Terminated: - if (jcr->ExpectedFiles > jcr->jr.JobFiles) { + if (jcr->impl_->ExpectedFiles > jcr->impl_->jr.JobFiles) { TermMsg = _("Restore OK -- warning file count mismatch"); } else { TermMsg = _("Restore OK"); @@ -488,14 +489,18 @@ void NativeRestoreCleanup(JobControlRecord* jcr, int TermCode) msg_type = M_ERROR; /* Generate error message */ if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->SD_msg_chan_started) { pthread_cancel(jcr->SD_msg_chan); } + if (jcr->impl_->SD_msg_chan_started) { + pthread_cancel(jcr->impl_->SD_msg_chan); + } } break; case JS_Canceled: TermMsg = _("Restore Canceled"); if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->SD_msg_chan_started) { pthread_cancel(jcr->SD_msg_chan); } + if (jcr->impl_->SD_msg_chan_started) { + pthread_cancel(jcr->impl_->SD_msg_chan); + } } break; default: @@ -526,18 +531,18 @@ void GenerateRestoreSummary(JobControlRecord* jcr, double kbps; PoolMem temp, secure_erase_status; - bstrftimes(sdt, sizeof(sdt), jcr->jr.StartTime); - bstrftimes(edt, sizeof(edt), jcr->jr.EndTime); - RunTime = jcr->jr.EndTime - jcr->jr.StartTime; + bstrftimes(sdt, sizeof(sdt), jcr->impl_->jr.StartTime); + bstrftimes(edt, sizeof(edt), jcr->impl_->jr.EndTime); + RunTime = jcr->impl_->jr.EndTime - jcr->impl_->jr.StartTime; if (RunTime <= 0) { kbps = 0; } else { - kbps = ((double)jcr->jr.JobBytes) / (1000.0 * (double)RunTime); + kbps = ((double)jcr->impl_->jr.JobBytes) / (1000.0 * (double)RunTime); } if (kbps < 0.05) { kbps = 0; } - JobstatusToAscii(jcr->FDJobStatus, fd_term_msg, sizeof(fd_term_msg)); - JobstatusToAscii(jcr->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); + JobstatusToAscii(jcr->impl_->FDJobStatus, fd_term_msg, sizeof(fd_term_msg)); + JobstatusToAscii(jcr->impl_->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); switch (jcr->getJobProtocol()) { case PT_NDMP_BAREOS: @@ -559,11 +564,12 @@ void GenerateRestoreSummary(JobControlRecord* jcr, " Bareos binary info: %s\n" " Termination: %s\n\n"), BAREOS, my_name, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER, - jcr->jr.JobId, jcr->jr.Job, jcr->res.client->resource_name_, sdt, - edt, edit_utime(RunTime, elapsed, sizeof(elapsed)), - edit_uint64_with_commas((uint64_t)jcr->ExpectedFiles, ec1), - edit_uint64_with_commas((uint64_t)jcr->jr.JobFiles, ec2), - edit_uint64_with_commas(jcr->jr.JobBytes, ec3), (float)kbps, + jcr->impl_->jr.JobId, jcr->impl_->jr.Job, + jcr->impl_->res.client->resource_name_, sdt, edt, + edit_utime(RunTime, elapsed, sizeof(elapsed)), + edit_uint64_with_commas((uint64_t)jcr->impl_->ExpectedFiles, ec1), + edit_uint64_with_commas((uint64_t)jcr->impl_->jr.JobFiles, ec2), + edit_uint64_with_commas(jcr->impl_->jr.JobBytes, ec3), (float)kbps, sd_term_msg, BAREOS_JOBLOG_MESSAGE, TermMsg); break; default: @@ -571,12 +577,14 @@ void GenerateRestoreSummary(JobControlRecord* jcr, Mmsg(temp, " Dir Secure Erase Cmd: %s\n", me->secure_erase_cmdline); PmStrcat(secure_erase_status, temp.c_str()); } - if (!bstrcmp(jcr->FDSecureEraseCmd, "*None*")) { - Mmsg(temp, " FD Secure Erase Cmd: %s\n", jcr->FDSecureEraseCmd); + if (!bstrcmp(jcr->impl_->FDSecureEraseCmd, "*None*")) { + Mmsg(temp, " FD Secure Erase Cmd: %s\n", + jcr->impl_->FDSecureEraseCmd); PmStrcat(secure_erase_status, temp.c_str()); } - if (!bstrcmp(jcr->SDSecureEraseCmd, "*None*")) { - Mmsg(temp, " SD Secure Erase Cmd: %s\n", jcr->SDSecureEraseCmd); + if (!bstrcmp(jcr->impl_->SDSecureEraseCmd, "*None*")) { + Mmsg(temp, " SD Secure Erase Cmd: %s\n", + jcr->impl_->SDSecureEraseCmd); PmStrcat(secure_erase_status, temp.c_str()); } @@ -600,11 +608,12 @@ void GenerateRestoreSummary(JobControlRecord* jcr, " Bareos binary info: %s\n" " Termination: %s\n\n"), BAREOS, my_name, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER, - jcr->jr.JobId, jcr->jr.Job, jcr->res.client->resource_name_, sdt, - edt, edit_utime(RunTime, elapsed, sizeof(elapsed)), - edit_uint64_with_commas((uint64_t)jcr->ExpectedFiles, ec1), - edit_uint64_with_commas((uint64_t)jcr->jr.JobFiles, ec2), - edit_uint64_with_commas(jcr->jr.JobBytes, ec3), (float)kbps, + jcr->impl_->jr.JobId, jcr->impl_->jr.Job, + jcr->impl_->res.client->resource_name_, sdt, edt, + edit_utime(RunTime, elapsed, sizeof(elapsed)), + edit_uint64_with_commas((uint64_t)jcr->impl_->ExpectedFiles, ec1), + edit_uint64_with_commas((uint64_t)jcr->impl_->jr.JobFiles, ec2), + edit_uint64_with_commas(jcr->impl_->jr.JobBytes, ec3), (float)kbps, jcr->JobErrors, fd_term_msg, sd_term_msg, secure_erase_status.c_str(), BAREOS_JOBLOG_MESSAGE, TermMsg); break; diff --git a/core/src/dird/scheduler.cc b/core/src/dird/scheduler.cc index 5e4a36dce5c..606ce327865 100644 --- a/core/src/dird/scheduler.cc +++ b/core/src/dird/scheduler.cc @@ -35,6 +35,7 @@ #include "include/bareos.h" #include "dird.h" #include "dird/dird_globals.h" +#include "dird/jcr_private.h" #include "dird/job.h" #include "dird/storage.h" #include "lib/parse_conf.h" @@ -106,7 +107,7 @@ JobControlRecord* wait_for_next_job(char* one_shot_job_to_run) Emsg1(M_ABORT, 0, _("Job %s not found\n"), one_shot_job_to_run); } Dmsg1(5, "Found one_shot_job_to_run %s\n", one_shot_job_to_run); - jcr = new_jcr(sizeof(JobControlRecord), DirdFreeJcr); + jcr = NewDirectorJcr(); SetJcrDefaults(jcr, job); return jcr; } @@ -166,7 +167,7 @@ JobControlRecord* wait_for_next_job(char* one_shot_job_to_run) } } - jcr = new_jcr(sizeof(JobControlRecord), DirdFreeJcr); + jcr = NewDirectorJcr(); run = next_job->run; /* pick up needed values */ job = next_job->job; @@ -187,33 +188,34 @@ JobControlRecord* wait_for_next_job(char* one_shot_job_to_run) if (run->level) { jcr->setJobLevel(run->level); /* override run level */ } if (run->pool) { - jcr->res.pool = run->pool; /* override pool */ - jcr->res.run_pool_override = true; + jcr->impl_->res.pool = run->pool; /* override pool */ + jcr->impl_->res.run_pool_override = true; } if (run->full_pool) { - jcr->res.full_pool = run->full_pool; /* override full pool */ - jcr->res.run_full_pool_override = true; + jcr->impl_->res.full_pool = run->full_pool; /* override full pool */ + jcr->impl_->res.run_full_pool_override = true; } if (run->vfull_pool) { - jcr->res.vfull_pool = run->vfull_pool; /* override virtual full pool */ - jcr->res.run_vfull_pool_override = true; + jcr->impl_->res.vfull_pool = + run->vfull_pool; /* override virtual full pool */ + jcr->impl_->res.run_vfull_pool_override = true; } if (run->inc_pool) { - jcr->res.inc_pool = run->inc_pool; /* override inc pool */ - jcr->res.run_inc_pool_override = true; + jcr->impl_->res.inc_pool = run->inc_pool; /* override inc pool */ + jcr->impl_->res.run_inc_pool_override = true; } if (run->diff_pool) { - jcr->res.diff_pool = run->diff_pool; /* override diff pool */ - jcr->res.run_diff_pool_override = true; + jcr->impl_->res.diff_pool = run->diff_pool; /* override diff pool */ + jcr->impl_->res.run_diff_pool_override = true; } if (run->next_pool) { - jcr->res.next_pool = run->next_pool; /* override next pool */ - jcr->res.run_next_pool_override = true; + jcr->impl_->res.next_pool = run->next_pool; /* override next pool */ + jcr->impl_->res.run_next_pool_override = true; } if (run->storage) { @@ -223,17 +225,21 @@ JobControlRecord* wait_for_next_job(char* one_shot_job_to_run) SetRwstorage(jcr, &store); /* override storage */ } - if (run->msgs) { jcr->res.messages = run->msgs; /* override messages */ } + if (run->msgs) { + jcr->impl_->res.messages = run->msgs; /* override messages */ + } if (run->Priority) { jcr->JobPriority = run->Priority; } - if (run->spool_data_set) { jcr->spool_data = run->spool_data; } + if (run->spool_data_set) { jcr->impl_->spool_data = run->spool_data; } if (run->accurate_set) { jcr->accurate = run->accurate; /* overwrite accurate mode */ } - if (run->MaxRunSchedTime_set) { jcr->MaxRunSchedTime = run->MaxRunSchedTime; } + if (run->MaxRunSchedTime_set) { + jcr->impl_->MaxRunSchedTime = run->MaxRunSchedTime; + } Dmsg0(debuglevel, "Leave wait_for_next_job()\n"); return jcr; diff --git a/core/src/dird/sd_cmds.cc b/core/src/dird/sd_cmds.cc index b494dc06de4..5f316363364 100644 --- a/core/src/dird/sd_cmds.cc +++ b/core/src/dird/sd_cmds.cc @@ -34,6 +34,7 @@ #include "dird/dird_globals.h" #include "dird/authenticate.h" #include "dird/getmsg.h" +#include "dird/jcr_private.h" #include "dird/job.h" #include "dird/msgchan.h" #include "dird/storage.h" @@ -93,10 +94,10 @@ bool ConnectToStorageDaemon(JobControlRecord* jcr, if (jcr->store_bsock) { return true; /* already connected */ } StorageResource* store; - if (jcr->res.write_storage) { - store = jcr->res.write_storage; + if (jcr->impl_->res.write_storage) { + store = jcr->impl_->res.write_storage; } else { - store = jcr->res.read_storage; + store = jcr->impl_->res.read_storage; } if (!store) { @@ -153,7 +154,7 @@ bool ConnectToStorageDaemon(JobControlRecord* jcr, BareosSocket* open_sd_bsock(UaContext* ua) { - StorageResource* store = ua->jcr->res.write_storage; + StorageResource* store = ua->jcr->impl_->res.write_storage; if (!store) { Dmsg0(200, "open_sd_bsock: No storage resource pointer set\n"); @@ -182,12 +183,12 @@ char* get_volume_name_from_SD(UaContext* ua, drive_number_t drive) { BareosSocket* sd; - StorageResource* store = ua->jcr->res.write_storage; + StorageResource* store = ua->jcr->impl_->res.write_storage; char dev_name[MAX_NAME_LENGTH]; char* VolName = nullptr; int rtn_slot; - ua->jcr->res.write_storage = store; + ua->jcr->impl_->res.write_storage = store; if (!(sd = open_sd_bsock(ua))) { ua->ErrorMsg(_("Could not open SD socket.\n")); return nullptr; @@ -266,7 +267,7 @@ dlist* native_get_vol_list(UaContext* ua, dlist* vol_list; BareosSocket* sd = nullptr; - ua->jcr->res.write_storage = store; + ua->jcr->impl_->res.write_storage = store; if (!(sd = open_sd_bsock(ua))) { return nullptr; } bstrncpy(dev_name, store->dev_name(), sizeof(dev_name)); @@ -547,7 +548,7 @@ slot_number_t NativeGetNumSlots(UaContext* ua, StorageResource* store) BareosSocket* sd; slot_number_t slots = 0; - ua->jcr->res.write_storage = store; + ua->jcr->impl_->res.write_storage = store; if (!(sd = open_sd_bsock(ua))) { return 0; } bstrncpy(dev_name, store->dev_name(), sizeof(dev_name)); @@ -579,7 +580,7 @@ drive_number_t NativeGetNumDrives(UaContext* ua, StorageResource* store) BareosSocket* sd; drive_number_t drives = 0; - ua->jcr->res.write_storage = store; + ua->jcr->impl_->res.write_storage = store; if (!(sd = open_sd_bsock(ua))) { return 0; } bstrncpy(dev_name, store->dev_name(), sizeof(dev_name)); @@ -613,7 +614,7 @@ bool CancelStorageDaemonJob(UaContext* ua, StorageResource* store, char* JobId) control_jcr = new_control_jcr("*JobCancel*", JT_SYSTEM); - control_jcr->res.write_storage = store; + control_jcr->impl_->res.write_storage = store; /* the next call will set control_jcr->store_bsock */ if (!ConnectToStorageDaemon(control_jcr, 10, me->SDConnectTimeout, true)) { @@ -641,18 +642,20 @@ bool CancelStorageDaemonJob(UaContext* ua, JobControlRecord* jcr, bool interactive) { - if (!ua->jcr->res.write_storage_list) { - if (jcr->res.read_storage_list) { - CopyWstorage(ua->jcr, jcr->res.read_storage_list, _("Job resource")); + if (!ua->jcr->impl_->res.write_storage_list) { + if (jcr->impl_->res.read_storage_list) { + CopyWstorage(ua->jcr, jcr->impl_->res.read_storage_list, + _("Job resource")); } else { - CopyWstorage(ua->jcr, jcr->res.write_storage_list, _("Job resource")); + CopyWstorage(ua->jcr, jcr->impl_->res.write_storage_list, + _("Job resource")); } } else { UnifiedStorageResource store; - if (jcr->res.read_storage_list) { - store.store = jcr->res.read_storage; + if (jcr->impl_->res.read_storage_list) { + store.store = jcr->impl_->res.read_storage; } else { - store.store = jcr->res.write_storage; + store.store = jcr->impl_->res.write_storage; } if (!store.store) { Dmsg0(200, "CancelStorageDaemonJob: No storage resource pointer set\n"); @@ -681,7 +684,7 @@ bool CancelStorageDaemonJob(UaContext* ua, TerminateAndCloseJcrStoreSocket(ua->jcr); - if (!interactive) { jcr->sd_canceled = true; } + if (!interactive) { jcr->impl_->sd_canceled = true; } SdMsgThreadSendSignal(jcr, TIMEOUT_SIGNAL); @@ -692,7 +695,7 @@ bool CancelStorageDaemonJob(UaContext* ua, void CancelStorageDaemonJob(JobControlRecord* jcr) { - if (jcr->sd_canceled) { return; /* cancel only once */ } + if (jcr->impl_->sd_canceled) { return; /* cancel only once */ } UaContext* ua = new_ua_context(jcr); JobControlRecord* control_jcr = new_control_jcr("*JobCancel*", JT_SYSTEM); @@ -776,7 +779,7 @@ bool NativeTransferVolume(UaContext* ua, bool retval = true; char dev_name[MAX_NAME_LENGTH]; - ua->jcr->res.write_storage = store; + ua->jcr->impl_->res.write_storage = store; if (!(sd = open_sd_bsock(ua))) { return false; } bstrncpy(dev_name, store->dev_name(), sizeof(dev_name)); @@ -823,7 +826,7 @@ bool NativeAutochangerVolumeOperation(UaContext* ua, bool retval = true; char dev_name[MAX_NAME_LENGTH]; - ua->jcr->res.write_storage = store; + ua->jcr->impl_->res.write_storage = store; if (!(sd = open_sd_bsock(ua))) { return false; } bstrncpy(dev_name, store->dev_name(), sizeof(dev_name)); @@ -860,21 +863,21 @@ bool SendSecureEraseReqToSd(JobControlRecord* jcr) int32_t n; BareosSocket* sd = jcr->store_bsock; - if (!jcr->SDSecureEraseCmd) { - jcr->SDSecureEraseCmd = GetPoolMemory(PM_NAME); + if (!jcr->impl_->SDSecureEraseCmd) { + jcr->impl_->SDSecureEraseCmd = GetPoolMemory(PM_NAME); } sd->fsend(getSecureEraseCmd); while ((n = BgetDirmsg(sd)) >= 0) { - jcr->SDSecureEraseCmd = - CheckPoolMemorySize(jcr->SDSecureEraseCmd, sd->message_length); - if (sscanf(sd->msg, OKSecureEraseCmd, jcr->SDSecureEraseCmd) == 1) { - Dmsg1(421, "Got SD Secure Erase Cmd: %s\n", jcr->SDSecureEraseCmd); + jcr->impl_->SDSecureEraseCmd = + CheckPoolMemorySize(jcr->impl_->SDSecureEraseCmd, sd->message_length); + if (sscanf(sd->msg, OKSecureEraseCmd, jcr->impl_->SDSecureEraseCmd) == 1) { + Dmsg1(421, "Got SD Secure Erase Cmd: %s\n", jcr->impl_->SDSecureEraseCmd); break; } else { Jmsg(jcr, M_WARNING, 0, _("Unexpected SD Secure Erase Cmd: %s\n"), sd->msg); - PmStrcpy(jcr->SDSecureEraseCmd, "*None*"); + PmStrcpy(jcr->impl_->SDSecureEraseCmd, "*None*"); return false; } } @@ -904,7 +907,7 @@ bool DoStorageResolve(UaContext* ua, StorageResource* store) PmStrcpy(lstore.store_source, _("unknown source")); SetWstorage(ua->jcr, &lstore); - ua->jcr->res.write_storage = store; + ua->jcr->impl_->res.write_storage = store; if (!(sd = open_sd_bsock(ua))) { return false; } for (int i = 1; i < ua->argc; i++) { @@ -926,9 +929,10 @@ bool SendStoragePluginOptions(JobControlRecord* jcr) const char* plugin_options; BareosSocket* sd = jcr->store_bsock; - if (jcr->res.job && jcr->res.job->SdPluginOptions && - jcr->res.job->SdPluginOptions->size()) { - foreach_alist_index (i, plugin_options, jcr->res.job->SdPluginOptions) { + if (jcr->impl_->res.job && jcr->impl_->res.job->SdPluginOptions && + jcr->impl_->res.job->SdPluginOptions->size()) { + foreach_alist_index (i, plugin_options, + jcr->impl_->res.job->SdPluginOptions) { PmStrcpy(cur_plugin_options, plugin_options); BashSpaces(cur_plugin_options.c_str()); diff --git a/core/src/dird/stats.cc b/core/src/dird/stats.cc index cd73c3d5136..3bf60dd7c4b 100644 --- a/core/src/dird/stats.cc +++ b/core/src/dird/stats.cc @@ -30,6 +30,7 @@ #include "include/bareos.h" #include "dird.h" #include "dird/dird_globals.h" +#include "dird/jcr_private.h" #include "cats/sql_pooling.h" #include "dird/sd_cmds.h" #include "dird/ua_server.h" @@ -130,17 +131,21 @@ extern "C" void* statistics_thread(void* arg) jcr = new_control_jcr("*StatisticsCollector*", JT_SYSTEM); - jcr->res.catalog = (CatalogResource*)my_config->GetNextRes(R_CATALOG, NULL); + jcr->impl_->res.catalog = + (CatalogResource*)my_config->GetNextRes(R_CATALOG, NULL); jcr->db = DbSqlGetPooledConnection( - jcr, jcr->res.catalog->db_driver, jcr->res.catalog->db_name, - jcr->res.catalog->db_user, jcr->res.catalog->db_password.value, - jcr->res.catalog->db_address, jcr->res.catalog->db_port, - jcr->res.catalog->db_socket, jcr->res.catalog->mult_db_connections, - jcr->res.catalog->disable_batch_insert, jcr->res.catalog->try_reconnect, - jcr->res.catalog->exit_on_fatal); + jcr, jcr->impl_->res.catalog->db_driver, jcr->impl_->res.catalog->db_name, + jcr->impl_->res.catalog->db_user, + jcr->impl_->res.catalog->db_password.value, + jcr->impl_->res.catalog->db_address, jcr->impl_->res.catalog->db_port, + jcr->impl_->res.catalog->db_socket, + jcr->impl_->res.catalog->mult_db_connections, + jcr->impl_->res.catalog->disable_batch_insert, + jcr->impl_->res.catalog->try_reconnect, + jcr->impl_->res.catalog->exit_on_fatal); if (jcr->db == NULL) { Jmsg(jcr, M_FATAL, 0, _("Could not open database \"%s\".\n"), - jcr->res.catalog->db_name); + jcr->impl_->res.catalog->db_name); goto bail_out; } @@ -197,7 +202,7 @@ extern "C" void* statistics_thread(void* arg) continue; } - jcr->res.read_storage = store; + jcr->impl_->res.read_storage = store; if (!ConnectToStorageDaemon(jcr, 2, 1, false)) { UnlockRes(my_config); continue; diff --git a/core/src/dird/storage.cc b/core/src/dird/storage.cc index 627018bf7f2..8d1842ee7fb 100644 --- a/core/src/dird/storage.cc +++ b/core/src/dird/storage.cc @@ -32,6 +32,7 @@ #include "include/bareos.h" #include "dird/dird.h" #include "dird/dird_globals.h" +#include "dird/jcr_private.h" #include "dird/sd_cmds.h" #include "lib/parse_conf.h" #include "lib/util.h" @@ -83,18 +84,20 @@ void CopyRstorage(JobControlRecord* jcr, alist* storage, const char* where) { if (storage) { StorageResource* store = nullptr; - if (jcr->res.read_storage_list) { delete jcr->res.read_storage_list; } - jcr->res.read_storage_list = new alist(10, not_owned_by_alist); + if (jcr->impl_->res.read_storage_list) { + delete jcr->impl_->res.read_storage_list; + } + jcr->impl_->res.read_storage_list = new alist(10, not_owned_by_alist); foreach_alist (store, storage) { - jcr->res.read_storage_list->append(store); + jcr->impl_->res.read_storage_list->append(store); } - if (!jcr->res.rstore_source) { - jcr->res.rstore_source = GetPoolMemory(PM_MESSAGE); + if (!jcr->impl_->res.rstore_source) { + jcr->impl_->res.rstore_source = GetPoolMemory(PM_MESSAGE); } - PmStrcpy(jcr->res.rstore_source, where); - if (jcr->res.read_storage_list) { - jcr->res.read_storage = - (StorageResource*)jcr->res.read_storage_list->first(); + PmStrcpy(jcr->impl_->res.rstore_source, where); + if (jcr->impl_->res.read_storage_list) { + jcr->impl_->res.read_storage = + (StorageResource*)jcr->impl_->res.read_storage_list->first(); } } } @@ -108,29 +111,29 @@ void SetRstorage(JobControlRecord* jcr, UnifiedStorageResource* store) StorageResource* storage = nullptr; if (!store->store) { return; } - if (jcr->res.read_storage_list) { FreeRstorage(jcr); } - if (!jcr->res.read_storage_list) { - jcr->res.read_storage_list = new alist(10, not_owned_by_alist); + if (jcr->impl_->res.read_storage_list) { FreeRstorage(jcr); } + if (!jcr->impl_->res.read_storage_list) { + jcr->impl_->res.read_storage_list = new alist(10, not_owned_by_alist); } - jcr->res.read_storage = store->store; - if (!jcr->res.rstore_source) { - jcr->res.rstore_source = GetPoolMemory(PM_MESSAGE); + jcr->impl_->res.read_storage = store->store; + if (!jcr->impl_->res.rstore_source) { + jcr->impl_->res.rstore_source = GetPoolMemory(PM_MESSAGE); } - PmStrcpy(jcr->res.rstore_source, store->store_source); - foreach_alist (storage, jcr->res.read_storage_list) { + PmStrcpy(jcr->impl_->res.rstore_source, store->store_source); + foreach_alist (storage, jcr->impl_->res.read_storage_list) { if (store->store == storage) { return; } } /* Store not in list, so add it */ - jcr->res.read_storage_list->prepend(store->store); + jcr->impl_->res.read_storage_list->prepend(store->store); } void FreeRstorage(JobControlRecord* jcr) { - if (jcr->res.read_storage_list) { - delete jcr->res.read_storage_list; - jcr->res.read_storage_list = NULL; + if (jcr->impl_->res.read_storage_list) { + delete jcr->impl_->res.read_storage_list; + jcr->impl_->res.read_storage_list = NULL; } - jcr->res.read_storage = NULL; + jcr->impl_->res.read_storage = NULL; } /** @@ -140,21 +143,24 @@ void CopyWstorage(JobControlRecord* jcr, alist* storage, const char* where) { if (storage) { StorageResource* st = nullptr; - if (jcr->res.write_storage_list) { delete jcr->res.write_storage_list; } - jcr->res.write_storage_list = new alist(10, not_owned_by_alist); + if (jcr->impl_->res.write_storage_list) { + delete jcr->impl_->res.write_storage_list; + } + jcr->impl_->res.write_storage_list = new alist(10, not_owned_by_alist); foreach_alist (st, storage) { Dmsg1(100, "write_storage_list=%s\n", st->resource_name_); - jcr->res.write_storage_list->append(st); + jcr->impl_->res.write_storage_list->append(st); } - if (!jcr->res.wstore_source) { - jcr->res.wstore_source = GetPoolMemory(PM_MESSAGE); + if (!jcr->impl_->res.wstore_source) { + jcr->impl_->res.wstore_source = GetPoolMemory(PM_MESSAGE); } - PmStrcpy(jcr->res.wstore_source, where); - if (jcr->res.write_storage_list) { - jcr->res.write_storage = - (StorageResource*)jcr->res.write_storage_list->first(); + PmStrcpy(jcr->impl_->res.wstore_source, where); + if (jcr->impl_->res.write_storage_list) { + jcr->impl_->res.write_storage = + (StorageResource*)jcr->impl_->res.write_storage_list->first(); Dmsg2(100, "write_storage=%s where=%s\n", - jcr->res.write_storage->resource_name_, jcr->res.wstore_source); + jcr->impl_->res.write_storage->resource_name_, + jcr->impl_->res.wstore_source); } } } @@ -168,34 +174,35 @@ void SetWstorage(JobControlRecord* jcr, UnifiedStorageResource* store) StorageResource* storage = nullptr; if (!store->store) { return; } - if (jcr->res.write_storage_list) { FreeWstorage(jcr); } - if (!jcr->res.write_storage_list) { - jcr->res.write_storage_list = new alist(10, not_owned_by_alist); + if (jcr->impl_->res.write_storage_list) { FreeWstorage(jcr); } + if (!jcr->impl_->res.write_storage_list) { + jcr->impl_->res.write_storage_list = new alist(10, not_owned_by_alist); } - jcr->res.write_storage = store->store; - if (!jcr->res.wstore_source) { - jcr->res.wstore_source = GetPoolMemory(PM_MESSAGE); + jcr->impl_->res.write_storage = store->store; + if (!jcr->impl_->res.wstore_source) { + jcr->impl_->res.wstore_source = GetPoolMemory(PM_MESSAGE); } - PmStrcpy(jcr->res.wstore_source, store->store_source); + PmStrcpy(jcr->impl_->res.wstore_source, store->store_source); Dmsg2(50, "write_storage=%s where=%s\n", - jcr->res.write_storage->resource_name_, jcr->res.wstore_source); - foreach_alist (storage, jcr->res.write_storage_list) { + jcr->impl_->res.write_storage->resource_name_, + jcr->impl_->res.wstore_source); + foreach_alist (storage, jcr->impl_->res.write_storage_list) { if (store->store == storage) { return; } } /* * Store not in list, so add it */ - jcr->res.write_storage_list->prepend(store->store); + jcr->impl_->res.write_storage_list->prepend(store->store); } void FreeWstorage(JobControlRecord* jcr) { - if (jcr->res.write_storage_list) { - delete jcr->res.write_storage_list; - jcr->res.write_storage_list = NULL; + if (jcr->impl_->res.write_storage_list) { + delete jcr->impl_->res.write_storage_list; + jcr->impl_->res.write_storage_list = NULL; } - jcr->res.write_storage = NULL; + jcr->impl_->res.write_storage = NULL; } /** @@ -213,32 +220,34 @@ void SetPairedStorage(JobControlRecord* jcr) /* * For a backup we look at the write storage. */ - if (jcr->res.write_storage_list) { + if (jcr->impl_->res.write_storage_list) { /* - * Setup the jcr->res.write_storage_list to point to all paired_storage - * entries of all the storage currently in the + * Setup the jcr->impl_->res.write_storage_list to point to all + * paired_storage entries of all the storage currently in the * jcrres.->write_storage_list. Save the original list under - * jcr->res.paired_read_write_storage_list. + * jcr->impl_->res.paired_read_write_storage_list. */ - jcr->res.paired_read_write_storage_list = jcr->res.write_storage_list; - jcr->res.write_storage_list = new alist(10, not_owned_by_alist); - foreach_alist (store, jcr->res.paired_read_write_storage_list) { + jcr->impl_->res.paired_read_write_storage_list = + jcr->impl_->res.write_storage_list; + jcr->impl_->res.write_storage_list = new alist(10, not_owned_by_alist); + foreach_alist (store, jcr->impl_->res.paired_read_write_storage_list) { if (store->paired_storage) { Dmsg1(100, "write_storage_list=%s\n", store->paired_storage->resource_name_); - jcr->res.write_storage_list->append(store->paired_storage); + jcr->impl_->res.write_storage_list->append(store->paired_storage); } } /* - * Swap the actual jcr->res.write_storage to point to the paired storage - * entry. We save the actual storage entry in paired_read_write_storage - * which is for restore in the FreePairedStorage() function. + * Swap the actual jcr->impl_->res.write_storage to point to the paired + * storage entry. We save the actual storage entry in + * paired_read_write_storage which is for restore in the + * FreePairedStorage() function. */ - store = jcr->res.write_storage; + store = jcr->impl_->res.write_storage; if (store->paired_storage) { - jcr->res.write_storage = store->paired_storage; - jcr->res.paired_read_write_storage = store; + jcr->impl_->res.write_storage = store->paired_storage; + jcr->impl_->res.paired_read_write_storage = store; } } else { Jmsg(jcr, M_FATAL, 0, @@ -249,15 +258,16 @@ void SetPairedStorage(JobControlRecord* jcr) /* * For a restores we look at the read storage. */ - if (jcr->res.read_storage_list) { + if (jcr->impl_->res.read_storage_list) { /* - * Setup the jcr->res.paired_read_write_storage_list to point to all - * paired_storage entries of all the storage currently in the - * jcr->res.read_storage_list. + * Setup the jcr->impl_->res.paired_read_write_storage_list to point to + * all paired_storage entries of all the storage currently in the + * jcr->impl_->res.read_storage_list. */ - jcr->res.paired_read_write_storage_list = + jcr->impl_->res.paired_read_write_storage_list = new alist(10, not_owned_by_alist); - foreach_alist (paired_read_write_storage, jcr->res.read_storage_list) { + foreach_alist (paired_read_write_storage, + jcr->impl_->res.read_storage_list) { store = (StorageResource*)my_config->GetNextRes(R_STORAGE, NULL); while (store) { if (store->paired_storage == paired_read_write_storage) { break; } @@ -271,15 +281,15 @@ void SetPairedStorage(JobControlRecord* jcr) * paired_read_write_storage as its paired storage. */ if (store) { - jcr->res.paired_read_write_storage_list->append(store); + jcr->impl_->res.paired_read_write_storage_list->append(store); /* * If the current processed paired_read_write_storage is also the - * current entry in jcr->res.read_storage update the + * current entry in jcr->impl_->res.read_storage update the * jcr->paired_read_write_storage to point to this storage entry. */ - if (paired_read_write_storage == jcr->res.read_storage) { - jcr->res.paired_read_write_storage = store; + if (paired_read_write_storage == jcr->impl_->res.read_storage) { + jcr->impl_->res.paired_read_write_storage = store; } } } @@ -293,32 +303,34 @@ void SetPairedStorage(JobControlRecord* jcr) /* * For a migrate or copy we look at the read storage. */ - if (jcr->res.read_storage_list) { + if (jcr->impl_->res.read_storage_list) { /* - * Setup the jcr->res.read_storage_list to point to all paired_storage - * entries of all the storage currently in the - * jcr->res.read_storage_list. Save the original list under - * jcr->res.paired_read_write_storage_list. + * Setup the jcr->impl_->res.read_storage_list to point to all + * paired_storage entries of all the storage currently in the + * jcr->impl_->res.read_storage_list. Save the original list under + * jcr->impl_->res.paired_read_write_storage_list. */ - jcr->res.paired_read_write_storage_list = jcr->res.read_storage_list; - jcr->res.read_storage_list = new alist(10, not_owned_by_alist); - foreach_alist (store, jcr->res.paired_read_write_storage_list) { + jcr->impl_->res.paired_read_write_storage_list = + jcr->impl_->res.read_storage_list; + jcr->impl_->res.read_storage_list = new alist(10, not_owned_by_alist); + foreach_alist (store, jcr->impl_->res.paired_read_write_storage_list) { if (store->paired_storage) { Dmsg1(100, "read_storage_list=%s\n", store->paired_storage->resource_name_); - jcr->res.read_storage_list->append(store->paired_storage); + jcr->impl_->res.read_storage_list->append(store->paired_storage); } } /* - * Swap the actual jcr->res.read_storage to point to the paired storage - * entry. We save the actual storage entry in paired_read_write_storage - * which is for restore in the FreePairedStorage() function. + * Swap the actual jcr->impl_->res.read_storage to point to the paired + * storage entry. We save the actual storage entry in + * paired_read_write_storage which is for restore in the + * FreePairedStorage() function. */ - store = jcr->res.read_storage; + store = jcr->impl_->res.read_storage; if (store->paired_storage) { - jcr->res.read_storage = store->paired_storage; - jcr->res.paired_read_write_storage = store; + jcr->impl_->res.read_storage = store->paired_storage; + jcr->impl_->res.paired_read_write_storage = store; } } else { Jmsg(jcr, M_FATAL, 0, @@ -340,49 +352,55 @@ void SetPairedStorage(JobControlRecord* jcr) */ void FreePairedStorage(JobControlRecord* jcr) { - if (jcr->res.paired_read_write_storage_list) { + if (jcr->impl_->res.paired_read_write_storage_list) { switch (jcr->getJobType()) { case JT_BACKUP: /* * For a backup we look at the write storage. */ - if (jcr->res.write_storage_list) { + if (jcr->impl_->res.write_storage_list) { /* - * The jcr->res.write_storage_list contain a set of paired storages. - * We just delete it content and swap back to the real master storage. + * The jcr->impl_->res.write_storage_list contain a set of paired + * storages. We just delete it content and swap back to the real + * master storage. */ - delete jcr->res.write_storage_list; - jcr->res.write_storage_list = jcr->res.paired_read_write_storage_list; - jcr->res.paired_read_write_storage_list = NULL; - jcr->res.write_storage = jcr->res.paired_read_write_storage; - jcr->res.paired_read_write_storage = NULL; + delete jcr->impl_->res.write_storage_list; + jcr->impl_->res.write_storage_list = + jcr->impl_->res.paired_read_write_storage_list; + jcr->impl_->res.paired_read_write_storage_list = NULL; + jcr->impl_->res.write_storage = + jcr->impl_->res.paired_read_write_storage; + jcr->impl_->res.paired_read_write_storage = NULL; } break; case JT_RESTORE: /* - * The jcr->res.read_storage_list contain a set of paired storages. - * For the read we created a list of alternative storage which we - * can just drop now. + * The jcr->impl_->res.read_storage_list contain a set of paired + * storages. For the read we created a list of alternative storage which + * we can just drop now. */ - delete jcr->res.paired_read_write_storage_list; - jcr->res.paired_read_write_storage_list = NULL; - jcr->res.paired_read_write_storage = NULL; + delete jcr->impl_->res.paired_read_write_storage_list; + jcr->impl_->res.paired_read_write_storage_list = NULL; + jcr->impl_->res.paired_read_write_storage = NULL; break; case JT_MIGRATE: case JT_COPY: /* * For a migrate or copy we look at the read storage. */ - if (jcr->res.read_storage_list) { + if (jcr->impl_->res.read_storage_list) { /* - * The jcr->res.read_storage_list contains a set of paired storages. - * We just delete it content and swap back to the real master storage. + * The jcr->impl_->res.read_storage_list contains a set of paired + * storages. We just delete it content and swap back to the real + * master storage. */ - delete jcr->res.read_storage_list; - jcr->res.read_storage_list = jcr->res.paired_read_write_storage_list; - jcr->res.paired_read_write_storage_list = NULL; - jcr->res.read_storage = jcr->res.paired_read_write_storage; - jcr->res.paired_read_write_storage = NULL; + delete jcr->impl_->res.read_storage_list; + jcr->impl_->res.read_storage_list = + jcr->impl_->res.paired_read_write_storage_list; + jcr->impl_->res.paired_read_write_storage_list = NULL; + jcr->impl_->res.read_storage = + jcr->impl_->res.paired_read_write_storage; + jcr->impl_->res.paired_read_write_storage = NULL; } break; default: @@ -406,8 +424,8 @@ bool HasPairedStorage(JobControlRecord* jcr) /* * For a backup we look at the write storage. */ - if (jcr->res.write_storage_list) { - foreach_alist (store, jcr->res.write_storage_list) { + if (jcr->impl_->res.write_storage_list) { + foreach_alist (store, jcr->impl_->res.write_storage_list) { if (!store->paired_storage) { return false; } } } else { @@ -420,8 +438,8 @@ bool HasPairedStorage(JobControlRecord* jcr) case JT_RESTORE: case JT_MIGRATE: case JT_COPY: - if (jcr->res.read_storage_list) { - foreach_alist (store, jcr->res.read_storage_list) { + if (jcr->impl_->res.read_storage_list) { + foreach_alist (store, jcr->impl_->res.read_storage_list) { if (!store->paired_storage) { return false; } } } else { @@ -450,7 +468,7 @@ bool SelectNextRstore(JobControlRecord* jcr, bootstrap_info& info) { UnifiedStorageResource ustore; - if (bstrcmp(jcr->res.read_storage->resource_name_, info.storage)) { + if (bstrcmp(jcr->impl_->res.read_storage->resource_name_, info.storage)) { return true; /* Same SD nothing to change */ } diff --git a/core/src/dird/testfind.cc b/core/src/dird/testfind.cc index 591d7b8c41f..210b02b3689 100644 --- a/core/src/dird/testfind.cc +++ b/core/src/dird/testfind.cc @@ -141,11 +141,11 @@ int main(int argc, char* const* argv) InitMsg(NULL, msg); } - jcr = new_jcr(sizeof(JobControlRecord), NULL); - jcr->res.fileset = + jcr = NewDirectorJcr(); // Ueb: null + jcr->impl_->res.fileset = (FilesetResource*)my_config->GetResWithName(R_FILESET, fileset_name); - if (jcr->res.fileset == NULL) { + if (jcr->impl_->res.fileset == NULL) { fprintf(stderr, "%s: Fileset not found\n", fileset_name); FilesetResource* var; @@ -413,7 +413,7 @@ static void CountFiles(FindFilesPacket* ar) static bool CopyFileset(FindFilesPacket* ff, JobControlRecord* jcr) { - FilesetResource* jcr_fileset = jcr->res.fileset; + FilesetResource* jcr_fileset = jcr->impl_->res.fileset; int num; bool include = true; diff --git a/core/src/dird/ua_cmds.cc b/core/src/dird/ua_cmds.cc index ca2a6aa60c5..93a54b4d454 100644 --- a/core/src/dird/ua_cmds.cc +++ b/core/src/dird/ua_cmds.cc @@ -35,6 +35,7 @@ #include "dird/ua_cmdstruct.h" #include "dird/expand.h" #include "dird/fd_cmds.h" +#include "dird/jcr_private.h" #include "dird/job.h" #include "dird/next_vol.h" #include "dird/sd_cmds.h" @@ -570,9 +571,9 @@ bool Do_a_command(UaContext* ua) Dmsg1(900, "Command: %s\n", ua->argk[0]); if (ua->argc == 0) { return false; } - while (ua->jcr->res.write_storage_list && - ua->jcr->res.write_storage_list->size()) { - ua->jcr->res.write_storage_list->remove(0); + while (ua->jcr->impl_->res.write_storage_list && + ua->jcr->impl_->res.write_storage_list->size()) { + ua->jcr->impl_->res.write_storage_list->remove(0); } len = strlen(ua->argk[0]); @@ -896,7 +897,7 @@ static inline bool SetbwlimitFiled(UaContext* ua, /* * Connect to File daemon */ - ua->jcr->res.client = client; + ua->jcr->impl_->res.client = client; ua->jcr->max_bandwidth = limit; /* @@ -921,7 +922,7 @@ static inline bool SetbwlimitFiled(UaContext* ua, ua->jcr->file_bsock->close(); delete ua->jcr->file_bsock; ua->jcr->file_bsock = NULL; - ua->jcr->res.client = NULL; + ua->jcr->impl_->res.client = NULL; ua->jcr->max_bandwidth = 0; return true; @@ -950,7 +951,7 @@ static inline bool setbwlimit_stored(UaContext* ua, /* * Connect to Storage daemon */ - ua->jcr->res.write_storage = store; + ua->jcr->impl_->res.write_storage = store; ua->jcr->max_bandwidth = limit; /* @@ -975,7 +976,7 @@ static inline bool setbwlimit_stored(UaContext* ua, ua->jcr->store_bsock->close(); delete ua->jcr->store_bsock; ua->jcr->store_bsock = NULL; - ua->jcr->res.write_storage = NULL; + ua->jcr->impl_->res.write_storage = NULL; ua->jcr->max_bandwidth = 0; return true; @@ -1017,10 +1018,10 @@ static bool SetbwlimitCmd(UaContext* ua, const char* cmd) switch (jcr->getJobType()) { case JT_COPY: case JT_MIGRATE: - store = jcr->res.read_storage; + store = jcr->impl_->res.read_storage; break; default: - client = jcr->res.client; + client = jcr->impl_->res.client; break; } FreeJcr(jcr); @@ -1230,7 +1231,7 @@ static void DoClientSetdebug(UaContext* ua, /* * Connect to File daemon */ - ua->jcr->res.client = client; + ua->jcr->impl_->res.client = client; /* * Try to connect for 15 seconds @@ -1245,7 +1246,7 @@ static void DoClientSetdebug(UaContext* ua, Dmsg0(120, "Connected to file daemon\n"); fd = ua->jcr->file_bsock; - if (ua->jcr->FDVersion >= FD_VERSION_53) { + if (ua->jcr->impl_->FDVersion >= FD_VERSION_53) { fd->fsend("setdebug=%d trace=%d hangup=%d timestamp=%d\n", level, trace_flag, hangup_flag, timestamp_flag); } else { @@ -1794,8 +1795,8 @@ static bool EstimateCmd(UaContext* ua, const char* cmd) return false; } - jcr->res.client = client; - jcr->res.fileset = fileset; + jcr->impl_->res.client = client; + jcr->impl_->res.fileset = fileset; CloseDb(ua); switch (client->Protocol) { @@ -1814,7 +1815,7 @@ static bool EstimateCmd(UaContext* ua, const char* cmd) if (!OpenDb(ua)) { return false; } - jcr->res.job = job; + jcr->impl_->res.job = job; jcr->setJobType(JT_BACKUP); jcr->start_time = time(NULL); InitJcrJobRecord(jcr); @@ -1826,8 +1827,8 @@ static bool EstimateCmd(UaContext* ua, const char* cmd) GetLevelSinceTime(jcr); ua->SendMsg(_("Connecting to Client %s at %s:%d\n"), - jcr->res.client->resource_name_, jcr->res.client->address, - jcr->res.client->FDport); + jcr->impl_->res.client->resource_name_, + jcr->impl_->res.client->address, jcr->impl_->res.client->FDport); if (!ConnectToFileDaemon(jcr, 1, 15, false)) { ua->ErrorMsg(_("Failed to connect to Client.\n")); return false; @@ -2118,14 +2119,15 @@ static bool DoTruncate(UaContext* ua, MediaDbRecord& mr) /* * Choose storage */ - ua->jcr->res.write_storage = ua->GetStoreResWithName(storage_dbr.Name); - if (!ua->jcr->res.write_storage) { + ua->jcr->impl_->res.write_storage = ua->GetStoreResWithName(storage_dbr.Name); + if (!ua->jcr->impl_->res.write_storage) { ua->ErrorMsg("failed to determine storage resource by name %s\n", storage_dbr.Name); goto bail_out; } - if (SendLabelRequest(ua, ua->jcr->res.write_storage, &mr, &mr, &pool_dbr, + if (SendLabelRequest(ua, ua->jcr->impl_->res.write_storage, &mr, &mr, + &pool_dbr, /* bool media_record_exists */ true, /* bool relabel */ @@ -2139,7 +2141,7 @@ static bool DoTruncate(UaContext* ua, MediaDbRecord& mr) } bail_out: - ua->jcr->res.write_storage = NULL; + ua->jcr->impl_->res.write_storage = NULL; return retval; } @@ -2438,7 +2440,7 @@ static void DoMountCmd(UaContext* ua, const char* cmd) if (!do_alldrives) { DoAutochangerVolumeOperation(ua, store.store, cmd, drive, slot); } else { - nr_drives = GetNumDrives(ua, ua->jcr->res.write_storage); + nr_drives = GetNumDrives(ua, ua->jcr->impl_->res.write_storage); for (drive_number_t i = 0; i < nr_drives; i++) { DoAutochangerVolumeOperation(ua, store.store, cmd, i, slot); } diff --git a/core/src/dird/ua_db.cc b/core/src/dird/ua_db.cc index b595aa4ba96..e01958fcd1e 100644 --- a/core/src/dird/ua_db.cc +++ b/core/src/dird/ua_db.cc @@ -30,6 +30,7 @@ #include "include/bareos.h" #include "dird.h" +#include "dird/jcr_private.h" #include "dird/ua_db.h" #include "cats/sql_pooling.h" #include "dird/ua_select.h" @@ -145,7 +146,7 @@ bool OpenDb(UaContext* ua, bool use_private) mult_db_conn = ua->catalog->mult_db_connections; if (use_private) { mult_db_conn = true; } - ua->jcr->res.catalog = ua->catalog; + ua->jcr->impl_->res.catalog = ua->catalog; Dmsg0(100, "UA Open database\n"); ua->db = DbSqlGetPooledConnection( ua->jcr, ua->catalog->db_driver, ua->catalog->db_name, diff --git a/core/src/dird/ua_dotcmds.cc b/core/src/dird/ua_dotcmds.cc index e140dc2fba3..1cb39b2aa72 100644 --- a/core/src/dird/ua_dotcmds.cc +++ b/core/src/dird/ua_dotcmds.cc @@ -742,7 +742,7 @@ static void DoClientCmd(UaContext* ua, ClientResource* client, const char* cmd) /* Connect to File daemon */ - ua->jcr->res.client = client; + ua->jcr->impl_->res.client = client; /* Try to connect for 15 seconds */ ua->SendMsg(_("Connecting to Client %s at %s:%d\n"), client->resource_name_, client->address, client->FDport); diff --git a/core/src/dird/ua_label.cc b/core/src/dird/ua_label.cc index ee6ab5174d6..3378d831e6f 100644 --- a/core/src/dird/ua_label.cc +++ b/core/src/dird/ua_label.cc @@ -39,6 +39,7 @@ #endif #include "dird/ndmp_dma_storage.h" +#include "dird/jcr_private.h" #include "dird/sd_cmds.h" #include "dird/storage.h" #include "dird/ua_db.h" @@ -67,7 +68,7 @@ static inline bool update_database(UaContext* ua, * Update existing media record. */ mr->InChanger = mr->Slot > 0; /* If slot give assume in changer */ - SetStorageidInMr(ua->jcr->res.write_storage, mr); + SetStorageidInMr(ua->jcr->impl_->res.write_storage, mr); if (!ua->db->UpdateMediaRecord(ua->jcr, mr)) { ua->ErrorMsg("%s", ua->db->strerror()); retval = false; @@ -79,7 +80,7 @@ static inline bool update_database(UaContext* ua, SetPoolDbrDefaultsInMediaDbr(mr, pr); mr->InChanger = mr->Slot > 0; /* If slot give assume in changer */ mr->Enabled = 1; - SetStorageidInMr(ua->jcr->res.write_storage, mr); + SetStorageidInMr(ua->jcr->impl_->res.write_storage, mr); if (ua->db->CreateMediaRecord(ua->jcr, mr)) { ua->InfoMsg(_("Catalog record for Volume \"%s\", Slot %hd successfully " @@ -119,7 +120,8 @@ static inline bool native_send_label_request(UaContext* ua, if (!(sd = open_sd_bsock(ua))) { return false; } - bstrncpy(dev_name, ua->jcr->res.write_storage->dev_name(), sizeof(dev_name)); + bstrncpy(dev_name, ua->jcr->impl_->res.write_storage->dev_name(), + sizeof(dev_name)); BashSpaces(dev_name); BashSpaces(mr->VolumeName); BashSpaces(mr->MediaType); @@ -288,19 +290,20 @@ static inline bool IsCleaningTape(UaContext* ua, /* * Find Pool resource */ - ua->jcr->res.pool = ua->GetPoolResWithName(pr->Name, false); - if (!ua->jcr->res.pool) { + ua->jcr->impl_->res.pool = ua->GetPoolResWithName(pr->Name, false); + if (!ua->jcr->impl_->res.pool) { ua->ErrorMsg(_("Pool \"%s\" resource not found for volume \"%s\"!\n"), pr->Name, mr->VolumeName); return false; } - retval = bstrncmp(mr->VolumeName, ua->jcr->res.pool->cleaning_prefix, - strlen(ua->jcr->res.pool->cleaning_prefix)); + retval = bstrncmp(mr->VolumeName, ua->jcr->impl_->res.pool->cleaning_prefix, + strlen(ua->jcr->impl_->res.pool->cleaning_prefix)); Dmsg4(100, "CLNprefix=%s: Vol=%s: len=%d bstrncmp=%s\n", - ua->jcr->res.pool->cleaning_prefix, mr->VolumeName, - strlen(ua->jcr->res.pool->cleaning_prefix), retval ? "true" : "false"); + ua->jcr->impl_->res.pool->cleaning_prefix, mr->VolumeName, + strlen(ua->jcr->impl_->res.pool->cleaning_prefix), + retval ? "true" : "false"); return retval; } @@ -315,7 +318,7 @@ static void label_from_barcodes(UaContext* ua, bool label_encrypt, bool yes) { - StorageResource* store = ua->jcr->res.write_storage; + StorageResource* store = ua->jcr->impl_->res.write_storage; PoolDbRecord pr; MediaDbRecord mr; vol_list_t* vl; @@ -325,7 +328,7 @@ static void label_from_barcodes(UaContext* ua, int max_slots; - max_slots = GetNumSlots(ua, ua->jcr->res.write_storage); + max_slots = GetNumSlots(ua, ua->jcr->impl_->res.write_storage); if (max_slots <= 0) { ua->WarningMsg(_("No slots in changer to scan.\n")); return; diff --git a/core/src/dird/ua_output.cc b/core/src/dird/ua_output.cc index 745ad5a0024..2ad019027ce 100644 --- a/core/src/dird/ua_output.cc +++ b/core/src/dird/ua_output.cc @@ -33,6 +33,7 @@ #include "include/bareos.h" #include "dird.h" #include "dird/dird_globals.h" +#include "dird/jcr_private.h" #include "dird/job.h" #include "dird/ua_cmdstruct.h" #include "cats/sql_pooling.h" @@ -1289,23 +1290,23 @@ static bool ListNextvol(UaContext* ua, int ndays) } } - jcr = new_jcr(sizeof(JobControlRecord), DirdFreeJcr); + jcr = NewDirectorJcr(); for (run = NULL; (run = find_next_run(run, job, runtime, ndays));) { if (!CompleteJcrForJob(jcr, job, run->pool)) { found = false; goto get_out; } - if (!jcr->jr.PoolId) { + if (!jcr->impl_->jr.PoolId) { ua->ErrorMsg(_("Could not find Pool for Job %s\n"), job->resource_name_); continue; } PoolDbRecord pr; - pr.PoolId = jcr->jr.PoolId; + pr.PoolId = jcr->impl_->jr.PoolId; if (!ua->db->GetPoolRecord(jcr, &pr)) { bstrncpy(pr.Name, "*UnknownPool*", sizeof(pr.Name)); } MediaDbRecord mr; - mr.PoolId = jcr->jr.PoolId; + mr.PoolId = jcr->impl_->jr.PoolId; GetJobStorage(&store, job, run); SetStorageidInMr(store.store, &mr); /* no need to set ScratchPoolId, since we use fnv_no_create_vol */ @@ -1419,7 +1420,7 @@ bool CompleteJcrForJob(JobControlRecord* jcr, PoolResource* pool) { SetJcrDefaults(jcr, job); - if (pool) { jcr->res.pool = pool; /* override */ } + if (pool) { jcr->impl_->res.pool = pool; /* override */ } if (jcr->db) { Dmsg0(100, "complete_jcr close db\n"); DbSqlClosePooledConnection(jcr, jcr->db); @@ -1428,22 +1429,25 @@ bool CompleteJcrForJob(JobControlRecord* jcr, Dmsg0(100, "complete_jcr open db\n"); jcr->db = DbSqlGetPooledConnection( - jcr, jcr->res.catalog->db_driver, jcr->res.catalog->db_name, - jcr->res.catalog->db_user, jcr->res.catalog->db_password.value, - jcr->res.catalog->db_address, jcr->res.catalog->db_port, - jcr->res.catalog->db_socket, jcr->res.catalog->mult_db_connections, - jcr->res.catalog->disable_batch_insert, jcr->res.catalog->try_reconnect, - jcr->res.catalog->exit_on_fatal); + jcr, jcr->impl_->res.catalog->db_driver, jcr->impl_->res.catalog->db_name, + jcr->impl_->res.catalog->db_user, + jcr->impl_->res.catalog->db_password.value, + jcr->impl_->res.catalog->db_address, jcr->impl_->res.catalog->db_port, + jcr->impl_->res.catalog->db_socket, + jcr->impl_->res.catalog->mult_db_connections, + jcr->impl_->res.catalog->disable_batch_insert, + jcr->impl_->res.catalog->try_reconnect, + jcr->impl_->res.catalog->exit_on_fatal); if (jcr->db == NULL) { Jmsg(jcr, M_FATAL, 0, _("Could not open database \"%s\".\n"), - jcr->res.catalog->db_name); + jcr->impl_->res.catalog->db_name); return false; } PoolDbRecord pr; - bstrncpy(pr.Name, jcr->res.pool->resource_name_, sizeof(pr.Name)); + bstrncpy(pr.Name, jcr->impl_->res.pool->resource_name_, sizeof(pr.Name)); while (!jcr->db->GetPoolRecord(jcr, &pr)) { /* get by Name */ /* Try to create the pool */ - if (CreatePool(jcr, jcr->db, jcr->res.pool, POOL_OP_CREATE) < 0) { + if (CreatePool(jcr, jcr->db, jcr->impl_->res.pool, POOL_OP_CREATE) < 0) { Jmsg(jcr, M_FATAL, 0, _("Pool %s not in database. %s"), pr.Name, jcr->db->strerror()); if (jcr->db) { @@ -1455,7 +1459,7 @@ bool CompleteJcrForJob(JobControlRecord* jcr, Jmsg(jcr, M_INFO, 0, _("Pool %s created in database.\n"), pr.Name); } } - jcr->jr.PoolId = pr.PoolId; + jcr->impl_->jr.PoolId = pr.PoolId; return true; } diff --git a/core/src/dird/ua_purge.cc b/core/src/dird/ua_purge.cc index 7b5ddcd0ba5..bc6e9f2b3da 100644 --- a/core/src/dird/ua_purge.cc +++ b/core/src/dird/ua_purge.cc @@ -34,6 +34,7 @@ #include "include/bareos.h" #include "dird.h" +#include "dird/jcr_private.h" #include "dird/next_vol.h" #include "dird/sd_cmds.h" #include "dird/ua_db.h" @@ -755,7 +756,7 @@ static bool ActionOnPurgeCmd(UaContext* ua, const char* cmd) /* * Choose storage */ - ua->jcr->res.write_storage = store = get_storage_resource(ua); + ua->jcr->impl_->res.write_storage = store = get_storage_resource(ua); if (!store) { goto bail_out; } switch (store->Protocol) { @@ -834,7 +835,7 @@ static bool ActionOnPurgeCmd(UaContext* ua, const char* cmd) bail_out: CloseDb(ua); if (sd) { CloseSdBsock(ua); } - ua->jcr->res.write_storage = NULL; + ua->jcr->impl_->res.write_storage = NULL; if (results) { free(results); } return true; diff --git a/core/src/dird/ua_restore.cc b/core/src/dird/ua_restore.cc index dd28ddbd3ff..344ff82742e 100644 --- a/core/src/dird/ua_restore.cc +++ b/core/src/dird/ua_restore.cc @@ -36,6 +36,7 @@ #include "include/bareos.h" #include "dird.h" #include "dird/dird_globals.h" +#include "dird/jcr_private.h" #include "dird/ua_db.h" #include "dird/ua_input.h" #include "dird/ua_select.h" @@ -1228,7 +1229,7 @@ static bool BuildDirectoryTree(UaContext* ua, RestoreContext* rx) * For NDMP restores its used in the DMA to know what to restore. * The tree is freed by the DMA when its done. */ - ua->jcr->restore_tree_root = tree.root; + ua->jcr->impl_->restore_tree_root = tree.root; return OK; } diff --git a/core/src/dird/ua_run.cc b/core/src/dird/ua_run.cc index 4df3333256c..f9e852320b7 100644 --- a/core/src/dird/ua_run.cc +++ b/core/src/dird/ua_run.cc @@ -28,6 +28,7 @@ */ #include "include/bareos.h" #include "dird.h" +#include "dird/jcr_private.h" #include "dird/job.h" #include "dird/migration.h" #include "dird/storage.h" @@ -390,10 +391,11 @@ int DoRunCmd(UaContext* ua, const char* cmd) * before returning. */ if (!jcr) { - jcr = new_jcr(sizeof(JobControlRecord), DirdFreeJcr); + jcr = NewDirectorJcr(); SetJcrDefaults(jcr, rc.job); - jcr->unlink_bsr = ua->jcr->unlink_bsr; /* copy unlink flag from caller */ - ua->jcr->unlink_bsr = false; + jcr->impl_->unlink_bsr = + ua->jcr->impl_->unlink_bsr; /* copy unlink flag from caller */ + ua->jcr->impl_->unlink_bsr = false; } /* @@ -407,9 +409,9 @@ int DoRunCmd(UaContext* ua, const char* cmd) /* * Transfer selected restore tree to new restore Job */ - if (ua->jcr->restore_tree_root) { - jcr->restore_tree_root = ua->jcr->restore_tree_root; - ua->jcr->restore_tree_root = NULL; + if (ua->jcr->impl_->restore_tree_root) { + jcr->impl_->restore_tree_root = ua->jcr->impl_->restore_tree_root; + ua->jcr->impl_->restore_tree_root = NULL; } try_again: @@ -503,22 +505,22 @@ int DoRunCmd(UaContext* ua, const char* cmd) * For interactive runs we set IgnoreLevelPoolOverrides as we already * performed the actual overrrides. */ - jcr->IgnoreLevelPoolOverides = true; + jcr->impl_->IgnoreLevelPoolOverides = true; if (ua->cmd[0] == 0 || bstrncasecmp(ua->cmd, NT_("yes"), strlen(ua->cmd)) || bstrncasecmp(ua->cmd, _("yes"), strlen(ua->cmd))) { JobId_t JobId; - Dmsg1(800, "Calling RunJob job=%x\n", jcr->res.job); + Dmsg1(800, "Calling RunJob job=%x\n", jcr->impl_->res.job); start_job: Dmsg3(100, "JobId=%u using pool %s priority=%d\n", (int)jcr->JobId, - jcr->res.pool->resource_name_, jcr->JobPriority); - Dmsg1(900, "Running a job; its spool_data = %d\n", jcr->spool_data); + jcr->impl_->res.pool->resource_name_, jcr->JobPriority); + Dmsg1(900, "Running a job; its spool_data = %d\n", jcr->impl_->spool_data); JobId = RunJob(jcr); Dmsg4(100, "JobId=%u NewJobId=%d using pool %s priority=%d\n", - (int)jcr->JobId, JobId, jcr->res.pool->resource_name_, + (int)jcr->JobId, JobId, jcr->impl_->res.pool->resource_name_, jcr->JobPriority); FreeJcr(jcr); /* release jcr */ @@ -602,7 +604,7 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc) case JT_BACKUP: if (!rc.pool_override && !jcr->is_JobLevel(L_VIRTUAL_FULL)) { ApplyPoolOverrides(jcr, true); - rc.pool = jcr->res.pool; + rc.pool = jcr->impl_->res.pool; rc.level_override = true; } break; @@ -623,7 +625,7 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc) /* Job */ rc.job = select_job_resource(ua); if (rc.job) { - jcr->res.job = rc.job; + jcr->impl_->res.job = rc.job; SetJcrDefaults(jcr, rc.job); goto try_again; } @@ -632,7 +634,7 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc) /* FileSet */ rc.fileset = select_fileset_resource(ua); if (rc.fileset) { - jcr->res.fileset = rc.fileset; + jcr->impl_->res.fileset = rc.fileset; goto try_again; } break; @@ -640,18 +642,18 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc) /* Client */ rc.client = select_client_resource(ua); if (rc.client) { - jcr->res.client = rc.client; + jcr->impl_->res.client = rc.client; goto try_again; } break; case 5: /* Backup Format */ if (GetCmd(ua, _("Please enter Backup Format: "))) { - if (jcr->backup_format) { - free(jcr->backup_format); - jcr->backup_format = NULL; + if (jcr->impl_->backup_format) { + free(jcr->impl_->backup_format); + jcr->impl_->backup_format = NULL; } - jcr->backup_format = strdup(ua->cmd); + jcr->impl_->backup_format = strdup(ua->cmd); goto try_again; } break; @@ -689,10 +691,11 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc) jcr->is_JobType(JT_VERIFY)) { /* Pool */ rc.pool = select_pool_resource(ua); if (rc.pool) { - jcr->res.pool = rc.pool; + jcr->impl_->res.pool = rc.pool; rc.level_override = false; rc.pool_override = true; - Dmsg1(100, "Set new pool=%s\n", jcr->res.pool->resource_name_); + Dmsg1(100, "Set new pool=%s\n", + jcr->impl_->res.pool->resource_name_); goto try_again; } } else { @@ -728,14 +731,14 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc) jcr->is_JobLevel(L_VIRTUAL_FULL))) { /* NextPool */ rc.next_pool = select_pool_resource(ua); if (rc.next_pool) { - jcr->res.next_pool = rc.next_pool; + jcr->impl_->res.next_pool = rc.next_pool; Dmsg1(100, "Set new next_pool=%s\n", - jcr->res.next_pool->resource_name_); + jcr->impl_->res.next_pool->resource_name_); goto try_again; } } else if (jcr->is_JobType(JT_VERIFY)) { /* Verify Job */ rc.verify_job = select_job_resource(ua); - if (rc.verify_job) { jcr->res.verify_job = rc.verify_job; } + if (rc.verify_job) { jcr->impl_->res.verify_job = rc.verify_job; } goto try_again; } else if (jcr->is_JobType(JT_RESTORE)) { /* Where */ if (GetCmd(ua, _("Please enter the full path prefix for restore (/ " @@ -756,11 +759,11 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc) } } else { /* Plugin Options */ if (GetCmd(ua, _("Please enter Plugin Options string: "))) { - if (jcr->plugin_options) { - free(jcr->plugin_options); - jcr->plugin_options = NULL; + if (jcr->impl_->plugin_options) { + free(jcr->impl_->plugin_options); + jcr->impl_->plugin_options = NULL; } - jcr->plugin_options = strdup(ua->cmd); + jcr->impl_->plugin_options = strdup(ua->cmd); goto try_again; } } @@ -772,11 +775,11 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc) goto try_again; } else if (jcr->is_JobType(JT_BACKUP)) { if (GetCmd(ua, _("Please enter Plugin Options string: "))) { - if (jcr->plugin_options) { - free(jcr->plugin_options); - jcr->plugin_options = NULL; + if (jcr->impl_->plugin_options) { + free(jcr->impl_->plugin_options); + jcr->impl_->plugin_options = NULL; } - jcr->plugin_options = strdup(ua->cmd); + jcr->impl_->plugin_options = strdup(ua->cmd); goto try_again; } } @@ -790,13 +793,13 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc) opt = DoPrompt(ua, "", _("Select replace option"), NULL, 0); if (opt >= 0) { rc.replace = ReplaceOptions[opt].name; - jcr->replace = ReplaceOptions[opt].token; + jcr->impl_->replace = ReplaceOptions[opt].token; } goto try_again; case 12: /* JobId */ rc.jid = NULL; /* force reprompt */ - jcr->RestoreJobId = 0; + jcr->impl_->RestoreJobId = 0; if (jcr->RestoreBootstrap) { ua->SendMsg( _("You must set the bootstrap file to NULL to be able to specify " @@ -806,11 +809,11 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc) case 13: /* Plugin Options */ if (GetCmd(ua, _("Please enter Plugin Options string: "))) { - if (jcr->plugin_options) { - free(jcr->plugin_options); - jcr->plugin_options = NULL; + if (jcr->impl_->plugin_options) { + free(jcr->impl_->plugin_options); + jcr->impl_->plugin_options = NULL; } - jcr->plugin_options = strdup(ua->cmd); + jcr->impl_->plugin_options = strdup(ua->cmd); goto try_again; } break; @@ -839,10 +842,10 @@ static bool ResetRestoreContext(UaContext* ua, JobControlRecord* jcr, RunContext& rc) { - jcr->res.verify_job = rc.verify_job; - jcr->res.previous_job = rc.previous_job; - jcr->res.pool = rc.pool; - jcr->res.next_pool = rc.next_pool; + jcr->impl_->res.verify_job = rc.verify_job; + jcr->impl_->res.previous_job = rc.previous_job; + jcr->impl_->res.pool = rc.pool; + jcr->impl_->res.next_pool = rc.next_pool; /* * See if an explicit pool override was performed. @@ -851,31 +854,32 @@ static bool ResetRestoreContext(UaContext* ua, * overrides are ignored. */ if (rc.pool_name) { - PmStrcpy(jcr->res.pool_source, _("command line")); - jcr->IgnoreLevelPoolOverides = true; - } else if (!rc.level_override && jcr->res.pool != jcr->res.job->pool) { - PmStrcpy(jcr->res.pool_source, _("user input")); + PmStrcpy(jcr->impl_->res.pool_source, _("command line")); + jcr->impl_->IgnoreLevelPoolOverides = true; + } else if (!rc.level_override && + jcr->impl_->res.pool != jcr->impl_->res.job->pool) { + PmStrcpy(jcr->impl_->res.pool_source, _("user input")); } SetRwstorage(jcr, rc.store); if (rc.next_pool_name) { - PmStrcpy(jcr->res.npool_source, _("command line")); - jcr->res.run_next_pool_override = true; - } else if (jcr->res.next_pool != jcr->res.pool->NextPool) { - PmStrcpy(jcr->res.npool_source, _("user input")); - jcr->res.run_next_pool_override = true; + PmStrcpy(jcr->impl_->res.npool_source, _("command line")); + jcr->impl_->res.run_next_pool_override = true; + } else if (jcr->impl_->res.next_pool != jcr->impl_->res.pool->NextPool) { + PmStrcpy(jcr->impl_->res.npool_source, _("user input")); + jcr->impl_->res.run_next_pool_override = true; } - jcr->res.client = rc.client; - if (jcr->res.client) { + jcr->impl_->res.client = rc.client; + if (jcr->impl_->res.client) { PmStrcpy(jcr->client_name, rc.client->resource_name_); } - jcr->res.fileset = rc.fileset; - jcr->ExpectedFiles = rc.files; + jcr->impl_->res.fileset = rc.fileset; + jcr->impl_->ExpectedFiles = rc.files; if (rc.catalog) { - jcr->res.catalog = rc.catalog; - PmStrcpy(jcr->res.catalog_source, _("user input")); + jcr->impl_->res.catalog = rc.catalog; + PmStrcpy(jcr->impl_->res.catalog_source, _("user input")); } PmStrcpy(jcr->comment, rc.comment); @@ -908,26 +912,26 @@ static bool ResetRestoreContext(UaContext* ua, } if (rc.plugin_options) { - if (jcr->plugin_options) { free(jcr->plugin_options); } - jcr->plugin_options = strdup(rc.plugin_options); + if (jcr->impl_->plugin_options) { free(jcr->impl_->plugin_options); } + jcr->impl_->plugin_options = strdup(rc.plugin_options); rc.plugin_options = NULL; } if (rc.replace) { - jcr->replace = 0; + jcr->impl_->replace = 0; for (int i = 0; ReplaceOptions[i].name; i++) { if (Bstrcasecmp(rc.replace, ReplaceOptions[i].name)) { - jcr->replace = ReplaceOptions[i].token; + jcr->impl_->replace = ReplaceOptions[i].token; } } - if (!jcr->replace) { + if (!jcr->impl_->replace) { ua->SendMsg(_("Invalid replace option: %s\n"), rc.replace); return false; } } else if (rc.job->replace) { - jcr->replace = rc.job->replace; + jcr->impl_->replace = rc.job->replace; } else { - jcr->replace = REPLACE_ALWAYS; + jcr->impl_->replace = REPLACE_ALWAYS; } rc.replace = NULL; @@ -943,7 +947,7 @@ static bool ResetRestoreContext(UaContext* ua, } if (rc.cloned) { - jcr->cloned = rc.cloned; + jcr->impl_->cloned = rc.cloned; rc.cloned = false; } @@ -959,7 +963,7 @@ static bool ResetRestoreContext(UaContext* ua, } rc.replace = ReplaceOptions[0].name; for (int i = 0; ReplaceOptions[i].name; i++) { - if (ReplaceOptions[i].token == jcr->replace) { + if (ReplaceOptions[i].token == jcr->impl_->replace) { rc.replace = ReplaceOptions[i].name; } } @@ -974,20 +978,22 @@ static bool ResetRestoreContext(UaContext* ua, if (rc.jid) { if (jcr->is_JobType(JT_BACKUP) && jcr->is_JobLevel(L_VIRTUAL_FULL)) { - if (!jcr->vf_jobids) { jcr->vf_jobids = GetPoolMemory(PM_MESSAGE); } - PmStrcpy(jcr->vf_jobids, rc.jid); + if (!jcr->impl_->vf_jobids) { + jcr->impl_->vf_jobids = GetPoolMemory(PM_MESSAGE); + } + PmStrcpy(jcr->impl_->vf_jobids, rc.jid); } else { /* * Note, this is also MigrateJobId and a VerifyJobId */ - jcr->RestoreJobId = str_to_int64(rc.jid); + jcr->impl_->RestoreJobId = str_to_int64(rc.jid); } rc.jid = NULL; } if (rc.backup_format) { - if (jcr->backup_format) { free(jcr->backup_format); } - jcr->backup_format = strdup(rc.backup_format); + if (jcr->impl_->backup_format) { free(jcr->impl_->backup_format); } + jcr->impl_->backup_format = strdup(rc.backup_format); rc.backup_format = NULL; } @@ -995,7 +1001,7 @@ static bool ResetRestoreContext(UaContext* ua, * Some options are not available through the menu * TODO: Add an advanced menu? */ - if (rc.spool_data_set) { jcr->spool_data = rc.spool_data; } + if (rc.spool_data_set) { jcr->impl_->spool_data = rc.spool_data; } if (rc.accurate_set) { jcr->accurate = rc.accurate; } @@ -1004,7 +1010,7 @@ static bool ResetRestoreContext(UaContext* ua, * but can run at the same time */ if (rc.ignoreduplicatecheck_set) { - jcr->IgnoreDuplicateJobChecking = rc.ignoreduplicatecheck; + jcr->impl_->IgnoreDuplicateJobChecking = rc.ignoreduplicatecheck; } return true; @@ -1232,10 +1238,11 @@ static bool DisplayJobParameters(UaContext* ua, "Storage: %s\n" "When: %s\n" "Priority: %d\n", - job->resource_name_, jcr->res.fileset->resource_name_, - NPRT(jcr->res.client->resource_name_), - jcr->res.write_storage ? jcr->res.write_storage->resource_name_ - : _("*None*"), + job->resource_name_, jcr->impl_->res.fileset->resource_name_, + NPRT(jcr->impl_->res.client->resource_name_), + jcr->impl_->res.write_storage + ? jcr->impl_->res.write_storage->resource_name_ + : _("*None*"), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } else { ua->SendMsg( @@ -1246,10 +1253,11 @@ static bool DisplayJobParameters(UaContext* ua, "Storage: %s\n" "When: %s\n" "Priority: %d\n"), - job->resource_name_, jcr->res.fileset->resource_name_, - NPRT(jcr->res.client->resource_name_), - jcr->res.write_storage ? jcr->res.write_storage->resource_name_ - : _("*None*"), + job->resource_name_, jcr->impl_->res.fileset->resource_name_, + NPRT(jcr->impl_->res.client->resource_name_), + jcr->impl_->res.write_storage + ? jcr->impl_->res.write_storage->resource_name_ + : _("*None*"), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } jcr->setJobLevel(L_FULL); @@ -1266,10 +1274,11 @@ static bool DisplayJobParameters(UaContext* ua, "Storage: %s\n" "When: %s\n" "Priority: %d\n", - job->resource_name_, jcr->res.fileset->resource_name_, - NPRT(jcr->res.client->resource_name_), - jcr->res.write_storage ? jcr->res.write_storage->resource_name_ - : _("*None*"), + job->resource_name_, jcr->impl_->res.fileset->resource_name_, + NPRT(jcr->impl_->res.client->resource_name_), + jcr->impl_->res.write_storage + ? jcr->impl_->res.write_storage->resource_name_ + : _("*None*"), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } else { ua->SendMsg( @@ -1280,10 +1289,11 @@ static bool DisplayJobParameters(UaContext* ua, "Storage: %s\n" "When: %s\n" "Priority: %d\n"), - job->resource_name_, jcr->res.fileset->resource_name_, - NPRT(jcr->res.client->resource_name_), - jcr->res.write_storage ? jcr->res.write_storage->resource_name_ - : _("*None*"), + job->resource_name_, jcr->impl_->res.fileset->resource_name_, + NPRT(jcr->impl_->res.client->resource_name_), + jcr->impl_->res.write_storage + ? jcr->impl_->res.write_storage->resource_name_ + : _("*None*"), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } jcr->setJobLevel(L_FULL); @@ -1300,10 +1310,11 @@ static bool DisplayJobParameters(UaContext* ua, "Storage: %s\n" "When: %s\n" "Priority: %d\n", - job->resource_name_, jcr->res.fileset->resource_name_, - NPRT(jcr->res.client->resource_name_), - jcr->res.write_storage ? jcr->res.write_storage->resource_name_ - : _("*None*"), + job->resource_name_, jcr->impl_->res.fileset->resource_name_, + NPRT(jcr->impl_->res.client->resource_name_), + jcr->impl_->res.write_storage + ? jcr->impl_->res.write_storage->resource_name_ + : _("*None*"), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } else { ua->SendMsg( @@ -1314,10 +1325,11 @@ static bool DisplayJobParameters(UaContext* ua, "Storage: %s\n" "When: %s\n" "Priority: %d\n"), - job->resource_name_, jcr->res.fileset->resource_name_, - NPRT(jcr->res.client->resource_name_), - jcr->res.write_storage ? jcr->res.write_storage->resource_name_ - : _("*None*"), + job->resource_name_, jcr->impl_->res.fileset->resource_name_, + NPRT(jcr->impl_->res.client->resource_name_), + jcr->impl_->res.write_storage + ? jcr->impl_->res.write_storage->resource_name_ + : _("*None*"), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } jcr->setJobLevel(L_FULL); @@ -1344,21 +1356,22 @@ static bool DisplayJobParameters(UaContext* ua, "Priority: %d\n" "%s%s%s", job->resource_name_, JobLevelToString(jcr->getJobLevel()), - jcr->res.client->resource_name_, jcr->backup_format, - jcr->res.fileset->resource_name_, - NPRT(jcr->res.pool->resource_name_), + jcr->impl_->res.client->resource_name_, jcr->impl_->backup_format, + jcr->impl_->res.fileset->resource_name_, + NPRT(jcr->impl_->res.pool->resource_name_), is_virtual ? "NextPool: " : "", - is_virtual - ? (jcr->res.next_pool ? jcr->res.next_pool->resource_name_ - : _("*None*")) - : "", + is_virtual ? (jcr->impl_->res.next_pool + ? jcr->impl_->res.next_pool->resource_name_ + : _("*None*")) + : "", is_virtual ? "\n" : "", - jcr->res.write_storage ? jcr->res.write_storage->resource_name_ - : _("*None*"), + jcr->impl_->res.write_storage + ? jcr->impl_->res.write_storage->resource_name_ + : _("*None*"), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority, - jcr->plugin_options ? "Plugin Options: " : "", - jcr->plugin_options ? jcr->plugin_options : "", - jcr->plugin_options ? "\n" : ""); + jcr->impl_->plugin_options ? "Plugin Options: " : "", + jcr->impl_->plugin_options ? jcr->impl_->plugin_options : "", + jcr->impl_->plugin_options ? "\n" : ""); } else { ua->SendMsg( _("Run Backup job\n" @@ -1374,32 +1387,35 @@ static bool DisplayJobParameters(UaContext* ua, "Priority: %d\n" "%s%s%s"), job->resource_name_, JobLevelToString(jcr->getJobLevel()), - jcr->res.client->resource_name_, jcr->backup_format, - jcr->res.fileset->resource_name_, - NPRT(jcr->res.pool->resource_name_), jcr->res.pool_source, - is_virtual ? "NextPool: " : "", - is_virtual - ? (jcr->res.next_pool ? jcr->res.next_pool->resource_name_ - : _("*None*")) - : "", + jcr->impl_->res.client->resource_name_, jcr->impl_->backup_format, + jcr->impl_->res.fileset->resource_name_, + NPRT(jcr->impl_->res.pool->resource_name_), + jcr->impl_->res.pool_source, is_virtual ? "NextPool: " : "", + is_virtual ? (jcr->impl_->res.next_pool + ? jcr->impl_->res.next_pool->resource_name_ + : _("*None*")) + : "", is_virtual ? " (From " : "", - is_virtual ? jcr->res.npool_source : "", is_virtual ? ")\n" : "", - jcr->res.write_storage ? jcr->res.write_storage->resource_name_ - : _("*None*"), - jcr->res.wstore_source, + is_virtual ? jcr->impl_->res.npool_source : "", + is_virtual ? ")\n" : "", + jcr->impl_->res.write_storage + ? jcr->impl_->res.write_storage->resource_name_ + : _("*None*"), + jcr->impl_->res.wstore_source, bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority, - jcr->plugin_options ? "Plugin Options: " : "", - jcr->plugin_options ? jcr->plugin_options : "", - jcr->plugin_options ? "\n" : ""); + jcr->impl_->plugin_options ? "Plugin Options: " : "", + jcr->impl_->plugin_options ? jcr->impl_->plugin_options : "", + jcr->impl_->plugin_options ? "\n" : ""); } } else { /* JT_VERIFY */ JobDbRecord jr; const char* Name; - if (jcr->res.verify_job) { - Name = jcr->res.verify_job->resource_name_; - } else if (jcr->RestoreJobId) { /* Display job name if jobid requested - */ - jr.JobId = jcr->RestoreJobId; + if (jcr->impl_->res.verify_job) { + Name = jcr->impl_->res.verify_job->resource_name_; + } else if (jcr->impl_ + ->RestoreJobId) { /* Display job name if jobid requested + */ + jr.JobId = jcr->impl_->RestoreJobId; if (!ua->db->GetJobRecord(jcr, &jr)) { ua->ErrorMsg( _("Could not get job record for selected JobId. ERR=%s"), @@ -1428,47 +1444,51 @@ static bool DisplayJobParameters(UaContext* ua, "When: %s\n" "Priority: %d\n", job->resource_name_, JobLevelToString(jcr->getJobLevel()), - jcr->res.client->resource_name_, jcr->res.fileset->resource_name_, - NPRT(jcr->res.pool->resource_name_), jcr->res.pool_source, - jcr->res.read_storage->resource_name_, jcr->res.rstore_source, - Name, verify_list, bstrutime(dt, sizeof(dt), jcr->sched_time), - jcr->JobPriority); + jcr->impl_->res.client->resource_name_, + jcr->impl_->res.fileset->resource_name_, + NPRT(jcr->impl_->res.pool->resource_name_), + jcr->impl_->res.pool_source, + jcr->impl_->res.read_storage->resource_name_, + jcr->impl_->res.rstore_source, Name, verify_list, + bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } else { - ua->SendMsg( - _("Run Verify Job\n" - "JobName: %s\n" - "Level: %s\n" - "Client: %s\n" - "FileSet: %s\n" - "Pool: %s (From %s)\n" - "Storage: %s (From %s)\n" - "Verify Job: %s\n" - "Verify List: %s\n" - "When: %s\n" - "Priority: %d\n"), - job->resource_name_, JobLevelToString(jcr->getJobLevel()), - jcr->res.client->resource_name_, jcr->res.fileset->resource_name_, - NPRT(jcr->res.pool->resource_name_), jcr->res.pool_source, - jcr->res.read_storage->resource_name_, jcr->res.rstore_source, - Name, verify_list, bstrutime(dt, sizeof(dt), jcr->sched_time), - jcr->JobPriority); + ua->SendMsg(_("Run Verify Job\n" + "JobName: %s\n" + "Level: %s\n" + "Client: %s\n" + "FileSet: %s\n" + "Pool: %s (From %s)\n" + "Storage: %s (From %s)\n" + "Verify Job: %s\n" + "Verify List: %s\n" + "When: %s\n" + "Priority: %d\n"), + job->resource_name_, JobLevelToString(jcr->getJobLevel()), + jcr->impl_->res.client->resource_name_, + jcr->impl_->res.fileset->resource_name_, + NPRT(jcr->impl_->res.pool->resource_name_), + jcr->impl_->res.pool_source, + jcr->impl_->res.read_storage->resource_name_, + jcr->impl_->res.rstore_source, Name, verify_list, + bstrutime(dt, sizeof(dt), jcr->sched_time), + jcr->JobPriority); } } break; case JT_RESTORE: - if (jcr->RestoreJobId == 0 && !jcr->RestoreBootstrap) { + if (jcr->impl_->RestoreJobId == 0 && !jcr->RestoreBootstrap) { if (rc.jid) { - jcr->RestoreJobId = str_to_int64(rc.jid); + jcr->impl_->RestoreJobId = str_to_int64(rc.jid); } else { if (!GetPint(ua, _("Please enter a JobId for restore: "))) { return false; } - jcr->RestoreJobId = ua->int64_val; + jcr->impl_->RestoreJobId = ua->int64_val; } } jcr->setJobLevel(L_FULL); /* default level */ - Dmsg1(800, "JobId to restore=%d\n", jcr->RestoreJobId); - if (jcr->RestoreJobId == 0) { + Dmsg1(800, "JobId to restore=%d\n", jcr->impl_->RestoreJobId); + if (jcr->impl_->RestoreJobId == 0) { /* RegexWhere is take before RestoreWhere */ if (jcr->RegexWhere || (job->RegexWhere && !jcr->where)) { if (ua->api) { @@ -1491,12 +1511,13 @@ static bool DisplayJobParameters(UaContext* ua, "Plugin Options: %s\n", job->resource_name_, NPRT(jcr->RestoreBootstrap), jcr->RegexWhere ? jcr->RegexWhere : job->RegexWhere, rc.replace, - jcr->res.fileset->resource_name_, rc.client_name, - jcr->res.client->resource_name_, jcr->backup_format, - jcr->res.read_storage->resource_name_, + jcr->impl_->res.fileset->resource_name_, rc.client_name, + jcr->impl_->res.client->resource_name_, + jcr->impl_->backup_format, + jcr->impl_->res.read_storage->resource_name_, bstrutime(dt, sizeof(dt), jcr->sched_time), - jcr->res.catalog->resource_name_, jcr->JobPriority, - NPRT(jcr->plugin_options)); + jcr->impl_->res.catalog->resource_name_, jcr->JobPriority, + NPRT(jcr->impl_->plugin_options)); } else { ua->SendMsg(_("Run Restore job\n" "JobName: %s\n" @@ -1514,13 +1535,13 @@ static bool DisplayJobParameters(UaContext* ua, "Plugin Options: %s\n"), job->resource_name_, NPRT(jcr->RestoreBootstrap), jcr->RegexWhere ? jcr->RegexWhere : job->RegexWhere, - rc.replace, jcr->res.fileset->resource_name_, - rc.client_name, jcr->res.client->resource_name_, - jcr->backup_format, - jcr->res.read_storage->resource_name_, + rc.replace, jcr->impl_->res.fileset->resource_name_, + rc.client_name, jcr->impl_->res.client->resource_name_, + jcr->impl_->backup_format, + jcr->impl_->res.read_storage->resource_name_, bstrutime(dt, sizeof(dt), jcr->sched_time), - jcr->res.catalog->resource_name_, jcr->JobPriority, - NPRT(jcr->plugin_options)); + jcr->impl_->res.catalog->resource_name_, + jcr->JobPriority, NPRT(jcr->impl_->plugin_options)); } } else { if (ua->api) { @@ -1543,12 +1564,13 @@ static bool DisplayJobParameters(UaContext* ua, "Plugin Options: %s\n", job->resource_name_, NPRT(jcr->RestoreBootstrap), jcr->where ? jcr->where : NPRT(job->RestoreWhere), rc.replace, - jcr->res.fileset->resource_name_, rc.client_name, - jcr->res.client->resource_name_, jcr->backup_format, - jcr->res.read_storage->resource_name_, + jcr->impl_->res.fileset->resource_name_, rc.client_name, + jcr->impl_->res.client->resource_name_, + jcr->impl_->backup_format, + jcr->impl_->res.read_storage->resource_name_, bstrutime(dt, sizeof(dt), jcr->sched_time), - jcr->res.catalog->resource_name_, jcr->JobPriority, - NPRT(jcr->plugin_options)); + jcr->impl_->res.catalog->resource_name_, jcr->JobPriority, + NPRT(jcr->impl_->plugin_options)); } else { ua->SendMsg(_("Run Restore job\n" "JobName: %s\n" @@ -1566,13 +1588,13 @@ static bool DisplayJobParameters(UaContext* ua, "Plugin Options: %s\n"), job->resource_name_, NPRT(jcr->RestoreBootstrap), jcr->where ? jcr->where : NPRT(job->RestoreWhere), - rc.replace, jcr->res.fileset->resource_name_, - rc.client_name, jcr->res.client->resource_name_, - jcr->backup_format, - jcr->res.read_storage->resource_name_, + rc.replace, jcr->impl_->res.fileset->resource_name_, + rc.client_name, jcr->impl_->res.client->resource_name_, + jcr->impl_->backup_format, + jcr->impl_->res.read_storage->resource_name_, bstrutime(dt, sizeof(dt), jcr->sched_time), - jcr->res.catalog->resource_name_, jcr->JobPriority, - NPRT(jcr->plugin_options)); + jcr->impl_->res.catalog->resource_name_, + jcr->JobPriority, NPRT(jcr->impl_->plugin_options)); } } @@ -1602,14 +1624,15 @@ static bool DisplayJobParameters(UaContext* ua, "Catalog: %s\n" "Priority: %d\n" "Plugin Options: %s\n"), - rc.replace, jcr->res.client->resource_name_, - jcr->backup_format, jcr->res.read_storage->resource_name_, - (jcr->RestoreJobId == 0) + rc.replace, jcr->impl_->res.client->resource_name_, + jcr->impl_->backup_format, + jcr->impl_->res.read_storage->resource_name_, + (jcr->impl_->RestoreJobId == 0) ? _("*None*") - : edit_uint64(jcr->RestoreJobId, ec1), + : edit_uint64(jcr->impl_->RestoreJobId, ec1), bstrutime(dt, sizeof(dt), jcr->sched_time), - jcr->res.catalog->resource_name_, jcr->JobPriority, - NPRT(jcr->plugin_options)); + jcr->impl_->res.catalog->resource_name_, jcr->JobPriority, + NPRT(jcr->impl_->plugin_options)); } break; case JT_COPY: @@ -1637,50 +1660,58 @@ static bool DisplayJobParameters(UaContext* ua, "Catalog: %s\n" "Priority: %d\n", prt_type, job->resource_name_, NPRT(jcr->RestoreBootstrap), - jcr->res.read_storage ? jcr->res.read_storage->resource_name_ - : _("*None*"), - NPRT(jcr->res.pool->resource_name_), - jcr->res.next_pool ? jcr->res.next_pool->resource_name_ - : _("*None*"), - jcr->res.write_storage ? jcr->res.write_storage->resource_name_ - : _("*None*"), - (jcr->MigrateJobId == 0) ? _("*None*") - : edit_uint64(jcr->MigrateJobId, ec1), + jcr->impl_->res.read_storage + ? jcr->impl_->res.read_storage->resource_name_ + : _("*None*"), + NPRT(jcr->impl_->res.pool->resource_name_), + jcr->impl_->res.next_pool + ? jcr->impl_->res.next_pool->resource_name_ + : _("*None*"), + jcr->impl_->res.write_storage + ? jcr->impl_->res.write_storage->resource_name_ + : _("*None*"), + (jcr->impl_->MigrateJobId == 0) + ? _("*None*") + : edit_uint64(jcr->impl_->MigrateJobId, ec1), bstrutime(dt, sizeof(dt), jcr->sched_time), - jcr->res.catalog->resource_name_, jcr->JobPriority); + jcr->impl_->res.catalog->resource_name_, jcr->JobPriority); } else { if (jcr->is_JobType(JT_COPY)) { prt_type = _("Run Copy job\n"); } else { prt_type = _("Run Migration job\n"); } - ua->SendMsg( - _("%s" - "JobName: %s\n" - "Bootstrap: %s\n" - "Read Storage: %s (From %s)\n" - "Pool: %s (From %s)\n" - "Write Storage: %s (From %s)\n" - "NextPool: %s (From %s)\n" - "JobId: %s\n" - "When: %s\n" - "Catalog: %s\n" - "Priority: %d\n"), - prt_type, job->resource_name_, NPRT(jcr->RestoreBootstrap), - jcr->res.read_storage ? jcr->res.read_storage->resource_name_ - : _("*None*"), - jcr->res.rstore_source, NPRT(jcr->res.pool->resource_name_), - jcr->res.pool_source, - jcr->res.write_storage ? jcr->res.write_storage->resource_name_ - : _("*None*"), - jcr->res.wstore_source, - jcr->res.next_pool ? jcr->res.next_pool->resource_name_ - : _("*None*"), - NPRT(jcr->res.npool_source), - jcr->MigrateJobId == 0 ? _("*None*") - : edit_uint64(jcr->MigrateJobId, ec1), - bstrutime(dt, sizeof(dt), jcr->sched_time), - jcr->res.catalog->resource_name_, jcr->JobPriority); + ua->SendMsg(_("%s" + "JobName: %s\n" + "Bootstrap: %s\n" + "Read Storage: %s (From %s)\n" + "Pool: %s (From %s)\n" + "Write Storage: %s (From %s)\n" + "NextPool: %s (From %s)\n" + "JobId: %s\n" + "When: %s\n" + "Catalog: %s\n" + "Priority: %d\n"), + prt_type, job->resource_name_, NPRT(jcr->RestoreBootstrap), + jcr->impl_->res.read_storage + ? jcr->impl_->res.read_storage->resource_name_ + : _("*None*"), + jcr->impl_->res.rstore_source, + NPRT(jcr->impl_->res.pool->resource_name_), + jcr->impl_->res.pool_source, + jcr->impl_->res.write_storage + ? jcr->impl_->res.write_storage->resource_name_ + : _("*None*"), + jcr->impl_->res.wstore_source, + jcr->impl_->res.next_pool + ? jcr->impl_->res.next_pool->resource_name_ + : _("*None*"), + NPRT(jcr->impl_->res.npool_source), + jcr->impl_->MigrateJobId == 0 + ? _("*None*") + : edit_uint64(jcr->impl_->MigrateJobId, ec1), + bstrutime(dt, sizeof(dt), jcr->sched_time), + jcr->impl_->res.catalog->resource_name_, jcr->JobPriority); } break; default: diff --git a/core/src/dird/ua_select.cc b/core/src/dird/ua_select.cc index 8d613488051..7a1c93f6596 100644 --- a/core/src/dird/ua_select.cc +++ b/core/src/dird/ua_select.cc @@ -31,6 +31,7 @@ #include "include/bareos.h" #include "dird.h" #include "dird/dird_globals.h" +#include "dird/jcr_private.h" #include "dird/storage.h" #include "dird/ua_input.h" #include "dird/ua_select.h" @@ -1202,7 +1203,7 @@ StorageResource* get_storage_resource(UaContext* ua, ua->ErrorMsg(_("JobId %s is not running.\n"), edit_int64(jobid, ed1)); return NULL; } - store = jcr->res.write_storage; + store = jcr->impl_->res.write_storage; FreeJcr(jcr); break; } else if (Bstrcasecmp(ua->argk[i], NT_("job")) || @@ -1215,7 +1216,7 @@ StorageResource* get_storage_resource(UaContext* ua, ua->ErrorMsg(_("Job \"%s\" is not running.\n"), ua->argv[i]); return NULL; } - store = jcr->res.write_storage; + store = jcr->impl_->res.write_storage; FreeJcr(jcr); break; } else if (Bstrcasecmp(ua->argk[i], NT_("ujobid"))) { @@ -1227,7 +1228,7 @@ StorageResource* get_storage_resource(UaContext* ua, ua->ErrorMsg(_("Job \"%s\" is not running.\n"), ua->argv[i]); return NULL; } - store = jcr->res.write_storage; + store = jcr->impl_->res.write_storage; FreeJcr(jcr); break; } @@ -1492,8 +1493,9 @@ alist* select_jobs(UaContext* ua, const char* reason) } if (jcr) { - if (jcr->res.job && - !ua->AclAccessOk(Job_ACL, jcr->res.job->resource_name_, true)) { + if (jcr->impl_->res.job && + !ua->AclAccessOk(Job_ACL, jcr->impl_->res.job->resource_name_, + true)) { ua->ErrorMsg(_("Unauthorized command from this console.\n")); goto bail_out; } @@ -1522,7 +1524,7 @@ alist* select_jobs(UaContext* ua, const char* reason) continue; } tjobs++; /* Count of all jobs */ - if (!ua->AclAccessOk(Job_ACL, jcr->res.job->resource_name_)) { + if (!ua->AclAccessOk(Job_ACL, jcr->impl_->res.job->resource_name_)) { continue; /* Skip not authorized */ } njobs++; /* Count of authorized jobs */ @@ -1581,7 +1583,7 @@ alist* select_jobs(UaContext* ua, const char* reason) continue; } - if (!ua->AclAccessOk(Job_ACL, jcr->res.job->resource_name_)) { + if (!ua->AclAccessOk(Job_ACL, jcr->impl_->res.job->resource_name_)) { continue; /* Skip not authorized */ } @@ -1638,7 +1640,7 @@ alist* select_jobs(UaContext* ua, const char* reason) if (jcr->JobId == 0) { /* This is us */ continue; } - if (!ua->AclAccessOk(Job_ACL, jcr->res.job->resource_name_)) { + if (!ua->AclAccessOk(Job_ACL, jcr->impl_->res.job->resource_name_)) { continue; /* Skip not authorized */ } Bsnprintf(buf, sizeof(buf), _("JobId=%s Job=%s"), diff --git a/core/src/dird/ua_server.cc b/core/src/dird/ua_server.cc index d1acb48fbd2..25d016b17a3 100644 --- a/core/src/dird/ua_server.cc +++ b/core/src/dird/ua_server.cc @@ -33,6 +33,7 @@ #include "dird/dird_globals.h" #include "dird/authenticate.h" #include "dird/authenticate_console.h" +#include "dird/jcr_private.h" #include "dird/job.h" #include "dird/pthread_detach_if_not_detached.h" #include "dird/ua_cmds.h" @@ -55,15 +56,15 @@ JobControlRecord* new_control_jcr(const char* base_name, int job_type) { JobControlRecord* jcr; - jcr = new_jcr(sizeof(JobControlRecord), DirdFreeJcr); + jcr = NewDirectorJcr(); /* * The job and defaults are not really used, but we set them up to ensure that * everything is correctly initialized. */ LockRes(my_config); - jcr->res.job = (JobResource*)my_config->GetNextRes(R_JOB, NULL); - SetJcrDefaults(jcr, jcr->res.job); + jcr->impl_->res.job = (JobResource*)my_config->GetNextRes(R_JOB, NULL); + SetJcrDefaults(jcr, jcr->impl_->res.job); UnlockRes(my_config); jcr->sd_auth_key = strdup("dummy"); /* dummy Storage daemon key */ diff --git a/core/src/dird/ua_status.cc b/core/src/dird/ua_status.cc index d491469142a..5a88a301571 100644 --- a/core/src/dird/ua_status.cc +++ b/core/src/dird/ua_status.cc @@ -30,6 +30,7 @@ #include "include/bareos.h" #include "dird.h" +#include "dird/jcr_private.h" #include "dird/dird_globals.h" #include "dird/fd_cmds.h" #include "dird/job.h" @@ -107,7 +108,7 @@ bool DotStatusCmd(UaContext* ua, const char* cmd) ua->SendMsg(OKdotstatus, ua->argk[2]); foreach_jcr (njcr) { if (njcr->JobId != 0 && - ua->AclAccessOk(Job_ACL, njcr->res.job->resource_name_)) { + ua->AclAccessOk(Job_ACL, njcr->impl_->res.job->resource_name_)) { ua->SendMsg(DotStatusJob, edit_int64(njcr->JobId, ed1), njcr->JobStatus, njcr->JobErrors); } @@ -776,12 +777,12 @@ static void PrtRuntime(UaContext* ua, sched_pkt* sp) if (sp->job->JobType == JT_BACKUP) { jcr->db = NULL; ok = CompleteJcrForJob(jcr, sp->job, sp->pool); - Dmsg1(250, "Using pool=%s\n", jcr->res.pool->resource_name_); + Dmsg1(250, "Using pool=%s\n", jcr->impl_->res.pool->resource_name_); if (jcr->db) { CloseDb = true; /* new db opened, remember to close it */ } if (ok) { - mr.PoolId = jcr->jr.PoolId; - jcr->res.write_storage = sp->store; - SetStorageidInMr(jcr->res.write_storage, &mr); + mr.PoolId = jcr->impl_->jr.PoolId; + jcr->impl_->res.write_storage = sp->store; + SetStorageidInMr(jcr->impl_->res.write_storage, &mr); Dmsg0(250, "call FindNextVolumeForAppend\n"); /* no need to set ScratchPoolId, since we use fnv_no_create_vol */ ok = FindNextVolumeForAppend(jcr, &mr, 1, NULL, fnv_no_create_vol, @@ -952,7 +953,7 @@ static void ListRunningJobs(UaContext* ua) } foreach_jcr (jcr) { if (jcr->JobId == 0 || - !ua->AclAccessOk(Job_ACL, jcr->res.job->resource_name_)) { + !ua->AclAccessOk(Job_ACL, jcr->impl_->res.job->resource_name_)) { continue; } njobs++; @@ -989,23 +990,23 @@ static void ListRunningJobs(UaContext* ua) break; case JS_WaitFD: emsg = (char*)GetPoolMemory(PM_FNAME); - if (!jcr->res.client) { + if (!jcr->impl_->res.client) { Mmsg(emsg, _("is waiting on Client")); } else { Mmsg(emsg, _("is waiting on Client %s"), - jcr->res.client->resource_name_); + jcr->impl_->res.client->resource_name_); } pool_mem = true; msg = emsg; break; case JS_WaitSD: emsg = (char*)GetPoolMemory(PM_FNAME); - if (jcr->res.write_storage) { + if (jcr->impl_->res.write_storage) { Mmsg(emsg, _("is waiting on Storage \"%s\""), - jcr->res.write_storage->resource_name_); - } else if (jcr->res.read_storage) { + jcr->impl_->res.write_storage->resource_name_); + } else if (jcr->impl_->res.read_storage) { Mmsg(emsg, _("is waiting on Storage \"%s\""), - jcr->res.read_storage->resource_name_); + jcr->impl_->res.read_storage->resource_name_); } else { Mmsg(emsg, _("is waiting on Storage")); } @@ -1062,7 +1063,7 @@ static void ListRunningJobs(UaContext* ua) /* * Now report Storage daemon status code */ - switch (jcr->SDJobStatus) { + switch (jcr->impl_->SDJobStatus) { case JS_WaitMount: if (pool_mem) { FreePoolMemory(emsg); @@ -1088,12 +1089,12 @@ static void ListRunningJobs(UaContext* ua) */ Mmsg(emsg, _("is waiting for Client to connect (Client Initiated " "Connection)")); - } else if (!jcr->res.client || !jcr->res.write_storage) { + } else if (!jcr->impl_->res.client || !jcr->impl_->res.write_storage) { Mmsg(emsg, _("is waiting for Client to connect to Storage daemon")); } else { Mmsg(emsg, _("is waiting for Client %s to connect to Storage %s"), - jcr->res.client->resource_name_, - jcr->res.write_storage->resource_name_); + jcr->impl_->res.client->resource_name_, + jcr->impl_->res.write_storage->resource_name_); } msg = emsg; break; @@ -1589,7 +1590,7 @@ static void StatusSlots(UaContext* ua, StorageResource* store) slot_number_t max_slots; changer_vol_list_t* vol_list = NULL; - ua->jcr->res.write_storage = store; + ua->jcr->impl_->res.write_storage = store; /* * Slot | Volume | Status | MediaType | Pool diff --git a/core/src/dird/ua_update.cc b/core/src/dird/ua_update.cc index a99e7e89a84..9e88a052206 100644 --- a/core/src/dird/ua_update.cc +++ b/core/src/dird/ua_update.cc @@ -31,6 +31,7 @@ #include "include/bareos.h" #include "dird.h" +#include "dird/jcr_private.h" #include "dird/next_vol.h" #include "dird/sd_cmds.h" #include "dird/storage.h" @@ -1040,7 +1041,7 @@ static void UpdateSlots(UaContext* ua) have_enabled = false; } - max_slots = GetNumSlots(ua, ua->jcr->res.write_storage); + max_slots = GetNumSlots(ua, ua->jcr->impl_->res.write_storage); Dmsg1(100, "max_slots=%d\n", max_slots); if (max_slots <= 0) { ua->WarningMsg(_("No slots in changer to scan.\n")); diff --git a/core/src/dird/vbackup.cc b/core/src/dird/vbackup.cc index 161a558880b..0e76cd72a2d 100644 --- a/core/src/dird/vbackup.cc +++ b/core/src/dird/vbackup.cc @@ -41,6 +41,7 @@ #include "dird/dird_globals.h" #include "dird/backup.h" #include "dird/bsr.h" +#include "dird/jcr_private.h" #include "dird/job.h" #include "dird/migration.h" #include "dird/msgchan.h" @@ -75,8 +76,9 @@ bool DoNativeVbackupInit(JobControlRecord* jcr) if (!AllowDuplicateJob(jcr)) { return false; } - jcr->jr.PoolId = GetOrCreatePoolRecord(jcr, jcr->res.pool->resource_name_); - if (jcr->jr.PoolId == 0) { + jcr->impl_->jr.PoolId = + GetOrCreatePoolRecord(jcr, jcr->impl_->res.pool->resource_name_); + if (jcr->impl_->jr.PoolId == 0) { Dmsg1(dbglevel, "JobId=%d no PoolId\n", (int)jcr->JobId); Jmsg(jcr, M_FATAL, 0, _("Could not get or create a Pool record.\n")); return false; @@ -88,46 +90,46 @@ bool DoNativeVbackupInit(JobControlRecord* jcr) * pool will be changed to point to the write pool, * which comes from pool->NextPool. */ - jcr->res.rpool = jcr->res.pool; /* save read pool */ - PmStrcpy(jcr->res.rpool_source, jcr->res.pool_source); + jcr->impl_->res.rpool = jcr->impl_->res.pool; /* save read pool */ + PmStrcpy(jcr->impl_->res.rpool_source, jcr->impl_->res.pool_source); /* * If pool storage specified, use it for restore */ - CopyRstorage(jcr, jcr->res.pool->storage, _("Pool resource")); + CopyRstorage(jcr, jcr->impl_->res.pool->storage, _("Pool resource")); - Dmsg2(dbglevel, "Read pool=%s (From %s)\n", jcr->res.rpool->resource_name_, - jcr->res.rpool_source); + Dmsg2(dbglevel, "Read pool=%s (From %s)\n", + jcr->impl_->res.rpool->resource_name_, jcr->impl_->res.rpool_source); jcr->start_time = time(NULL); - jcr->jr.StartTime = jcr->start_time; - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->jr)) { + jcr->impl_->jr.StartTime = jcr->start_time; + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); } /* * See if there is a next pool override. */ - if (jcr->res.run_next_pool_override) { - PmStrcpy(jcr->res.npool_source, _("Run NextPool override")); - PmStrcpy(jcr->res.pool_source, _("Run NextPool override")); + if (jcr->impl_->res.run_next_pool_override) { + PmStrcpy(jcr->impl_->res.npool_source, _("Run NextPool override")); + PmStrcpy(jcr->impl_->res.pool_source, _("Run NextPool override")); storage_source = _("Storage from Run NextPool override"); } else { /* * See if there is a next pool override in the Job definition. */ - if (jcr->res.job->next_pool) { - jcr->res.next_pool = jcr->res.job->next_pool; - PmStrcpy(jcr->res.npool_source, _("Job's NextPool resource")); - PmStrcpy(jcr->res.pool_source, _("Job's NextPool resource")); + if (jcr->impl_->res.job->next_pool) { + jcr->impl_->res.next_pool = jcr->impl_->res.job->next_pool; + PmStrcpy(jcr->impl_->res.npool_source, _("Job's NextPool resource")); + PmStrcpy(jcr->impl_->res.pool_source, _("Job's NextPool resource")); storage_source = _("Storage from Job's NextPool resource"); } else { /* * Fall back to the pool's NextPool definition. */ - jcr->res.next_pool = jcr->res.pool->NextPool; - PmStrcpy(jcr->res.npool_source, _("Job Pool's NextPool resource")); - PmStrcpy(jcr->res.pool_source, _("Job Pool's NextPool resource")); + jcr->impl_->res.next_pool = jcr->impl_->res.pool->NextPool; + PmStrcpy(jcr->impl_->res.npool_source, _("Job Pool's NextPool resource")); + PmStrcpy(jcr->impl_->res.pool_source, _("Job Pool's NextPool resource")); storage_source = _("Storage from Pool's NextPool resource"); } } @@ -137,21 +139,22 @@ bool DoNativeVbackupInit(JobControlRecord* jcr) * record exists in the database. Note, in this case, we * will be migrating from pool to pool->NextPool. */ - if (jcr->res.next_pool) { - jcr->jr.PoolId = - GetOrCreatePoolRecord(jcr, jcr->res.next_pool->resource_name_); - if (jcr->jr.PoolId == 0) { return false; } + if (jcr->impl_->res.next_pool) { + jcr->impl_->jr.PoolId = + GetOrCreatePoolRecord(jcr, jcr->impl_->res.next_pool->resource_name_); + if (jcr->impl_->jr.PoolId == 0) { return false; } } - if (!SetMigrationWstorage(jcr, jcr->res.pool, jcr->res.next_pool, - storage_source)) { + if (!SetMigrationWstorage(jcr, jcr->impl_->res.pool, + jcr->impl_->res.next_pool, storage_source)) { return false; } - jcr->res.pool = jcr->res.next_pool; + jcr->impl_->res.pool = jcr->impl_->res.next_pool; Dmsg2(dbglevel, "Write pool=%s read rpool=%s\n", - jcr->res.pool->resource_name_, jcr->res.rpool->resource_name_); + jcr->impl_->res.pool->resource_name_, + jcr->impl_->res.rpool->resource_name_); // CreateClones(jcr); @@ -173,22 +176,23 @@ bool DoNativeVbackup(JobControlRecord* jcr) char ed1[100]; int JobLevel_of_first_job; - if (!jcr->res.read_storage_list) { + if (!jcr->impl_->res.read_storage_list) { Jmsg(jcr, M_FATAL, 0, _("No storage for reading given.\n")); return false; } - if (!jcr->res.write_storage_list) { + if (!jcr->impl_->res.write_storage_list) { Jmsg(jcr, M_FATAL, 0, _("No storage for writing given.\n")); return false; } Dmsg2(100, "read_storage_list=%p write_storage_list=%p\n", - jcr->res.read_storage_list, jcr->res.write_storage_list); - Dmsg2( - 100, "Read store=%s, write store=%s\n", - ((StorageResource*)jcr->res.read_storage_list->first())->resource_name_, - ((StorageResource*)jcr->res.write_storage_list->first())->resource_name_); + jcr->impl_->res.read_storage_list, jcr->impl_->res.write_storage_list); + Dmsg2(100, "Read store=%s, write store=%s\n", + ((StorageResource*)jcr->impl_->res.read_storage_list->first()) + ->resource_name_, + ((StorageResource*)jcr->impl_->res.write_storage_list->first()) + ->resource_name_); /* * Print Job Start message @@ -205,13 +209,13 @@ bool DoNativeVbackup(JobControlRecord* jcr) /* * See if we already got a list of jobids to use. */ - if (jcr->vf_jobids) { - Dmsg1(10, "jobids=%s\n", jcr->vf_jobids); - jobids = strdup(jcr->vf_jobids); + if (jcr->impl_->vf_jobids) { + Dmsg1(10, "jobids=%s\n", jcr->impl_->vf_jobids); + jobids = strdup(jcr->impl_->vf_jobids); } else { db_list_ctx jobids_ctx; - jcr->db->AccurateGetJobids(jcr, &jcr->jr, &jobids_ctx); + jcr->db->AccurateGetJobids(jcr, &jcr->impl_->jr, &jobids_ctx); Dmsg1(10, "consolidate candidates: %s.\n", jobids_ctx.list); if (jobids_ctx.count == 0) { @@ -229,8 +233,8 @@ bool DoNativeVbackup(JobControlRecord* jcr) */ p = strchr(jobids, ','); /* find oldest jobid */ if (p) { *p = '\0'; } - jcr->previous_jr = JobDbRecord{}; - jcr->previous_jr.JobId = str_to_int64(jobids); + jcr->impl_->previous_jr = JobDbRecord{}; + jcr->impl_->previous_jr.JobId = str_to_int64(jobids); Dmsg1(10, "Previous JobId=%s\n", jobids); /* @@ -238,15 +242,15 @@ bool DoNativeVbackup(JobControlRecord* jcr) */ if (p) { *p = ','; } - if (!jcr->db->GetJobRecord(jcr, &jcr->previous_jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->previous_jr)) { Jmsg(jcr, M_FATAL, 0, _("Error getting Job record for first Job: ERR=%s"), jcr->db->strerror()); goto bail_out; } - JobLevel_of_first_job = jcr->previous_jr.JobLevel; - Dmsg2(10, "Level of first consolidated job %d: %s\n", jcr->previous_jr.JobId, - job_level_to_str(JobLevel_of_first_job)); + JobLevel_of_first_job = jcr->impl_->previous_jr.JobLevel; + Dmsg2(10, "Level of first consolidated job %d: %s\n", + jcr->impl_->previous_jr.JobId, job_level_to_str(JobLevel_of_first_job)); /* * Now we find the newest job that ran and store its info in @@ -261,11 +265,11 @@ bool DoNativeVbackup(JobControlRecord* jcr) p = jobids; } - jcr->previous_jr = JobDbRecord{}; - jcr->previous_jr.JobId = str_to_int64(p); + jcr->impl_->previous_jr = JobDbRecord{}; + jcr->impl_->previous_jr.JobId = str_to_int64(p); Dmsg1(10, "Previous JobId=%s\n", p); - if (!jcr->db->GetJobRecord(jcr, &jcr->previous_jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->previous_jr)) { Jmsg(jcr, M_FATAL, 0, _("Error getting Job record for previous Job: ERR=%s"), jcr->db->strerror()); @@ -295,8 +299,8 @@ bool DoNativeVbackup(JobControlRecord* jcr) /* * Now start a job with the Storage daemon */ - if (!StartStorageDaemonJob(jcr, jcr->res.read_storage_list, - jcr->res.write_storage_list, + if (!StartStorageDaemonJob(jcr, jcr->impl_->res.read_storage_list, + jcr->impl_->res.write_storage_list, /* send_bsr */ true)) { goto bail_out; } @@ -313,14 +317,14 @@ bool DoNativeVbackup(JobControlRecord* jcr) * is after the start of this run. */ jcr->start_time = time(NULL); - jcr->jr.StartTime = jcr->start_time; - jcr->jr.JobTDate = jcr->start_time; + jcr->impl_->jr.StartTime = jcr->start_time; + jcr->impl_->jr.JobTDate = jcr->start_time; jcr->setJobStatus(JS_Running); /* * Update job start record */ - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->jr)) { + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); goto bail_out; } @@ -349,7 +353,7 @@ bool DoNativeVbackup(JobControlRecord* jcr) * Note, the SD stores in jcr->JobFiles/ReadBytes/JobBytes/JobErrors */ WaitForStorageDaemonTermination(jcr); - jcr->setJobStatus(jcr->SDJobStatus); + jcr->setJobStatus(jcr->impl_->SDJobStatus); jcr->db_batch->WriteBatchFileRecords( jcr); /* used by bulk batch file insert */ if (!jcr->is_JobStatus(JS_Terminated)) { goto bail_out; } @@ -359,8 +363,8 @@ bool DoNativeVbackup(JobControlRecord* jcr) /* * Remove the successfully consolidated jobids from the database */ - if (jcr->res.job->AlwaysIncremental && - jcr->res.job->AlwaysIncrementalJobRetention) { + if (jcr->impl_->res.job->AlwaysIncremental && + jcr->impl_->res.job->AlwaysIncrementalJobRetention) { UaContext* ua; ua = new_ua_context(jcr); PurgeJobsFromCatalog(ua, jobids); @@ -394,8 +398,8 @@ void NativeVbackupCleanup(JobControlRecord* jcr, int TermCode, int JobLevel) switch (jcr->JobStatus) { case JS_Terminated: case JS_Warnings: - jcr->jr.JobLevel = JobLevel; /* We want this to appear as what the first - consolidated job was */ + jcr->impl_->jr.JobLevel = JobLevel; /* We want this to appear as what the + first consolidated job was */ Jmsg(jcr, M_INFO, 0, _("Joblevel was set to joblevel of first consolidated job: %s\n"), job_level_to_str(JobLevel)); @@ -404,11 +408,11 @@ void NativeVbackupCleanup(JobControlRecord* jcr, int TermCode, int JobLevel) break; } - jcr->JobFiles = jcr->SDJobFiles; - jcr->JobBytes = jcr->SDJobBytes; + jcr->JobFiles = jcr->impl_->SDJobFiles; + jcr->JobBytes = jcr->impl_->SDJobBytes; if (jcr->getJobStatus() == JS_Terminated && - (jcr->JobErrors || jcr->SDErrors)) { + (jcr->JobErrors || jcr->impl_->SDErrors)) { TermCode = JS_Warnings; } @@ -420,22 +424,22 @@ void NativeVbackupCleanup(JobControlRecord* jcr, int TermCode, int JobLevel) Mmsg(query, "UPDATE Job SET StartTime='%s',EndTime='%s'," "JobTDate=%s WHERE JobId=%s", - jcr->previous_jr.cStartTime, jcr->previous_jr.cEndTime, - edit_uint64(jcr->previous_jr.JobTDate, ec1), + jcr->impl_->previous_jr.cStartTime, jcr->impl_->previous_jr.cEndTime, + edit_uint64(jcr->impl_->previous_jr.JobTDate, ec1), edit_uint64(jcr->JobId, ec2)); jcr->db->SqlQuery(query.c_str()); /* * Get the fully updated job record */ - if (!jcr->db->GetJobRecord(jcr, &jcr->jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Job record for Job report: ERR=%s"), jcr->db->strerror()); jcr->setJobStatus(JS_ErrorTerminated); } - bstrncpy(cr.Name, jcr->res.client->resource_name_, sizeof(cr.Name)); + bstrncpy(cr.Name, jcr->impl_->res.client->resource_name_, sizeof(cr.Name)); if (!jcr->db->GetClientRecord(jcr, &cr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Client record for Job report: ERR=%s"), @@ -457,14 +461,18 @@ void NativeVbackupCleanup(JobControlRecord* jcr, int TermCode, int JobLevel) msg_type = M_ERROR; /* Generate error message */ if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->SD_msg_chan_started) { pthread_cancel(jcr->SD_msg_chan); } + if (jcr->impl_->SD_msg_chan_started) { + pthread_cancel(jcr->impl_->SD_msg_chan); + } } break; case JS_Canceled: TermMsg = _("Backup Canceled"); if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->SD_msg_chan_started) { pthread_cancel(jcr->SD_msg_chan); } + if (jcr->impl_->SD_msg_chan_started) { + pthread_cancel(jcr->impl_->SD_msg_chan); + } } break; default: @@ -522,12 +530,12 @@ static bool CreateBootstrapFile(JobControlRecord* jcr, char* jobids) } AddVolumeInformationToBsr(ua, rx.bsr.get()); - jcr->ExpectedFiles = WriteBsrFile(ua, rx); + jcr->impl_->ExpectedFiles = WriteBsrFile(ua, rx); if (debug_level >= 10) { - Dmsg1(000, "Found %d files to consolidate.\n", jcr->ExpectedFiles); + Dmsg1(000, "Found %d files to consolidate.\n", jcr->impl_->ExpectedFiles); } FreeUaContext(ua); rx.bsr.reset(nullptr); - return jcr->ExpectedFiles != 0; + return jcr->impl_->ExpectedFiles != 0; } } /* namespace directordaemon */ diff --git a/core/src/dird/verify.cc b/core/src/dird/verify.cc index 04305f9e3e2..be72942f702 100644 --- a/core/src/dird/verify.cc +++ b/core/src/dird/verify.cc @@ -41,6 +41,7 @@ #include "dird/backup.h" #include "dird/fd_cmds.h" #include "dird/getmsg.h" +#include "dird/jcr_private.h" #include "dird/job.h" #include "dird/msgchan.h" #include "dird/sd_cmds.h" @@ -119,7 +120,8 @@ bool DoVerify(JobControlRecord* jcr) FreeWstorage(jcr); /* we don't write */ - new (&jcr->previous_jr) JobDbRecord(); // placement new instead of memset + new (&jcr->impl_->previous_jr) + JobDbRecord(); // placement new instead of memset /* * Find JobId of last job that ran. Note, we do this when @@ -138,10 +140,11 @@ bool DoVerify(JobControlRecord* jcr) case L_VERIFY_CATALOG: case L_VERIFY_VOLUME_TO_CATALOG: case L_VERIFY_DISK_TO_CATALOG: - jr = jcr->jr; - if (jcr->res.verify_job && (JobLevel == L_VERIFY_VOLUME_TO_CATALOG || - JobLevel == L_VERIFY_DISK_TO_CATALOG)) { - Name = jcr->res.verify_job->resource_name_; + jr = jcr->impl_->jr; + if (jcr->impl_->res.verify_job && + (JobLevel == L_VERIFY_VOLUME_TO_CATALOG || + JobLevel == L_VERIFY_DISK_TO_CATALOG)) { + Name = jcr->impl_->res.verify_job->resource_name_; } else { Name = NULL; } @@ -150,8 +153,8 @@ bool DoVerify(JobControlRecord* jcr) /* * See if user supplied a jobid= as run argument or from menu */ - if (jcr->VerifyJobId) { - verify_jobid = jcr->VerifyJobId; + if (jcr->impl_->VerifyJobId) { + verify_jobid = jcr->impl_->VerifyJobId; Dmsg1(100, "Supplied jobid=%d\n", verify_jobid); } else { @@ -175,22 +178,22 @@ bool DoVerify(JobControlRecord* jcr) * Now get the job record for the previous backup that interests * us. We use the verify_jobid that we found above. */ - jcr->previous_jr.JobId = verify_jobid; - if (!jcr->db->GetJobRecord(jcr, &jcr->previous_jr)) { + jcr->impl_->previous_jr.JobId = verify_jobid; + if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->previous_jr)) { Jmsg(jcr, M_FATAL, 0, _("Could not get job record for previous Job. ERR=%s"), jcr->db->strerror()); return false; } - if (!(jcr->previous_jr.JobStatus == JS_Terminated || - jcr->previous_jr.JobStatus == JS_Warnings)) { + if (!(jcr->impl_->previous_jr.JobStatus == JS_Terminated || + jcr->impl_->previous_jr.JobStatus == JS_Warnings)) { Jmsg(jcr, M_FATAL, 0, _("Last Job %d did not Terminate normally. JobStatus=%c\n"), - verify_jobid, jcr->previous_jr.JobStatus); + verify_jobid, jcr->impl_->previous_jr.JobStatus); return false; } Jmsg(jcr, M_INFO, 0, _("Verifying against JobId=%d Job=%s\n"), - jcr->previous_jr.JobId, jcr->previous_jr.Job); + jcr->impl_->previous_jr.JobId, jcr->impl_->previous_jr.Job); } /* @@ -214,8 +217,8 @@ bool DoVerify(JobControlRecord* jcr) return true; /* get out */ } - if (jcr->res.verify_job) { - jcr->res.fileset = jcr->res.verify_job->fileset; + if (jcr->impl_->res.verify_job) { + jcr->impl_->res.fileset = jcr->impl_->res.verify_job->fileset; } break; default: @@ -223,9 +226,10 @@ bool DoVerify(JobControlRecord* jcr) break; } - Dmsg2(100, "ClientId=%u JobLevel=%c\n", jcr->previous_jr.ClientId, JobLevel); + Dmsg2(100, "ClientId=%u JobLevel=%c\n", jcr->impl_->previous_jr.ClientId, + JobLevel); - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->jr)) { + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); return false; } @@ -250,12 +254,12 @@ bool DoVerify(JobControlRecord* jcr) /* * Now start a job with the Storage daemon */ - if (!StartStorageDaemonJob(jcr, jcr->res.read_storage_list, NULL, + if (!StartStorageDaemonJob(jcr, jcr->impl_->res.read_storage_list, NULL, /* send_bsr */ true)) { return false; } - jcr->passive_client = jcr->res.client->passive; + jcr->passive_client = jcr->impl_->res.client->passive; if (!jcr->passive_client) { /* * Start the Job in the SD. @@ -282,11 +286,11 @@ bool DoVerify(JobControlRecord* jcr) /* * Check if the file daemon supports passive client mode. */ - if (jcr->passive_client && jcr->FDVersion < FD_VERSION_51) { + if (jcr->passive_client && jcr->impl_->FDVersion < FD_VERSION_51) { Jmsg(jcr, M_FATAL, 0, _("Client \"%s\" doesn't support passive client mode. " "Please upgrade your client or disable compat mode.\n"), - jcr->res.client->resource_name_); + jcr->impl_->res.client->resource_name_); goto bail_out; } break; @@ -329,7 +333,7 @@ bool DoVerify(JobControlRecord* jcr) } if (!jcr->passive_client) { - StorageResource* store = jcr->res.read_storage; + StorageResource* store = jcr->impl_->res.read_storage; /* * Send Storage daemon address to the File daemon @@ -337,7 +341,7 @@ bool DoVerify(JobControlRecord* jcr) if (store->SDDport == 0) { store->SDDport = store->SDport; } TlsPolicy tls_policy; - if (jcr->res.client->connection_successful_handshake_ != + if (jcr->impl_->res.client->connection_successful_handshake_ != ClientConnectionHandshakeMode::kTlsFirst) { tls_policy = store->GetPolicy(); } else { @@ -353,10 +357,10 @@ bool DoVerify(JobControlRecord* jcr) goto bail_out; } } else { - ClientResource* client = jcr->res.client; + ClientResource* client = jcr->impl_->res.client; TlsPolicy tls_policy; - if (jcr->res.client->connection_successful_handshake_ != + if (jcr->impl_->res.client->connection_successful_handshake_ != ClientConnectionHandshakeMode::kTlsFirst) { tls_policy = client->GetPolicy(); } else { @@ -422,33 +426,36 @@ bool DoVerify(JobControlRecord* jcr) * Verify from catalog */ Dmsg0(10, "Verify level=catalog\n"); - jcr->sd_msg_thread_done = true; /* no SD msg thread, so it is done */ - jcr->SDJobStatus = JS_Terminated; - GetAttributesAndCompareToCatalog(jcr, jcr->previous_jr.JobId); + jcr->impl_->sd_msg_thread_done = + true; /* no SD msg thread, so it is done */ + jcr->impl_->SDJobStatus = JS_Terminated; + GetAttributesAndCompareToCatalog(jcr, jcr->impl_->previous_jr.JobId); break; case L_VERIFY_VOLUME_TO_CATALOG: /* * Verify Volume to catalog entries */ Dmsg0(10, "Verify level=volume\n"); - GetAttributesAndCompareToCatalog(jcr, jcr->previous_jr.JobId); + GetAttributesAndCompareToCatalog(jcr, jcr->impl_->previous_jr.JobId); break; case L_VERIFY_DISK_TO_CATALOG: /* * Verify Disk attributes to catalog */ Dmsg0(10, "Verify level=disk_to_catalog\n"); - jcr->sd_msg_thread_done = true; /* no SD msg thread, so it is done */ - jcr->SDJobStatus = JS_Terminated; - GetAttributesAndCompareToCatalog(jcr, jcr->previous_jr.JobId); + jcr->impl_->sd_msg_thread_done = + true; /* no SD msg thread, so it is done */ + jcr->impl_->SDJobStatus = JS_Terminated; + GetAttributesAndCompareToCatalog(jcr, jcr->impl_->previous_jr.JobId); break; case L_VERIFY_INIT: /* * Build catalog */ Dmsg0(10, "Verify level=init\n"); - jcr->sd_msg_thread_done = true; /* no SD msg thread, so it is done */ - jcr->SDJobStatus = JS_Terminated; + jcr->impl_->sd_msg_thread_done = + true; /* no SD msg thread, so it is done */ + jcr->impl_->SDJobStatus = JS_Terminated; GetAttributesAndPutInCatalog(jcr); jcr->db->EndTransaction(jcr); /* Terminate any open transaction */ jcr->db_batch->WriteBatchFileRecords(jcr); @@ -490,9 +497,9 @@ void VerifyCleanup(JobControlRecord* jcr, int TermCode) JobLevel = jcr->getJobLevel(); Dmsg3(900, "JobLevel=%c Expected=%u JobFiles=%u\n", JobLevel, - jcr->ExpectedFiles, jcr->JobFiles); + jcr->impl_->ExpectedFiles, jcr->JobFiles); if (JobLevel == L_VERIFY_VOLUME_TO_CATALOG && - jcr->ExpectedFiles != jcr->JobFiles) { + jcr->impl_->ExpectedFiles != jcr->JobFiles) { TermCode = JS_ErrorTerminated; } @@ -500,9 +507,9 @@ void VerifyCleanup(JobControlRecord* jcr, int TermCode) if (JobCanceled(jcr)) { CancelStorageDaemonJob(jcr); } - if (jcr->unlink_bsr && jcr->RestoreBootstrap) { + if (jcr->impl_->unlink_bsr && jcr->RestoreBootstrap) { SecureErase(jcr, jcr->RestoreBootstrap); - jcr->unlink_bsr = false; + jcr->impl_->unlink_bsr = false; } msg_type = M_INFO; /* By default INFO message */ @@ -530,18 +537,19 @@ void VerifyCleanup(JobControlRecord* jcr, int TermCode) _("Inappropriate term code: %d %c\n"), TermCode, TermCode); break; } - bstrftimes(sdt, sizeof(sdt), jcr->jr.StartTime); - bstrftimes(edt, sizeof(edt), jcr->jr.EndTime); - if (jcr->res.verify_job) { - Name = jcr->res.verify_job->resource_name_; + bstrftimes(sdt, sizeof(sdt), jcr->impl_->jr.StartTime); + bstrftimes(edt, sizeof(edt), jcr->impl_->jr.EndTime); + if (jcr->impl_->res.verify_job) { + Name = jcr->impl_->res.verify_job->resource_name_; } else { Name = ""; } - JobstatusToAscii(jcr->FDJobStatus, fd_term_msg, sizeof(fd_term_msg)); + JobstatusToAscii(jcr->impl_->FDJobStatus, fd_term_msg, sizeof(fd_term_msg)); switch (JobLevel) { case L_VERIFY_VOLUME_TO_CATALOG: - JobstatusToAscii(jcr->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); + JobstatusToAscii(jcr->impl_->SDJobStatus, sd_term_msg, + sizeof(sd_term_msg)); Jmsg(jcr, msg_type, 0, _("%s %s %s (%s):\n" " Build OS: %s %s %s\n" @@ -562,10 +570,11 @@ void VerifyCleanup(JobControlRecord* jcr, int TermCode) " Bareos binary info: %s\n" " Termination: %s\n\n"), BAREOS, my_name, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER, - jcr->jr.JobId, jcr->jr.Job, jcr->res.fileset->resource_name_, - JobLevelToString(JobLevel), jcr->res.client->resource_name_, - jcr->previous_jr.JobId, Name, sdt, edt, - edit_uint64_with_commas(jcr->ExpectedFiles, ec1), + jcr->impl_->jr.JobId, jcr->impl_->jr.Job, + jcr->impl_->res.fileset->resource_name_, JobLevelToString(JobLevel), + jcr->impl_->res.client->resource_name_, + jcr->impl_->previous_jr.JobId, Name, sdt, edt, + edit_uint64_with_commas(jcr->impl_->ExpectedFiles, ec1), edit_uint64_with_commas(jcr->JobFiles, ec2), jcr->JobErrors, fd_term_msg, sd_term_msg, BAREOS_JOBLOG_MESSAGE, TermMsg); break; @@ -588,9 +597,10 @@ void VerifyCleanup(JobControlRecord* jcr, int TermCode) " Bareos binary info: %s\n" " Termination: %s\n\n"), BAREOS, my_name, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER, - jcr->jr.JobId, jcr->jr.Job, jcr->res.fileset->resource_name_, - JobLevelToString(JobLevel), jcr->res.client->resource_name_, - jcr->previous_jr.JobId, Name, sdt, edt, + jcr->impl_->jr.JobId, jcr->impl_->jr.Job, + jcr->impl_->res.fileset->resource_name_, JobLevelToString(JobLevel), + jcr->impl_->res.client->resource_name_, + jcr->impl_->previous_jr.JobId, Name, sdt, edt, edit_uint64_with_commas(jcr->JobFiles, ec1), jcr->JobErrors, fd_term_msg, BAREOS_JOBLOG_MESSAGE, TermMsg); break; @@ -616,7 +626,7 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId) fd = jcr->file_bsock; fdbr.JobId = JobId; - jcr->FileIndex = 0; + jcr->impl_->FileIndex = 0; Dmsg0(20, "dir: waiting to receive file attributes\n"); /* @@ -636,7 +646,8 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId) if (JobCanceled(jcr)) { goto bail_out; } fname = CheckPoolMemorySize(fname, fd->message_length); - jcr->fname = CheckPoolMemorySize(jcr->fname, fd->message_length); + jcr->impl_->fname = + CheckPoolMemorySize(jcr->impl_->fname, fd->message_length); Dmsg1(200, "Atts+Digest=%s\n", fd->msg); if ((len = sscanf(fd->msg, "%ld %d %100s", &file_index, &stream, fname)) != 3) { @@ -672,25 +683,26 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId) int32_t LinkFIf, LinkFIc; Dmsg2(400, "file_index=%d attr=%s\n", file_index, attr); jcr->JobFiles++; - jcr->FileIndex = file_index; /* remember attribute file_index */ - jcr->previous_jr.FileIndex = file_index; + jcr->impl_->FileIndex = file_index; /* remember attribute file_index */ + jcr->impl_->previous_jr.FileIndex = file_index; DecodeStat(attr, &statf, sizeof(statf), &LinkFIf); /* decode file stat packet */ do_Digest = CRYPTO_DIGEST_NONE; - jcr->fn_printed = false; - PmStrcpy(jcr->fname, fname); /* move filename into JobControlRecord */ + jcr->impl_->fn_printed = false; + PmStrcpy(jcr->impl_->fname, + fname); /* move filename into JobControlRecord */ - Dmsg2(040, "dirdfname); + Dmsg2(040, "dirdimpl_->fname); Dmsg1(020, "dirddb->GetFileAttributesRecord(jcr, jcr->fname, - &jcr->previous_jr, &fdbr)) { - Jmsg(jcr, M_INFO, 0, _("New file: %s\n"), jcr->fname); - Dmsg1(020, _("File not in catalog: %s\n"), jcr->fname); + if (!jcr->db->GetFileAttributesRecord( + jcr, jcr->impl_->fname, &jcr->impl_->previous_jr, &fdbr)) { + Jmsg(jcr, M_INFO, 0, _("New file: %s\n"), jcr->impl_->fname); + Dmsg1(020, _("File not in catalog: %s\n"), jcr->impl_->fname); jcr->setJobStatus(JS_Differences); continue; } else { @@ -701,7 +713,7 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId) jcr->db->MarkFileRecord(jcr, fdbr.FileId, jcr->JobId); } - Dmsg3(400, "Found %s in catalog. inx=%d Opts=%s\n", jcr->fname, + Dmsg3(400, "Found %s in catalog. inx=%d Opts=%s\n", jcr->impl_->fname, file_index, Opts_Digest.c_str()); DecodeStat(fdbr.LStat, &statc, sizeof(statc), &LinkFIc); /* decode catalog stat */ @@ -800,7 +812,7 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId) } break; case '5': /* compare MD5 */ - Dmsg1(500, "set Do_MD5 for %s\n", jcr->fname); + Dmsg1(500, "set Do_MD5 for %s\n", jcr->impl_->fname); do_Digest = CRYPTO_DIGEST_MD5; break; case '1': /* compare SHA1 */ @@ -815,7 +827,7 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId) break; case STREAM_RESTORE_OBJECT: - Dmsg1(400, "RESTORE_OBJECT %s\n", jcr->fname); + Dmsg1(400, "RESTORE_OBJECT %s\n", jcr->impl_->fname); break; default: @@ -830,10 +842,10 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId) * When ever we get a digest it MUST have been * preceded by an attributes record, which sets attr_file_index */ - if (jcr->FileIndex != (uint32_t)file_index) { + if (jcr->impl_->FileIndex != (uint32_t)file_index) { Jmsg2(jcr, M_FATAL, 0, _("MD5/SHA1 index %d not same as attributes %d\n"), - file_index, jcr->FileIndex); + file_index, jcr->impl_->FileIndex); goto bail_out; } if (do_Digest != CRYPTO_DIGEST_NONE) { @@ -864,7 +876,7 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId) /* Now find all the files that are missing -- i.e. all files in * the database where the MarkId != current JobId */ - jcr->fn_printed = false; + jcr->impl_->fn_printed = false; Mmsg(buf, "SELECT Path.Path,File.Name FROM File,Path " "WHERE File.JobId=%d AND File.FileIndex > 0 " @@ -872,7 +884,7 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId) JobId, jcr->JobId); /* MissingHandler is called for each file found */ jcr->db->SqlQuery(buf.c_str(), MissingHandler, (void*)jcr); - if (jcr->fn_printed) { jcr->setJobStatus(JS_Differences); } + if (jcr->impl_->fn_printed) { jcr->setJobStatus(JS_Differences); } bail_out: FreePoolMemory(fname); @@ -889,12 +901,12 @@ static int MissingHandler(void* ctx, int num_fields, char** row) JobControlRecord* jcr = (JobControlRecord*)ctx; if (JobCanceled(jcr)) { return 1; } - if (!jcr->fn_printed) { + if (!jcr->impl_->fn_printed) { Qmsg(jcr, M_WARNING, 0, _("The following files are in the Catalog but not on %s:\n"), jcr->getJobLevel() == L_VERIFY_VOLUME_TO_CATALOG ? "the Volume(s)" : "disk"); - jcr->fn_printed = true; + jcr->impl_->fn_printed = true; } Qmsg(jcr, M_INFO, 0, " %s%s\n", row[0] ? row[0] : "", row[1] ? row[1] : ""); @@ -906,9 +918,9 @@ static int MissingHandler(void* ctx, int num_fields, char** row) */ static void PrtFname(JobControlRecord* jcr) { - if (!jcr->fn_printed) { - Jmsg(jcr, M_INFO, 0, _("File: %s\n"), jcr->fname); - jcr->fn_printed = true; + if (!jcr->impl_->fn_printed) { + Jmsg(jcr, M_INFO, 0, _("File: %s\n"), jcr->impl_->fname); + jcr->impl_->fn_printed = true; } } } /* namespace directordaemon */ diff --git a/core/src/filed/jcr_private.h b/core/src/filed/jcr_private.h index efef6f77224..4469c35e30a 100644 --- a/core/src/filed/jcr_private.h +++ b/core/src/filed/jcr_private.h @@ -42,7 +42,6 @@ struct CryptoContext { POOLMEM* pki_session_encoded = nullptr; /**< Cached DER-encoded copy of pki_session */ int32_t pki_session_encoded_size = 0; /**< Size of DER-encoded pki_session */ }; -/* clang-format on */ struct JobControlRecordPrivate { uint32_t num_files_examined = 0; /**< Files examined this job */ @@ -76,13 +75,13 @@ struct JobControlRecordPrivate { bool enable_vss = false; /**< VSS used by FD */ bool got_metadata = false; /**< Set when found job_metadata */ bool multi_restore = false; /**< Dir can do multiple storage restore */ - filedaemon::BareosAccurateFilelist* file_list = - nullptr; /**< Previous file list (accurate mode) */ + filedaemon::BareosAccurateFilelist* file_list = nullptr; /**< Previous file list (accurate mode) */ uint64_t base_size = 0; /**< Compute space saved with base job */ filedaemon::save_pkt* plugin_sp = nullptr; /**< Plugin save packet */ #ifdef HAVE_WIN32 VSSClient* pVSSClient = nullptr; /**< VSS Client Instance */ #endif }; +/* clang-format on */ #endif // BAREOS_SRC_FILED_JCR_H_ diff --git a/core/src/include/jcr.h b/core/src/include/jcr.h index 3fdfa0629e8..8cb8b35e7d7 100644 --- a/core/src/include/jcr.h +++ b/core/src/include/jcr.h @@ -52,15 +52,6 @@ typedef struct s_tree_root TREE_ROOT; class dlist; -namespace directordaemon { -class JobResource; -class StorageResource; -class ClientResource; -class PoolResource; -class FilesetResource; -class CatalogResource; -} // namespace directordaemon - namespace storagedaemon { struct VolumeList; class DeviceControlRecord; @@ -194,16 +185,6 @@ enum (jcr->JobStatus == JS_Canceled || jcr->JobStatus == JS_ErrorTerminated || \ jcr->JobStatus == JS_FatalError) -#define JobWaiting(jcr) \ - (jcr->job_started && \ - (jcr->JobStatus == JS_WaitFD || jcr->JobStatus == JS_WaitSD || \ - jcr->JobStatus == JS_WaitMedia || jcr->JobStatus == JS_WaitMount || \ - jcr->JobStatus == JS_WaitStoreRes || jcr->JobStatus == JS_WaitJobRes || \ - jcr->JobStatus == JS_WaitClientRes || jcr->JobStatus == JS_WaitMaxJobs || \ - jcr->JobStatus == JS_WaitPriority || jcr->SDJobStatus == JS_WaitMedia || \ - jcr->SDJobStatus == JS_WaitMount || jcr->SDJobStatus == JS_WaitDevice || \ - jcr->SDJobStatus == JS_WaitMaxJobs)) - #define foreach_jcr(jcr) \ for (jcr = jcr_walk_start(); jcr; (jcr = jcr_walk_next(jcr))) @@ -229,46 +210,6 @@ struct CopyThreadContext; struct JobControlRecordPrivate; -/* clang-format off */ -#ifdef DIRECTOR_DAEMON -struct Resources { - directordaemon::JobResource* job = nullptr; /**< Job resource */ - directordaemon::JobResource* verify_job = nullptr; /**< Job resource of verify previous job */ - directordaemon::JobResource* previous_job = nullptr; /**< Job resource of migration previous job */ - directordaemon::StorageResource* read_storage = nullptr; /**< Selected read storage */ - directordaemon::StorageResource* write_storage = nullptr; /**< Selected write storage */ - directordaemon::StorageResource* paired_read_write_storage = nullptr; /*< Selected paired storage (savedwrite_storage or read_storage)*/ - directordaemon::ClientResource* client = nullptr; /**< Client resource */ - directordaemon::PoolResource* pool = nullptr; /**< Pool resource = write for migration */ - directordaemon::PoolResource* rpool = nullptr; /**< Read pool. Used only in migration */ - directordaemon::PoolResource* full_pool = nullptr; /**< Full backup pool resource */ - directordaemon::PoolResource* vfull_pool = nullptr; /**< Virtual Full backup pool resource */ - directordaemon::PoolResource* inc_pool = nullptr; /**< Incremental backup pool resource */ - directordaemon::PoolResource* diff_pool = nullptr; /**< Differential backup pool resource */ - directordaemon::PoolResource* next_pool = nullptr; /**< Next Pool used for migration/copy and virtual backup */ - directordaemon::FilesetResource* fileset = nullptr; /**< FileSet resource */ - directordaemon::CatalogResource* catalog = nullptr; /**< Catalog resource */ - MessagesResource* messages = nullptr; /**< Default message handler */ - POOLMEM* pool_source = nullptr; /**< Where pool came from */ - POOLMEM* npool_source = nullptr; /**< Where next pool came from */ - POOLMEM* rpool_source = nullptr; /**< Where migrate read pool came from */ - POOLMEM* rstore_source = nullptr; /**< Where read storage came from */ - POOLMEM* wstore_source = nullptr; /**< Where write storage came from */ - POOLMEM* catalog_source = nullptr; /**< Where catalog came from */ - alist* read_storage_list = nullptr; /**< Read storage possibilities */ - alist* write_storage_list = nullptr; /**< Write storage possibilities */ - alist* paired_read_write_storage_list = nullptr; /**< Paired storage possibilities - * (saved write_storage_list or read_storage_list) */ - bool run_pool_override = false; /**< Pool override was given on run cmdline */ - bool run_full_pool_override = false; /**< Full pool override was given on run cmdline */ - bool run_vfull_pool_override = false; /**< Virtual Full pool override was given on run cmdline */ - bool run_inc_pool_override = false; /**< Incremental pool override was given on run cmdline */ - bool run_diff_pool_override = false; /**< Differential pool override was given on run cmdline */ - bool run_next_pool_override = false; /**< Next pool override was given on run cmdline */ -}; -/* clang-format on */ -#endif - /* clang-format off */ struct CompressionContext { POOLMEM* deflate_buffer{nullptr}; /**< Buffer used for deflation (compression) */ @@ -449,86 +390,6 @@ class JobControlRecord { htable* path_list = nullptr; /**< Directory list (used by findlib) */ bool is_passive_client_connection_probing = false; /**< Set if director probes a passive client connection */ - /* - * Daemon specific part of JobControlRecord - * This should be empty in the library - */ - -#ifdef DIRECTOR_DAEMON - /* - * Director Daemon specific data part of JobControlRecord - */ - pthread_t SD_msg_chan = 0; /**< Message channel thread id */ - bool SD_msg_chan_started = false; /**< Message channel thread started */ - pthread_cond_t start_wait = PTHREAD_COND_INITIALIZER; /**< Wait for FD to start Job */ - pthread_cond_t term_wait = PTHREAD_COND_INITIALIZER; /**< Wait for job termination */ - pthread_cond_t nextrun_ready = PTHREAD_COND_INITIALIZER; /**< Wait for job next run to become ready */ - BareosSocket* ua = nullptr; /**< User agent */ - Resources res; /**< Resources assigned */ - TREE_ROOT* restore_tree_root = nullptr; /**< Selected files to restore (some protocols need this info) */ - storagedaemon::BootStrapRecord* bsr = nullptr; /**< Bootstrap record -- has everything */ - char* backup_format = nullptr; /**< Backup format used when doing a NDMP backup */ - char* plugin_options = nullptr; /**< User set options for plugin */ - uint32_t SDJobFiles = 0; /**< Number of files written, this job */ - uint64_t SDJobBytes = 0; /**< Number of bytes processed this job */ - uint32_t SDErrors = 0; /**< Number of non-fatal errors */ - volatile int32_t SDJobStatus = 0; /**< Storage Job Status */ - volatile int32_t FDJobStatus = 0; /**< File daemon Job Status */ - uint32_t DumpLevel = 0; /**< Dump level when doing a NDMP backup */ - uint32_t ExpectedFiles = 0; /**< Expected restore files */ - uint32_t MediaId = 0; /**< DB record IDs associated with this job */ - uint32_t FileIndex = 0; /**< Last FileIndex processed */ - utime_t MaxRunSchedTime = 0; /**< Max run time in seconds from Initial Scheduled time */ - JobDbRecord jr; /**< Job DB record for current job */ - JobDbRecord previous_jr; /**< Previous job database record */ - JobControlRecord* mig_jcr = nullptr; /**< JobControlRecord for migration/copy job */ - char FSCreateTime[MAX_TIME_LENGTH]{0}; /**< FileSet CreateTime as returned from DB */ - char since[MAX_TIME_LENGTH]{0}; /**< Since time */ - char PrevJob[MAX_NAME_LENGTH]{0}; /**< Previous job name assiciated with since time */ - union { - JobId_t RestoreJobId; /**< Restore JobId specified by UA */ - JobId_t MigrateJobId; /**< Migration JobId specified by UA */ - JobId_t VerifyJobId; /**< Verify JobId specified by UA */ - }; - POOLMEM* fname = nullptr; /**< Name to put into catalog */ - POOLMEM* client_uname = nullptr; /**< Client uname */ - POOLMEM* FDSecureEraseCmd = nullptr; /**< Report: Secure Erase Command */ - POOLMEM* SDSecureEraseCmd = nullptr; /**< Report: Secure Erase Command */ - POOLMEM* vf_jobids = nullptr; /**< JobIds to use for Virtual Full */ - uint32_t replace = 0; /**< Replace option */ - int32_t NumVols = 0; /**< Number of Volume used in pool */ - int32_t reschedule_count = 0; /**< Number of times rescheduled */ - int32_t FDVersion = 0; /**< File daemon version number */ - int64_t spool_size = 0; /**< Spool size for this job */ - volatile bool sd_msg_thread_done = false; /**< Set when Storage message thread done */ - bool IgnoreDuplicateJobChecking = false; /**< Set in migration jobs */ - bool IgnoreLevelPoolOverides = false; /**< Set if a cmdline pool was specified */ - bool IgnoreClientConcurrency = false; /**< Set in migration jobs */ - bool IgnoreStorageConcurrency = false; /**< Set in migration jobs */ - bool spool_data = false; /**< Spool data in SD */ - bool acquired_resource_locks = false; /**< Set if resource locks acquired */ - bool start_wait_inited = false; /**< Set when cond var inited */ - bool term_wait_inited = false; /**< Set when cond var inited */ - bool nextrun_ready_inited = false; /**< Set when cond var inited */ - bool fn_printed = false; /**< Printed filename */ - bool needs_sd = false; /**< Set if SD needed by Job */ - bool cloned = false; /**< Set if cloned */ - bool unlink_bsr = false; /**< Unlink bsr file created */ - bool VSS = false; /**< VSS used by FD */ - bool Encrypt = false; /**< Encryption used by FD */ - bool stats_enabled = false; /**< Keep all job records in a table for long term statistics */ - bool no_maxtime = false; /**< Don't check Max*Time for this JobControlRecord */ - bool keep_sd_auth_key = false; /**< Clear or not the SD auth key after connection*/ - bool use_accurate_chksum = false; /**< Use or not checksum option in accurate code */ - bool sd_canceled = false; /**< Set if SD canceled */ - bool remote_replicate = false; /**< Replicate data to remote SD */ - bool RescheduleIncompleteJobs = false; /**< Set if incomplete can be rescheduled */ - bool HasQuota = false; /**< Client has quota limits */ - bool HasSelectedJobs = false; /**< Migration/Copy Job did actually select some JobIds */ - directordaemon::ClientConnectionHandshakeMode connection_handshake_try_ = - directordaemon::ClientConnectionHandshakeMode::kUndefined; -#endif /* DIRECTOR_DAEMON */ - JobControlRecordPrivate* impl_; #ifdef STORAGE_DAEMON From 042d2cf5a6781be200fed01c92a68d828018873b Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Wed, 6 Nov 2019 08:23:09 +0100 Subject: [PATCH 03/23] stored: move daemon private data to separate file --- core/src/include/jcr.h | 77 ------------ core/src/plugins/stored/scsicrypto-sd.cc | 5 +- core/src/stored/acquire.cc | 23 ++-- core/src/stored/append.cc | 7 +- core/src/stored/authenticate.cc | 7 +- core/src/stored/bcopy.cc | 27 ++-- core/src/stored/bextract.cc | 7 +- core/src/stored/bls.cc | 11 +- core/src/stored/bscan.cc | 61 +++++---- core/src/stored/bsr.cc | 28 +++-- core/src/stored/btape.cc | 29 +++-- core/src/stored/butil.cc | 59 +++++---- core/src/stored/dev.cc | 26 ++-- core/src/stored/device.cc | 19 +-- core/src/stored/dir_cmd.cc | 50 ++++---- core/src/stored/fd_cmds.cc | 43 +++---- core/src/stored/jcr_private.h | 96 +++++++++++++++ core/src/stored/job.cc | 115 +++++++++-------- core/src/stored/job.h | 2 + core/src/stored/label.cc | 19 +-- core/src/stored/mac.cc | 150 ++++++++++++----------- core/src/stored/mount.cc | 8 +- core/src/stored/ndmp_tape.cc | 53 ++++---- core/src/stored/read.cc | 9 +- core/src/stored/read_ctx.h | 14 +++ core/src/stored/read_record.cc | 22 ++-- core/src/stored/record.cc | 4 +- core/src/stored/record.h | 13 -- core/src/stored/reserve.cc | 66 +++++----- core/src/stored/sd_cmds.cc | 13 +- core/src/stored/sd_plugins.cc | 29 ++--- core/src/stored/sd_stats.cc | 5 +- core/src/stored/spool.cc | 30 ++--- core/src/stored/status.cc | 9 +- core/src/stored/stored.cc | 26 ++-- core/src/tests/sd_reservation.cc | 5 +- 36 files changed, 629 insertions(+), 538 deletions(-) create mode 100644 core/src/stored/jcr_private.h diff --git a/core/src/include/jcr.h b/core/src/include/jcr.h index 8cb8b35e7d7..1299fe1a754 100644 --- a/core/src/include/jcr.h +++ b/core/src/include/jcr.h @@ -37,10 +37,6 @@ #include #include "lib/tls_conf.h" -#ifdef STORAGE_DAEMON -#include "stored/read_ctx.h" -#endif - #ifdef DIRECTOR_DAEMON #include "cats/cats.h" #include "dird/client_connection_handshake_mode.h" @@ -52,13 +48,6 @@ typedef struct s_tree_root TREE_ROOT; class dlist; -namespace storagedaemon { -struct VolumeList; -class DeviceControlRecord; -class DirectorResource; -struct BootStrapRecord; -} // namespace storagedaemon - namespace filedaemon { class BareosAccurateFilelist; struct save_pkt; @@ -391,72 +380,6 @@ class JobControlRecord { bool is_passive_client_connection_probing = false; /**< Set if director probes a passive client connection */ JobControlRecordPrivate* impl_; - -#ifdef STORAGE_DAEMON - /* - * Storage Daemon specific part of JobControlRecord - */ - JobControlRecord* next_dev = nullptr; /**< Next JobControlRecord attached to device */ - JobControlRecord* prev_dev = nullptr; /**< Previous JobControlRecord attached to device */ - char* dir_auth_key = nullptr; /**< Dir auth key */ - pthread_cond_t job_start_wait = PTHREAD_COND_INITIALIZER; /**< Wait for FD to start Job */ - pthread_cond_t job_end_wait = PTHREAD_COND_INITIALIZER; /**< Wait for Job to end */ - int32_t type = 0; - storagedaemon::DeviceControlRecord* read_dcr = nullptr; /**< Device context for reading */ - storagedaemon::DeviceControlRecord* dcr = nullptr; /**< Device context record */ - alist* dcrs = nullptr; /**< List of dcrs open */ - POOLMEM* job_name = nullptr; /**< Base Job name (not unique) */ - POOLMEM* fileset_name = nullptr; /**< FileSet */ - POOLMEM* fileset_md5 = nullptr; /**< MD5 for FileSet */ - POOLMEM* backup_format = nullptr; /**< Backup format used when doing a NDMP backup */ - storagedaemon::VolumeList* VolList = nullptr; /**< List to read */ - int32_t NumWriteVolumes = 0; /**< Number of volumes written */ - int32_t NumReadVolumes = 0; /**< Total number of volumes to read */ - int32_t CurReadVolume = 0; /**< Current read volume number */ - int32_t label_errors = 0; /**< Count of label errors */ - bool session_opened = false; - bool remote_replicate = false; /**< Replicate data to remote SD */ - int32_t Ticket = 0; /**< Ticket for this job */ - bool ignore_label_errors = false; /**< Ignore Volume label errors */ - bool spool_attributes = false; /**< Set if spooling attributes */ - bool no_attributes = false; /**< Set if no attributes wanted */ - int64_t spool_size = 0; /**< Spool size for this job */ - bool spool_data = false; /**< Set to spool data */ - int32_t CurVol = 0; /**< Current Volume count */ - storagedaemon::DirectorResource* director = nullptr; /**< Director resource */ - alist* plugin_options = nullptr; /**< Specific Plugin Options sent by DIR */ - alist* write_store = nullptr; /**< List of write storage devices sent by DIR */ - alist* read_store = nullptr; /**< List of read devices sent by DIR */ - alist* reserve_msgs = nullptr; /**< Reserve fail messages */ - bool acquired_storage = false; /**< Did we acquire our reserved storage already or not */ - bool PreferMountedVols = false; /**< Prefer mounted vols rather than new */ - bool Resched = false; /**< Job may be rescheduled */ - bool insert_jobmedia_records = false; /**< Need to insert job media records */ - uint64_t RemainingQuota = 0; /**< Available bytes to use as quota */ - - /* - * Parameters for Open Read Session - */ - storagedaemon::READ_CTX* rctx = nullptr; /**< Read context used to keep track of what is processed or not */ - storagedaemon::BootStrapRecord* bsr = nullptr; /**< Bootstrap record -- has everything */ - bool mount_next_volume = false; /**< Set to cause next volume mount */ - uint32_t read_VolSessionId = 0; - uint32_t read_VolSessionTime = 0; - uint32_t read_StartFile = 0; - uint32_t read_EndFile = 0; - uint32_t read_StartBlock = 0; - uint32_t read_EndBlock = 0; - - /* - * Device wait times - */ - int32_t min_wait = 0; - int32_t max_wait = 0; - int32_t max_num_wait = 0; - int32_t wait_sec = 0; - int32_t rem_wait_sec = 0; - int32_t num_wait = 0; -#endif /* STORAGE_DAEMON */ }; /* clang-format on */ diff --git a/core/src/plugins/stored/scsicrypto-sd.cc b/core/src/plugins/stored/scsicrypto-sd.cc index 5b251ac2d2a..07b3784055d 100644 --- a/core/src/plugins/stored/scsicrypto-sd.cc +++ b/core/src/plugins/stored/scsicrypto-sd.cc @@ -61,6 +61,7 @@ */ #include "include/bareos.h" #include "stored/stored.h" +#include "stored/jcr_private.h" #include "lib/berrno.h" #include "lib/status.h" #include "lib/crypto_wrap.h" @@ -365,8 +366,8 @@ static bRC do_set_scsi_encryption_key(void* value) * has been wrapped using RFC3394 key wrapping. We first copy the current * wrapped key into a temporary variable for unwrapping. */ - if (dcr->jcr && dcr->jcr->director) { - director = dcr->jcr->director; + if (dcr->jcr && dcr->jcr->impl_->director) { + director = dcr->jcr->impl_->director; if (director->keyencrkey.value) { char WrappedVolEncrKey[MAX_NAME_LENGTH]; diff --git a/core/src/stored/acquire.cc b/core/src/stored/acquire.cc index 9a799575e19..2fa5e2a110b 100644 --- a/core/src/stored/acquire.cc +++ b/core/src/stored/acquire.cc @@ -43,6 +43,7 @@ #include "lib/berrno.h" #include "include/jcr.h" #include "stored/block.h" +#include "stored/jcr_private.h" namespace storagedaemon { @@ -112,7 +113,7 @@ bool AcquireDeviceForRead(DeviceControlRecord* dcr) } /* Find next Volume, if any */ - vol = jcr->VolList; + vol = jcr->impl_->VolList; if (!vol) { char ed1[50]; Jmsg(jcr, M_FATAL, 0, @@ -120,12 +121,12 @@ bool AcquireDeviceForRead(DeviceControlRecord* dcr) edit_int64(jcr->JobId, ed1)); goto get_out; } - jcr->CurReadVolume++; - for (i = 1; i < jcr->CurReadVolume; i++) { vol = vol->next; } + jcr->impl_->CurReadVolume++; + for (i = 1; i < jcr->impl_->CurReadVolume; i++) { vol = vol->next; } if (!vol) { Jmsg(jcr, M_FATAL, 0, _("Logic error: no next volume to read. Numvol=%d Curvol=%d\n"), - jcr->NumReadVolumes, jcr->CurReadVolume); + jcr->impl_->NumReadVolumes, jcr->impl_->CurReadVolume); goto get_out; /* should not happen */ } SetDcrFromVol(dcr, vol); @@ -166,8 +167,8 @@ bool AcquireDeviceForRead(DeviceControlRecord* dcr) LockReservations(); memset(&rctx, 0, sizeof(ReserveContext)); rctx.jcr = jcr; - jcr->read_dcr = dcr; - jcr->reserve_msgs = new alist(10, not_owned_by_alist); + jcr->impl_->read_dcr = dcr; + jcr->impl_->reserve_msgs = new alist(10, not_owned_by_alist); rctx.any_drive = true; rctx.device_name = vol->device; store = new DirectorStorage; @@ -508,7 +509,7 @@ DeviceControlRecord* AcquireDeviceForAppend(DeviceControlRecord* dcr) } dev->num_writers++; /* we are now a writer */ - if (jcr->NumWriteVolumes == 0) { jcr->NumWriteVolumes = 1; } + if (jcr->impl_->NumWriteVolumes == 0) { jcr->impl_->NumWriteVolumes = 1; } dev->VolCatInfo.VolCatJobs++; /* increment number of jobs on vol */ Dmsg4(100, "=== nwriters=%d nres=%d vcatjob=%d dev=%s\n", dev->num_writers, dev->NumReserved(), dev->VolCatInfo.VolCatJobs, dev->print_name()); @@ -782,8 +783,8 @@ void SetupNewDcrDevice(JobControlRecord* jcr, /* * Use job spoolsize prior to device spoolsize */ - if (jcr && jcr->spool_size) { - dcr->max_job_spool_size = jcr->spool_size; + if (jcr && jcr->impl_->spool_size) { + dcr->max_job_spool_size = jcr->impl_->spool_size; } else { dcr->max_job_spool_size = dev->device->max_job_spool_size; } @@ -876,9 +877,9 @@ void FreeDeviceControlRecord(DeviceControlRecord* dcr) if (dcr->rec) { FreeRecord(dcr->rec); } - if (jcr && jcr->dcr == dcr) { jcr->dcr = NULL; } + if (jcr && jcr->impl_->dcr == dcr) { jcr->impl_->dcr = NULL; } - if (jcr && jcr->read_dcr == dcr) { jcr->read_dcr = NULL; } + if (jcr && jcr->impl_->read_dcr == dcr) { jcr->impl_->read_dcr = NULL; } V(dcr->mutex_); diff --git a/core/src/stored/append.cc b/core/src/stored/append.cc index a7492f825ac..0e9d18fe842 100644 --- a/core/src/stored/append.cc +++ b/core/src/stored/append.cc @@ -32,6 +32,7 @@ #include "stored/acquire.h" #include "stored/append.h" #include "stored/fd_cmds.h" +#include "stored/jcr_private.h" #include "stored/label.h" #include "stored/spool.h" #include "lib/bget_msg.h" @@ -60,7 +61,7 @@ bool DoAppendData(JobControlRecord* jcr, BareosSocket* bs, const char* what) int32_t n, file_index, stream, last_file_index, job_elapsed; bool ok = true; char buf1[100]; - DeviceControlRecord* dcr = jcr->dcr; + DeviceControlRecord* dcr = jcr->impl_->dcr; Device* dev; POOLMEM* rec_data; char ec[50]; @@ -362,11 +363,11 @@ bool SendAttrsToDir(JobControlRecord* jcr, DeviceRecord* rec) rec->maskedStream == STREAM_UNIX_ATTRIBUTES_EX || rec->maskedStream == STREAM_RESTORE_OBJECT || CryptoDigestStreamType(rec->maskedStream) != CRYPTO_DIGEST_NONE) { - if (!jcr->no_attributes) { + if (!jcr->impl_->no_attributes) { BareosSocket* dir = jcr->dir_bsock; if (AreAttributesSpooled(jcr)) { dir->SetSpooling(); } Dmsg0(850, "Send attributes to dir.\n"); - if (!jcr->dcr->DirUpdateFileAttributes(rec)) { + if (!jcr->impl_->dcr->DirUpdateFileAttributes(rec)) { Jmsg(jcr, M_FATAL, 0, _("Error updating file attributes. ERR=%s\n"), dir->bstrerror()); dir->ClearSpooling(); diff --git a/core/src/stored/authenticate.cc b/core/src/stored/authenticate.cc index 6d0b0dc7f39..9d0b50831e3 100644 --- a/core/src/stored/authenticate.cc +++ b/core/src/stored/authenticate.cc @@ -30,7 +30,7 @@ #include "include/bareos.h" #include "stored/stored.h" #include "stored/stored_globals.h" -#include "include/jcr.h" +#include "stored/jcr_private.h" #include "lib/parse_conf.h" #include "lib/bsock.h" #include "lib/bnet_network_dump.h" @@ -89,7 +89,7 @@ bool AuthenticateDirector(JobControlRecord* jcr) UnbashSpaces(dirname); director = (DirectorResource*)my_config->GetResWithName(R_DIRECTOR, dirname); - jcr->director = director; + jcr->impl_->director = director; if (!director) { Dmsg2(debuglevel, "Connection from unknown Director %s at %s rejected.\n", @@ -161,7 +161,8 @@ bool AuthenticateWithStoragedaemon(JobControlRecord* jcr) password.value = jcr->sd_auth_key; if (!sd->AuthenticateOutboundConnection( - jcr, my_config->CreateOwnQualifiedNameForNetworkDump(), identity, password, me)) { + jcr, my_config->CreateOwnQualifiedNameForNetworkDump(), identity, + password, me)) { Jmsg1(jcr, M_FATAL, 0, _("Authorization problem: Two way security handshake failed with " "Storage daemon at %s\n"), diff --git a/core/src/stored/bcopy.cc b/core/src/stored/bcopy.cc index 9658c3142dd..7d81fb24996 100644 --- a/core/src/stored/bcopy.cc +++ b/core/src/stored/bcopy.cc @@ -34,6 +34,7 @@ #include "lib/crypto_cache.h" #include "stored/acquire.h" #include "stored/butil.h" +#include "stored/jcr_private.h" #include "stored/label.h" #include "stored/mount.h" #include "stored/read_record.h" @@ -207,9 +208,9 @@ int main(int argc, char* argv[]) true); /* read device */ if (!in_jcr) { exit(1); } - in_jcr->ignore_label_errors = ignore_label_errors; + in_jcr->impl_->ignore_label_errors = ignore_label_errors; - in_dev = in_jcr->dcr->dev; + in_dev = in_jcr->impl_->dcr->dev; if (!in_dev) { exit(1); } /* @@ -222,7 +223,7 @@ int main(int argc, char* argv[]) false); /* write device */ if (!out_jcr) { exit(1); } - out_dev = out_jcr->dcr->dev; + out_dev = out_jcr->impl_->dcr->dev; if (!out_dev) { exit(1); } Dmsg0(100, "About to acquire device for writing\n"); @@ -231,22 +232,22 @@ int main(int argc, char* argv[]) * For we must now acquire the device for writing */ out_dev->rLock(false); - if (!out_dev->open(out_jcr->dcr, OPEN_READ_WRITE)) { + if (!out_dev->open(out_jcr->impl_->dcr, OPEN_READ_WRITE)) { Emsg1(M_FATAL, 0, _("dev open failed: %s\n"), out_dev->errmsg); out_dev->Unlock(); exit(1); } out_dev->Unlock(); - if (!AcquireDeviceForAppend(out_jcr->dcr)) { + if (!AcquireDeviceForAppend(out_jcr->impl_->dcr)) { FreeJcr(in_jcr); exit(1); } - out_block = out_jcr->dcr->block; + out_block = out_jcr->impl_->dcr->block; - ok = ReadRecords(in_jcr->dcr, RecordCb, MountNextReadVolume); + ok = ReadRecords(in_jcr->impl_->dcr, RecordCb, MountNextReadVolume); if (ok || out_dev->CanWrite()) { - if (!out_jcr->dcr->WriteBlockToDevice()) { + if (!out_jcr->impl_->dcr->WriteBlockToDevice()) { Pmsg0(000, _("Write of last block failed.\n")); } } @@ -305,10 +306,10 @@ static bool RecordCb(DeviceControlRecord* in_dcr, DeviceRecord* rec) /* Skipping record, because does not match BootStrapRecord filter */ return true; } - while (!WriteRecordToBlock(out_jcr->dcr, rec)) { + while (!WriteRecordToBlock(out_jcr->impl_->dcr, rec)) { Dmsg2(150, "!WriteRecordToBlock data_len=%d rem=%d\n", rec->data_len, rec->remainder); - if (!out_jcr->dcr->WriteBlockToDevice()) { + if (!out_jcr->impl_->dcr->WriteBlockToDevice()) { Dmsg2(90, "Got WriteBlockToDev error on device %s: ERR=%s\n", out_dev->print_name(), out_dev->bstrerror()); Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"), @@ -316,7 +317,7 @@ static bool RecordCb(DeviceControlRecord* in_dcr, DeviceRecord* rec) return false; } } - if (!out_jcr->dcr->WriteBlockToDevice()) { + if (!out_jcr->impl_->dcr->WriteBlockToDevice()) { Dmsg2(90, "Got WriteBlockToDev error on device %s: ERR=%s\n", out_dev->print_name(), out_dev->bstrerror()); Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"), @@ -341,10 +342,10 @@ static bool RecordCb(DeviceControlRecord* in_dcr, DeviceRecord* rec) return true; } records++; - while (!WriteRecordToBlock(out_jcr->dcr, rec)) { + while (!WriteRecordToBlock(out_jcr->impl_->dcr, rec)) { Dmsg2(150, "!WriteRecordToBlock data_len=%d rem=%d\n", rec->data_len, rec->remainder); - if (!out_jcr->dcr->WriteBlockToDevice()) { + if (!out_jcr->impl_->dcr->WriteBlockToDevice()) { Dmsg2(90, "Got WriteBlockToDev error on device %s: ERR=%s\n", out_dev->print_name(), out_dev->bstrerror()); Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"), diff --git a/core/src/stored/bextract.cc b/core/src/stored/bextract.cc index 927f5b2bb99..6b69b232a14 100644 --- a/core/src/stored/bextract.cc +++ b/core/src/stored/bextract.cc @@ -34,6 +34,7 @@ #include "lib/crypto_cache.h" #include "stored/acquire.h" #include "stored/butil.h" +#include "stored/jcr_private.h" #include "stored/mount.h" #include "stored/read_record.h" #include "findlib/find.h" @@ -402,9 +403,9 @@ static void DoExtract(char* devname) jcr = SetupJcr("bextract", devname, bsr, director, dcr, VolumeName, true); /* read device */ if (!jcr) { exit(1); } - dev = jcr->read_dcr->dev; + dev = jcr->impl_->read_dcr->dev; if (!dev) { exit(1); } - dcr = jcr->read_dcr; + dcr = jcr->impl_->read_dcr; /* * Make sure where directory exists and that it is a directory @@ -453,7 +454,7 @@ static void DoExtract(char* devname) CleanupCompression(jcr); - CleanDevice(jcr->dcr); + CleanDevice(jcr->impl_->dcr); dev->term(); FreeDeviceControlRecord(dcr); FreeJcr(jcr); diff --git a/core/src/stored/bls.cc b/core/src/stored/bls.cc index 6da1a28707c..10a07135c96 100644 --- a/core/src/stored/bls.cc +++ b/core/src/stored/bls.cc @@ -36,6 +36,7 @@ #include "findlib/find.h" #include "stored/acquire.h" #include "stored/butil.h" +#include "stored/jcr_private.h" #include "stored/label.h" #include "stored/match_bsr.h" #include "stored/mount.h" @@ -253,10 +254,10 @@ int main(int argc, char* argv[]) jcr = SetupJcr("bls", argv[i], bsr, director, dcr, VolumeName, true); /* read device */ if (!jcr) { exit(1); } - jcr->ignore_label_errors = ignore_label_errors; - dev = jcr->dcr->dev; + jcr->impl_->ignore_label_errors = ignore_label_errors; + dev = jcr->impl_->dcr->dev; if (!dev) { exit(1); } - dcr = jcr->dcr; + dcr = jcr->impl_->dcr; rec = new_record(); attr = new_attr(jcr); /* @@ -289,9 +290,9 @@ static void do_close(JobControlRecord* jcr) { FreeAttr(attr); FreeRecord(rec); - CleanDevice(jcr->dcr); + CleanDevice(jcr->impl_->dcr); dev->term(); - FreeDeviceControlRecord(jcr->dcr); + FreeDeviceControlRecord(jcr->impl_->dcr); FreeJcr(jcr); } diff --git a/core/src/stored/bscan.cc b/core/src/stored/bscan.cc index 556831c57e9..9960955ad50 100644 --- a/core/src/stored/bscan.cc +++ b/core/src/stored/bscan.cc @@ -33,6 +33,7 @@ #include "include/bareos.h" #include "stored/stored.h" #include "stored/stored_globals.h" +#include "stored/jcr_private.h" #include "lib/crypto_cache.h" #include "findlib/find.h" #include "cats/cats.h" @@ -342,7 +343,7 @@ int main(int argc, char* argv[]) dcr = new DeviceControlRecord; bjcr = SetupJcr("bscan", argv[0], bsr, director, dcr, VolumeName, true); if (!bjcr) { exit(1); } - dev = bjcr->read_dcr->dev; + dev = bjcr->impl_->read_dcr->dev; if (showProgress) { char ed1[50]; @@ -385,9 +386,9 @@ int main(int argc, char* argv[]) } DbFlushBackends(); - CleanDevice(bjcr->dcr); + CleanDevice(bjcr->impl_->dcr); dev->term(); - FreeDeviceControlRecord(bjcr->dcr); + FreeDeviceControlRecord(bjcr->impl_->dcr); FreeJcr(bjcr); return 0; @@ -415,8 +416,8 @@ static bool BscanMountNextReadVolume(DeviceControlRecord* dcr) mdcr->EndBlock = dcr->EndBlock; mdcr->EndFile = dcr->EndFile; mdcr->VolMediaId = dcr->VolMediaId; - mjcr->read_dcr->VolLastIndex = dcr->VolLastIndex; - if (mjcr->insert_jobmedia_records) { + mjcr->impl_->read_dcr->VolLastIndex = dcr->VolLastIndex; + if (mjcr->impl_->insert_jobmedia_records) { if (!CreateJobmediaRecord(db, mjcr)) { Pmsg2(000, _("Could not create JobMedia record for Volume=%s Job=%s\n"), dev->getVolCatName(), mjcr->Job); @@ -463,7 +464,7 @@ static void do_scan() /* * Detach bscan's jcr as we are not a real Job on the tape */ - ReadRecords(bjcr->read_dcr, RecordCb, BscanMountNextReadVolume); + ReadRecords(bjcr->impl_->read_dcr, RecordCb, BscanMountNextReadVolume); if (update_db) { db->WriteBatchFileRecords(bjcr); /* used by bulk batch file insert */ @@ -681,7 +682,7 @@ static bool RecordCb(DeviceControlRecord* dcr, DeviceRecord* rec) * Process label, if Job record exists don't update db */ mjcr = CreateJobRecord(db, &jr, &label, rec); - dcr = mjcr->read_dcr; + dcr = mjcr->impl_->read_dcr; update_db = save_update_db; jr.PoolId = pr.PoolId; @@ -690,8 +691,8 @@ static bool RecordCb(DeviceControlRecord* dcr, DeviceRecord* rec) mjcr->client_name = GetPoolMemory(PM_FNAME); PmStrcpy(mjcr->client_name, label.ClientName); - mjcr->fileset_name = GetPoolMemory(PM_FNAME); - PmStrcpy(mjcr->fileset_name, label.FileSetName); + mjcr->impl_->fileset_name = GetPoolMemory(PM_FNAME); + PmStrcpy(mjcr->impl_->fileset_name, label.FileSetName); bstrncpy(dcr->pool_type, label.PoolType, sizeof(dcr->pool_type)); bstrncpy(dcr->pool_name, label.PoolName, sizeof(dcr->pool_name)); @@ -705,9 +706,9 @@ static bool RecordCb(DeviceControlRecord* dcr, DeviceRecord* rec) jr.JobId); db->SqlQuery(sql_buffer.c_str(), db_int64_handler, &jmr_count); if (jmr_count.value > 0) { - mjcr->insert_jobmedia_records = false; + mjcr->impl_->insert_jobmedia_records = false; } else { - mjcr->insert_jobmedia_records = true; + mjcr->impl_->insert_jobmedia_records = true; } if (rec->VolSessionId != jr.VolSessionId) { @@ -770,9 +771,11 @@ static bool RecordCb(DeviceControlRecord* dcr, DeviceRecord* rec) /* * Create JobMedia record */ - mjcr->read_dcr->VolLastIndex = dcr->VolLastIndex; - if (mjcr->insert_jobmedia_records) { CreateJobmediaRecord(db, mjcr); } - FreeDeviceControlRecord(mjcr->read_dcr); + mjcr->impl_->read_dcr->VolLastIndex = dcr->VolLastIndex; + if (mjcr->impl_->insert_jobmedia_records) { + CreateJobmediaRecord(db, mjcr); + } + FreeDeviceControlRecord(mjcr->impl_->read_dcr); FreeJcr(mjcr); } break; @@ -829,7 +832,7 @@ static bool RecordCb(DeviceControlRecord* dcr, DeviceRecord* rec) } return true; } - dcr = mjcr->read_dcr; + dcr = mjcr->impl_->read_dcr; if (dcr->VolFirstIndex == 0) { dcr->VolFirstIndex = block->FirstIndex; } /* @@ -1068,14 +1071,19 @@ static void BscanFreeJcr(JobControlRecord* jcr) if (jcr->RestoreBootstrap) { free(jcr->RestoreBootstrap); } - if (jcr->dcr) { - FreeDeviceControlRecord(jcr->dcr); - jcr->dcr = NULL; + if (jcr->impl_->dcr) { + FreeDeviceControlRecord(jcr->impl_->dcr); + jcr->impl_->dcr = NULL; + } + + if (jcr->impl_->read_dcr) { + FreeDeviceControlRecord(jcr->impl_->read_dcr); + jcr->impl_->read_dcr = NULL; } - if (jcr->read_dcr) { - FreeDeviceControlRecord(jcr->read_dcr); - jcr->read_dcr = NULL; + if (jcr->impl_) { + delete jcr->impl_; + jcr->impl_ = nullptr; } Dmsg0(200, "End bscan FreeJcr\n"); @@ -1093,7 +1101,7 @@ static bool CreateFileAttributesRecord(BareosDb* db, char* ap, DeviceRecord* rec) { - DeviceControlRecord* dcr = mjcr->read_dcr; + DeviceControlRecord* dcr = mjcr->impl_->read_dcr; ar.fname = fname; ar.link = lname; ar.ClientId = mjcr->ClientId; @@ -1445,7 +1453,7 @@ static bool UpdateJobRecord(BareosDb* db, "Last Volume Bytes: %s\n" "Bareos binary info: %s\n" "Termination: %s\n\n"), - edt, mjcr->JobId, mjcr->Job, mjcr->fileset_name, + edt, mjcr->JobId, mjcr->Job, mjcr->impl_->fileset_name, job_level_to_str(mjcr->getJobLevel()), mjcr->client_name, sdt, edt, edit_uint64_with_commas(mjcr->JobFiles, ec1), edit_uint64_with_commas(mjcr->JobBytes, ec2), mjcr->VolSessionId, @@ -1460,7 +1468,7 @@ static bool UpdateJobRecord(BareosDb* db, static bool CreateJobmediaRecord(BareosDb* db, JobControlRecord* mjcr) { JobMediaDbRecord jmr; - DeviceControlRecord* dcr = mjcr->read_dcr; + DeviceControlRecord* dcr = mjcr->impl_->read_dcr; dcr->EndBlock = dev->EndBlock; dcr->EndFile = dev->EndFile; @@ -1542,6 +1550,7 @@ static JobControlRecord* create_jcr(JobDbRecord* jr, * the JobId and the ClientId. */ jobjcr = new_jcr(sizeof(JobControlRecord), BscanFreeJcr); + jobjcr->impl_ = new JobControlRecordPrivate; jobjcr->setJobType(jr->JobType); jobjcr->setJobLevel(jr->JobLevel); jobjcr->JobStatus = jr->JobStatus; @@ -1552,8 +1561,8 @@ static JobControlRecord* create_jcr(JobDbRecord* jr, jobjcr->VolSessionId = rec->VolSessionId; jobjcr->VolSessionTime = rec->VolSessionTime; jobjcr->ClientId = jr->ClientId; - jobjcr->dcr = jobjcr->read_dcr = new DeviceControlRecord; - SetupNewDcrDevice(jobjcr, jobjcr->dcr, dev, NULL); + jobjcr->impl_->dcr = jobjcr->impl_->read_dcr = new DeviceControlRecord; + SetupNewDcrDevice(jobjcr, jobjcr->impl_->dcr, dev, NULL); return jobjcr; } diff --git a/core/src/stored/bsr.cc b/core/src/stored/bsr.cc index 8bd396b1f35..7b5459c56c6 100644 --- a/core/src/stored/bsr.cc +++ b/core/src/stored/bsr.cc @@ -40,6 +40,7 @@ #include "include/bareos.h" #include "stored/bsr.h" +#include "stored/jcr_private.h" #include "stored/stored.h" #include "include/jcr.h" @@ -795,13 +796,13 @@ static VolumeList* new_restore_volume() */ static bool AddRestoreVolume(JobControlRecord* jcr, VolumeList* vol) { - VolumeList* next = jcr->VolList; + VolumeList* next = jcr->impl_->VolList; /* Add volume to volume manager's read list */ AddReadVolume(jcr, vol->VolumeName); - if (!next) { /* list empty ? */ - jcr->VolList = vol; /* yes, add volume */ + if (!next) { /* list empty ? */ + jcr->impl_->VolList = vol; /* yes, add volume */ } else { /* Loop through all but last */ for (; next->next; next = next->next) { @@ -837,10 +838,10 @@ void CreateRestoreVolumeList(JobControlRecord* jcr) /* * Build a list of volumes to be processed */ - jcr->NumReadVolumes = 0; - jcr->CurReadVolume = 0; - if (jcr->bsr) { - BootStrapRecord* bsr = jcr->bsr; + jcr->impl_->NumReadVolumes = 0; + jcr->impl_->CurReadVolume = 0; + if (jcr->impl_->bsr) { + BootStrapRecord* bsr = jcr->impl_->bsr; if (!bsr->volume || !bsr->volume->VolumeName[0]) { return; } for (; bsr; bsr = bsr->next) { BsrVolume* bsrvol; @@ -860,7 +861,7 @@ void CreateRestoreVolumeList(JobControlRecord* jcr) vol->Slot = bsrvol->Slot; vol->start_file = sfile; if (AddRestoreVolume(jcr, vol)) { - jcr->NumReadVolumes++; + jcr->impl_->NumReadVolumes++; Dmsg2(400, "Added volume=%s mediatype=%s\n", vol->VolumeName, vol->MediaType); } else { @@ -872,14 +873,15 @@ void CreateRestoreVolumeList(JobControlRecord* jcr) } } else { /* This is the old way -- deprecated */ - for (p = jcr->dcr->VolumeName; p && *p;) { + for (p = jcr->impl_->dcr->VolumeName; p && *p;) { n = strchr(p, '|'); /* volume name separator */ if (n) { *n++ = 0; /* Terminate name */ } vol = new_restore_volume(); bstrncpy(vol->VolumeName, p, sizeof(vol->VolumeName)); - bstrncpy(vol->MediaType, jcr->dcr->media_type, sizeof(vol->MediaType)); + bstrncpy(vol->MediaType, jcr->impl_->dcr->media_type, + sizeof(vol->MediaType)); if (AddRestoreVolume(jcr, vol)) { - jcr->NumReadVolumes++; + jcr->impl_->NumReadVolumes++; } else { free((char*)vol); } @@ -890,7 +892,7 @@ void CreateRestoreVolumeList(JobControlRecord* jcr) void FreeRestoreVolumeList(JobControlRecord* jcr) { - VolumeList* vol = jcr->VolList; + VolumeList* vol = jcr->impl_->VolList; VolumeList* tmp; for (; vol;) { @@ -899,7 +901,7 @@ void FreeRestoreVolumeList(JobControlRecord* jcr) free(vol); vol = tmp; } - jcr->VolList = NULL; + jcr->impl_->VolList = NULL; } } /* namespace storagedaemon */ diff --git a/core/src/stored/btape.cc b/core/src/stored/btape.cc index 459ba409663..48b931a6e47 100644 --- a/core/src/stored/btape.cc +++ b/core/src/stored/btape.cc @@ -43,6 +43,7 @@ #include "stored/bsr.h" #include "stored/butil.h" #include "stored/device.h" +#include "stored/jcr_private.h" #include "stored/label.h" #include "stored/read_record.h" #include "stored/sd_backends.h" @@ -310,7 +311,7 @@ int main(int margc, char* margv[]) false); /* write device */ if (!jcr) { exit(1); } - dev = jcr->dcr->dev; + dev = jcr->impl_->dcr->dev; if (!dev) { exit(1); } if (!dev->IsTape()) { @@ -2172,7 +2173,7 @@ static void fillcmd() exit_code = 1; return; } - block = jcr->dcr->block; + block = jcr->impl_->dcr->block; Dmsg0(100, "Just after AcquireDeviceForAppend\n"); /* @@ -2198,7 +2199,7 @@ static void fillcmd() /* * Generate data as if from File daemon, write to device */ - jcr->dcr->VolFirstIndex = 0; + jcr->impl_->dcr->VolFirstIndex = 0; time(&jcr->run_time); /* start counting time for rates */ bstrftime(buf1, sizeof(buf1), jcr->run_time, "%H:%M:%S"); @@ -2344,15 +2345,15 @@ static void fillcmd() Pmsg3(0, _("\n\n%s Done filling tape at %d:%d. Now beginning re-read of " "tape ...\n"), - buf1, jcr->dcr->dev->file, jcr->dcr->dev->block_num); + buf1, jcr->impl_->dcr->dev->file, jcr->impl_->dcr->dev->block_num); } else { Pmsg3(0, _("\n\n%s Done filling tapes at %d:%d. Now beginning re-read of " "first tape ...\n"), - buf1, jcr->dcr->dev->file, jcr->dcr->dev->block_num); + buf1, jcr->impl_->dcr->dev->file, jcr->impl_->dcr->dev->block_num); } - jcr->dcr->block = block; + jcr->impl_->dcr->block = block; if (!do_unfill()) { Pmsg0(000, _("do_unfill failed.\n")); exit_code = 1; @@ -2445,12 +2446,14 @@ static bool do_unfill() last_block = last_block1; FreeRestoreVolumeList(jcr); - jcr->bsr = NULL; + jcr->impl_->bsr = NULL; bstrncpy(dcr->VolumeName, "TestVolume1|TestVolume2", sizeof(dcr->VolumeName)); CreateRestoreVolumeList(jcr); - if (jcr->VolList != NULL) { - jcr->VolList->Slot = 1; - if (jcr->VolList->next != NULL) { jcr->VolList->next->Slot = 2; } + if (jcr->impl_->VolList != NULL) { + jcr->impl_->VolList->Slot = 1; + if (jcr->impl_->VolList->next != NULL) { + jcr->impl_->VolList->next->Slot = 2; + } } SetVolumeName("TestVolume1", 1); @@ -2470,7 +2473,7 @@ static bool do_unfill() dev->close(dcr); dev->num_writers = 0; - jcr->dcr->clear_will_write(); + jcr->impl_->dcr->clear_will_write(); if (!AcquireDeviceForRead(dcr)) { Pmsg1(-1, "%s", dev->errmsg); @@ -2697,7 +2700,7 @@ static int FlushBlock(DeviceBlock* block, int dump) stop = -1; /* stop, but do simplified test */ } else { /* Full test in progress */ - if (!FixupDeviceBlockWriteError(jcr->dcr)) { + if (!FixupDeviceBlockWriteError(jcr->impl_->dcr)) { Pmsg1(000, _("Cannot fixup device error. %s\n"), dev->bstrerror()); ok = false; dev->Unlock(); @@ -3063,7 +3066,7 @@ static bool MyMountNextReadVolume(DeviceControlRecord* dcr) static void SetVolumeName(const char* VolName, int volnum) { - DeviceControlRecord* dcr = jcr->dcr; + DeviceControlRecord* dcr = jcr->impl_->dcr; volumename = VolName; vol_num = volnum; dev->setVolCatName(VolName); diff --git a/core/src/stored/butil.cc b/core/src/stored/butil.cc index 3943f5051a1..955b41a75ef 100644 --- a/core/src/stored/butil.cc +++ b/core/src/stored/butil.cc @@ -40,6 +40,7 @@ #include "stored/autochanger.h" #include "stored/device.h" #include "stored/bsr.h" +#include "stored/jcr_private.h" #include "lib/parse_bsr.h" #include "lib/parse_conf.h" #include "include/jcr.h" @@ -68,27 +69,28 @@ JobControlRecord* SetupJcr(const char* name, bool readonly) { JobControlRecord* jcr = new_jcr(sizeof(JobControlRecord), MyFreeJcr); + jcr->impl_ = new JobControlRecordPrivate; - jcr->bsr = bsr; - jcr->director = director; + jcr->impl_->bsr = bsr; + jcr->impl_->director = director; jcr->VolSessionId = 1; jcr->VolSessionTime = (uint32_t)time(NULL); - jcr->NumReadVolumes = 0; - jcr->NumWriteVolumes = 0; + jcr->impl_->NumReadVolumes = 0; + jcr->impl_->NumWriteVolumes = 0; jcr->JobId = 0; jcr->setJobType(JT_CONSOLE); jcr->setJobLevel(L_FULL); jcr->JobStatus = JS_Terminated; jcr->where = strdup(""); - jcr->job_name = GetPoolMemory(PM_FNAME); - PmStrcpy(jcr->job_name, "Dummy.Job.Name"); + jcr->impl_->job_name = GetPoolMemory(PM_FNAME); + PmStrcpy(jcr->impl_->job_name, "Dummy.Job.Name"); jcr->client_name = GetPoolMemory(PM_FNAME); PmStrcpy(jcr->client_name, "Dummy.Client.Name"); bstrncpy(jcr->Job, name, sizeof(jcr->Job)); - jcr->fileset_name = GetPoolMemory(PM_FNAME); - PmStrcpy(jcr->fileset_name, "Dummy.fileset.name"); - jcr->fileset_md5 = GetPoolMemory(PM_FNAME); - PmStrcpy(jcr->fileset_md5, "Dummy.fileset.md5"); + jcr->impl_->fileset_name = GetPoolMemory(PM_FNAME); + PmStrcpy(jcr->impl_->fileset_name, "Dummy.fileset.name"); + jcr->impl_->fileset_md5 = GetPoolMemory(PM_FNAME); + PmStrcpy(jcr->impl_->fileset_md5, "Dummy.fileset.md5"); NewPlugins(jcr); /* instantiate plugins */ @@ -140,7 +142,7 @@ static bool setup_to_access_device(DeviceControlRecord* dcr, } else { VolName[0] = 0; } - if (!jcr->bsr && VolName[0] == 0) { + if (!jcr->impl_->bsr && VolName[0] == 0) { if (!bstrncmp(dev_name, "/dev/", 5)) { /* Try stripping file part */ p = dev_name + strlen(dev_name); @@ -165,7 +167,7 @@ static bool setup_to_access_device(DeviceControlRecord* dcr, return false; } device->dev = dev; - jcr->dcr = dcr; + jcr->impl_->dcr = dcr; SetupNewDcrDevice(jcr, dcr, dev, NULL); if (!readonly) { dcr->SetWillWrite(); } @@ -179,7 +181,7 @@ static bool setup_to_access_device(DeviceControlRecord* dcr, if (readonly) { /* read only access? */ Dmsg0(100, "Acquire device for read\n"); if (!AcquireDeviceForRead(dcr)) { return false; } - jcr->read_dcr = dcr; + jcr->impl_->read_dcr = dcr; } else { if (!FirstOpenDevice(dcr)) { Jmsg1(jcr, M_FATAL, 0, _("Cannot open %s\n"), dev->print_name()); @@ -196,9 +198,9 @@ static bool setup_to_access_device(DeviceControlRecord* dcr, */ static void MyFreeJcr(JobControlRecord* jcr) { - if (jcr->job_name) { - FreePoolMemory(jcr->job_name); - jcr->job_name = NULL; + if (jcr->impl_->job_name) { + FreePoolMemory(jcr->impl_->job_name); + jcr->impl_->job_name = NULL; } if (jcr->client_name) { @@ -206,14 +208,14 @@ static void MyFreeJcr(JobControlRecord* jcr) jcr->client_name = NULL; } - if (jcr->fileset_name) { - FreePoolMemory(jcr->fileset_name); - jcr->fileset_name = NULL; + if (jcr->impl_->fileset_name) { + FreePoolMemory(jcr->impl_->fileset_name); + jcr->impl_->fileset_name = NULL; } - if (jcr->fileset_md5) { - FreePoolMemory(jcr->fileset_md5); - jcr->fileset_md5 = NULL; + if (jcr->impl_->fileset_md5) { + FreePoolMemory(jcr->impl_->fileset_md5); + jcr->impl_->fileset_md5 = NULL; } if (jcr->comment) { @@ -221,11 +223,16 @@ static void MyFreeJcr(JobControlRecord* jcr) jcr->comment = NULL; } - if (jcr->VolList) { FreeRestoreVolumeList(jcr); } + if (jcr->impl_->VolList) { FreeRestoreVolumeList(jcr); } - if (jcr->dcr) { - FreeDeviceControlRecord(jcr->dcr); - jcr->dcr = NULL; + if (jcr->impl_->dcr) { + FreeDeviceControlRecord(jcr->impl_->dcr); + jcr->impl_->dcr = NULL; + } + + if (jcr->impl_) { + delete jcr->impl_; + jcr->impl_ = nullptr; } return; diff --git a/core/src/stored/dev.cc b/core/src/stored/dev.cc index 834bcccccc8..790cfc4096f 100644 --- a/core/src/stored/dev.cc +++ b/core/src/stored/dev.cc @@ -76,6 +76,8 @@ #include "stored/block.h" #include "stored/stored.h" #include "stored/autochanger.h" +#include "stored/bsr.h" +#include "stored/jcr_private.h" #include "stored/sd_backends.h" #include "lib/btimers.h" #include "include/jcr.h" @@ -445,23 +447,23 @@ void InitDeviceWaitTimers(DeviceControlRecord* dcr) dev->num_wait = 0; dev->poll = false; - jcr->min_wait = 60 * 60; - jcr->max_wait = 24 * 60 * 60; - jcr->max_num_wait = 9; /* 5 waits =~ 1 day, then 1 day at a time */ - jcr->wait_sec = jcr->min_wait; - jcr->rem_wait_sec = jcr->wait_sec; - jcr->num_wait = 0; + jcr->impl_->min_wait = 60 * 60; + jcr->impl_->max_wait = 24 * 60 * 60; + jcr->impl_->max_num_wait = 9; /* 5 waits =~ 1 day, then 1 day at a time */ + jcr->impl_->wait_sec = jcr->impl_->min_wait; + jcr->impl_->rem_wait_sec = jcr->impl_->wait_sec; + jcr->impl_->num_wait = 0; } void InitJcrDeviceWaitTimers(JobControlRecord* jcr) { /* ******FIXME******* put these on config variables */ - jcr->min_wait = 60 * 60; - jcr->max_wait = 24 * 60 * 60; - jcr->max_num_wait = 9; /* 5 waits =~ 1 day, then 1 day at a time */ - jcr->wait_sec = jcr->min_wait; - jcr->rem_wait_sec = jcr->wait_sec; - jcr->num_wait = 0; + jcr->impl_->min_wait = 60 * 60; + jcr->impl_->max_wait = 24 * 60 * 60; + jcr->impl_->max_num_wait = 9; /* 5 waits =~ 1 day, then 1 day at a time */ + jcr->impl_->wait_sec = jcr->impl_->min_wait; + jcr->impl_->rem_wait_sec = jcr->impl_->wait_sec; + jcr->impl_->num_wait = 0; } /** diff --git a/core/src/stored/device.cc b/core/src/stored/device.cc index fcccbd75507..6b5a21e1e93 100644 --- a/core/src/stored/device.cc +++ b/core/src/stored/device.cc @@ -53,6 +53,7 @@ #include "stored/bsr.h" #include "stored/stored.h" /* pull in Storage Daemon headers */ #include "stored/device.h" +#include "stored/jcr_private.h" #include "stored/match_bsr.h" #include "lib/edit.h" #include "include/jcr.h" @@ -172,7 +173,7 @@ bool FixupDeviceBlockWriteError(DeviceControlRecord* dcr, int retries) } /* Clear NewVol now because DirGetVolumeInfo() already done */ - jcr->dcr->NewVol = false; + jcr->impl_->dcr->NewVol = false; SetNewVolumeParameters(dcr); jcr->run_time += time(NULL) - wait_time; /* correct run time for mount wait */ @@ -230,7 +231,7 @@ void SetNewVolumeParameters(DeviceControlRecord* dcr) Jmsg1(jcr, M_ERROR, 0, "%s", jcr->errmsg); } SetNewFileParameters(dcr); - jcr->NumWriteVolumes++; + jcr->impl_->NumWriteVolumes++; dcr->NewVol = false; } @@ -312,9 +313,9 @@ BootStrapRecord* PositionDeviceToFirstFile(JobControlRecord* jcr, * Now find and position to first file and block * on this tape. */ - if (jcr->bsr) { - jcr->bsr->Reposition = true; /* force repositioning */ - bsr = find_next_bsr(jcr->bsr, dev); + if (jcr->impl_->bsr) { + jcr->impl_->bsr->Reposition = true; /* force repositioning */ + bsr = find_next_bsr(jcr->impl_->bsr, dev); if (GetBsrStartAddr(bsr, &file, &block) > 0) { Jmsg(jcr, M_INFO, 0, _("Forward spacing Volume \"%s\" to file:block %u:%u.\n"), @@ -338,15 +339,15 @@ bool TryDeviceRepositioning(JobControlRecord* jcr, BootStrapRecord* bsr; Device* dev = dcr->dev; - bsr = find_next_bsr(jcr->bsr, dev); - if (bsr == NULL && jcr->bsr->mount_next_volume) { + bsr = find_next_bsr(jcr->impl_->bsr, dev); + if (bsr == NULL && jcr->impl_->bsr->mount_next_volume) { Dmsg0(500, "Would mount next volume here\n"); Dmsg2(500, "Current position (file:block) %u:%u\n", dev->file, dev->block_num); - jcr->bsr->mount_next_volume = false; + jcr->impl_->bsr->mount_next_volume = false; if (!dev->AtEot()) { /* Set EOT flag to force mount of next Volume */ - jcr->mount_next_volume = true; + jcr->impl_->mount_next_volume = true; dev->SetEot(); } rec->Block = 0; diff --git a/core/src/stored/dir_cmd.cc b/core/src/stored/dir_cmd.cc index 92d7297331d..d1eb69bd67d 100644 --- a/core/src/stored/dir_cmd.cc +++ b/core/src/stored/dir_cmd.cc @@ -48,6 +48,7 @@ #include "stored/autochanger.h" #include "stored/bsr.h" #include "stored/fd_cmds.h" +#include "stored/jcr_private.h" #include "stored/job.h" #include "stored/label.h" #include "stored/ndmp_tape.h" @@ -244,17 +245,15 @@ void* HandleDirectorConnection(BareosSocket* dir) /* * This is a connection from the Director, so setup a JobControlRecord */ - jcr = new_jcr(sizeof(JobControlRecord), - StoredFreeJcr); /* create Job Control Record */ - NewPlugins(jcr); /* instantiate plugins */ - jcr->dir_bsock = dir; /* save Director bsock */ + jcr = NewStoredJcr(); + NewPlugins(jcr); /* instantiate plugins */ + jcr->dir_bsock = dir; /* save Director bsock */ jcr->dir_bsock->SetJcr(jcr); - jcr->dcrs = new alist(10, not_owned_by_alist); /* * Initialize Start Job condition variable */ - errstat = pthread_cond_init(&jcr->job_start_wait, NULL); + errstat = pthread_cond_init(&jcr->impl_->job_start_wait, NULL); if (errstat != 0) { BErrNo be; Jmsg1(jcr, M_FATAL, 0, @@ -266,7 +265,7 @@ void* HandleDirectorConnection(BareosSocket* dir) /* * Initialize End Job condition variable */ - errstat = pthread_cond_init(&jcr->job_end_wait, NULL); + errstat = pthread_cond_init(&jcr->impl_->job_end_wait, NULL); if (errstat != 0) { BErrNo be; Jmsg1(jcr, M_FATAL, 0, _("Unable to init job end cond variable: ERR=%s\n"), @@ -305,7 +304,7 @@ void* HandleDirectorConnection(BareosSocket* dir) found = false; for (i = 0; cmds[i].cmd; i++) { if (bstrncmp(cmds[i].cmd, dir->msg, strlen(cmds[i].cmd))) { - if ((!cmds[i].monitoraccess) && (jcr->director->monitor)) { + if ((!cmds[i].monitoraccess) && (jcr->impl_->director->monitor)) { Dmsg1(100, "Command \"%s\" is invalid.\n", cmds[i].cmd); dir->fsend(invalid_cmd); dir->signal(BNET_EOD); @@ -497,7 +496,7 @@ static bool CancelCmd(JobControlRecord* cjcr) Dmsg2(800, "Cancel JobId=%d %p\n", jcr->JobId, jcr); if (!jcr->authenticated && (oldStatus == JS_WaitFD || oldStatus == JS_WaitSD)) { - pthread_cond_signal(&jcr->job_start_wait); /* wake waiting thread */ + pthread_cond_signal(&jcr->impl_->job_start_wait); /* wake waiting thread */ } if (jcr->file_bsock) { @@ -509,7 +508,7 @@ static bool CancelCmd(JobControlRecord* cjcr) /* * Still waiting for FD to connect, release it */ - pthread_cond_signal(&jcr->job_start_wait); /* wake waiting job */ + pthread_cond_signal(&jcr->impl_->job_start_wait); /* wake waiting job */ Dmsg2(800, "Signal FD connect jid=%d %p\n", jcr->JobId, jcr); } } @@ -517,16 +516,17 @@ static bool CancelCmd(JobControlRecord* cjcr) /* * If thread waiting on mount, wake him */ - if (jcr->dcr && jcr->dcr->dev && jcr->dcr->dev->waiting_for_mount()) { - pthread_cond_broadcast(&jcr->dcr->dev->wait_next_vol); + if (jcr->impl_->dcr && jcr->impl_->dcr->dev && + jcr->impl_->dcr->dev->waiting_for_mount()) { + pthread_cond_broadcast(&jcr->impl_->dcr->dev->wait_next_vol); Dmsg1(100, "JobId=%u broadcast wait_device_release\n", (uint32_t)jcr->JobId); ReleaseDeviceCond(); } - if (jcr->read_dcr && jcr->read_dcr->dev && - jcr->read_dcr->dev->waiting_for_mount()) { - pthread_cond_broadcast(&jcr->read_dcr->dev->wait_next_vol); + if (jcr->impl_->read_dcr && jcr->impl_->read_dcr->dev && + jcr->impl_->read_dcr->dev->waiting_for_mount()) { + pthread_cond_broadcast(&jcr->impl_->read_dcr->dev->wait_next_vol); Dmsg1(100, "JobId=%u broadcast wait_device_release\n", (uint32_t)jcr->JobId); ReleaseDeviceCond(); @@ -550,7 +550,7 @@ static bool CancelCmd(JobControlRecord* cjcr) } } - pthread_cond_signal(&jcr->job_end_wait); /* wake waiting job */ + pthread_cond_signal(&jcr->impl_->job_end_wait); /* wake waiting job */ jcr->MyThreadSendSignal(TIMEOUT_SIGNAL); dir->fsend(_("3000 JobId=%ld Job=\"%s\" marked to be %s.\n"), jcr->JobId, @@ -1314,12 +1314,12 @@ static inline bool GetBootstrapFile(JobControlRecord* jcr, BareosSocket* sock) } fclose(bs); Dmsg0(10, "=== end bootstrap file ===\n"); - jcr->bsr = libbareos::parse_bsr(jcr, jcr->RestoreBootstrap); - if (!jcr->bsr) { + jcr->impl_->bsr = libbareos::parse_bsr(jcr, jcr->RestoreBootstrap); + if (!jcr->impl_->bsr) { Jmsg(jcr, M_FATAL, 0, _("Error parsing bootstrap file.\n")); goto bail_out; } - if (debug_level >= 10) { libbareos::DumpBsr(jcr->bsr, true); } + if (debug_level >= 10) { libbareos::DumpBsr(jcr->impl_->bsr, true); } /* If we got a bootstrap, we are reading, so create read volume list */ CreateRestoreVolumeList(jcr); ok = true; @@ -1651,8 +1651,8 @@ static bool ReplicateCmd(JobControlRecord* jcr) storage_daemon_socket->SetSourceAddress(me->SDsrc_addr); if (!jcr->max_bandwidth) { - if (jcr->director->max_bandwidth_per_job) { - jcr->max_bandwidth = jcr->director->max_bandwidth_per_job; + if (jcr->impl_->director->max_bandwidth_per_job) { + jcr->max_bandwidth = jcr->impl_->director->max_bandwidth_per_job; } else if (me->max_bandwidth_per_job) { jcr->max_bandwidth = me->max_bandwidth_per_job; } @@ -1707,7 +1707,7 @@ static bool ReplicateCmd(JobControlRecord* jcr) connect_state(ReplicateCmdState::kAuthenticated); Dmsg0(110, "Authenticated with SD.\n"); - jcr->remote_replicate = true; + jcr->impl_->remote_replicate = true; storage_daemon_socket.release(); /* jcr->store_bsock */ return dir->fsend(OK_replicate); @@ -1828,10 +1828,10 @@ static bool PluginoptionsCmd(JobControlRecord* jcr) } UnbashSpaces(plugin_options); - if (!jcr->plugin_options) { - jcr->plugin_options = new alist(10, owned_by_alist); + if (!jcr->impl_->plugin_options) { + jcr->impl_->plugin_options = new alist(10, owned_by_alist); } - jcr->plugin_options->append(strdup(plugin_options)); + jcr->impl_->plugin_options->append(strdup(plugin_options)); /* * Send OK to Director diff --git a/core/src/stored/fd_cmds.cc b/core/src/stored/fd_cmds.cc index c6d26df588a..82176b42d75 100644 --- a/core/src/stored/fd_cmds.cc +++ b/core/src/stored/fd_cmds.cc @@ -39,6 +39,7 @@ #include "stored/append.h" #include "stored/authenticate.h" #include "stored/fd_cmds.h" +#include "stored/jcr_private.h" #include "stored/read.h" #include "stored/sd_stats.h" #include "lib/bnet.h" @@ -153,7 +154,7 @@ void* HandleFiledConnection(BareosSocket* fd, char* job_name) UpdateJobStatistics(jcr, now); } - pthread_cond_signal(&jcr->job_start_wait); /* wake waiting job */ + pthread_cond_signal(&jcr->impl_->job_start_wait); /* wake waiting job */ FreeJcr(jcr); return NULL; @@ -262,7 +263,7 @@ static bool AppendDataCmd(JobControlRecord* jcr) BareosSocket* fd = jcr->file_bsock; Dmsg1(120, "Append data: %s", fd->msg); - if (jcr->session_opened) { + if (jcr->impl_->session_opened) { Dmsg1(110, "msg); jcr->setJobType(JT_BACKUP); if (DoAppendData(jcr, fd, "FD")) { @@ -284,7 +285,7 @@ static bool AppendEndSession(JobControlRecord* jcr) BareosSocket* fd = jcr->file_bsock; Dmsg1(120, "storedmsg); - if (!jcr->session_opened) { + if (!jcr->impl_->session_opened) { PmStrcpy(jcr->errmsg, _("Attempt to close non-open session.\n")); fd->fsend(NOT_opened); return false; @@ -300,13 +301,13 @@ static bool AppendOpenSession(JobControlRecord* jcr) BareosSocket* fd = jcr->file_bsock; Dmsg1(120, "Append open session: %s", fd->msg); - if (jcr->session_opened) { + if (jcr->impl_->session_opened) { PmStrcpy(jcr->errmsg, _("Attempt to open already open session.\n")); fd->fsend(NO_open); return false; } - jcr->session_opened = true; + jcr->impl_->session_opened = true; /* Send "Ticket" to File Daemon */ fd->fsend(OK_open, jcr->VolSessionId); @@ -325,7 +326,7 @@ static bool AppendCloseSession(JobControlRecord* jcr) BareosSocket* fd = jcr->file_bsock; Dmsg1(120, "msg); - if (!jcr->session_opened) { + if (!jcr->impl_->session_opened) { PmStrcpy(jcr->errmsg, _("Attempt to close non-open session.\n")); fd->fsend(NOT_opened); return false; @@ -339,7 +340,7 @@ static bool AppendCloseSession(JobControlRecord* jcr) fd->signal(BNET_EOD); /* send EOD to File daemon */ - jcr->session_opened = false; + jcr->impl_->session_opened = false; return true; } @@ -354,7 +355,7 @@ static bool ReadDataCmd(JobControlRecord* jcr) BareosSocket* fd = jcr->file_bsock; Dmsg1(120, "Read data: %s", fd->msg); - if (jcr->session_opened) { + if (jcr->impl_->session_opened) { Dmsg1(120, "msg); return DoReadData(jcr); } else { @@ -374,31 +375,31 @@ static bool ReadOpenSession(JobControlRecord* jcr) BareosSocket* fd = jcr->file_bsock; Dmsg1(120, "%s\n", fd->msg); - if (jcr->session_opened) { + if (jcr->impl_->session_opened) { PmStrcpy(jcr->errmsg, _("Attempt to open read on non-open session.\n")); fd->fsend(NO_open); return false; } - if (sscanf(fd->msg, read_open, jcr->read_dcr->VolumeName, - &jcr->read_VolSessionId, &jcr->read_VolSessionTime, - &jcr->read_StartFile, &jcr->read_EndFile, &jcr->read_StartBlock, - &jcr->read_EndBlock) == 7) { - if (jcr->session_opened) { + if (sscanf(fd->msg, read_open, jcr->impl_->read_dcr->VolumeName, + &jcr->impl_->read_VolSessionId, &jcr->impl_->read_VolSessionTime, + &jcr->impl_->read_StartFile, &jcr->impl_->read_EndFile, + &jcr->impl_->read_StartBlock, &jcr->impl_->read_EndBlock) == 7) { + if (jcr->impl_->session_opened) { PmStrcpy(jcr->errmsg, _("Attempt to open read on non-open session.\n")); fd->fsend(NOT_opened); return false; } Dmsg4(100, "ReadOpenSession got: JobId=%d Vol=%s VolSessId=%ld VolSessT=%ld\n", - jcr->JobId, jcr->read_dcr->VolumeName, jcr->read_VolSessionId, - jcr->read_VolSessionTime); + jcr->JobId, jcr->impl_->read_dcr->VolumeName, + jcr->impl_->read_VolSessionId, jcr->impl_->read_VolSessionTime); Dmsg4(100, " StartF=%ld EndF=%ld StartB=%ld EndB=%ld\n", - jcr->read_StartFile, jcr->read_EndFile, jcr->read_StartBlock, - jcr->read_EndBlock); + jcr->impl_->read_StartFile, jcr->impl_->read_EndFile, + jcr->impl_->read_StartBlock, jcr->impl_->read_EndBlock); } - jcr->session_opened = true; + jcr->impl_->session_opened = true; jcr->setJobType(JT_RESTORE); /* @@ -419,7 +420,7 @@ static bool ReadCloseSession(JobControlRecord* jcr) BareosSocket* fd = jcr->file_bsock; Dmsg1(120, "Read close session: %s\n", fd->msg); - if (!jcr->session_opened) { + if (!jcr->impl_->session_opened) { fd->fsend(NOT_opened); return false; } @@ -432,7 +433,7 @@ static bool ReadCloseSession(JobControlRecord* jcr) fd->signal(BNET_EOD); /* send EOD to File daemon */ - jcr->session_opened = false; + jcr->impl_->session_opened = false; return true; } diff --git a/core/src/stored/jcr_private.h b/core/src/stored/jcr_private.h new file mode 100644 index 00000000000..147e51a7225 --- /dev/null +++ b/core/src/stored/jcr_private.h @@ -0,0 +1,96 @@ +/* + BAREOS® - Backup Archiving REcovery Open Sourced + + Copyright (C) 2000-2012 Free Software Foundation Europe e.V. + Copyright (C) 2011-2012 Planets Communications B.V. + Copyright (C) 2013-2019 Bareos GmbH & Co. KG + + This program is Free Software; you can redistribute it and/or + modify it under the terms of version three of the GNU Affero General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#ifndef BAREOS_SRC_STORED_JCR_PRIVATE_H_ +#define BAREOS_SRC_STORED_JCR_PRIVATE_H_ + +#include "stored/read_ctx.h" + +namespace storagedaemon { +struct VolumeList; +class DeviceControlRecord; +class DirectorResource; +struct BootStrapRecord; +} // namespace storagedaemon + +/* clang-format off */ +struct JobControlRecordPrivate { + JobControlRecord* next_dev = nullptr; /**< Next JobControlRecord attached to device */ + JobControlRecord* prev_dev = nullptr; /**< Previous JobControlRecord attached to device */ + pthread_cond_t job_start_wait = PTHREAD_COND_INITIALIZER; /**< Wait for FD to start Job */ + pthread_cond_t job_end_wait = PTHREAD_COND_INITIALIZER; /**< Wait for Job to end */ + storagedaemon::DeviceControlRecord* read_dcr = nullptr; /**< Device context for reading */ + storagedaemon::DeviceControlRecord* dcr = nullptr; /**< Device context record */ + POOLMEM* job_name = nullptr; /**< Base Job name (not unique) */ + POOLMEM* fileset_name = nullptr; /**< FileSet */ + POOLMEM* fileset_md5 = nullptr; /**< MD5 for FileSet */ + POOLMEM* backup_format = nullptr; /**< Backup format used when doing a NDMP backup */ + storagedaemon::VolumeList* VolList = nullptr; /**< List to read */ + int32_t NumWriteVolumes = 0; /**< Number of volumes written */ + int32_t NumReadVolumes = 0; /**< Total number of volumes to read */ + int32_t CurReadVolume = 0; /**< Current read volume number */ + int32_t label_errors = 0; /**< Count of label errors */ + bool session_opened = false; + bool remote_replicate = false; /**< Replicate data to remote SD */ + int32_t Ticket = 0; /**< Ticket for this job */ + bool ignore_label_errors = false; /**< Ignore Volume label errors */ + bool spool_attributes = false; /**< Set if spooling attributes */ + bool no_attributes = false; /**< Set if no attributes wanted */ + int64_t spool_size = 0; /**< Spool size for this job */ + bool spool_data = false; /**< Set to spool data */ + storagedaemon::DirectorResource* director = nullptr; /**< Director resource */ + alist* plugin_options = nullptr; /**< Specific Plugin Options sent by DIR */ + alist* write_store = nullptr; /**< List of write storage devices sent by DIR */ + alist* read_store = nullptr; /**< List of read devices sent by DIR */ + alist* reserve_msgs = nullptr; /**< Reserve fail messages */ + bool acquired_storage = false; /**< Did we acquire our reserved storage already or not */ + bool PreferMountedVols = false; /**< Prefer mounted vols rather than new */ + bool insert_jobmedia_records = false; /**< Need to insert job media records */ + uint64_t RemainingQuota = 0; /**< Available bytes to use as quota */ + + /* + * Parameters for Open Read Session + */ + storagedaemon::READ_CTX* rctx = nullptr; /**< Read context used to keep track of what is processed or not */ + storagedaemon::BootStrapRecord* bsr = nullptr; /**< Bootstrap record -- has everything */ + bool mount_next_volume = false; /**< Set to cause next volume mount */ + uint32_t read_VolSessionId = 0; + uint32_t read_VolSessionTime = 0; + uint32_t read_StartFile = 0; + uint32_t read_EndFile = 0; + uint32_t read_StartBlock = 0; + uint32_t read_EndBlock = 0; + + /* + * Device wait times + */ + int32_t min_wait = 0; + int32_t max_wait = 0; + int32_t max_num_wait = 0; + int32_t wait_sec = 0; + int32_t rem_wait_sec = 0; + int32_t num_wait = 0; +}; +/* clang-format on */ + +#endif // BAREOS_SRC_STORED_JCR_PRIVATE_H_ diff --git a/core/src/stored/job.cc b/core/src/stored/job.cc index 0f356b65740..b156fd877a4 100644 --- a/core/src/stored/job.cc +++ b/core/src/stored/job.cc @@ -33,6 +33,7 @@ #include "stored/bsr.h" #include "stored/acquire.h" #include "stored/fd_cmds.h" +#include "stored/jcr_private.h" #include "stored/ndmp_tape.h" #include "stored/read_record.h" #include "stored/stored_globals.h" @@ -134,27 +135,27 @@ bool job_cmd(JobControlRecord* jcr) } bstrncpy(jcr->Job, job, sizeof(jcr->Job)); UnbashSpaces(job_name); - jcr->job_name = GetPoolMemory(PM_NAME); - PmStrcpy(jcr->job_name, job_name); + jcr->impl_->job_name = GetPoolMemory(PM_NAME); + PmStrcpy(jcr->impl_->job_name, job_name); UnbashSpaces(client_name); jcr->client_name = GetPoolMemory(PM_NAME); PmStrcpy(jcr->client_name, client_name); UnbashSpaces(fileset_name); - jcr->fileset_name = GetPoolMemory(PM_NAME); - PmStrcpy(jcr->fileset_name, fileset_name); + jcr->impl_->fileset_name = GetPoolMemory(PM_NAME); + PmStrcpy(jcr->impl_->fileset_name, fileset_name); jcr->setJobType(JobType); jcr->setJobLevel(level); - jcr->no_attributes = no_attributes; - jcr->spool_attributes = spool_attributes; - jcr->spool_data = spool_data; - jcr->spool_size = str_to_int64(spool_size); - jcr->fileset_md5 = GetPoolMemory(PM_NAME); - PmStrcpy(jcr->fileset_md5, fileset_md5); - jcr->PreferMountedVols = PreferMountedVols; - jcr->RemainingQuota = quota; + jcr->impl_->no_attributes = no_attributes; + jcr->impl_->spool_attributes = spool_attributes; + jcr->impl_->spool_data = spool_data; + jcr->impl_->spool_size = str_to_int64(spool_size); + jcr->impl_->fileset_md5 = GetPoolMemory(PM_NAME); + PmStrcpy(jcr->impl_->fileset_md5, fileset_md5); + jcr->impl_->PreferMountedVols = PreferMountedVols; + jcr->impl_->RemainingQuota = quota; UnbashSpaces(backup_format); - jcr->backup_format = GetPoolMemory(PM_NAME); - PmStrcpy(jcr->backup_format, backup_format); + jcr->impl_->backup_format = GetPoolMemory(PM_NAME); + PmStrcpy(jcr->impl_->backup_format, backup_format); jcr->authenticated = false; Dmsg1(50, "Quota set as %llu\n", quota); @@ -199,7 +200,8 @@ bool DoJobRun(JobControlRecord* jcr) */ P(mutex); while (!jcr->authenticated && !JobCanceled(jcr)) { - errstat = pthread_cond_timedwait(&jcr->job_start_wait, &mutex, &timeout); + errstat = + pthread_cond_timedwait(&jcr->impl_->job_start_wait, &mutex, &timeout); if (errstat == ETIMEDOUT || errstat == EINVAL || errstat == EPERM) { break; } @@ -225,7 +227,7 @@ bool DoJobRun(JobControlRecord* jcr) */ Dmsg2(800, "Wait for end job jid=%d %p\n", jcr->JobId, jcr); P(mutex); - pthread_cond_wait(&jcr->job_end_wait, &mutex); + pthread_cond_wait(&jcr->impl_->job_end_wait, &mutex); V(mutex); } Dmsg2(800, "Done jid=%d %p\n", jcr->JobId, jcr); @@ -294,8 +296,8 @@ bool nextRunCmd(JobControlRecord* jcr) P(mutex); while (!jcr->authenticated && !JobCanceled(jcr)) { - errstat = - pthread_cond_timedwait(&jcr->job_start_wait, &mutex, &timeout); + errstat = pthread_cond_timedwait(&jcr->impl_->job_start_wait, &mutex, + &timeout); if (errstat == ETIMEDOUT || errstat == EINVAL || errstat == EPERM) { break; } @@ -318,7 +320,7 @@ bool nextRunCmd(JobControlRecord* jcr) */ Dmsg2(800, "Wait for end job jid=%d %p\n", jcr->JobId, jcr); P(mutex); - pthread_cond_wait(&jcr->job_end_wait, &mutex); + pthread_cond_wait(&jcr->impl_->job_end_wait, &mutex); V(mutex); } Dmsg2(800, "Done jid=%d %p\n", jcr->JobId, jcr); @@ -414,27 +416,27 @@ void StoredFreeJcr(JobControlRecord* jcr) jcr->file_bsock = NULL; } - if (jcr->job_name) { FreePoolMemory(jcr->job_name); } + if (jcr->impl_->job_name) { FreePoolMemory(jcr->impl_->job_name); } if (jcr->client_name) { FreeMemory(jcr->client_name); jcr->client_name = NULL; } - if (jcr->fileset_name) { FreeMemory(jcr->fileset_name); } + if (jcr->impl_->fileset_name) { FreeMemory(jcr->impl_->fileset_name); } - if (jcr->fileset_md5) { FreeMemory(jcr->fileset_md5); } + if (jcr->impl_->fileset_md5) { FreeMemory(jcr->impl_->fileset_md5); } - if (jcr->backup_format) { FreeMemory(jcr->backup_format); } + if (jcr->impl_->backup_format) { FreeMemory(jcr->impl_->backup_format); } - if (jcr->bsr) { - libbareos::FreeBsr(jcr->bsr); - jcr->bsr = NULL; + if (jcr->impl_->bsr) { + libbareos::FreeBsr(jcr->impl_->bsr); + jcr->impl_->bsr = NULL; } - if (jcr->rctx) { - FreeReadContext(jcr->rctx); - jcr->rctx = NULL; + if (jcr->impl_->rctx) { + FreeReadContext(jcr->impl_->rctx); + jcr->impl_->rctx = NULL; } if (jcr->compress.deflate_buffer || jcr->compress.inflate_buffer) { @@ -451,53 +453,48 @@ void StoredFreeJcr(JobControlRecord* jcr) jcr->RestoreBootstrap = NULL; } - if (jcr->next_dev || jcr->prev_dev) { + if (jcr->impl_->next_dev || jcr->impl_->prev_dev) { Emsg0(M_FATAL, 0, _("In FreeJcr(), but still attached to device!!!!\n")); } - pthread_cond_destroy(&jcr->job_start_wait); - pthread_cond_destroy(&jcr->job_end_wait); - - if (jcr->dcrs) { - delete jcr->dcrs; - jcr->dcrs = NULL; - } + pthread_cond_destroy(&jcr->impl_->job_start_wait); + pthread_cond_destroy(&jcr->impl_->job_end_wait); /* * Avoid a double free */ - if (jcr->dcr == jcr->read_dcr) { jcr->read_dcr = NULL; } + if (jcr->impl_->dcr == jcr->impl_->read_dcr) { jcr->impl_->read_dcr = NULL; } - if (jcr->dcr) { - FreeDeviceControlRecord(jcr->dcr); - jcr->dcr = NULL; + if (jcr->impl_->dcr) { + FreeDeviceControlRecord(jcr->impl_->dcr); + jcr->impl_->dcr = NULL; } - if (jcr->read_dcr) { - FreeDeviceControlRecord(jcr->read_dcr); - jcr->read_dcr = NULL; + if (jcr->impl_->read_dcr) { + FreeDeviceControlRecord(jcr->impl_->read_dcr); + jcr->impl_->read_dcr = NULL; } - if (jcr->plugin_options) { delete jcr->plugin_options; } + if (jcr->impl_->plugin_options) { delete jcr->impl_->plugin_options; } - if (jcr->read_store) { + if (jcr->impl_->read_store) { DirectorStorage* store = nullptr; - foreach_alist (store, jcr->read_store) { + foreach_alist (store, jcr->impl_->read_store) { delete store->device; delete store; } - delete jcr->read_store; - jcr->read_store = NULL; + delete jcr->impl_->read_store; + jcr->impl_->read_store = NULL; } - if (jcr->write_store) { + if (jcr->impl_->write_store) { DirectorStorage* store = nullptr; - foreach_alist (store, jcr->write_store) { + foreach_alist (store, jcr->impl_->write_store) { delete store->device; delete store; } - delete jcr->write_store; - jcr->write_store = NULL; + delete jcr->impl_->write_store; + jcr->impl_->write_store = NULL; } FreePlugins(jcr); /* release instantiated plugins */ @@ -508,9 +505,21 @@ void StoredFreeJcr(JobControlRecord* jcr) GetFirstPortHostOrder(me->SDaddrs)); } + if (jcr->impl_) { + delete jcr->impl_; + jcr->impl_ = nullptr; + } + Dmsg0(200, "End stored FreeJcr\n"); return; } +JobControlRecord* NewStoredJcr() +{ + JobControlRecord* jcr = new_jcr(sizeof(JobControlRecord), StoredFreeJcr); + jcr->impl_ = new JobControlRecordPrivate; + return jcr; +} + } /* namespace storagedaemon */ diff --git a/core/src/stored/job.h b/core/src/stored/job.h index 67fce8d3d50..debf04539bf 100644 --- a/core/src/stored/job.h +++ b/core/src/stored/job.h @@ -30,6 +30,8 @@ bool FinishCmd(JobControlRecord* jcr); bool job_cmd(JobControlRecord* jcr); bool nextRunCmd(JobControlRecord* jcr); +JobControlRecord* NewStoredJcr(); + } /* namespace storagedaemon */ #endif // BAREOS_STORED_JOB_H_ diff --git a/core/src/stored/label.cc b/core/src/stored/label.cc index 0ff2e67eb13..b3633d32d07 100644 --- a/core/src/stored/label.cc +++ b/core/src/stored/label.cc @@ -33,6 +33,7 @@ #include "stored/stored_globals.h" #include "stored/dev.h" #include "stored/device.h" +#include "stored/jcr_private.h" #include "stored/label.h" #include "lib/edit.h" #include "include/jcr.h" @@ -131,7 +132,7 @@ int ReadDevVolumeLabel(DeviceControlRecord* dcr) Mmsg(jcr->errmsg, _("Wrong Volume mounted on device %s: Wanted %s have %s\n"), dev->print_name(), VolName, dev->VolHdr.VolumeName); - if (!dev->poll && jcr->label_errors++ > 100) { + if (!dev->poll && jcr->impl_->label_errors++ > 100) { Jmsg(jcr, M_FATAL, 0, _("Too many tries: %s"), jcr->errmsg); } goto bail_out; @@ -177,7 +178,7 @@ int ReadDevVolumeLabel(DeviceControlRecord* dcr) if (!dev->IsVolumeToUnload()) { dev->ClearUnload(); } if (!ok) { - if (forge_on || jcr->ignore_label_errors) { + if (forge_on || jcr->impl_->ignore_label_errors) { dev->SetLabeled(); /* set has Bareos label */ Jmsg(jcr, M_ERROR, 0, "%s", jcr->errmsg); goto ok_out; @@ -213,7 +214,7 @@ int ReadDevVolumeLabel(DeviceControlRecord* dcr) Mmsg(jcr->errmsg, _("Volume on %s has bad Bareos label type: %x\n"), dev->print_name(), dev->VolHdr.LabelType); Dmsg1(130, "%s", jcr->errmsg); - if (!dev->poll && jcr->label_errors++ > 100) { + if (!dev->poll && jcr->impl_->label_errors++ > 100) { Jmsg(jcr, M_FATAL, 0, _("Too many tries: %s"), jcr->errmsg); } Dmsg0(150, "return VOL_LABEL_ERROR\n"); @@ -236,7 +237,7 @@ int ReadDevVolumeLabel(DeviceControlRecord* dcr) * Cancel Job if too many label errors * => we are in a loop */ - if (!dev->poll && jcr->label_errors++ > 100) { + if (!dev->poll && jcr->impl_->label_errors++ > 100) { Jmsg(jcr, M_FATAL, 0, "Too many tries: %s", jcr->errmsg); } Dmsg0(150, "return VOL_NAME_ERROR\n"); @@ -543,8 +544,8 @@ static void CreateVolumeLabelRecord(DeviceControlRecord* dcr, rec->FileIndex = dev->VolHdr.LabelType; rec->VolSessionId = jcr->VolSessionId; rec->VolSessionTime = jcr->VolSessionTime; - rec->Stream = jcr->NumWriteVolumes; - rec->maskedStream = jcr->NumWriteVolumes; + rec->Stream = jcr->impl_->NumWriteVolumes; + rec->maskedStream = jcr->impl_->NumWriteVolumes; Dmsg2(150, "Created Vol label rec: FI=%s len=%d\n", FI_to_ascii(buf, rec->FileIndex), rec->data_len); } @@ -627,16 +628,16 @@ static void CreateSessionLabel(DeviceControlRecord* dcr, SerString(dcr->pool_name); SerString(dcr->pool_type); - SerString(jcr->job_name); /* base Job name */ + SerString(jcr->impl_->job_name); /* base Job name */ SerString(jcr->client_name); /* Added in VerNum 10 */ SerString(jcr->Job); /* Unique name of this Job */ - SerString(jcr->fileset_name); + SerString(jcr->impl_->fileset_name); ser_uint32(jcr->getJobType()); ser_uint32(jcr->getJobLevel()); /* Added in VerNum 11 */ - SerString(jcr->fileset_md5); + SerString(jcr->impl_->fileset_md5); if (label == EOS_LABEL) { ser_uint32(jcr->JobFiles); diff --git a/core/src/stored/mac.cc b/core/src/stored/mac.cc index f103cfdab45..4668430073b 100644 --- a/core/src/stored/mac.cc +++ b/core/src/stored/mac.cc @@ -36,6 +36,7 @@ #include "stored/bsr.h" #include "stored/append.h" #include "stored/device.h" +#include "stored/jcr_private.h" #include "stored/label.h" #include "stored/mount.h" #include "stored/read_record.h" @@ -119,7 +120,7 @@ static bool CloneRecordInternally(DeviceControlRecord* dcr, DeviceRecord* rec) bool retval = false; bool translated_record = false; JobControlRecord* jcr = dcr->jcr; - Device* dev = jcr->dcr->dev; + Device* dev = jcr->impl_->dcr->dev; char buf1[100], buf2[100]; /* @@ -148,10 +149,10 @@ static bool CloneRecordInternally(DeviceControlRecord* dcr, DeviceRecord* rec) if (jcr->is_JobType(JT_MIGRATE) || jcr->is_JobType(JT_COPY)) { bstrncpy(jcr->Job, label->Job, sizeof(jcr->Job)); - PmStrcpy(jcr->job_name, label->JobName); + PmStrcpy(jcr->impl_->job_name, label->JobName); PmStrcpy(jcr->client_name, label->ClientName); - PmStrcpy(jcr->fileset_name, label->FileSetName); - PmStrcpy(jcr->fileset_md5, label->FileSetMD5); + PmStrcpy(jcr->impl_->fileset_name, label->FileSetName); + PmStrcpy(jcr->impl_->fileset_md5, label->FileSetMD5); } jcr->setJobType(label->JobType); jcr->setJobLevel(label->JobLevel); @@ -170,7 +171,7 @@ static bool CloneRecordInternally(DeviceControlRecord* dcr, DeviceRecord* rec) jcr->start_time = jcr->sched_time; /* write the SOS Label with the existing timestamp infos */ - if (!WriteSessionLabel(jcr->dcr, SOS_LABEL)) { + if (!WriteSessionLabel(jcr->impl_->dcr, SOS_LABEL)) { Jmsg1(jcr, M_FATAL, 0, _("Write session label failed. ERR=%s\n"), dev->bstrerror()); jcr->setJobStatus(JS_ErrorTerminated); @@ -222,10 +223,10 @@ static bool CloneRecordInternally(DeviceControlRecord* dcr, DeviceRecord* rec) /* * Perform record translations. */ - jcr->dcr->before_rec = rec; - jcr->dcr->after_rec = NULL; - if (GeneratePluginEvent(jcr, bsdEventWriteRecordTranslation, jcr->dcr) != - bRC_OK) { + jcr->impl_->dcr->before_rec = rec; + jcr->impl_->dcr->after_rec = NULL; + if (GeneratePluginEvent(jcr, bsdEventWriteRecordTranslation, + jcr->impl_->dcr) != bRC_OK) { goto bail_out; } @@ -235,17 +236,17 @@ static bool CloneRecordInternally(DeviceControlRecord* dcr, DeviceRecord* rec) * taken place we just point the after_rec pointer to same DeviceRecord as in * the before_rec pointer. */ - if (!jcr->dcr->after_rec) { - jcr->dcr->after_rec = jcr->dcr->before_rec; + if (!jcr->impl_->dcr->after_rec) { + jcr->impl_->dcr->after_rec = jcr->impl_->dcr->before_rec; } else { translated_record = true; } - while (!WriteRecordToBlock(jcr->dcr, jcr->dcr->after_rec)) { + while (!WriteRecordToBlock(jcr->impl_->dcr, jcr->impl_->dcr->after_rec)) { Dmsg4(200, "!WriteRecordToBlock blkpos=%u:%u len=%d rem=%d\n", dev->file, - dev->block_num, jcr->dcr->after_rec->data_len, - jcr->dcr->after_rec->remainder); - if (!jcr->dcr->WriteBlockToDevice()) { + dev->block_num, jcr->impl_->dcr->after_rec->data_len, + jcr->impl_->dcr->after_rec->remainder); + if (!jcr->impl_->dcr->WriteBlockToDevice()) { Dmsg2(90, "Got WriteBlockToDev error on device %s. %s\n", dev->print_name(), dev->bstrerror()); Jmsg2(jcr, M_FATAL, 0, _("Fatal append error on device %s: ERR=%s\n"), @@ -258,33 +259,34 @@ static bool CloneRecordInternally(DeviceControlRecord* dcr, DeviceRecord* rec) /* * Restore packet */ - jcr->dcr->after_rec->VolSessionId = jcr->dcr->after_rec->last_VolSessionId; - jcr->dcr->after_rec->VolSessionTime = - jcr->dcr->after_rec->last_VolSessionTime; + jcr->impl_->dcr->after_rec->VolSessionId = + jcr->impl_->dcr->after_rec->last_VolSessionId; + jcr->impl_->dcr->after_rec->VolSessionTime = + jcr->impl_->dcr->after_rec->last_VolSessionTime; - if (jcr->dcr->after_rec->FileIndex < 0) { + if (jcr->impl_->dcr->after_rec->FileIndex < 0) { retval = true; /* don't send LABELs to Dir */ goto bail_out; } jcr->JobBytes += - jcr->dcr->after_rec->data_len; /* increment bytes of this job */ + jcr->impl_->dcr->after_rec->data_len; /* increment bytes of this job */ Dmsg5(500, "wrote_record JobId=%d FI=%s SessId=%d Strm=%s len=%d\n", - jcr->JobId, FI_to_ascii(buf1, jcr->dcr->after_rec->FileIndex), - jcr->dcr->after_rec->VolSessionId, - stream_to_ascii(buf2, jcr->dcr->after_rec->Stream, - jcr->dcr->after_rec->FileIndex), - jcr->dcr->after_rec->data_len); + jcr->JobId, FI_to_ascii(buf1, jcr->impl_->dcr->after_rec->FileIndex), + jcr->impl_->dcr->after_rec->VolSessionId, + stream_to_ascii(buf2, jcr->impl_->dcr->after_rec->Stream, + jcr->impl_->dcr->after_rec->FileIndex), + jcr->impl_->dcr->after_rec->data_len); - SendAttrsToDir(jcr, jcr->dcr->after_rec); + SendAttrsToDir(jcr, jcr->impl_->dcr->after_rec); retval = true; bail_out: if (translated_record) { - FreeRecord(jcr->dcr->after_rec); - jcr->dcr->after_rec = NULL; + FreeRecord(jcr->impl_->dcr->after_rec); + jcr->impl_->dcr->after_rec = NULL; } return retval; @@ -433,22 +435,22 @@ static inline void CheckAutoXflation(JobControlRecord* jcr) /* * Check autodeflation. */ - switch (jcr->read_dcr->autodeflate) { + switch (jcr->impl_->read_dcr->autodeflate) { case IO_DIRECTION_IN: case IO_DIRECTION_INOUT: Dmsg0(200, "Clearing autodeflate on read_dcr\n"); - jcr->read_dcr->autodeflate = IO_DIRECTION_NONE; + jcr->impl_->read_dcr->autodeflate = IO_DIRECTION_NONE; break; default: break; } - if (jcr->dcr) { - switch (jcr->dcr->autodeflate) { + if (jcr->impl_->dcr) { + switch (jcr->impl_->dcr->autodeflate) { case IO_DIRECTION_OUT: case IO_DIRECTION_INOUT: Dmsg0(200, "Clearing autodeflate on write dcr\n"); - jcr->dcr->autodeflate = IO_DIRECTION_NONE; + jcr->impl_->dcr->autodeflate = IO_DIRECTION_NONE; break; default: break; @@ -458,22 +460,22 @@ static inline void CheckAutoXflation(JobControlRecord* jcr) /* * Check autoinflation. */ - switch (jcr->read_dcr->autoinflate) { + switch (jcr->impl_->read_dcr->autoinflate) { case IO_DIRECTION_IN: case IO_DIRECTION_INOUT: Dmsg0(200, "Clearing autoinflate on read_dcr\n"); - jcr->read_dcr->autoinflate = IO_DIRECTION_NONE; + jcr->impl_->read_dcr->autoinflate = IO_DIRECTION_NONE; break; default: break; } - if (jcr->dcr) { - switch (jcr->dcr->autoinflate) { + if (jcr->impl_->dcr) { + switch (jcr->impl_->dcr->autoinflate) { case IO_DIRECTION_OUT: case IO_DIRECTION_INOUT: Dmsg0(200, "Clearing autoinflate on write dcr\n"); - jcr->dcr->autoinflate = IO_DIRECTION_NONE; + jcr->impl_->dcr->autoinflate = IO_DIRECTION_NONE; break; default: break; @@ -492,7 +494,7 @@ bool DoMacRun(JobControlRecord* jcr) bool ok = true; bool acquire_fail = false; BareosSocket* dir = jcr->dir_bsock; - Device* dev = jcr->dcr->dev; + Device* dev = jcr->impl_->dcr->dev; switch (jcr->getJobType()) { case JT_MIGRATE: @@ -514,7 +516,7 @@ bool DoMacRun(JobControlRecord* jcr) Dmsg0(20, "Start read data.\n"); - if (jcr->NumReadVolumes == 0) { + if (jcr->impl_->NumReadVolumes == 0) { Jmsg(jcr, M_FATAL, 0, _("No Volume names found for %s.\n"), Type); goto bail_out; } @@ -527,29 +529,30 @@ bool DoMacRun(JobControlRecord* jcr) /* * See if we perform both read and write or read only. */ - if (jcr->remote_replicate) { + if (jcr->impl_->remote_replicate) { BareosSocket* sd; - if (!jcr->read_dcr) { + if (!jcr->impl_->read_dcr) { Jmsg(jcr, M_FATAL, 0, _("Read device not properly initialized.\n")); goto bail_out; } - Dmsg1(100, "read_dcr=%p\n", jcr->read_dcr); - Dmsg3(200, "Found %d volumes names for %s. First=%s\n", jcr->NumReadVolumes, - Type, jcr->VolList->VolumeName); + Dmsg1(100, "read_dcr=%p\n", jcr->impl_->read_dcr); + Dmsg3(200, "Found %d volumes names for %s. First=%s\n", + jcr->impl_->NumReadVolumes, Type, jcr->impl_->VolList->VolumeName); /* * Ready devices for reading. */ - if (!AcquireDeviceForRead(jcr->read_dcr)) { + if (!AcquireDeviceForRead(jcr->impl_->read_dcr)) { ok = false; acquire_fail = true; goto bail_out; } - Dmsg2(200, "===== After acquire pos %u:%u\n", jcr->read_dcr->dev->file, - jcr->read_dcr->dev->block_num); + Dmsg2(200, "===== After acquire pos %u:%u\n", + jcr->impl_->read_dcr->dev->file, + jcr->impl_->read_dcr->dev->block_num); jcr->sendJobStatus(JS_Running); @@ -574,12 +577,12 @@ bool DoMacRun(JobControlRecord* jcr) */ if (BgetMsg(sd) >= 0) { Dmsg1(110, "msg); - if (sscanf(sd->msg, OK_start_replicate, &jcr->Ticket) != 1) { + if (sscanf(sd->msg, OK_start_replicate, &jcr->impl_->Ticket) != 1) { Jmsg(jcr, M_FATAL, 0, _("Bad response to start replicate: %s\n"), sd->msg); goto bail_out; } - Dmsg1(110, "Got Ticket=%d\n", jcr->Ticket); + Dmsg1(110, "Got Ticket=%d\n", jcr->impl_->Ticket); } else { Jmsg(jcr, M_FATAL, 0, _("Bad response from stored to start replicate command\n")); @@ -589,7 +592,7 @@ bool DoMacRun(JobControlRecord* jcr) /* * Let the remote SD know we are now really going to send the data. */ - sd->fsend(ReplicateData, jcr->Ticket); + sd->fsend(ReplicateData, jcr->impl_->Ticket); Dmsg1(110, ">stored: %s", sd->msg); /* @@ -609,7 +612,8 @@ bool DoMacRun(JobControlRecord* jcr) /* * Read all data and send it to remote SD. */ - ok = ReadRecords(jcr->read_dcr, CloneRecordToRemoteSd, MountNextReadVolume); + ok = ReadRecords(jcr->impl_->read_dcr, CloneRecordToRemoteSd, + MountNextReadVolume); /* * Send the last EOD to close the last data transfer and a next EOD to @@ -648,27 +652,28 @@ bool DoMacRun(JobControlRecord* jcr) /* Inform Storage daemon that we are done */ sd->signal(BNET_TERMINATE); } else { - if (!jcr->read_dcr) { + if (!jcr->impl_->read_dcr) { Jmsg(jcr, M_FATAL, 0, _("Read device not properly initialized.\n")); goto bail_out; } - Dmsg2(100, "read_dcr=%p write_dcr=%p\n", jcr->read_dcr, jcr->dcr); - Dmsg3(200, "Found %d volumes names for %s. First=%s\n", jcr->NumReadVolumes, - Type, jcr->VolList->VolumeName); + Dmsg2(100, "read_dcr=%p write_dcr=%p\n", jcr->impl_->read_dcr, + jcr->impl_->dcr); + Dmsg3(200, "Found %d volumes names for %s. First=%s\n", + jcr->impl_->NumReadVolumes, Type, jcr->impl_->VolList->VolumeName); /* * Ready devices for reading and writing. */ - if (!AcquireDeviceForRead(jcr->read_dcr) || - !AcquireDeviceForAppend(jcr->dcr)) { + if (!AcquireDeviceForRead(jcr->impl_->read_dcr) || + !AcquireDeviceForAppend(jcr->impl_->dcr)) { ok = false; acquire_fail = true; goto bail_out; } - Dmsg2(200, "===== After acquire pos %u:%u\n", jcr->dcr->dev->file, - jcr->dcr->dev->block_num); + Dmsg2(200, "===== After acquire pos %u:%u\n", jcr->impl_->dcr->dev->file, + jcr->impl_->dcr->dev->block_num); jcr->sendJobStatus(JS_Running); @@ -678,7 +683,7 @@ bool DoMacRun(JobControlRecord* jcr) now = (utime_t)time(NULL); UpdateJobStatistics(jcr, now); - if (!BeginDataSpool(jcr->dcr)) { + if (!BeginDataSpool(jcr->impl_->dcr)) { ok = false; goto bail_out; } @@ -688,21 +693,22 @@ bool DoMacRun(JobControlRecord* jcr) goto bail_out; } - jcr->dcr->VolFirstIndex = jcr->dcr->VolLastIndex = 0; + jcr->impl_->dcr->VolFirstIndex = jcr->impl_->dcr->VolLastIndex = 0; jcr->run_time = time(NULL); - SetStartVolPosition(jcr->dcr); + SetStartVolPosition(jcr->impl_->dcr); jcr->JobFiles = 0; /* * Read all data and make a local clone of it. */ - ok = ReadRecords(jcr->read_dcr, CloneRecordInternally, MountNextReadVolume); + ok = ReadRecords(jcr->impl_->read_dcr, CloneRecordInternally, + MountNextReadVolume); } bail_out: if (!ok) { jcr->setJobStatus(JS_ErrorTerminated); } - if (!acquire_fail && !jcr->remote_replicate && jcr->dcr) { + if (!acquire_fail && !jcr->impl_->remote_replicate && jcr->impl_->dcr) { /* * Don't use time_t for job_elapsed as time_t can be 32 or 64 bits, * and the subsequent Jmsg() editing will break @@ -722,7 +728,7 @@ bool DoMacRun(JobControlRecord* jcr) /* * Write End Of Session Label */ - DeviceControlRecord* dcr = jcr->dcr; + DeviceControlRecord* dcr = jcr->impl_->dcr; if (!WriteSessionLabel(dcr, EOS_LABEL)) { /* * Print only if ok and not cancelled to avoid spurious messages @@ -741,7 +747,7 @@ bool DoMacRun(JobControlRecord* jcr) /* * Flush out final partial block of this session */ - if (!jcr->dcr->WriteBlockToDevice()) { + if (!jcr->impl_->dcr->WriteBlockToDevice()) { Jmsg2(jcr, M_FATAL, 0, _("Fatal append error on device %s: ERR=%s\n"), dev->print_name(), dev->bstrerror()); Dmsg0(100, _("Set ok=FALSE after WriteBlockToDevice.\n")); @@ -753,12 +759,12 @@ bool DoMacRun(JobControlRecord* jcr) if (!ok) { - DiscardDataSpool(jcr->dcr); + DiscardDataSpool(jcr->impl_->dcr); } else { /* * Note: if commit is OK, the device will remain blocked */ - CommitDataSpool(jcr->dcr); + CommitDataSpool(jcr->impl_->dcr); } job_elapsed = time(NULL) - jcr->run_time; @@ -772,7 +778,7 @@ bool DoMacRun(JobControlRecord* jcr) /* * Release the device -- and send final Vol info to DIR */ - ReleaseDevice(jcr->dcr); + ReleaseDevice(jcr->impl_->dcr); if (!ok || JobCanceled(jcr)) { DiscardAttributeSpool(jcr); @@ -781,8 +787,8 @@ bool DoMacRun(JobControlRecord* jcr) } } - if (jcr->read_dcr) { - if (!ReleaseDevice(jcr->read_dcr)) { ok = false; } + if (jcr->impl_->read_dcr) { + if (!ReleaseDevice(jcr->impl_->read_dcr)) { ok = false; } } jcr->sendJobStatus(); /* update director */ diff --git a/core/src/stored/mount.cc b/core/src/stored/mount.cc index 30afb66a98a..ffe0a98678c 100644 --- a/core/src/stored/mount.cc +++ b/core/src/stored/mount.cc @@ -32,6 +32,7 @@ #include "stored/stored.h" /* pull in Storage Daemon headers */ #include "stored/acquire.h" #include "stored/autochanger.h" +#include "stored/jcr_private.h" #include "stored/label.h" #include "lib/edit.h" #include "include/jcr.h" @@ -952,14 +953,15 @@ bool MountNextReadVolume(DeviceControlRecord* dcr) { Device* dev = dcr->dev; JobControlRecord* jcr = dcr->jcr; - Dmsg2(90, "NumReadVolumes=%d CurReadVolume=%d\n", jcr->NumReadVolumes, - jcr->CurReadVolume); + Dmsg2(90, "NumReadVolumes=%d CurReadVolume=%d\n", jcr->impl_->NumReadVolumes, + jcr->impl_->CurReadVolume); VolumeUnused(dcr); /* release current volume */ /* * End Of Tape -- mount next Volume (if another specified) */ - if (jcr->NumReadVolumes > 1 && jcr->CurReadVolume < jcr->NumReadVolumes) { + if (jcr->impl_->NumReadVolumes > 1 && + jcr->impl_->CurReadVolume < jcr->impl_->NumReadVolumes) { dev->Lock(); dev->close(dcr); dev->SetRead(); diff --git a/core/src/stored/ndmp_tape.cc b/core/src/stored/ndmp_tape.cc index e1f227d65bb..f7264b614f0 100644 --- a/core/src/stored/ndmp_tape.cc +++ b/core/src/stored/ndmp_tape.cc @@ -46,6 +46,7 @@ #include "stored/acquire.h" #include "stored/bsr.h" #include "stored/device.h" +#include "stored/jcr_private.h" #include "stored/label.h" #include "stored/mount.h" #include "stored/read_record.h" @@ -326,7 +327,7 @@ static inline bool bndmp_write_data_to_block(JobControlRecord* jcr, uint32_t data_length) { bool retval = false; - DeviceControlRecord* dcr = jcr->dcr; + DeviceControlRecord* dcr = jcr->impl_->dcr; POOLMEM* rec_data; if (!dcr) { @@ -375,8 +376,8 @@ static inline bool bndmp_read_data_from_block(JobControlRecord* jcr, uint32_t wanted_data_length, uint32_t* data_length) { - DeviceControlRecord* dcr = jcr->read_dcr; - READ_CTX* rctx = jcr->rctx; + DeviceControlRecord* dcr = jcr->impl_->read_dcr; + READ_CTX* rctx = jcr->impl_->rctx; bool done = false; bool ok = true; @@ -479,7 +480,7 @@ static inline bool bndmp_read_data_from_block(JobControlRecord* jcr, */ static inline bool BndmpCreateVirtualFile(JobControlRecord* jcr, char* filename) { - DeviceControlRecord* dcr = jcr->dcr; + DeviceControlRecord* dcr = jcr->impl_->dcr; struct stat statp; time_t now = time(NULL); PoolMem attribs(PM_NAME), data(PM_NAME); @@ -591,7 +592,7 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess, * In NDMP terms this is the same as a FD connecting so wake any waiting * threads. */ - pthread_cond_signal(&jcr->job_start_wait); + pthread_cond_signal(&jcr->impl_->job_start_wait); /* * Save the JobControlRecord to ndm_session binding so everything furher @@ -623,9 +624,9 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess, * Depending on the open mode select the right DeviceControlRecord. */ if (will_write) { - dcr = jcr->dcr; + dcr = jcr->impl_->dcr; } else { - dcr = jcr->read_dcr; + dcr = jcr->impl_->read_dcr; } if (!dcr) { @@ -653,7 +654,7 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess, * One NDMP backup Job can be one or more save sessions so we keep * track if we already acquired the storage. */ - if (!jcr->acquired_storage) { + if (!jcr->impl_->acquired_storage) { /* * Actually acquire the device which we reserved. */ @@ -671,7 +672,7 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess, /* * Keep track that we acquired the storage. */ - jcr->acquired_storage = true; + jcr->impl_->acquired_storage = true; Dmsg1(50, "Begin append device=%s\n", dcr->dev->print_name()); @@ -729,16 +730,16 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess, /* * Setup internal system for reading data (if not done before). */ - if (!jcr->acquired_storage) { + if (!jcr->impl_->acquired_storage) { Dmsg0(20, "Start read data.\n"); - if (jcr->NumReadVolumes == 0) { + if (jcr->impl_->NumReadVolumes == 0) { Jmsg(jcr, M_FATAL, 0, _("No Volume names found for restore.\n")); goto bail_out; } Dmsg2(200, "Found %d volumes names to restore. First=%s\n", - jcr->NumReadVolumes, jcr->VolList->VolumeName); + jcr->impl_->NumReadVolumes, jcr->impl_->VolList->VolumeName); /* * Ready device for reading @@ -757,7 +758,7 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess, /* * Keep track that we acquired the storage. */ - jcr->acquired_storage = true; + jcr->impl_->acquired_storage = true; /* * Change the Job to running state. @@ -767,13 +768,13 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess, Dmsg1(50, "Begin reading device=%s\n", dcr->dev->print_name()); PositionDeviceToFirstFile(jcr, dcr); - jcr->mount_next_volume = false; + jcr->impl_->mount_next_volume = false; /* * Allocate a new read context for this Job. */ rctx = new_read_context(); - jcr->rctx = rctx; + jcr->impl_->rctx = rctx; /* * Read the first block and setup record processing. @@ -851,7 +852,7 @@ extern "C" ndmp9_error BndmpTapeClose(struct ndm_session* sess) } } - pthread_cond_signal(&jcr->job_end_wait); /* wake any waiting thread */ + pthread_cond_signal(&jcr->impl_->job_end_wait); /* wake any waiting thread */ ndmos_tape_initialize(sess); @@ -1033,7 +1034,7 @@ static inline void UnregisterCallbackHooks(struct ndm_session* sess) void EndOfNdmpBackup(JobControlRecord* jcr) { - DeviceControlRecord* dcr = jcr->dcr; + DeviceControlRecord* dcr = jcr->impl_->dcr; char ec[50]; /* @@ -1099,9 +1100,9 @@ void EndOfNdmpBackup(JobControlRecord* jcr) /* * Release the device -- and send final Vol info to DIR and unlock it. */ - if (jcr->acquired_storage) { + if (jcr->impl_->acquired_storage) { ReleaseDevice(dcr); - jcr->acquired_storage = false; + jcr->impl_->acquired_storage = false; } else { dcr->UnreserveDevice(); } @@ -1112,16 +1113,16 @@ void EndOfNdmpBackup(JobControlRecord* jcr) void EndOfNdmpRestore(JobControlRecord* jcr) { - if (jcr->rctx) { - FreeReadContext(jcr->rctx); - jcr->rctx = NULL; + if (jcr->impl_->rctx) { + FreeReadContext(jcr->impl_->rctx); + jcr->impl_->rctx = NULL; } - if (jcr->acquired_storage) { - ReleaseDevice(jcr->read_dcr); - jcr->acquired_storage = false; + if (jcr->impl_->acquired_storage) { + ReleaseDevice(jcr->impl_->read_dcr); + jcr->impl_->acquired_storage = false; } else { - jcr->read_dcr->UnreserveDevice(); + jcr->impl_->read_dcr->UnreserveDevice(); } } diff --git a/core/src/stored/read.cc b/core/src/stored/read.cc index 9b65681bc36..0e9bc57153b 100644 --- a/core/src/stored/read.cc +++ b/core/src/stored/read.cc @@ -32,6 +32,7 @@ #include "stored/stored.h" #include "stored/acquire.h" #include "stored/bsr.h" +#include "stored/jcr_private.h" #include "stored/mount.h" #include "stored/read_record.h" #include "lib/bnet.h" @@ -57,7 +58,7 @@ static char rec_header[] = "rechdr %ld %ld %ld %ld %ld"; bool DoReadData(JobControlRecord* jcr) { BareosSocket* fd = jcr->file_bsock; - DeviceControlRecord* dcr = jcr->read_dcr; + DeviceControlRecord* dcr = jcr->impl_->read_dcr; bool ok = true; Dmsg0(20, "Start read data.\n"); @@ -67,14 +68,14 @@ bool DoReadData(JobControlRecord* jcr) return false; } - if (jcr->NumReadVolumes == 0) { + if (jcr->impl_->NumReadVolumes == 0) { Jmsg(jcr, M_FATAL, 0, _("No Volume names found for restore.\n")); fd->fsend(FD_error); return false; } Dmsg2(200, "Found %d volumes names to restore. First=%s\n", - jcr->NumReadVolumes, jcr->VolList->VolumeName); + jcr->impl_->NumReadVolumes, jcr->impl_->VolList->VolumeName); /* * Ready device for reading @@ -104,7 +105,7 @@ bool DoReadData(JobControlRecord* jcr) */ fd->signal(BNET_EOD); - if (!ReleaseDevice(jcr->read_dcr)) { ok = false; } + if (!ReleaseDevice(jcr->impl_->read_dcr)) { ok = false; } Dmsg0(30, "Done reading.\n"); return ok; diff --git a/core/src/stored/read_ctx.h b/core/src/stored/read_ctx.h index 8af7ba21269..f325ff87c76 100644 --- a/core/src/stored/read_ctx.h +++ b/core/src/stored/read_ctx.h @@ -24,8 +24,22 @@ #ifndef BAREOS_STORED_READ_CTX_H_ #define BAREOS_STORED_READ_CTX_H_ 1 +#include "stored/record.h" + namespace storagedaemon { +struct DeviceRecord; + +/* clang-format off */ +struct Read_Context { + DeviceRecord* rec = nullptr; /**< Record currently being processed */ + dlist* recs = nullptr; /**< Linked list of record packets open */ + Session_Label sessrec; /**< Start Of Session record info */ + uint32_t records_processed = 0; /**< Number of records processed from this block */ + int32_t lastFileIndex = 0; /**< Last File Index processed */ +}; +/* clang-format on */ + typedef struct Read_Context READ_CTX; } /* namespace storagedaemon */ diff --git a/core/src/stored/read_record.cc b/core/src/stored/read_record.cc index d0278560962..cb6de0be79f 100644 --- a/core/src/stored/read_record.cc +++ b/core/src/stored/read_record.cc @@ -39,8 +39,10 @@ #include "stored/stored.h" #include "stored/butil.h" #include "stored/device.h" +#include "stored/jcr_private.h" #include "stored/label.h" #include "stored/match_bsr.h" +#include "stored/read_ctx.h" #include "include/jcr.h" namespace storagedaemon { @@ -220,15 +222,15 @@ bool ReadNextBlockFromDevice(DeviceControlRecord* dcr, trec->FileIndex = EOT_LABEL; trec->File = dcr->dev->file; *status = RecordCb(dcr, trec); - if (jcr->mount_next_volume) { - jcr->mount_next_volume = false; + if (jcr->impl_->mount_next_volume) { + jcr->impl_->mount_next_volume = false; dcr->dev->ClearEot(); } FreeRecord(trec); } return false; } - jcr->mount_next_volume = false; + jcr->impl_->mount_next_volume = false; /* * We just have a new tape up, now read the label (first record) @@ -261,7 +263,7 @@ bool ReadNextBlockFromDevice(DeviceControlRecord* dcr, * I/O error or strange end of tape */ DisplayTapeErrorStatus(jcr, dcr->dev); - if (forge_on || jcr->ignore_label_errors) { + if (forge_on || jcr->impl_->ignore_label_errors) { dcr->dev->fsr(1); /* try skipping bad record */ Pmsg0(000, _("Did fsr in attemp to skip bad record.\n")); continue; @@ -327,11 +329,11 @@ bool ReadNextRecordFromBlock(DeviceControlRecord* dcr, */ if (rec->FileIndex < 0) { HandleSessionRecord(dcr->dev, rec, &rctx->sessrec); - if (jcr->bsr) { + if (jcr->impl_->bsr) { /* * We just check block FI and FT not FileIndex */ - rec->match_stat = MatchBsrBlock(jcr->bsr, dcr->block); + rec->match_stat = MatchBsrBlock(jcr->impl_->bsr, dcr->block); } else { rec->match_stat = 0; } @@ -342,9 +344,9 @@ bool ReadNextRecordFromBlock(DeviceControlRecord* dcr, /* * Apply BootStrapRecord filter */ - if (jcr->bsr) { + if (jcr->impl_->bsr) { rec->match_stat = - MatchBsr(jcr->bsr, rec, &dev->VolHdr, &rctx->sessrec, jcr); + MatchBsr(jcr->impl_->bsr, rec, &dev->VolHdr, &rctx->sessrec, jcr); if (rec->match_stat == -1) { /* no more possible matches */ *done = true; /* all items found, stop */ Dmsg2(debuglevel, "All done=(file:block) %u:%u\n", dev->file, @@ -375,7 +377,7 @@ bool ReadNextRecordFromBlock(DeviceControlRecord* dcr, if (rctx->lastFileIndex != READ_NO_FILEINDEX && rctx->lastFileIndex != rec->FileIndex) { - if (IsThisBsrDone(jcr->bsr, rec) && + if (IsThisBsrDone(jcr->impl_->bsr, rec) && TryDeviceRepositioning(jcr, rec, dcr)) { Dmsg2(debuglevel, "This bsr done, break pos %u:%u\n", dev->file, dev->block_num); @@ -410,7 +412,7 @@ bool ReadRecords(DeviceControlRecord* dcr, rctx = new_read_context(); PositionDeviceToFirstFile(jcr, dcr); - jcr->mount_next_volume = false; + jcr->impl_->mount_next_volume = false; while (ok && !done) { if (JobCanceled(jcr)) { diff --git a/core/src/stored/record.cc b/core/src/stored/record.cc index 9d9a2ca4d94..8b4660bceb8 100644 --- a/core/src/stored/record.cc +++ b/core/src/stored/record.cc @@ -29,6 +29,7 @@ */ #include "include/bareos.h" +#include "stored/jcr_private.h" #include "stored/stored.h" #include "lib/attribs.h" #include "lib/util.h" @@ -684,7 +685,8 @@ bool DeviceControlRecord::WriteRecord() } jcr->JobBytes += after_rec->data_len; /* increment bytes this job */ - if (jcr->RemainingQuota && jcr->JobBytes > jcr->RemainingQuota) { + if (jcr->impl_->RemainingQuota && + jcr->JobBytes > jcr->impl_->RemainingQuota) { Jmsg0(jcr, M_FATAL, 0, _("Quota Exceeded. Job Terminated.\n")); goto bail_out; } diff --git a/core/src/stored/record.h b/core/src/stored/record.h index 368a156ac78..38f92ed3c51 100644 --- a/core/src/stored/record.h +++ b/core/src/stored/record.h @@ -247,19 +247,6 @@ struct Session_Label { #define SERIAL_BUFSIZE 1024 /**< Volume serialisation buffer size */ -/** - * Read context used to keep track of what is processed or not. - */ -/* clang-format off */ -struct Read_Context { - DeviceRecord* rec = nullptr; /**< Record currently being processed */ - dlist* recs = nullptr; /**< Linked list of record packets open */ - Session_Label sessrec; /**< Start Of Session record info */ - uint32_t records_processed = 0; /**< Number of records processed from this block */ - int32_t lastFileIndex = 0; /**< Last File Index processed */ -}; -/* clang-format on */ - struct DelayedDataStream { int32_t stream = 0; /**< stream less new bits */ char* content = nullptr; /**< stream data */ diff --git a/core/src/stored/reserve.cc b/core/src/stored/reserve.cc index 100219cf107..9038413a8ab 100644 --- a/core/src/stored/reserve.cc +++ b/core/src/stored/reserve.cc @@ -33,6 +33,7 @@ #include "stored/stored_globals.h" #include "stored/acquire.h" #include "stored/autochanger.h" +#include "stored/jcr_private.h" #include "stored/wait.h" #include "lib/berrno.h" #include "lib/util.h" @@ -209,7 +210,7 @@ static bool UseDeviceCmd(JobControlRecord* jcr) * If there are multiple devices, the director sends us * use_device for each device that it wants to use. */ - jcr->reserve_msgs = new alist(10, not_owned_by_alist); + jcr->impl_->reserve_msgs = new alist(10, not_owned_by_alist); do { Dmsg1(debuglevel, "msg); ok = sscanf(dir->msg, use_storage, StoreName.c_str(), media_type.c_str(), @@ -218,9 +219,9 @@ static bool UseDeviceCmd(JobControlRecord* jcr) if (!ok) { break; } dirstore = new alist(10, not_owned_by_alist); if (append) { - jcr->write_store = dirstore; + jcr->impl_->write_store = dirstore; } else { - jcr->read_store = dirstore; + jcr->impl_->read_store = dirstore; } rctx.append = append; UnbashSpaces(StoreName); @@ -250,11 +251,11 @@ static bool UseDeviceCmd(JobControlRecord* jcr) } while (ok && dir->recv() >= 0); InitJcrDeviceWaitTimers(jcr); - jcr->dcr = new StorageDaemonDeviceControlRecord; - SetupNewDcrDevice(jcr, jcr->dcr, NULL, NULL); - if (rctx.append) { jcr->dcr->SetWillWrite(); } + jcr->impl_->dcr = new StorageDaemonDeviceControlRecord; + SetupNewDcrDevice(jcr, jcr->impl_->dcr, NULL, NULL); + if (rctx.append) { jcr->impl_->dcr->SetWillWrite(); } - if (!jcr->dcr) { + if (!jcr->impl_->dcr) { BareosSocket* dir = jcr->dir_bsock; dir->fsend(_("3939 Could not get dcr\n")); Dmsg1(debuglevel, ">dird: %s", dir->msg); @@ -281,9 +282,9 @@ static bool UseDeviceCmd(JobControlRecord* jcr) * Put new dcr in proper location */ if (rctx.append) { - rctx.jcr->dcr = jcr->dcr; + rctx.jcr->impl_->dcr = jcr->impl_->dcr; } else { - rctx.jcr->read_dcr = jcr->dcr; + rctx.jcr->impl_->read_dcr = jcr->impl_->dcr; } LockReservations(); @@ -293,7 +294,7 @@ static bool UseDeviceCmd(JobControlRecord* jcr) rctx.have_volume = false; rctx.VolumeName[0] = 0; rctx.any_drive = false; - if (!jcr->PreferMountedVols) { + if (!jcr->impl_->PreferMountedVols) { /* * Here we try to find a drive that is not used. * This will maximize the use of available drives. @@ -428,12 +429,12 @@ bool FindSuitableDeviceForJob(JobControlRecord* jcr, ReserveContext& rctx) DirectorStorage* store; char* device_name = nullptr; alist* dirstore; - DeviceControlRecord* dcr = jcr->dcr; + DeviceControlRecord* dcr = jcr->impl_->dcr; if (rctx.append) { - dirstore = jcr->write_store; + dirstore = jcr->impl_->write_store; } else { - dirstore = jcr->read_store; + dirstore = jcr->impl_->read_store; } Dmsg5(debuglevel, "Start find_suit_dev PrefMnt=%d exact=%d suitable=%d chgronly=%d " @@ -600,11 +601,12 @@ int SearchResForDevice(ReserveContext& rctx) */ if (rctx.store->append == SD_APPEND) { Dmsg2(debuglevel, "Device %s reserved=%d for append.\n", - rctx.device->resource_name_, rctx.jcr->dcr->dev->NumReserved()); + rctx.device->resource_name_, + rctx.jcr->impl_->dcr->dev->NumReserved()); } else { Dmsg2(debuglevel, "Device %s reserved=%d for read.\n", rctx.device->resource_name_, - rctx.jcr->read_dcr->dev->NumReserved()); + rctx.jcr->impl_->read_dcr->dev->NumReserved()); } return status; } @@ -632,11 +634,12 @@ int SearchResForDevice(ReserveContext& rctx) */ if (rctx.store->append == SD_APPEND) { Dmsg2(debuglevel, "Device %s reserved=%d for append.\n", - rctx.device->resource_name_, rctx.jcr->dcr->dev->NumReserved()); + rctx.device->resource_name_, + rctx.jcr->impl_->dcr->dev->NumReserved()); } else { Dmsg2(debuglevel, "Device %s reserved=%d for read.\n", rctx.device->resource_name_, - rctx.jcr->read_dcr->dev->NumReserved()); + rctx.jcr->impl_->read_dcr->dev->NumReserved()); } return status; } @@ -666,11 +669,11 @@ int SearchResForDevice(ReserveContext& rctx) if (rctx.store->append == SD_APPEND) { Dmsg2(debuglevel, "Device %s reserved=%d for append.\n", rctx.device->resource_name_, - rctx.jcr->dcr->dev->NumReserved()); + rctx.jcr->impl_->dcr->dev->NumReserved()); } else { Dmsg2(debuglevel, "Device %s reserved=%d for read.\n", rctx.device->resource_name_, - rctx.jcr->read_dcr->dev->NumReserved()); + rctx.jcr->impl_->read_dcr->dev->NumReserved()); } return status; } @@ -726,11 +729,12 @@ static int ReserveDevice(ReserveContext& rctx) Dmsg1(debuglevel, "try reserve %s\n", rctx.device->resource_name_); if (rctx.store->append) { - SetupNewDcrDevice(rctx.jcr, rctx.jcr->dcr, rctx.device->dev, NULL); - dcr = rctx.jcr->dcr; + SetupNewDcrDevice(rctx.jcr, rctx.jcr->impl_->dcr, rctx.device->dev, NULL); + dcr = rctx.jcr->impl_->dcr; } else { - SetupNewDcrDevice(rctx.jcr, rctx.jcr->read_dcr, rctx.device->dev, NULL); - dcr = rctx.jcr->read_dcr; + SetupNewDcrDevice(rctx.jcr, rctx.jcr->impl_->read_dcr, rctx.device->dev, + NULL); + dcr = rctx.jcr->impl_->read_dcr; } if (!dcr) { @@ -753,7 +757,7 @@ static int ReserveDevice(ReserveContext& rctx) ok = ReserveDeviceForAppend(dcr, rctx); if (!ok) { goto bail_out; } - rctx.jcr->dcr = dcr; + rctx.jcr->impl_->dcr = dcr; Dmsg5(debuglevel, "Reserved=%d dev_name=%s mediatype=%s pool=%s ok=%d\n", dcr->dev->NumReserved(), dcr->dev_name, dcr->media_type, dcr->pool_name, ok); @@ -812,7 +816,7 @@ static int ReserveDevice(ReserveContext& rctx) } else { ok = ReserveDeviceForRead(dcr); if (ok) { - rctx.jcr->read_dcr = dcr; + rctx.jcr->impl_->read_dcr = dcr; Dmsg5(debuglevel, "Read reserved=%d dev_name=%s mediatype=%s pool=%s ok=%d\n", dcr->dev->NumReserved(), dcr->dev_name, dcr->media_type, @@ -1225,7 +1229,7 @@ static void QueueReserveMessage(JobControlRecord* jcr) jcr->lock(); - msgs = jcr->reserve_msgs; + msgs = jcr->impl_->reserve_msgs; if (!msgs) { goto bail_out; } /* * Look for duplicate message. If found, do not insert @@ -1243,7 +1247,7 @@ static void QueueReserveMessage(JobControlRecord* jcr) /* * Message unique, so insert it. */ - jcr->reserve_msgs->push(strdup(jcr->errmsg)); + jcr->impl_->reserve_msgs->push(strdup(jcr->errmsg)); bail_out: jcr->unlock(); @@ -1258,7 +1262,7 @@ static void PopReserveMessages(JobControlRecord* jcr) char* msg; jcr->lock(); - msgs = jcr->reserve_msgs; + msgs = jcr->impl_->reserve_msgs; if (!msgs) { goto bail_out; } while ((msg = (char*)msgs->pop())) { free(msg); } bail_out: @@ -1272,9 +1276,9 @@ void ReleaseReserveMessages(JobControlRecord* jcr) { PopReserveMessages(jcr); jcr->lock(); - if (!jcr->reserve_msgs) { goto bail_out; } - delete jcr->reserve_msgs; - jcr->reserve_msgs = NULL; + if (!jcr->impl_->reserve_msgs) { goto bail_out; } + delete jcr->impl_->reserve_msgs; + jcr->impl_->reserve_msgs = NULL; bail_out: jcr->unlock(); diff --git a/core/src/stored/sd_cmds.cc b/core/src/stored/sd_cmds.cc index 92decc445da..15c9e97be65 100644 --- a/core/src/stored/sd_cmds.cc +++ b/core/src/stored/sd_cmds.cc @@ -38,6 +38,7 @@ #include "stored/stored_globals.h" #include "stored/append.h" #include "stored/authenticate.h" +#include "stored/jcr_private.h" #include "stored/sd_stats.h" #include "stored/sd_stats.h" #include "lib/bnet.h" @@ -145,7 +146,7 @@ void* handle_stored_connection(BareosSocket* sd, char* job_name) if (!jcr->authenticated) { jcr->setJobStatus(JS_ErrorTerminated); } - pthread_cond_signal(&jcr->job_start_wait); /* wake waiting job */ + pthread_cond_signal(&jcr->impl_->job_start_wait); /* wake waiting job */ FreeJcr(jcr); return NULL; @@ -238,7 +239,7 @@ bool DoListenRun(JobControlRecord* jcr) */ P(mutex); while (!jcr->authenticated && !JobCanceled(jcr)) { - errstat = pthread_cond_wait(&jcr->job_start_wait, &mutex); + errstat = pthread_cond_wait(&jcr->impl_->job_start_wait, &mutex); if (errstat == EINVAL || errstat == EPERM) { break; } Dmsg1(800, "=== Auth cond errstat=%d\n", errstat); } @@ -299,13 +300,13 @@ static bool StartReplicationSession(JobControlRecord* jcr) BareosSocket* sd = jcr->store_bsock; Dmsg1(120, "Start replication session: %s", sd->msg); - if (jcr->session_opened) { + if (jcr->impl_->session_opened) { PmStrcpy(jcr->errmsg, _("Attempt to open already open session.\n")); sd->fsend(NO_open); return false; } - jcr->session_opened = true; + jcr->impl_->session_opened = true; /* * Send "Ticket" to Storage Daemon @@ -326,7 +327,7 @@ static bool ReplicateData(JobControlRecord* jcr) BareosSocket* sd = jcr->store_bsock; Dmsg1(120, "Replicate data: %s", sd->msg); - if (jcr->session_opened) { + if (jcr->impl_->session_opened) { utime_t now; /* @@ -359,7 +360,7 @@ static bool EndReplicationSession(JobControlRecord* jcr) BareosSocket* sd = jcr->store_bsock; Dmsg1(120, "storedmsg); - if (!jcr->session_opened) { + if (!jcr->impl_->session_opened) { PmStrcpy(jcr->errmsg, _("Attempt to close non-open session.\n")); sd->fsend(NOT_opened); return false; diff --git a/core/src/stored/sd_plugins.cc b/core/src/stored/sd_plugins.cc index 89db607bce3..d346cbe45a9 100644 --- a/core/src/stored/sd_plugins.cc +++ b/core/src/stored/sd_plugins.cc @@ -31,6 +31,7 @@ #include "include/bareos.h" #include "stored/stored.h" #include "stored/stored_globals.h" +#include "stored/jcr_private.h" #include "sd_plugins.h" #include "lib/crypto_cache.h" #include "stored/sd_stats.h" @@ -516,7 +517,7 @@ static inline bpContext* instantiate_plugin(JobControlRecord* jcr, /** * Send a bsdEventNewPluginOptions event to all plugins configured in - * jcr->plugin_options. + * jcr->impl_->plugin_options. */ void DispatchNewPluginOptions(JobControlRecord* jcr) { @@ -532,11 +533,11 @@ void DispatchNewPluginOptions(JobControlRecord* jcr) if (!sd_plugin_list || sd_plugin_list->empty()) { return; } - if (jcr->plugin_options && jcr->plugin_options->size()) { + if (jcr->impl_->plugin_options && jcr->impl_->plugin_options->size()) { eventType = bsdEventNewPluginOptions; event.eventType = eventType; - foreach_alist_index (i, plugin_options, jcr->plugin_options) { + foreach_alist_index (i, plugin_options, jcr->impl_->plugin_options) { /* * Make a private copy of plugin options. */ @@ -703,7 +704,7 @@ static bRC bareosGetValue(bpContext* ctx, bsdrVariable var, void* value) if (jcr) { switch (var) { case bsdVarJob: - *((char**)value) = jcr->job_name; + *((char**)value) = jcr->impl_->job_name; Dmsg1(debuglevel, "sd-plugin: return bsdVarJobName=%s\n", NPRT(*((char**)value))); break; @@ -727,8 +728,8 @@ static bRC bareosGetValue(bpContext* ctx, bsdrVariable var, void* value) NPRT(*((char**)value))); break; case bsdVarPool: - if (jcr->dcr) { - *((char**)value) = jcr->dcr->pool_name; + if (jcr->impl_->dcr) { + *((char**)value) = jcr->impl_->dcr->pool_name; Dmsg1(debuglevel, "sd-plugin: return bsdVarPool=%s\n", NPRT(*((char**)value))); } else { @@ -736,8 +737,8 @@ static bRC bareosGetValue(bpContext* ctx, bsdrVariable var, void* value) } break; case bsdVarPoolType: - if (jcr->dcr) { - *((char**)value) = jcr->dcr->pool_type; + if (jcr->impl_->dcr) { + *((char**)value) = jcr->impl_->dcr->pool_type; Dmsg1(debuglevel, "sd-plugin: return bsdVarPoolType=%s\n", NPRT(*((char**)value))); } else { @@ -745,8 +746,8 @@ static bRC bareosGetValue(bpContext* ctx, bsdrVariable var, void* value) } break; case bsdVarStorage: - if (jcr->dcr && jcr->dcr->device) { - *((char**)value) = jcr->dcr->device->resource_name_; + if (jcr->impl_->dcr && jcr->impl_->dcr->device) { + *((char**)value) = jcr->impl_->dcr->device->resource_name_; Dmsg1(debuglevel, "sd-plugin: return bsdVarStorage=%s\n", NPRT(*((char**)value))); } else { @@ -754,8 +755,8 @@ static bRC bareosGetValue(bpContext* ctx, bsdrVariable var, void* value) } break; case bsdVarMediaType: - if (jcr->dcr) { - *((char**)value) = jcr->dcr->media_type; + if (jcr->impl_->dcr) { + *((char**)value) = jcr->impl_->dcr->media_type; Dmsg1(debuglevel, "sd-plugin: return bsdVarMediaType=%s\n", NPRT(*((char**)value))); } else { @@ -773,8 +774,8 @@ static bRC bareosGetValue(bpContext* ctx, bsdrVariable var, void* value) jcr->JobStatus); break; case bsdVarVolumeName: - if (jcr->dcr) { - *((char**)value) = jcr->dcr->VolumeName; + if (jcr->impl_->dcr) { + *((char**)value) = jcr->impl_->dcr->VolumeName; Dmsg1(debuglevel, "sd-plugin: return bsdVarVolumeName=%s\n", NPRT(*((char**)value))); } else { diff --git a/core/src/stored/sd_stats.cc b/core/src/stored/sd_stats.cc index c0320884dff..dc48c788300 100644 --- a/core/src/stored/sd_stats.cc +++ b/core/src/stored/sd_stats.cc @@ -28,6 +28,7 @@ #include "include/bareos.h" #include "stored/stored.h" #include "stored/stored_globals.h" +#include "stored/jcr_private.h" #include "lib/util.h" #include "include/jcr.h" #include "lib/parse_conf.h" @@ -305,8 +306,8 @@ void UpdateJobStatistics(JobControlRecord* jcr, utime_t now) job_stat->timestamp = now; job_stat->JobFiles = jcr->JobFiles; job_stat->JobBytes = jcr->JobBytes; - if (jcr->dcr && jcr->dcr->device) { - job_stat->DevName = strdup(jcr->dcr->device->resource_name_); + if (jcr->impl_->dcr && jcr->impl_->dcr->device) { + job_stat->DevName = strdup(jcr->impl_->dcr->device->resource_name_); } else { job_stat->DevName = strdup("unknown"); } diff --git a/core/src/stored/spool.cc b/core/src/stored/spool.cc index bde81a61276..a5c8624913d 100644 --- a/core/src/stored/spool.cc +++ b/core/src/stored/spool.cc @@ -32,6 +32,7 @@ #include "stored/stored_globals.h" #include "stored/acquire.h" #include "stored/device.h" +#include "stored/jcr_private.h" #include "lib/berrno.h" #include "lib/bsock.h" #include "lib/edit.h" @@ -118,7 +119,7 @@ bool BeginDataSpool(DeviceControlRecord* dcr) { bool status = true; - if (dcr->jcr->spool_data) { + if (dcr->jcr->impl_->spool_data) { Dmsg0(100, "Turning on data spooling\n"); dcr->spool_data = true; status = OpenDataSpoolFile(dcr); @@ -186,7 +187,7 @@ static bool OpenDataSpoolFile(DeviceControlRecord* dcr) if ((spool_fd = open(name, O_CREAT | O_TRUNC | O_RDWR | O_BINARY, 0640)) >= 0) { dcr->spool_fd = spool_fd; - dcr->jcr->spool_attributes = true; + dcr->jcr->impl_->spool_attributes = true; } else { BErrNo be; @@ -250,7 +251,7 @@ static bool DespoolData(DeviceControlRecord* dcr, bool commit) BareosSocket* dir = jcr->dir_bsock; Dmsg0(100, "Despooling data\n"); - if (jcr->dcr->job_spool_size == 0) { + if (jcr->impl_->dcr->job_spool_size == 0) { Jmsg(jcr, M_WARNING, 0, _("Despooling zero bytes. Your disk is probably FULL!\n")); } @@ -264,13 +265,13 @@ static bool DespoolData(DeviceControlRecord* dcr, bool commit) Jmsg(jcr, M_INFO, 0, _("Committing spooled data to Volume \"%s\". Despooling %s bytes " "...\n"), - jcr->dcr->VolumeName, - edit_uint64_with_commas(jcr->dcr->job_spool_size, ec1)); + jcr->impl_->dcr->VolumeName, + edit_uint64_with_commas(jcr->impl_->dcr->job_spool_size, ec1)); jcr->setJobStatus(JS_DataCommitting); } else { Jmsg(jcr, M_INFO, 0, _("Writing spooled data to Volume. Despooling %s bytes ...\n"), - edit_uint64_with_commas(jcr->dcr->job_spool_size, ec1)); + edit_uint64_with_commas(jcr->impl_->dcr->job_spool_size, ec1)); jcr->setJobStatus(JS_DataDespooling); } jcr->sendJobStatus(JS_DataDespooling); @@ -369,12 +370,13 @@ static bool DespoolData(DeviceControlRecord* dcr, bool commit) if (despool_elapsed <= 0) { despool_elapsed = 1; } - Jmsg( - jcr, M_INFO, 0, - _("Despooling elapsed time = %02d:%02d:%02d, Transfer rate = %s " - "Bytes/second\n"), - despool_elapsed / 3600, despool_elapsed % 3600 / 60, despool_elapsed % 60, - edit_uint64_with_suffix(jcr->dcr->job_spool_size / despool_elapsed, ec1)); + Jmsg(jcr, M_INFO, 0, + _("Despooling elapsed time = %02d:%02d:%02d, Transfer rate = %s " + "Bytes/second\n"), + despool_elapsed / 3600, despool_elapsed % 3600 / 60, + despool_elapsed % 60, + edit_uint64_with_suffix( + jcr->impl_->dcr->job_spool_size / despool_elapsed, ec1)); dcr->block = block; /* reset block */ @@ -685,7 +687,7 @@ static bool WriteSpoolData(DeviceControlRecord* dcr) bool AreAttributesSpooled(JobControlRecord* jcr) { - return jcr->spool_attributes && jcr->dir_bsock->spool_fd_ != -1; + return jcr->impl_->spool_attributes && jcr->dir_bsock->spool_fd_ != -1; } /** @@ -697,7 +699,7 @@ bool AreAttributesSpooled(JobControlRecord* jcr) */ bool BeginAttributeSpool(JobControlRecord* jcr) { - if (!jcr->no_attributes && jcr->spool_attributes) { + if (!jcr->impl_->no_attributes && jcr->impl_->spool_attributes) { return OpenAttrSpoolFile(jcr, jcr->dir_bsock); } return true; diff --git a/core/src/stored/status.cc b/core/src/stored/status.cc index 4ea380911da..0cf35d31c9f 100644 --- a/core/src/stored/status.cc +++ b/core/src/stored/status.cc @@ -31,6 +31,7 @@ #include "include/bareos.h" #include "stored/stored.h" #include "stored/stored_globals.h" +#include "stored/jcr_private.h" #include "lib/status.h" #include "stored/spool.h" #include "lib/edit.h" @@ -687,8 +688,8 @@ static void ListRunningJobs(StatusPacket* sp) job_type_to_str(jcr->getJobType()), jcr->Job); sendit(msg, len, sp); } - dcr = jcr->dcr; - rdcr = jcr->read_dcr; + dcr = jcr->impl_->dcr; + rdcr = jcr->impl_->read_dcr; if ((dcr && dcr->device) || (rdcr && rdcr->device)) { bstrncpy(JobName, jcr->Job, sizeof(JobName)); /* There are three periods after the Job name */ @@ -776,7 +777,7 @@ static inline void SendDriveReserveMessages(JobControlRecord* jcr, char* msg; jcr->lock(); - msgs = jcr->reserve_msgs; + msgs = jcr->impl_->reserve_msgs; if (!msgs || msgs->size() == 0) { goto bail_out; } for (i = msgs->size() - 1; i >= 0; i--) { msg = (char*)msgs->get(i); @@ -804,7 +805,7 @@ static void ListJobsWaitingOnReservation(StatusPacket* sp) } foreach_jcr (jcr) { - if (!jcr->reserve_msgs) { continue; } + if (!jcr->impl_->reserve_msgs) { continue; } SendDriveReserveMessages(jcr, sp); } endeach_jcr(jcr); diff --git a/core/src/stored/stored.cc b/core/src/stored/stored.cc index b446d70088f..c312c946593 100644 --- a/core/src/stored/stored.cc +++ b/core/src/stored/stored.cc @@ -40,6 +40,7 @@ #include "stored/autochanger.h" #include "stored/bsr.h" #include "stored/device.h" +#include "stored/jcr_private.h" #include "stored/job.h" #include "stored/label.h" #include "stored/ndmp_tape.h" @@ -533,14 +534,14 @@ extern "C" void* device_initialization(void* arg) LockRes(my_config); pthread_detach(pthread_self()); - jcr = new_jcr(sizeof(JobControlRecord), StoredFreeJcr); + jcr = NewStoredJcr(); NewPlugins(jcr); /* instantiate plugins */ jcr->setJobType(JT_SYSTEM); /* * Initialize job start condition variable */ - errstat = pthread_cond_init(&jcr->job_start_wait, NULL); + errstat = pthread_cond_init(&jcr->impl_->job_start_wait, NULL); if (errstat != 0) { BErrNo be; Jmsg1(jcr, M_ABORT, 0, @@ -551,7 +552,7 @@ extern "C" void* device_initialization(void* arg) /* * Initialize job end condition variable */ - errstat = pthread_cond_init(&jcr->job_end_wait, NULL); + errstat = pthread_cond_init(&jcr->impl_->job_end_wait, NULL); if (errstat != 0) { BErrNo be; Jmsg1(jcr, M_ABORT, 0, @@ -570,9 +571,9 @@ extern "C" void* device_initialization(void* arg) } dcr = new StorageDaemonDeviceControlRecord; - jcr->dcr = dcr; + jcr->impl_->dcr = dcr; SetupNewDcrDevice(jcr, dcr, dev, NULL); - jcr->dcr->SetWillWrite(); + jcr->impl_->dcr->SetWillWrite(); GeneratePluginEvent(jcr, bsdEventDeviceInit, dcr); if (dev->IsAutochanger()) { /* @@ -588,7 +589,7 @@ extern "C" void* device_initialization(void* arg) dev->print_name()); Dmsg1(20, "Could not open device %s\n", dev->print_name()); FreeDeviceControlRecord(dcr); - jcr->dcr = NULL; + jcr->impl_->dcr = NULL; continue; } } @@ -606,7 +607,7 @@ extern "C" void* device_initialization(void* arg) } } FreeDeviceControlRecord(dcr); - jcr->dcr = NULL; + jcr->impl_->dcr = NULL; } FreeJcr(jcr); init_done = true; @@ -660,15 +661,16 @@ static jcr->MyThreadSendSignal(TIMEOUT_SIGNAL); Dmsg1(100, "term_stored killing JobId=%d\n", jcr->JobId); /* ***FIXME*** wiffle through all dcrs */ - if (jcr->dcr && jcr->dcr->dev && jcr->dcr->dev->blocked()) { - pthread_cond_broadcast(&jcr->dcr->dev->wait_next_vol); + if (jcr->impl_->dcr && jcr->impl_->dcr->dev && + jcr->impl_->dcr->dev->blocked()) { + pthread_cond_broadcast(&jcr->impl_->dcr->dev->wait_next_vol); Dmsg1(100, "JobId=%u broadcast wait_device_release\n", (uint32_t)jcr->JobId); ReleaseDeviceCond(); } - if (jcr->read_dcr && jcr->read_dcr->dev && - jcr->read_dcr->dev->blocked()) { - pthread_cond_broadcast(&jcr->read_dcr->dev->wait_next_vol); + if (jcr->impl_->read_dcr && jcr->impl_->read_dcr->dev && + jcr->impl_->read_dcr->dev->blocked()) { + pthread_cond_broadcast(&jcr->impl_->read_dcr->dev->wait_next_vol); Dmsg1(100, "JobId=%u broadcast wait_device_release\n", (uint32_t)jcr->JobId); ReleaseDeviceCond(); diff --git a/core/src/tests/sd_reservation.cc b/core/src/tests/sd_reservation.cc index 5c93fbee991..4cccc8a33d9 100644 --- a/core/src/tests/sd_reservation.cc +++ b/core/src/tests/sd_reservation.cc @@ -31,6 +31,7 @@ #include "lib/crypto_cache.h" #include "lib/edit.h" #include "lib/parse_conf.h" +#include "stored/jcr_private.h" #include "stored/job.h" #include "stored/sd_plugins.h" #include "stored/sd_stats.h" @@ -113,7 +114,7 @@ struct TestJob { TestJob() = delete; TestJob(uint32_t jobid) { - jcr = new_jcr(sizeof(JobControlRecord), storagedaemon::StoredFreeJcr); + jcr = NewStoredJcr(); jcr->JobId = jobid; jcr->sd_auth_key = strdup("no key set"); } @@ -137,7 +138,7 @@ void WaitThenUnreserve(std::unique_ptr&); void WaitThenUnreserve(std::unique_ptr& job) { std::this_thread::sleep_for(std::chrono::milliseconds(10)); - job->jcr->dcr->UnreserveDevice(); + job->jcr->impl_->dcr->UnreserveDevice(); ReleaseDeviceCond(); } From fbc128b2d04cf905f72bee24087568930505e873 Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Tue, 5 Nov 2019 17:50:37 +0100 Subject: [PATCH 04/23] jcr: delete copy/move constructor and assignment operator --- core/src/include/jcr.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/src/include/jcr.h b/core/src/include/jcr.h index 1299fe1a754..83ddfe3fae7 100644 --- a/core/src/include/jcr.h +++ b/core/src/include/jcr.h @@ -236,6 +236,10 @@ class JobControlRecord { public: JobControlRecord(); ~JobControlRecord(); + JobControlRecord(const JobControlRecord &other) = delete; + JobControlRecord(const JobControlRecord &&other) = delete; + JobControlRecord& operator=(const JobControlRecord& other) = delete; + JobControlRecord& operator=(const JobControlRecord&& other) = delete; void lock() { P(mutex); } void unlock() { V(mutex); } From 2de06498311daa8878f95a3a82f1a0e1f9bd7717 Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Wed, 6 Nov 2019 09:58:05 +0100 Subject: [PATCH 05/23] jcr: cleanup forward declarations --- core/src/filed/jcr_private.h | 4 ++++ core/src/findlib/match.h | 2 ++ core/src/include/jcr.h | 21 +++------------------ core/src/stored/jcr_private.h | 3 +++ 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/core/src/filed/jcr_private.h b/core/src/filed/jcr_private.h index 4469c35e30a..30fe47dbe37 100644 --- a/core/src/filed/jcr_private.h +++ b/core/src/filed/jcr_private.h @@ -29,6 +29,10 @@ struct acl_data_t; struct xattr_data_t; +namespace filedaemon { +class BareosAccurateFilelist; +} + /* clang-format off */ struct CryptoContext { bool pki_sign = false; /**< Enable PKI Signatures? */ diff --git a/core/src/findlib/match.h b/core/src/findlib/match.h index b5a406aa0ec..d519942e137 100644 --- a/core/src/findlib/match.h +++ b/core/src/findlib/match.h @@ -21,6 +21,8 @@ #ifndef BAREOS_FINDLIB_MATCH_H_ #define BAREOS_FINDLIB_MATCH_H_ +struct FindFilesPacket; + void InitIncludeExcludeFiles(FindFilesPacket* ff); void TermIncludeExcludeFiles(FindFilesPacket* ff); void AddFnameToIncludeList(FindFilesPacket* ff, diff --git a/core/src/include/jcr.h b/core/src/include/jcr.h index 83ddfe3fae7..e3a30eb4d31 100644 --- a/core/src/include/jcr.h +++ b/core/src/include/jcr.h @@ -48,11 +48,6 @@ typedef struct s_tree_root TREE_ROOT; class dlist; -namespace filedaemon { -class BareosAccurateFilelist; -struct save_pkt; -} // namespace filedaemon - /** * Backup/Verify level code. These are stored in the DB */ @@ -179,19 +174,12 @@ enum #define endeach_jcr(jcr) JcrWalkEnd(jcr) -#define SD_APPEND 1 -#define SD_READ 0 - -/** - * Forward referenced structures - */ class JobControlRecord; class BareosSocket; class BareosDb; class htable; struct AttributesDbRecord; -struct FindFilesPacket; struct bpContext; #ifdef HAVE_WIN32 struct CopyThreadContext; @@ -232,7 +220,7 @@ class JobControlRecord { int32_t JobType_ = 0; /**< Backup, restore, verify ... */ int32_t JobLevel_ = 0; /**< Job level */ int32_t Protocol_ = 0; /**< Backup Protocol */ - bool my_thread_killable = false; /**< Can we kill the thread? */ + bool my_thread_killable = false; public: JobControlRecord(); ~JobControlRecord(); @@ -291,11 +279,8 @@ class JobControlRecord { void SetKillable(bool killable); /**< in lib/jcr.c */ bool IsKillable() const { return my_thread_killable; } - /* - * Global part of JobControlRecord common to all daemons - */ - dlink link; /**< JobControlRecord chain link */ - pthread_t my_thread_id = 0; /**< Id of thread controlling jcr */ + dlink link; /**< JobControlRecord chain link */ + pthread_t my_thread_id = 0; /**< Id of thread controlling jcr */ BareosSocket* dir_bsock = nullptr; /**< Director bsock or NULL if we are him */ BareosSocket* store_bsock = nullptr; /**< Storage connection socket */ BareosSocket* file_bsock; /**< File daemon connection socket */ diff --git a/core/src/stored/jcr_private.h b/core/src/stored/jcr_private.h index 147e51a7225..6b8c74bd53f 100644 --- a/core/src/stored/jcr_private.h +++ b/core/src/stored/jcr_private.h @@ -26,6 +26,9 @@ #include "stored/read_ctx.h" +#define SD_APPEND 1 +#define SD_READ 0 + namespace storagedaemon { struct VolumeList; class DeviceControlRecord; From f62b3bec1bb8c063644ba597b8981eafcda86df4 Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Wed, 6 Nov 2019 10:04:56 +0100 Subject: [PATCH 06/23] jcr: remove the size argument and memset from new_jcr --- core/src/dird/job.cc | 2 +- core/src/filed/dir_cmd.cc | 2 +- core/src/include/jcr.h | 2 +- core/src/lib/jcr.cc | 7 +++---- core/src/stored/bscan.cc | 2 +- core/src/stored/butil.cc | 2 +- core/src/stored/job.cc | 2 +- core/src/tools/btestls.cc | 2 +- 8 files changed, 10 insertions(+), 11 deletions(-) diff --git a/core/src/dird/job.cc b/core/src/dird/job.cc index 5274bdf472e..7ecc410e6bf 100644 --- a/core/src/dird/job.cc +++ b/core/src/dird/job.cc @@ -1695,7 +1695,7 @@ void GetJobStorage(UnifiedStorageResource* store, JobControlRecord* NewDirectorJcr() { - JobControlRecord* jcr = new_jcr(sizeof(JobControlRecord), DirdFreeJcr); + JobControlRecord* jcr = new_jcr(DirdFreeJcr); jcr->impl_ = new JobControlRecordPrivate; return jcr; } diff --git a/core/src/filed/dir_cmd.cc b/core/src/filed/dir_cmd.cc index b86ae1b27a7..35c1baa5ced 100644 --- a/core/src/filed/dir_cmd.cc +++ b/core/src/filed/dir_cmd.cc @@ -412,7 +412,7 @@ static inline bool AreMaxConcurrentJobsExceeded() static JobControlRecord* NewFiledJcr() { - JobControlRecord* jcr = new_jcr(sizeof(JobControlRecord), FiledFreeJcr); + JobControlRecord* jcr = new_jcr(FiledFreeJcr); jcr->impl_ = new JobControlRecordPrivate; return jcr; } diff --git a/core/src/include/jcr.h b/core/src/include/jcr.h index e3a30eb4d31..c58f6d974d4 100644 --- a/core/src/include/jcr.h +++ b/core/src/include/jcr.h @@ -377,7 +377,7 @@ class JobControlRecord { */ extern int GetNextJobidFromList(char** p, uint32_t* JobId); extern bool InitJcrSubsystem(int timeout); -extern JobControlRecord* new_jcr(int size, JCR_free_HANDLER* daemon_free_jcr); +extern JobControlRecord* new_jcr(JCR_free_HANDLER* daemon_free_jcr); extern JobControlRecord* get_jcr_by_id(uint32_t JobId); extern JobControlRecord* get_jcr_by_session(uint32_t SessionId, uint32_t SessionTime); diff --git a/core/src/lib/jcr.cc b/core/src/lib/jcr.cc index 0aca24255f4..e70e8970f9d 100644 --- a/core/src/lib/jcr.cc +++ b/core/src/lib/jcr.cc @@ -224,13 +224,12 @@ JobControlRecord::JobControlRecord() SetTimeoutHandler(); } -JobControlRecord* new_jcr(int size, JCR_free_HANDLER* daemon_free_jcr) +JobControlRecord* new_jcr(JCR_free_HANDLER* daemon_free_jcr) { Dmsg0(debuglevel, "Enter new_jcr\n"); - JobControlRecord* jcr; - jcr = (JobControlRecord*)malloc(size); - memset(jcr, 0, size); + JobControlRecord* jcr = + static_cast(malloc(sizeof(JobControlRecord))); jcr = new (jcr) JobControlRecord(); jcr->daemon_free_jcr = daemon_free_jcr; diff --git a/core/src/stored/bscan.cc b/core/src/stored/bscan.cc index 9960955ad50..42c117bab87 100644 --- a/core/src/stored/bscan.cc +++ b/core/src/stored/bscan.cc @@ -1549,7 +1549,7 @@ static JobControlRecord* create_jcr(JobDbRecord* jr, * Transfer as much as possible to the Job JobControlRecord. Most important is * the JobId and the ClientId. */ - jobjcr = new_jcr(sizeof(JobControlRecord), BscanFreeJcr); + jobjcr = new_jcr(BscanFreeJcr); jobjcr->impl_ = new JobControlRecordPrivate; jobjcr->setJobType(jr->JobType); jobjcr->setJobLevel(jr->JobLevel); diff --git a/core/src/stored/butil.cc b/core/src/stored/butil.cc index 955b41a75ef..48aa4568890 100644 --- a/core/src/stored/butil.cc +++ b/core/src/stored/butil.cc @@ -68,7 +68,7 @@ JobControlRecord* SetupJcr(const char* name, const char* VolumeName, bool readonly) { - JobControlRecord* jcr = new_jcr(sizeof(JobControlRecord), MyFreeJcr); + JobControlRecord* jcr = new_jcr(MyFreeJcr); jcr->impl_ = new JobControlRecordPrivate; jcr->impl_->bsr = bsr; diff --git a/core/src/stored/job.cc b/core/src/stored/job.cc index b156fd877a4..2112d5ca1b0 100644 --- a/core/src/stored/job.cc +++ b/core/src/stored/job.cc @@ -517,7 +517,7 @@ void StoredFreeJcr(JobControlRecord* jcr) JobControlRecord* NewStoredJcr() { - JobControlRecord* jcr = new_jcr(sizeof(JobControlRecord), StoredFreeJcr); + JobControlRecord* jcr = new_jcr(StoredFreeJcr); jcr->impl_ = new JobControlRecordPrivate; return jcr; } diff --git a/core/src/tools/btestls.cc b/core/src/tools/btestls.cc index 6e6259ba8f6..28eccab08c2 100644 --- a/core/src/tools/btestls.cc +++ b/core/src/tools/btestls.cc @@ -133,7 +133,7 @@ int main(int argc, char* const* argv) argc -= optind; argv += optind; - jcr = new_jcr(sizeof(JobControlRecord), NULL); + jcr = new_jcr(nullptr); ff = init_find_files(); if (argc == 0 && !inc) { From 8a88cd5043230c7e8b23ef17ccf03135f9ec3d42 Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Wed, 6 Nov 2019 10:30:44 +0100 Subject: [PATCH 07/23] jcr: refactore initializers --- core/src/include/jcr.h | 185 ++++++++++++++++++++--------------------- 1 file changed, 92 insertions(+), 93 deletions(-) diff --git a/core/src/include/jcr.h b/core/src/include/jcr.h index c58f6d974d4..67d177e7c07 100644 --- a/core/src/include/jcr.h +++ b/core/src/include/jcr.h @@ -191,8 +191,8 @@ struct JobControlRecordPrivate; struct CompressionContext { POOLMEM* deflate_buffer{nullptr}; /**< Buffer used for deflation (compression) */ POOLMEM* inflate_buffer{nullptr}; /**< Buffer used for inflation (decompression) */ - uint32_t deflate_buffer_size{0}; /**< Length of deflation buffer */ - uint32_t inflate_buffer_size{0}; /**< Length of inflation buffer */ + uint32_t deflate_buffer_size{}; /**< Length of deflation buffer */ + uint32_t inflate_buffer_size{}; /**< Length of inflation buffer */ struct { #ifdef HAVE_LIBZ void* pZLIB{nullptr}; /**< ZLIB compression session data */ @@ -207,7 +207,7 @@ struct CompressionContext { struct job_callback_item { void (*JobEndCb)(JobControlRecord* jcr, void*); - void* ctx = nullptr; + void* ctx{}; }; typedef void(JCR_free_HANDLER)(JobControlRecord* jcr); @@ -216,11 +216,11 @@ typedef void(JCR_free_HANDLER)(JobControlRecord* jcr); class JobControlRecord { private: pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; /**< Jcr mutex */ - volatile int32_t _use_count = 0; /**< Use count */ - int32_t JobType_ = 0; /**< Backup, restore, verify ... */ - int32_t JobLevel_ = 0; /**< Job level */ - int32_t Protocol_ = 0; /**< Backup Protocol */ - bool my_thread_killable = false; + volatile int32_t _use_count{}; /**< Use count */ + int32_t JobType_{}; /**< Backup, restore, verify ... */ + int32_t JobLevel_{}; /**< Job level */ + int32_t Protocol_{}; /**< Backup Protocol */ + bool my_thread_killable{}; public: JobControlRecord(); ~JobControlRecord(); @@ -280,95 +280,94 @@ class JobControlRecord { bool IsKillable() const { return my_thread_killable; } dlink link; /**< JobControlRecord chain link */ - pthread_t my_thread_id = 0; /**< Id of thread controlling jcr */ - BareosSocket* dir_bsock = nullptr; /**< Director bsock or NULL if we are him */ - BareosSocket* store_bsock = nullptr; /**< Storage connection socket */ - BareosSocket* file_bsock; /**< File daemon connection socket */ - JCR_free_HANDLER* daemon_free_jcr = nullptr; /**< Local free routine */ - dlist* msg_queue = nullptr; /**< Queued messages */ + pthread_t my_thread_id{}; /**< Id of thread controlling jcr */ + BareosSocket* dir_bsock{}; /**< Director bsock or NULL if we are him */ + BareosSocket* store_bsock{}; /**< Storage connection socket */ + BareosSocket* file_bsock{}; /**< File daemon connection socket */ + JCR_free_HANDLER* daemon_free_jcr{}; /**< Local free routine */ + dlist* msg_queue{}; /**< Queued messages */ pthread_mutex_t msg_queue_mutex = PTHREAD_MUTEX_INITIALIZER; /**< message queue mutex */ - bool dequeuing_msgs = false; /**< Set when dequeuing messages */ - alist job_end_callbacks; /**< callbacks called at Job end */ - POOLMEM* VolumeName = nullptr; /**< Volume name desired -- pool_memory */ - POOLMEM* errmsg = nullptr; /**< Edited error message */ - char Job[MAX_NAME_LENGTH]{0}; /**< Unique name of this Job */ - - uint32_t JobId = 0; /**< Director's JobId */ - uint32_t VolSessionId = 0; - uint32_t VolSessionTime = 0; - uint32_t JobFiles = 0; /**< Number of files written, this job */ - uint32_t JobErrors = 0; /**< Number of non-fatal errors this job */ - uint32_t JobWarnings = 0; /**< Number of warning messages */ - uint32_t LastRate = 0; /**< Last sample bytes/sec */ - uint64_t JobBytes = 0; /**< Number of bytes processed this job */ - uint64_t LastJobBytes = 0; /**< Last sample number bytes */ - uint64_t ReadBytes = 0; /**< Bytes read -- before compression */ - FileId_t FileId = 0; /**< Last FileId used */ - volatile int32_t JobStatus = 0; /**< ready, running, blocked, terminated */ - int32_t JobPriority = 0; /**< Job priority */ - time_t sched_time = 0; /**< Job schedule time, i.e. when it should start */ - time_t initial_sched_time = 0; /**< Original sched time before any reschedules are done */ - time_t start_time = 0; /**< When job actually started */ - time_t run_time = 0; /**< Used for computing speed */ - time_t last_time = 0; /**< Last sample time */ - time_t end_time = 0; /**< Job end time */ - time_t wait_time_sum = 0; /**< Cumulative wait time since job start */ - time_t wait_time = 0; /**< Timestamp when job have started to wait */ - time_t job_started_time = 0; /**< Time when the MaxRunTime start to count */ - POOLMEM* client_name = nullptr; /**< Client name */ - POOLMEM* JobIds = nullptr; /**< User entered string of JobIds */ - POOLMEM* RestoreBootstrap = nullptr; /**< Bootstrap file to restore */ - POOLMEM* stime = nullptr; /**< start time for incremental/differential */ - char* sd_auth_key = nullptr; /**< SD auth key */ - TlsPolicy sd_tls_policy; /**< SD Tls Policy */ - MessagesResource* jcr_msgs = nullptr; /**< Copy of message resource -- actually used */ - uint32_t ClientId = 0; /**< Client associated with Job */ - char* where = nullptr; /**< Prefix to restore files to */ - char* RegexWhere = nullptr; /**< File relocation in restore */ - alist* where_bregexp = nullptr; /**< BareosRegex alist for path manipulation */ - int32_t cached_pnl = 0; /**< Cached path length */ - POOLMEM* cached_path = nullptr; /**< Cached path */ - bool passive_client = false; /**< Client is a passive client e.g. doesn't initiate any network connection */ - bool prefix_links = false; /**< Prefix links with Where path */ - bool gui = false; /**< Set if gui using console */ - bool authenticated = false; /**< Set when client authenticated */ - bool cached_attribute = false; /**< Set if attribute is cached */ - bool batch_started = false; /**< Set if batch mode started */ - bool cmd_plugin = false; /**< Set when processing a command Plugin = */ - bool opt_plugin = false; /**< Set when processing an option Plugin = */ - bool keep_path_list = false; /**< Keep newly created path in a hash */ - bool accurate = false; /**< True if job is accurate */ - bool HasBase = false; /**< True if job use base jobs */ - bool rerunning = false; /**< Rerunning an incomplete job */ - bool job_started = false; /**< Set when the job is actually started */ - bool suppress_output = false; /**< Set if this JobControlRecord should not output any Jmsgs */ - JobControlRecord* cjcr = nullptr; /**< Controlling JobControlRecord when this - * is a slave JobControlRecord being - * controlled by another JobControlRecord - * used for sending normal and fatal errors. - */ - int32_t buf_size = 0; /**< Length of buffer */ + bool dequeuing_msgs{}; /**< Set when dequeuing messages */ + alist job_end_callbacks; /**< callbacks called at Job end */ + POOLMEM* VolumeName{}; /**< Volume name desired -- pool_memory */ + POOLMEM* errmsg{}; /**< Edited error message */ + char Job[MAX_NAME_LENGTH]{}; /**< Unique name of this Job */ + + uint32_t JobId{}; /**< Director's JobId */ + uint32_t VolSessionId{}; + uint32_t VolSessionTime{}; + uint32_t JobFiles{}; /**< Number of files written, this job */ + uint32_t JobErrors{}; /**< Number of non-fatal errors this job */ + uint32_t JobWarnings{}; /**< Number of warning messages */ + uint32_t LastRate{}; /**< Last sample bytes/sec */ + uint64_t JobBytes{}; /**< Number of bytes processed this job */ + uint64_t LastJobBytes{}; /**< Last sample number bytes */ + uint64_t ReadBytes{}; /**< Bytes read -- before compression */ + FileId_t FileId{}; /**< Last FileId used */ + volatile int32_t JobStatus{}; /**< ready, running, blocked, terminated */ + int32_t JobPriority{}; /**< Job priority */ + time_t sched_time{}; /**< Job schedule time, i.e. when it should start */ + time_t initial_sched_time{}; /**< Original sched time before any reschedules are done */ + time_t start_time{}; /**< When job actually started */ + time_t run_time{}; /**< Used for computing speed */ + time_t last_time{}; /**< Last sample time */ + time_t end_time{}; /**< Job end time */ + time_t wait_time_sum{}; /**< Cumulative wait time since job start */ + time_t wait_time{}; /**< Timestamp when job have started to wait */ + time_t job_started_time{}; /**< Time when the MaxRunTime start to count */ + POOLMEM* client_name{}; /**< Client name */ + POOLMEM* JobIds{}; /**< User entered string of JobIds */ + POOLMEM* RestoreBootstrap{}; /**< Bootstrap file to restore */ + POOLMEM* stime{}; /**< start time for incremental/differential */ + char* sd_auth_key{}; /**< SD auth key */ + TlsPolicy sd_tls_policy; /**< SD Tls Policy */ + MessagesResource* jcr_msgs{}; /**< Copy of message resource -- actually used */ + uint32_t ClientId{}; /**< Client associated with Job */ + char* where{}; /**< Prefix to restore files to */ + char* RegexWhere{}; /**< File relocation in restore */ + alist* where_bregexp{}; /**< BareosRegex alist for path manipulation */ + int32_t cached_pnl{}; /**< Cached path length */ + POOLMEM* cached_path{}; /**< Cached path */ + bool passive_client{}; /**< Client is a passive client e.g. doesn't initiate any network connection */ + bool prefix_links{}; /**< Prefix links with Where path */ + bool gui{}; /**< Set if gui using console */ + bool authenticated{}; /**< Set when client authenticated */ + bool cached_attribute{}; /**< Set if attribute is cached */ + bool batch_started{}; /**< Set if batch mode started */ + bool cmd_plugin{}; /**< Set when processing a command Plugin = */ + bool opt_plugin{}; /**< Set when processing an option Plugin = */ + bool keep_path_list{}; /**< Keep newly created path in a hash */ + bool accurate{}; /**< True if job is accurate */ + bool HasBase{}; /**< True if job use base jobs */ + bool rerunning{}; /**< Rerunning an incomplete job */ + bool job_started{}; /**< Set when the job is actually started */ + bool suppress_output{}; /**< Set if this JobControlRecord should not output any Jmsgs */ + JobControlRecord* cjcr{}; /**< Controlling JobControlRecord when this + is a slave JobControlRecord being + controlled by another JobControlRecord + used for sending normal and fatal errors. */ + int32_t buf_size{}; /**< Length of buffer */ CompressionContext compress; /**< Compression ctx */ #ifdef HAVE_WIN32 - CopyThreadContext* cp_thread = nullptr; /**< Copy Thread ctx */ + CopyThreadContext* cp_thread{}; /**< Copy Thread ctx */ #endif - POOLMEM* attr = nullptr; /**< Attribute string from SD */ - BareosDb* db = nullptr; /**< database pointer */ - BareosDb* db_batch = nullptr; /**< database pointer for batch and accurate */ - uint64_t nb_base_files = 0; /**< Number of base files */ - uint64_t nb_base_files_used = 0; /**< Number of useful files in base */ - - AttributesDbRecord* ar = nullptr; /**< DB attribute record */ - guid_list* id_list = nullptr; /**< User/group id to name list */ - - alist* plugin_ctx_list = nullptr; /**< List of contexts for plugins */ - bpContext* plugin_ctx = nullptr; /**< Current plugin context */ - POOLMEM* comment = nullptr; /**< Comment for this Job */ - int64_t max_bandwidth = 0; /**< Bandwidth limit for this Job */ - htable* path_list = nullptr; /**< Directory list (used by findlib) */ - bool is_passive_client_connection_probing = false; /**< Set if director probes a passive client connection */ - - JobControlRecordPrivate* impl_; + POOLMEM* attr{}; /**< Attribute string from SD */ + BareosDb* db{}; /**< database pointer */ + BareosDb* db_batch{}; /**< database pointer for batch and accurate */ + uint64_t nb_base_files{}; /**< Number of base files */ + uint64_t nb_base_files_used{}; /**< Number of useful files in base */ + + AttributesDbRecord* ar{}; /**< DB attribute record */ + guid_list* id_list{}; /**< User/group id to name list */ + + alist* plugin_ctx_list{}; /**< List of contexts for plugins */ + bpContext* plugin_ctx{}; /**< Current plugin context */ + POOLMEM* comment{}; /**< Comment for this Job */ + int64_t max_bandwidth{}; /**< Bandwidth limit for this Job */ + htable* path_list{}; /**< Directory list (used by findlib) */ + bool is_passive_client_connection_probing{}; /**< Set if director probes a passive client connection */ + + JobControlRecordPrivate* impl_{nullptr}; /* Pointer to implementation of each daemon */ }; /* clang-format on */ From 279aba4c4f3aafc160fd8b1a2bd30bcdd20386ce Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Wed, 6 Nov 2019 10:37:05 +0100 Subject: [PATCH 08/23] jcr: rename implementation pointer --- core/src/dird/admin.cc | 14 +- core/src/dird/archive.cc | 14 +- core/src/dird/authenticate.cc | 8 +- core/src/dird/autoprune.cc | 12 +- core/src/dird/backup.cc | 246 ++++---- core/src/dird/bsr.cc | 14 +- core/src/dird/catreq.cc | 32 +- core/src/dird/consolidate.cc | 66 +-- core/src/dird/dir_plugins.cc | 56 +- core/src/dird/dird_conf.cc | 18 +- core/src/dird/expand.cc | 22 +- core/src/dird/fd_cmds.cc | 152 ++--- core/src/dird/getmsg.cc | 4 +- core/src/dird/inc_conf.cc | 4 +- core/src/dird/jcr_private.h | 8 +- core/src/dird/job.cc | 550 +++++++++--------- core/src/dird/jobq.cc | 206 +++---- core/src/dird/migrate.cc | 410 ++++++------- core/src/dird/msgchan.cc | 88 +-- core/src/dird/ndmp_dma_backup_NDMP_BAREOS.cc | 48 +- core/src/dird/ndmp_dma_backup_NDMP_NATIVE.cc | 50 +- core/src/dird/ndmp_dma_backup_common.cc | 30 +- core/src/dird/ndmp_dma_generic.cc | 36 +- core/src/dird/ndmp_dma_restore_NDMP_BAREOS.cc | 70 +-- core/src/dird/ndmp_dma_restore_NDMP_NATIVE.cc | 20 +- core/src/dird/ndmp_dma_restore_common.cc | 14 +- core/src/dird/ndmp_dma_storage.cc | 8 +- core/src/dird/newvol.cc | 4 +- core/src/dird/next_vol.cc | 22 +- core/src/dird/quota.cc | 160 ++--- core/src/dird/recycle.cc | 4 +- core/src/dird/restore.cc | 104 ++-- core/src/dird/scheduler.cc | 30 +- core/src/dird/sd_cmds.cc | 64 +- core/src/dird/stats.cc | 24 +- core/src/dird/storage.cc | 198 +++---- core/src/dird/testfind.cc | 6 +- core/src/dird/ua_cmds.cc | 42 +- core/src/dird/ua_db.cc | 2 +- core/src/dird/ua_dotcmds.cc | 2 +- core/src/dird/ua_label.cc | 22 +- core/src/dird/ua_output.cc | 34 +- core/src/dird/ua_purge.cc | 4 +- core/src/dird/ua_restore.cc | 2 +- core/src/dird/ua_run.cc | 394 ++++++------- core/src/dird/ua_select.cc | 16 +- core/src/dird/ua_server.cc | 4 +- core/src/dird/ua_status.cc | 34 +- core/src/dird/ua_update.cc | 2 +- core/src/dird/vbackup.cc | 136 ++--- core/src/dird/verify.cc | 150 ++--- core/src/filed/accurate.cc | 56 +- core/src/filed/authenticate.cc | 2 +- core/src/filed/backup.cc | 116 ++-- core/src/filed/compression.cc | 2 +- core/src/filed/crypto.cc | 102 ++-- core/src/filed/dir_cmd.cc | 244 ++++---- core/src/filed/estimate.cc | 12 +- core/src/filed/fd_plugins.cc | 38 +- core/src/filed/fileset.cc | 36 +- core/src/filed/heartbeat.cc | 60 +- core/src/filed/restore.cc | 138 ++--- core/src/filed/sd_cmds.cc | 4 +- core/src/filed/status.cc | 16 +- core/src/filed/verify.cc | 26 +- core/src/filed/verify_vol.cc | 6 +- core/src/include/jcr.h | 2 +- core/src/plugins/stored/scsicrypto-sd.cc | 4 +- core/src/stored/acquire.cc | 22 +- core/src/stored/append.cc | 6 +- core/src/stored/authenticate.cc | 2 +- core/src/stored/bcopy.cc | 26 +- core/src/stored/bextract.cc | 6 +- core/src/stored/bls.cc | 10 +- core/src/stored/bscan.cc | 60 +- core/src/stored/bsr.cc | 24 +- core/src/stored/btape.cc | 28 +- core/src/stored/butil.cc | 60 +- core/src/stored/dev.cc | 24 +- core/src/stored/device.cc | 18 +- core/src/stored/dir_cmd.cc | 42 +- core/src/stored/fd_cmds.cc | 42 +- core/src/stored/job.cc | 102 ++-- core/src/stored/label.cc | 18 +- core/src/stored/mac.cc | 142 ++--- core/src/stored/mount.cc | 8 +- core/src/stored/ndmp_tape.cc | 52 +- core/src/stored/read.cc | 8 +- core/src/stored/read_record.cc | 20 +- core/src/stored/record.cc | 4 +- core/src/stored/reserve.cc | 62 +- core/src/stored/sd_cmds.cc | 12 +- core/src/stored/sd_plugins.cc | 26 +- core/src/stored/sd_stats.cc | 4 +- core/src/stored/spool.cc | 18 +- core/src/stored/status.cc | 8 +- core/src/stored/stored.cc | 24 +- core/src/tests/sd_reservation.cc | 2 +- core/src/win32/filed/vss.cc | 14 +- 99 files changed, 2706 insertions(+), 2712 deletions(-) diff --git a/core/src/dird/admin.cc b/core/src/dird/admin.cc index 75bcd0022d9..37a19bf91c3 100644 --- a/core/src/dird/admin.cc +++ b/core/src/dird/admin.cc @@ -54,9 +54,9 @@ bool DoAdminInit(JobControlRecord* jcr) */ bool do_admin(JobControlRecord* jcr) { - jcr->impl_->jr.JobId = jcr->JobId; + jcr->impl->jr.JobId = jcr->JobId; - jcr->impl_->fname = (char*)GetPoolMemory(PM_FNAME); + jcr->impl->fname = (char*)GetPoolMemory(PM_FNAME); /* * Print Job Start message @@ -84,7 +84,7 @@ void AdminCleanup(JobControlRecord* jcr, int TermCode) UpdateJobEnd(jcr, TermCode); - if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Job record for Job report: ERR=%s"), jcr->db->strerror()); @@ -109,9 +109,9 @@ void AdminCleanup(JobControlRecord* jcr, int TermCode) sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus); break; } - bstrftimes(schedt, sizeof(schedt), jcr->impl_->jr.SchedTime); - bstrftimes(sdt, sizeof(sdt), jcr->impl_->jr.StartTime); - bstrftimes(edt, sizeof(edt), jcr->impl_->jr.EndTime); + bstrftimes(schedt, sizeof(schedt), jcr->impl->jr.SchedTime); + bstrftimes(sdt, sizeof(sdt), jcr->impl->jr.StartTime); + bstrftimes(edt, sizeof(edt), jcr->impl->jr.EndTime); Jmsg(jcr, msg_type, 0, _("BAREOS " VERSION " (" LSMDATE "): %s\n" @@ -122,7 +122,7 @@ void AdminCleanup(JobControlRecord* jcr, int TermCode) " End time: %s\n" " Bareos binary info: %s\n" " Termination: %s\n\n"), - edt, jcr->impl_->jr.JobId, jcr->impl_->jr.Job, schedt, sdt, edt, + edt, jcr->impl->jr.JobId, jcr->impl->jr.Job, schedt, sdt, edt, BAREOS_JOBLOG_MESSAGE, TermMsg); Dmsg0(debuglevel, "Leave AdminCleanup()\n"); diff --git a/core/src/dird/archive.cc b/core/src/dird/archive.cc index 49efd80926d..eabcc3078ce 100644 --- a/core/src/dird/archive.cc +++ b/core/src/dird/archive.cc @@ -53,9 +53,9 @@ bool DoArchiveInit(JobControlRecord* jcr) */ bool DoArchive(JobControlRecord* jcr) { - jcr->impl_->jr.JobId = jcr->JobId; + jcr->impl->jr.JobId = jcr->JobId; - jcr->impl_->fname = (char*)GetPoolMemory(PM_FNAME); + jcr->impl->fname = (char*)GetPoolMemory(PM_FNAME); /* * Print Job Start message @@ -83,7 +83,7 @@ void ArchiveCleanup(JobControlRecord* jcr, int TermCode) UpdateJobEnd(jcr, TermCode); - if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Job record for Job report: ERR=%s"), jcr->db->strerror()); @@ -109,9 +109,9 @@ void ArchiveCleanup(JobControlRecord* jcr, int TermCode) break; } - bstrftimes(schedt, sizeof(schedt), jcr->impl_->jr.SchedTime); - bstrftimes(sdt, sizeof(sdt), jcr->impl_->jr.StartTime); - bstrftimes(edt, sizeof(edt), jcr->impl_->jr.EndTime); + bstrftimes(schedt, sizeof(schedt), jcr->impl->jr.SchedTime); + bstrftimes(sdt, sizeof(sdt), jcr->impl->jr.StartTime); + bstrftimes(edt, sizeof(edt), jcr->impl->jr.EndTime); Jmsg(jcr, msg_type, 0, _("BAREOS " VERSION " (" LSMDATE "): %s\n" @@ -122,7 +122,7 @@ void ArchiveCleanup(JobControlRecord* jcr, int TermCode) " End time: %s\n" " Bareos binary info: %s\n" " Termination: %s\n\n"), - edt, jcr->impl_->jr.JobId, jcr->impl_->jr.Job, schedt, sdt, edt, + edt, jcr->impl->jr.JobId, jcr->impl->jr.Job, schedt, sdt, edt, BAREOS_JOBLOG_MESSAGE, TermMsg); Dmsg0(debuglevel, "Leave ArchiveCleanup()\n"); diff --git a/core/src/dird/authenticate.cc b/core/src/dird/authenticate.cc index af402dbfa1c..404b6ee0150 100644 --- a/core/src/dird/authenticate.cc +++ b/core/src/dird/authenticate.cc @@ -126,9 +126,9 @@ bool AuthenticateWithFileDaemon(JobControlRecord* jcr) if (jcr->authenticated) { return true; } BareosSocket* fd = jcr->file_bsock; - ClientResource* client = jcr->impl_->res.client; + ClientResource* client = jcr->impl->res.client; - if (jcr->impl_->connection_handshake_try_ == + if (jcr->impl->connection_handshake_try_ == ClientConnectionHandshakeMode::kTlsFirst) { std::string qualified_resource_name; if (!my_config->GetQualifiedResourceNameTypeConverter()->ResourceToString( @@ -192,9 +192,9 @@ bool AuthenticateWithFileDaemon(JobControlRecord* jcr) } Dmsg1(110, "msg); - jcr->impl_->FDVersion = 0; + jcr->impl->FDVersion = 0; if (!bstrncmp(fd->msg, FDOKhello, sizeof(FDOKhello)) && - sscanf(fd->msg, FDOKnewHello, &jcr->impl_->FDVersion) != 1) { + sscanf(fd->msg, FDOKnewHello, &jcr->impl->FDVersion) != 1) { Dmsg0(debuglevel, _("File daemon rejected Hello command\n")); Jmsg(jcr, M_FATAL, 0, _("File daemon at \"%s:%d\" rejected Hello command\n"), fd->host(), diff --git a/core/src/dird/autoprune.cc b/core/src/dird/autoprune.cc index a3f9ea2c96f..e666d5e03f9 100644 --- a/core/src/dird/autoprune.cc +++ b/core/src/dird/autoprune.cc @@ -51,14 +51,14 @@ void DoAutoprune(JobControlRecord* jcr) PoolResource* pool; bool pruned; - if (!jcr->impl_->res.client) { /* temp -- remove me */ + if (!jcr->impl->res.client) { /* temp -- remove me */ return; } ua = new_ua_context(jcr); - job = jcr->impl_->res.job; - client = jcr->impl_->res.client; - pool = jcr->impl_->res.pool; + job = jcr->impl->res.job; + client = jcr->impl->res.client; + pool = jcr->impl->res.pool; if (job->PruneJobs || client->AutoPrune) { PruneJobs(ua, client, pool, jcr->getJobType()); @@ -94,8 +94,8 @@ void PruneVolumes(JobControlRecord* jcr, PoolMem query(PM_MESSAGE); char ed1[50], ed2[100], ed3[50]; - Dmsg1(100, "Prune volumes PoolId=%d\n", jcr->impl_->jr.PoolId); - if (!jcr->impl_->res.job->PruneVolumes && !jcr->impl_->res.pool->AutoPrune) { + Dmsg1(100, "Prune volumes PoolId=%d\n", jcr->impl->jr.PoolId); + if (!jcr->impl->res.job->PruneVolumes && !jcr->impl->res.pool->AutoPrune) { Dmsg0(100, "AutoPrune not set in Pool.\n"); return; } diff --git a/core/src/dird/backup.cc b/core/src/dird/backup.cc index c518e64642c..d1c23c3bf76 100644 --- a/core/src/dird/backup.cc +++ b/core/src/dird/backup.cc @@ -73,15 +73,15 @@ static char EndJob[] = static inline bool ValidateClient(JobControlRecord* jcr) { - switch (jcr->impl_->res.client->Protocol) { + switch (jcr->impl->res.client->Protocol) { case APT_NATIVE: return true; default: Jmsg( jcr, M_FATAL, 0, _("Client %s has illegal backup protocol %s for Native backup\n"), - jcr->impl_->res.client->resource_name_, - AuthenticationProtocolTypeToString(jcr->impl_->res.client->Protocol)); + jcr->impl->res.client->resource_name_, + AuthenticationProtocolTypeToString(jcr->impl->res.client->Protocol)); return false; } } @@ -132,7 +132,7 @@ static inline bool ValidateStorage(JobControlRecord* jcr) { StorageResource* store = nullptr; - foreach_alist (store, jcr->impl_->res.write_storage_list) { + foreach_alist (store, jcr->impl->res.write_storage_list) { switch (store->Protocol) { case APT_NATIVE: continue; @@ -157,15 +157,15 @@ bool DoNativeBackupInit(JobControlRecord* jcr) if (!AllowDuplicateJob(jcr)) { return false; } - jcr->impl_->jr.PoolId = - GetOrCreatePoolRecord(jcr, jcr->impl_->res.pool->resource_name_); - if (jcr->impl_->jr.PoolId == 0) { return false; } + jcr->impl->jr.PoolId = + GetOrCreatePoolRecord(jcr, jcr->impl->res.pool->resource_name_); + if (jcr->impl->jr.PoolId == 0) { return false; } /* * If pool storage specified, use it instead of job storage */ - CopyWstorage(jcr, jcr->impl_->res.pool->storage, _("Pool resource")); - if (!jcr->impl_->res.write_storage_list) { + CopyWstorage(jcr, jcr->impl->res.pool->storage, _("Pool resource")); + if (!jcr->impl->res.write_storage_list) { Jmsg(jcr, M_FATAL, 0, _("No Storage specification found in Job or Pool.\n")); return false; @@ -191,13 +191,13 @@ static bool GetBaseJobids(JobControlRecord* jcr, db_list_ctx* jobids) JobId_t id; char str_jobid[50]; - if (!jcr->impl_->res.job->base) { + if (!jcr->impl->res.job->base) { return false; /* no base job, stop accurate */ } - jr.StartTime = jcr->impl_->jr.StartTime; + jr.StartTime = jcr->impl->jr.StartTime; - foreach_alist (job, jcr->impl_->res.job->base) { + foreach_alist (job, jcr->impl->res.job->base) { bstrncpy(jr.Name, job->resource_name_, sizeof(jr.Name)); jcr->db->GetBaseJobid(jcr, &jr, &id); @@ -227,7 +227,7 @@ static int AccurateListHandler(void* ctx, int num_fields, char** row) } /* sending with checksum */ - if (jcr->impl_->use_accurate_chksum && num_fields == 9 && + if (jcr->impl->use_accurate_chksum && num_fields == 9 && row[6][0] && /* skip checksum = '0' */ row[6][1]) { jcr->file_bsock->fsend("%s%s%c%s%c%s%c%s", row[0], row[1], 0, row[4], 0, @@ -251,9 +251,9 @@ static bool IsChecksumNeededByFileset(JobControlRecord* jcr) bool in_block = false; bool have_basejob_option = false; - if (!jcr->impl_->res.job || !jcr->impl_->res.job->fileset) { return false; } + if (!jcr->impl->res.job || !jcr->impl->res.job->fileset) { return false; } - fs = jcr->impl_->res.job->fileset; + fs = jcr->impl->res.job->fileset; for (std::size_t i = 0; i < fs->include_items.size(); i++) { inc = fs->include_items[i]; @@ -330,7 +330,7 @@ bool SendAccurateCurrentFiles(JobControlRecord* jcr) /* * For Incr/Diff level, we search for older jobs */ - jcr->db->AccurateGetJobids(jcr, &jcr->impl_->jr, &jobids); + jcr->db->AccurateGetJobids(jcr, &jcr->impl->jr, &jobids); /* * We are in Incr/Diff, but no Full to build the accurate list... @@ -344,7 +344,7 @@ bool SendAccurateCurrentFiles(JobControlRecord* jcr) /* * Don't send and store the checksum if fileset doesn't require it */ - jcr->impl_->use_accurate_chksum = IsChecksumNeededByFileset(jcr); + jcr->impl->use_accurate_chksum = IsChecksumNeededByFileset(jcr); if (jcr->JobId) { /* display the message only for real jobs */ Jmsg(jcr, M_INFO, 0, _("Sending Accurate information.\n")); } @@ -364,7 +364,7 @@ bool SendAccurateCurrentFiles(JobControlRecord* jcr) jcr->db->strerror()); return false; } - if (!jcr->db->GetBaseFileList(jcr, jcr->impl_->use_accurate_chksum, + if (!jcr->db->GetBaseFileList(jcr, jcr->impl->use_accurate_chksum, AccurateListHandler, (void*)jcr)) { Jmsg(jcr, M_FATAL, 0, "error in jcr->db->GetBaseFileList:%s\n", jcr->db->strerror()); @@ -377,7 +377,7 @@ bool SendAccurateCurrentFiles(JobControlRecord* jcr) } jcr->db_batch->GetFileList( - jcr, jobids.list, jcr->impl_->use_accurate_chksum, false /* no delta */, + jcr, jobids.list, jcr->impl->use_accurate_chksum, false /* no delta */, AccurateListHandler, (void*)jcr); } @@ -407,9 +407,9 @@ bool DoNativeBackup(JobControlRecord* jcr) edit_uint64(jcr->JobId, ed1), jcr->Job); jcr->setJobStatus(JS_Running); - Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->impl_->jr.JobId, - jcr->impl_->jr.JobLevel); - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { + Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->impl->jr.JobId, + jcr->impl->jr.JobLevel); + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); return false; } @@ -445,7 +445,7 @@ bool DoNativeBackup(JobControlRecord* jcr) /* * Now start a job with the Storage daemon */ - if (!StartStorageDaemonJob(jcr, NULL, jcr->impl_->res.write_storage_list)) { + if (!StartStorageDaemonJob(jcr, NULL, jcr->impl->res.write_storage_list)) { return false; } @@ -453,7 +453,7 @@ bool DoNativeBackup(JobControlRecord* jcr) * When the client is not in passive mode we can put the SD in * listen mode for the FD connection. */ - jcr->passive_client = jcr->impl_->res.client->passive; + jcr->passive_client = jcr->impl->res.client->passive; if (!jcr->passive_client) { /* * Start the job prior to starting the message thread below @@ -484,11 +484,11 @@ bool DoNativeBackup(JobControlRecord* jcr) /* * Check if the file daemon supports passive client mode. */ - if (jcr->passive_client && jcr->impl_->FDVersion < FD_VERSION_51) { + if (jcr->passive_client && jcr->impl->FDVersion < FD_VERSION_51) { Jmsg(jcr, M_FATAL, 0, _("Client \"%s\" doesn't support passive client mode. " "Please upgrade your client or disable compat mode.\n"), - jcr->impl_->res.client->resource_name_); + jcr->impl->res.client->resource_name_); goto close_fd; } @@ -508,18 +508,18 @@ bool DoNativeBackup(JobControlRecord* jcr) Dmsg1(500, "Unexpected %s secure erase\n", "client"); } - if (jcr->impl_->res.job->max_bandwidth > 0) { - jcr->max_bandwidth = jcr->impl_->res.job->max_bandwidth; - } else if (jcr->impl_->res.client->max_bandwidth > 0) { - jcr->max_bandwidth = jcr->impl_->res.client->max_bandwidth; + if (jcr->impl->res.job->max_bandwidth > 0) { + jcr->max_bandwidth = jcr->impl->res.job->max_bandwidth; + } else if (jcr->impl->res.client->max_bandwidth > 0) { + jcr->max_bandwidth = jcr->impl->res.client->max_bandwidth; } if (jcr->max_bandwidth > 0) { SendBwlimitToFd(jcr, jcr->Job); /* Old clients don't have this command */ } - client = jcr->impl_->res.client; - store = jcr->impl_->res.write_storage; + client = jcr->impl->res.client; + store = jcr->impl->res.write_storage; char* connection_target_address; /* @@ -536,7 +536,7 @@ bool DoNativeBackup(JobControlRecord* jcr) */ TlsPolicy tls_policy; - if (jcr->impl_->res.client->connection_successful_handshake_ != + if (jcr->impl->res.client->connection_successful_handshake_ != ClientConnectionHandshakeMode::kTlsFirst) { tls_policy = store->GetPolicy(); } else { @@ -558,7 +558,7 @@ bool DoNativeBackup(JobControlRecord* jcr) } else { /* passive client */ TlsPolicy tls_policy; - if (jcr->impl_->res.client->connection_successful_handshake_ != + if (jcr->impl->res.client->connection_successful_handshake_ != ClientConnectionHandshakeMode::kTlsFirst) { tls_policy = client->GetPolicy(); } else { @@ -618,8 +618,8 @@ bool DoNativeBackup(JobControlRecord* jcr) * is after the start of this run. */ jcr->start_time = time(NULL); - jcr->impl_->jr.StartTime = jcr->start_time; - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { + jcr->impl->jr.StartTime = jcr->start_time; + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); } @@ -707,10 +707,10 @@ int WaitForJobTermination(JobControlRecord* jcr, int timeout) */ while ((n = BgetDirmsg(fd)) >= 0) { if (!fd_ok && - sscanf(fd->msg, EndJob, &jcr->impl_->FDJobStatus, &JobFiles, + sscanf(fd->msg, EndJob, &jcr->impl->FDJobStatus, &JobFiles, &ReadBytes, &JobBytes, &JobErrors, &VSS, &Encrypt) == 7) { fd_ok = true; - jcr->setJobStatus(jcr->impl_->FDJobStatus); + jcr->setJobStatus(jcr->impl->FDJobStatus); Dmsg1(100, "FDStatus=%c\n", (char)jcr->JobStatus); } else { Jmsg(jcr, M_WARNING, 0, _("Unexpected Client Job message: %s\n"), @@ -724,7 +724,7 @@ int WaitForJobTermination(JobControlRecord* jcr, int timeout) int i = 0; Jmsg(jcr, M_FATAL, 0, _("Network error with FD during %s: ERR=%s\n"), job_type_to_str(jcr->getJobType()), fd->bstrerror()); - while (i++ < 10 && jcr->impl_->res.job->RescheduleIncompleteJobs && + while (i++ < 10 && jcr->impl->res.job->RescheduleIncompleteJobs && jcr->IsCanceled()) { Bmicrosleep(3, 0); } @@ -737,12 +737,12 @@ int WaitForJobTermination(JobControlRecord* jcr, int timeout) * the SD despool. */ Dmsg5(100, "cancel=%d fd_ok=%d FDJS=%d JS=%d SDJS=%d\n", jcr->IsCanceled(), - fd_ok, jcr->impl_->FDJobStatus, jcr->JobStatus, - jcr->impl_->SDJobStatus); + fd_ok, jcr->impl->FDJobStatus, jcr->JobStatus, + jcr->impl->SDJobStatus); if (jcr->IsCanceled() || - (!jcr->impl_->res.job->RescheduleIncompleteJobs && !fd_ok)) { + (!jcr->impl->res.job->RescheduleIncompleteJobs && !fd_ok)) { Dmsg4(100, "fd_ok=%d FDJS=%d JS=%d SDJS=%d\n", fd_ok, - jcr->impl_->FDJobStatus, jcr->JobStatus, jcr->impl_->SDJobStatus); + jcr->impl->FDJobStatus, jcr->JobStatus, jcr->impl->SDJobStatus); CancelStorageDaemonJob(jcr); } @@ -760,8 +760,8 @@ int WaitForJobTermination(JobControlRecord* jcr, int timeout) jcr->ReadBytes = ReadBytes; jcr->JobBytes = JobBytes; jcr->JobWarnings = JobWarnings; - jcr->impl_->VSS = VSS; - jcr->impl_->Encrypt = Encrypt; + jcr->impl->VSS = VSS; + jcr->impl->Encrypt = Encrypt; } else { Jmsg(jcr, M_FATAL, 0, _("No Job status returned from FD.\n")); } @@ -774,13 +774,13 @@ int WaitForJobTermination(JobControlRecord* jcr, int timeout) * Return the first error status we find Dir, FD, or SD */ if (!fd_ok || IsBnetError(fd)) { /* if fd not set, that use !fd_ok */ - jcr->impl_->FDJobStatus = JS_ErrorTerminated; + jcr->impl->FDJobStatus = JS_ErrorTerminated; } if (jcr->JobStatus != JS_Terminated) { return jcr->JobStatus; } - if (jcr->impl_->FDJobStatus != JS_Terminated) { - return jcr->impl_->FDJobStatus; + if (jcr->impl->FDJobStatus != JS_Terminated) { + return jcr->impl->FDJobStatus; } - return jcr->impl_->SDJobStatus; + return jcr->impl->SDJobStatus; } /* @@ -796,20 +796,20 @@ void NativeBackupCleanup(JobControlRecord* jcr, int TermCode) Dmsg2(100, "Enter backup_cleanup %d %c\n", TermCode, TermCode); if (jcr->is_JobStatus(JS_Terminated) && - (jcr->JobErrors || jcr->impl_->SDErrors || jcr->JobWarnings)) { + (jcr->JobErrors || jcr->impl->SDErrors || jcr->JobWarnings)) { TermCode = JS_Warnings; } UpdateJobEnd(jcr, TermCode); - if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Job record for Job report: ERR=%s"), jcr->db->strerror()); jcr->setJobStatus(JS_ErrorTerminated); } - bstrncpy(cr.Name, jcr->impl_->res.client->resource_name_, sizeof(cr.Name)); + bstrncpy(cr.Name, jcr->impl->res.client->resource_name_, sizeof(cr.Name)); if (!jcr->db->GetClientRecord(jcr, &cr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Client record for Job report: ERR=%s"), @@ -834,8 +834,8 @@ void NativeBackupCleanup(JobControlRecord* jcr, int TermCode) msg_type = M_ERROR; /* Generate error message */ if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->impl_->SD_msg_chan_started) { - pthread_cancel(jcr->impl_->SD_msg_chan); + if (jcr->impl->SD_msg_chan_started) { + pthread_cancel(jcr->impl->SD_msg_chan); } } break; @@ -843,8 +843,8 @@ void NativeBackupCleanup(JobControlRecord* jcr, int TermCode) TermMsg = _("Backup Canceled"); if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->impl_->SD_msg_chan_started) { - pthread_cancel(jcr->impl_->SD_msg_chan); + if (jcr->impl->SD_msg_chan_started) { + pthread_cancel(jcr->impl->SD_msg_chan); } } break; @@ -864,8 +864,8 @@ void UpdateBootstrapFile(JobControlRecord* jcr) /* * Now update the bootstrap file if any */ - if (jcr->IsTerminatedOk() && jcr->impl_->jr.JobBytes && - jcr->impl_->res.job->WriteBootstrap) { + if (jcr->IsTerminatedOk() && jcr->impl->jr.JobBytes && + jcr->impl->res.job->WriteBootstrap) { FILE* fd; int VolCount; int got_pipe = 0; @@ -874,7 +874,7 @@ void UpdateBootstrapFile(JobControlRecord* jcr) char edt[50], ed1[50], ed2[50]; POOLMEM* fname = GetPoolMemory(PM_FNAME); - fname = edit_job_codes(jcr, fname, jcr->impl_->res.job->WriteBootstrap, ""); + fname = edit_job_codes(jcr, fname, jcr->impl->res.job->WriteBootstrap, ""); if (*fname == '|') { got_pipe = 1; bpipe = OpenBpipe(fname + 1, 0, "w"); /* skip first char "|" */ @@ -890,14 +890,14 @@ void UpdateBootstrapFile(JobControlRecord* jcr) _("Could not get Job Volume Parameters to " "update Bootstrap file. ERR=%s\n"), jcr->db->strerror()); - if (jcr->impl_->SDJobFiles != 0) { + if (jcr->impl->SDJobFiles != 0) { jcr->setJobStatus(JS_ErrorTerminated); } } /* Start output with when and who wrote it */ bstrftimes(edt, sizeof(edt), time(NULL)); - fprintf(fd, "# %s - %s - %s%s\n", edt, jcr->impl_->jr.Job, - JobLevelToString(jcr->getJobLevel()), jcr->impl_->since); + fprintf(fd, "# %s - %s - %s%s\n", edt, jcr->impl->jr.Job, + JobLevelToString(jcr->getJobLevel()), jcr->impl->since); for (int i = 0; i < VolCount; i++) { /* Write the record */ fprintf(fd, "Volume=\"%s\"\n", VolParams[i].VolumeName); @@ -957,28 +957,28 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty secure_erase_status, compress_algo_list; - bstrftimes(schedt, sizeof(schedt), jcr->impl_->jr.SchedTime); - bstrftimes(sdt, sizeof(sdt), jcr->impl_->jr.StartTime); - bstrftimes(edt, sizeof(edt), jcr->impl_->jr.EndTime); - RunTime = jcr->impl_->jr.EndTime - jcr->impl_->jr.StartTime; + bstrftimes(schedt, sizeof(schedt), jcr->impl->jr.SchedTime); + bstrftimes(sdt, sizeof(sdt), jcr->impl->jr.StartTime); + bstrftimes(edt, sizeof(edt), jcr->impl->jr.EndTime); + RunTime = jcr->impl->jr.EndTime - jcr->impl->jr.StartTime; bstrftimes(gdt, sizeof(gdt), - jcr->impl_->res.client->GraceTime + - jcr->impl_->res.client->SoftQuotaGracePeriod); + jcr->impl->res.client->GraceTime + + jcr->impl->res.client->SoftQuotaGracePeriod); if (RunTime <= 0) { kbps = 0; } else { - kbps = ((double)jcr->impl_->jr.JobBytes) / (1000.0 * (double)RunTime); + kbps = ((double)jcr->impl->jr.JobBytes) / (1000.0 * (double)RunTime); } - if (!jcr->db->GetJobVolumeNames(jcr, jcr->impl_->jr.JobId, jcr->VolumeName)) { + if (!jcr->db->GetJobVolumeNames(jcr, jcr->impl->jr.JobId, jcr->VolumeName)) { /* * Note, if the job has erred, most likely it did not write any * tape, so suppress this "error" message since in that case * it is normal. Or look at it the other way, only for a * normal exit should we complain about this error. */ - if (jcr->IsTerminatedOk() && jcr->impl_->jr.JobBytes) { + if (jcr->IsTerminatedOk() && jcr->impl->jr.JobBytes) { Jmsg(jcr, M_ERROR, 0, "%s", jcr->db->strerror()); } jcr->VolumeName[0] = 0; /* none */ @@ -1013,36 +1013,36 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty } } - JobstatusToAscii(jcr->impl_->FDJobStatus, fd_term_msg, sizeof(fd_term_msg)); - JobstatusToAscii(jcr->impl_->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); + JobstatusToAscii(jcr->impl->FDJobStatus, fd_term_msg, sizeof(fd_term_msg)); + JobstatusToAscii(jcr->impl->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); switch (jcr->getJobProtocol()) { case PT_NDMP_BAREOS: Mmsg(level_info, _( " Backup Level: %s%s\n"), - JobLevelToString(jcr->getJobLevel()), jcr->impl_->since); + JobLevelToString(jcr->getJobLevel()), jcr->impl->since); Mmsg(statistics, _( " NDMP Files Written: %s\n" " SD Files Written: %s\n" " NDMP Bytes Written: %s (%sB)\n" " SD Bytes Written: %s (%sB)\n"), - edit_uint64_with_commas(jcr->impl_->jr.JobFiles, ec1), - edit_uint64_with_commas(jcr->impl_->SDJobFiles, ec2), - edit_uint64_with_commas(jcr->impl_->jr.JobBytes, ec3), - edit_uint64_with_suffix(jcr->impl_->jr.JobBytes, ec4), - edit_uint64_with_commas(jcr->impl_->SDJobBytes, ec5), - edit_uint64_with_suffix(jcr->impl_->SDJobBytes, ec6)); + edit_uint64_with_commas(jcr->impl->jr.JobFiles, ec1), + edit_uint64_with_commas(jcr->impl->SDJobFiles, ec2), + edit_uint64_with_commas(jcr->impl->jr.JobBytes, ec3), + edit_uint64_with_suffix(jcr->impl->jr.JobBytes, ec4), + edit_uint64_with_commas(jcr->impl->SDJobBytes, ec5), + edit_uint64_with_suffix(jcr->impl->SDJobBytes, ec6)); break; case PT_NDMP_NATIVE: Mmsg(level_info, _( " Backup Level: %s%s\n"), - JobLevelToString(jcr->getJobLevel()), jcr->impl_->since); + JobLevelToString(jcr->getJobLevel()), jcr->impl->since); Mmsg(statistics, _( " NDMP Files Written: %s\n" " NDMP Bytes Written: %s (%sB)\n"), - edit_uint64_with_commas(jcr->impl_->jr.JobFiles, ec1), - edit_uint64_with_commas(jcr->impl_->jr.JobBytes, ec3), - edit_uint64_with_suffix(jcr->impl_->jr.JobBytes, ec4)); + edit_uint64_with_commas(jcr->impl->jr.JobFiles, ec1), + edit_uint64_with_commas(jcr->impl->jr.JobBytes, ec3), + edit_uint64_with_suffix(jcr->impl->jr.JobBytes, ec4)); break; default: if (jcr->is_JobLevel(L_VIRTUAL_FULL)) { @@ -1051,32 +1051,32 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty Mmsg(statistics, _( " SD Files Written: %s\n" " SD Bytes Written: %s (%sB)\n"), - edit_uint64_with_commas(jcr->impl_->SDJobFiles, ec2), - edit_uint64_with_commas(jcr->impl_->SDJobBytes, ec5), - edit_uint64_with_suffix(jcr->impl_->SDJobBytes, ec6)); + edit_uint64_with_commas(jcr->impl->SDJobFiles, ec2), + edit_uint64_with_commas(jcr->impl->SDJobBytes, ec5), + edit_uint64_with_suffix(jcr->impl->SDJobBytes, ec6)); } else { Mmsg(level_info, _( " Backup Level: %s%s\n"), - JobLevelToString(jcr->getJobLevel()), jcr->impl_->since); + JobLevelToString(jcr->getJobLevel()), jcr->impl->since); Mmsg(statistics, _( " FD Files Written: %s\n" " SD Files Written: %s\n" " FD Bytes Written: %s (%sB)\n" " SD Bytes Written: %s (%sB)\n"), - edit_uint64_with_commas(jcr->impl_->jr.JobFiles, ec1), - edit_uint64_with_commas(jcr->impl_->SDJobFiles, ec2), - edit_uint64_with_commas(jcr->impl_->jr.JobBytes, ec3), - edit_uint64_with_suffix(jcr->impl_->jr.JobBytes, ec4), - edit_uint64_with_commas(jcr->impl_->SDJobBytes, ec5), - edit_uint64_with_suffix(jcr->impl_->SDJobBytes, ec6)); + edit_uint64_with_commas(jcr->impl->jr.JobFiles, ec1), + edit_uint64_with_commas(jcr->impl->SDJobFiles, ec2), + edit_uint64_with_commas(jcr->impl->jr.JobBytes, ec3), + edit_uint64_with_suffix(jcr->impl->jr.JobBytes, ec4), + edit_uint64_with_commas(jcr->impl->SDJobBytes, ec5), + edit_uint64_with_suffix(jcr->impl->SDJobBytes, ec6)); } break; } - if (jcr->impl_->HasQuota) { - if (jcr->impl_->res.client->GraceTime != 0) { - bstrftimes(gdt, sizeof(gdt), jcr->impl_->res.client->GraceTime + - jcr->impl_->res.client->SoftQuotaGracePeriod); + if (jcr->impl->HasQuota) { + if (jcr->impl->res.client->GraceTime != 0) { + bstrftimes(gdt, sizeof(gdt), jcr->impl->res.client->GraceTime + + jcr->impl->res.client->SoftQuotaGracePeriod); } else { bstrncpy(gdt, "Soft Quota not exceeded", sizeof(gdt)); } @@ -1086,14 +1086,14 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty " Soft Quota: %s (%sB)\n" " Hard Quota: %s (%sB)\n" " Grace Expiry Date: %s\n"), - edit_uint64_with_commas(jcr->impl_->jr.JobSumTotalBytes+jcr->impl_->SDJobBytes, ec1), - edit_uint64_with_suffix(jcr->impl_->jr.JobSumTotalBytes+jcr->impl_->SDJobBytes, ec2), - edit_uint64_with_commas(jcr->impl_->res.client->QuotaLimit, ec3), - edit_uint64_with_suffix(jcr->impl_->res.client->QuotaLimit, ec4), - edit_uint64_with_commas(jcr->impl_->res.client->SoftQuota, ec5), - edit_uint64_with_suffix(jcr->impl_->res.client->SoftQuota, ec6), - edit_uint64_with_commas(jcr->impl_->res.client->HardQuota, ec7), - edit_uint64_with_suffix(jcr->impl_->res.client->HardQuota, ec8), + edit_uint64_with_commas(jcr->impl->jr.JobSumTotalBytes+jcr->impl->SDJobBytes, ec1), + edit_uint64_with_suffix(jcr->impl->jr.JobSumTotalBytes+jcr->impl->SDJobBytes, ec2), + edit_uint64_with_commas(jcr->impl->res.client->QuotaLimit, ec3), + edit_uint64_with_suffix(jcr->impl->res.client->QuotaLimit, ec4), + edit_uint64_with_commas(jcr->impl->res.client->SoftQuota, ec5), + edit_uint64_with_suffix(jcr->impl->res.client->SoftQuota, ec6), + edit_uint64_with_commas(jcr->impl->res.client->HardQuota, ec7), + edit_uint64_with_suffix(jcr->impl->res.client->HardQuota, ec8), gdt); } @@ -1107,7 +1107,7 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty " SD Errors: %d\n" " SD termination status: %s\n" " Accurate: %s\n"), - jcr->impl_->SDErrors, + jcr->impl->SDErrors, sd_term_msg, jcr->accurate ? _("yes") : _("no")); } else { @@ -1123,8 +1123,8 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty jcr->nb_base_files, jcr->nb_base_files_used, jcr->nb_base_files_used * 100.0 / jcr->nb_base_files, - jcr->impl_->VSS ? _("yes") : _("no"), - jcr->impl_->Encrypt ? _("yes") : _("no"), + jcr->impl->VSS ? _("yes") : _("no"), + jcr->impl->Encrypt ? _("yes") : _("no"), jcr->accurate ? _("yes") : _("no")); } else { Mmsg(client_options, _( @@ -1134,8 +1134,8 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty " Accurate: %s\n"), compress, compress_algo_list.c_str(), - jcr->impl_->VSS ? _("yes") : _("no"), - jcr->impl_->Encrypt ? _("yes") : _("no"), + jcr->impl->VSS ? _("yes") : _("no"), + jcr->impl->Encrypt ? _("yes") : _("no"), jcr->accurate ? _("yes") : _("no")); } @@ -1145,7 +1145,7 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty " FD termination status: %s\n" " SD termination status: %s\n"), jcr->JobErrors, - jcr->impl_->SDErrors, + jcr->impl->SDErrors, fd_term_msg, sd_term_msg); @@ -1153,12 +1153,12 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty Mmsg(temp," Dir Secure Erase Cmd: %s\n", me->secure_erase_cmdline); PmStrcat(secure_erase_status, temp.c_str()); } - if (!bstrcmp(jcr->impl_->FDSecureEraseCmd, "*None*")) { - Mmsg(temp, " FD Secure Erase Cmd: %s\n", jcr->impl_->FDSecureEraseCmd); + if (!bstrcmp(jcr->impl->FDSecureEraseCmd, "*None*")) { + Mmsg(temp, " FD Secure Erase Cmd: %s\n", jcr->impl->FDSecureEraseCmd); PmStrcat(secure_erase_status, temp.c_str()); } - if (!bstrcmp(jcr->impl_->SDSecureEraseCmd, "*None*")) { - Mmsg(temp, " SD Secure Erase Cmd: %s\n", jcr->impl_->SDSecureEraseCmd); + if (!bstrcmp(jcr->impl->SDSecureEraseCmd, "*None*")) { + Mmsg(temp, " SD Secure Erase Cmd: %s\n", jcr->impl->SDSecureEraseCmd); PmStrcat(secure_erase_status, temp.c_str()); } } @@ -1196,14 +1196,14 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty " Termination: %s\n\n"), BAREOS, my_name, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER, - jcr->impl_->jr.JobId, - jcr->impl_->jr.Job, + jcr->impl->jr.JobId, + jcr->impl->jr.Job, level_info.c_str(), - jcr->impl_->res.client->resource_name_, cr->Uname, - jcr->impl_->res.fileset->resource_name_, jcr->impl_->FSCreateTime, - jcr->impl_->res.pool->resource_name_, jcr->impl_->res.pool_source, - jcr->impl_->res.catalog->resource_name_, jcr->impl_->res.catalog_source, - jcr->impl_->res.write_storage->resource_name_, jcr->impl_->res.wstore_source, + jcr->impl->res.client->resource_name_, cr->Uname, + jcr->impl->res.fileset->resource_name_, jcr->impl->FSCreateTime, + jcr->impl->res.pool->resource_name_, jcr->impl->res.pool_source, + jcr->impl->res.catalog->resource_name_, jcr->impl->res.catalog_source, + jcr->impl->res.write_storage->resource_name_, jcr->impl->res.wstore_source, schedt, sdt, edt, diff --git a/core/src/dird/bsr.cc b/core/src/dird/bsr.cc index de15c7721ed..6ac3b4f8e70 100644 --- a/core/src/dird/bsr.cc +++ b/core/src/dird/bsr.cc @@ -253,13 +253,13 @@ static void MakeUniqueRestoreFilename(UaContext* ua, PoolMem& fname) int i = FindArgWithValue(ua, "bootstrap"); if (i >= 0) { Mmsg(fname, "%s", ua->argv[i]); - jcr->impl_->unlink_bsr = false; + jcr->impl->unlink_bsr = false; } else { P(mutex); uniq++; V(mutex); Mmsg(fname, "%s/%s.restore.%u.bsr", working_directory, my_name, uniq); - jcr->impl_->unlink_bsr = true; + jcr->impl->unlink_bsr = true; } if (jcr->RestoreBootstrap) { free(jcr->RestoreBootstrap); } jcr->RestoreBootstrap = strdup(fname.c_str()); @@ -603,7 +603,7 @@ bool OpenBootstrapFile(JobControlRecord* jcr, bootstrap_info& info) info.ua = NULL; if (!jcr->RestoreBootstrap) { return false; } - bstrncpy(info.storage, jcr->impl_->res.read_storage->resource_name_, + bstrncpy(info.storage, jcr->impl->res.read_storage->resource_name_, MAX_NAME_LENGTH); bs = fopen(jcr->RestoreBootstrap, "rb"); @@ -643,7 +643,7 @@ static inline bool IsOnSameStorage(JobControlRecord* jcr, char* new_one) /* * With old FD, we send the whole bootstrap to the storage */ - if (jcr->impl_->FDVersion < FD_VERSION_2) { return true; } + if (jcr->impl->FDVersion < FD_VERSION_2) { return true; } /* * We are in init loop ? shoudn't fail here @@ -653,7 +653,7 @@ static inline bool IsOnSameStorage(JobControlRecord* jcr, char* new_one) /* * Same name */ - if (bstrcmp(new_one, jcr->impl_->res.read_storage->resource_name_)) { + if (bstrcmp(new_one, jcr->impl->res.read_storage->resource_name_)) { return true; } @@ -668,8 +668,8 @@ static inline bool IsOnSameStorage(JobControlRecord* jcr, char* new_one) * If Port and Hostname/IP are same, we are talking to the same * Storage Daemon */ - if (jcr->impl_->res.read_storage->SDport != new_store->SDport || - !bstrcmp(jcr->impl_->res.read_storage->address, new_store->address)) { + if (jcr->impl->res.read_storage->SDport != new_store->SDport || + !bstrcmp(jcr->impl->res.read_storage->address, new_store->address)) { return false; } diff --git a/core/src/dird/catreq.cc b/core/src/dird/catreq.cc index 114aa1f272b..8719a5c2766 100644 --- a/core/src/dird/catreq.cc +++ b/core/src/dird/catreq.cc @@ -89,7 +89,7 @@ static int SendVolumeInfoToStorageDaemon(JobControlRecord* jcr, int status; char ed1[50], ed2[50], ed3[50], ed4[50], ed5[50], ed6[50]; - jcr->impl_->MediaId = mr->MediaId; + jcr->impl->MediaId = mr->MediaId; PmStrcpy(jcr->VolumeName, mr->VolumeName); BashSpaces(mr->VolumeName); status = sd->fsend( @@ -146,7 +146,7 @@ void CatalogRequest(JobControlRecord* jcr, BareosSocket* bs) ok = jcr->db->GetPoolRecord(jcr, &pr); if (ok) { mr.PoolId = pr.PoolId; - SetStorageidInMr(jcr->impl_->res.write_storage, &mr); + SetStorageidInMr(jcr->impl->res.write_storage, &mr); mr.ScratchPoolId = pr.ScratchPoolId; ok = FindNextVolumeForAppend(jcr, &mr, index, unwanted_volumes.c_str(), fnv_create_vol, fnv_prune); @@ -187,10 +187,10 @@ void CatalogRequest(JobControlRecord* jcr, BareosSocket* bs) * Pool matches, and it is either Append or Recycle * and Media Type matches and Pool allows any volume. */ - if (mr.PoolId != jcr->impl_->jr.PoolId) { + if (mr.PoolId != jcr->impl->jr.PoolId) { reason = _("not in Pool"); } else if (!bstrcmp(mr.MediaType, - jcr->impl_->res.write_storage->media_type)) { + jcr->impl->res.write_storage->media_type)) { reason = _("not correct MediaType"); } else { /* @@ -297,13 +297,13 @@ void CatalogRequest(JobControlRecord* jcr, BareosSocket* bs) * However, do so only if we are writing the tape, i.e. * the number of VolWrites has increased. */ - if (jcr->impl_->res.write_storage && sdmr.VolWrites > mr.VolWrites) { + if (jcr->impl->res.write_storage && sdmr.VolWrites > mr.VolWrites) { Dmsg2(050, "Update StorageId old=%d new=%d\n", mr.StorageId, - jcr->impl_->res.write_storage->StorageId); + jcr->impl->res.write_storage->StorageId); /* * Update StorageId after write */ - SetStorageidInMr(jcr->impl_->res.write_storage, &mr); + SetStorageidInMr(jcr->impl->res.write_storage, &mr); } else { /* * Nothing written, reset same StorageId @@ -356,8 +356,8 @@ void CatalogRequest(JobControlRecord* jcr, BareosSocket* bs) /* * Request to create a JobMedia record */ - if (jcr->impl_->mig_jcr) { - jm.JobId = jcr->impl_->mig_jcr->JobId; + if (jcr->impl->mig_jcr) { + jm.JobId = jcr->impl->mig_jcr->JobId; } else { jm.JobId = jcr->JobId; } @@ -468,7 +468,7 @@ static void UpdateAttribute(JobControlRecord* jcr, Dmsg5(400, "UpdCat VolSessId=%d VolSessT=%d FI=%d Strm=%d reclen=%d\n", VolSessionId, VolSessionTime, FileIndex, Stream, reclen); - jcr->impl_->SDJobBytes += + jcr->impl->SDJobBytes += reclen; /* update number of bytes transferred for quotas */ /* @@ -525,8 +525,8 @@ static void UpdateAttribute(JobControlRecord* jcr, } ar->Stream = Stream; ar->link = NULL; - if (jcr->impl_->mig_jcr) { - ar->JobId = jcr->impl_->mig_jcr->JobId; + if (jcr->impl->mig_jcr) { + ar->JobId = jcr->impl->mig_jcr->JobId; } else { ar->JobId = jcr->JobId; } @@ -552,8 +552,8 @@ static void UpdateAttribute(JobControlRecord* jcr, ro.Stream = Stream; ro.FileIndex = FileIndex; - if (jcr->impl_->mig_jcr) { - ro.JobId = jcr->impl_->mig_jcr->JobId; + if (jcr->impl->mig_jcr) { + ro.JobId = jcr->impl->mig_jcr->JobId; } else { ro.JobId = jcr->JobId; } @@ -679,7 +679,7 @@ static void UpdateAttribute(JobControlRecord* jcr, */ void CatalogUpdate(JobControlRecord* jcr, BareosSocket* bs) { - if (!jcr->impl_->res.pool->catalog_files) { + if (!jcr->impl->res.pool->catalog_files) { return; /* user disabled cataloging */ } @@ -717,7 +717,7 @@ bool DespoolAttributesFromFile(JobControlRecord* jcr, const char* file) Dmsg0(100, "Begin DespoolAttributesFromFile\n"); - if (jcr->IsJobCanceled() || !jcr->impl_->res.pool->catalog_files || + if (jcr->IsJobCanceled() || !jcr->impl->res.pool->catalog_files || !jcr->db) { goto bail_out; /* user disabled cataloging */ } diff --git a/core/src/dird/consolidate.cc b/core/src/dird/consolidate.cc index d73d90d865f..c68d9fd8cc8 100644 --- a/core/src/dird/consolidate.cc +++ b/core/src/dird/consolidate.cc @@ -68,7 +68,7 @@ static inline void StartNewConsolidationJob(JobControlRecord* jcr, ua = new_ua_context(jcr); ua->batch = true; Mmsg(ua->cmd, "run job=\"%s\" jobid=%s level=VirtualFull %s", jobname, - jcr->impl_->vf_jobids, jcr->accurate ? "accurate=yes" : "accurate=no"); + jcr->impl->vf_jobids, jcr->accurate ? "accurate=yes" : "accurate=no"); Dmsg1(debuglevel, "=============== consolidate cmd=%s\n", ua->cmd); ParseUaArgs(ua); /* parse command */ @@ -102,15 +102,15 @@ bool DoConsolidate(JobControlRecord* jcr) int32_t fullconsolidations_started = 0; int32_t max_full_consolidations = 0; - tmpjob = jcr->impl_->res.job; /* Memorize job */ + tmpjob = jcr->impl->res.job; /* Memorize job */ /* * Get Value for MaxFullConsolidations from Consolidation job */ - max_full_consolidations = jcr->impl_->res.job->MaxFullConsolidations; + max_full_consolidations = jcr->impl->res.job->MaxFullConsolidations; - jcr->impl_->jr.JobId = jcr->JobId; - jcr->impl_->fname = (char*)GetPoolMemory(PM_FNAME); + jcr->impl->jr.JobId = jcr->JobId; + jcr->impl->fname = (char*)GetPoolMemory(PM_FNAME); /* * Print Job Start message @@ -133,12 +133,12 @@ bool DoConsolidate(JobControlRecord* jcr) /* * Fake always incremental job as job of current jcr. */ - jcr->impl_->res.job = job; - jcr->impl_->res.fileset = job->fileset; - jcr->impl_->res.client = job->client; - jcr->impl_->jr.JobLevel = L_INCREMENTAL; - jcr->impl_->jr.limit = 0; - jcr->impl_->jr.StartTime = 0; + jcr->impl->res.job = job; + jcr->impl->res.fileset = job->fileset; + jcr->impl->res.client = job->client; + jcr->impl->jr.JobLevel = L_INCREMENTAL; + jcr->impl->jr.limit = 0; + jcr->impl->jr.StartTime = 0; if (!GetOrCreateFilesetRecord(jcr)) { Jmsg(jcr, M_FATAL, 0, _("JobId=%d no FileSet\n"), (int)jcr->JobId); @@ -155,7 +155,7 @@ bool DoConsolidate(JobControlRecord* jcr) /* * First determine the number of total incrementals */ - jcr->db->AccurateGetJobids(jcr, &jcr->impl_->jr, &jobids_ctx); + jcr->db->AccurateGetJobids(jcr, &jcr->impl->jr, &jobids_ctx); incrementals_total = jobids_ctx.count - 1; Dmsg1(10, "unlimited jobids list: %s.\n", jobids_ctx.list); @@ -167,19 +167,19 @@ bool DoConsolidate(JobControlRecord* jcr) if (job->AlwaysIncrementalJobRetention) { char sdt[50]; - jcr->impl_->jr.StartTime = now - job->AlwaysIncrementalJobRetention; - bstrftimes(sdt, sizeof(sdt), jcr->impl_->jr.StartTime); + jcr->impl->jr.StartTime = now - job->AlwaysIncrementalJobRetention; + bstrftimes(sdt, sizeof(sdt), jcr->impl->jr.StartTime); Jmsg(jcr, M_INFO, 0, _("%s: considering jobs older than %s for consolidation.\n"), job->resource_name_, sdt); Dmsg4(10, _("%s: considering jobs with ClientId %d and FilesetId %d older " "than %s for consolidation.\n"), - job->resource_name_, jcr->impl_->jr.ClientId, - jcr->impl_->jr.FileSetId, sdt); + job->resource_name_, jcr->impl->jr.ClientId, + jcr->impl->jr.FileSetId, sdt); } - jcr->db->AccurateGetJobids(jcr, &jcr->impl_->jr, &jobids_ctx); + jcr->db->AccurateGetJobids(jcr, &jcr->impl->jr, &jobids_ctx); Dmsg1(10, "consolidate candidates: %s.\n", jobids_ctx.list); /** @@ -203,12 +203,12 @@ bool DoConsolidate(JobControlRecord* jcr) Dmsg2(10, "Incrementals found/required. (%d/%d).\n", incrementals_total, job->AlwaysIncrementalKeepNumber); if ((max_incrementals_to_consolidate + 1) > 1) { - jcr->impl_->jr.limit = max_incrementals_to_consolidate + 1; + jcr->impl->jr.limit = max_incrementals_to_consolidate + 1; Dmsg3(10, "total: %d, to_consolidate: %d, limit: %d.\n", incrementals_total, max_incrementals_to_consolidate, - jcr->impl_->jr.limit); + jcr->impl->jr.limit); jobids_ctx.reset(); - jcr->db->AccurateGetJobids(jcr, &jcr->impl_->jr, &jobids_ctx); + jcr->db->AccurateGetJobids(jcr, &jcr->impl->jr, &jobids_ctx); incrementals_to_consolidate = jobids_ctx.count - 1; Dmsg2(10, "%d consolidate ids after limit: %s.\n", jobids_ctx.count, jobids_ctx.list); @@ -257,18 +257,18 @@ bool DoConsolidate(JobControlRecord* jcr) /** * Get db record of oldest jobid and check its age */ - jcr->impl_->previous_jr = JobDbRecord{}; - jcr->impl_->previous_jr.JobId = str_to_int64(jobids); + jcr->impl->previous_jr = JobDbRecord{}; + jcr->impl->previous_jr.JobId = str_to_int64(jobids); Dmsg1(10, "Previous JobId=%s\n", jobids); - if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->previous_jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl->previous_jr)) { Jmsg(jcr, M_FATAL, 0, _("Error getting Job record for first Job: ERR=%s"), jcr->db->strerror()); goto bail_out; } - starttime = jcr->impl_->previous_jr.JobTDate; + starttime = jcr->impl->previous_jr.JobTDate; oldest_allowed_starttime = now - job->AlwaysIncrementalMaxFullAge; bstrftimes(sdt_allowed, sizeof(sdt_allowed), oldest_allowed_starttime); bstrftimes(sdt_starttime, sizeof(sdt_starttime), starttime); @@ -310,10 +310,10 @@ bool DoConsolidate(JobControlRecord* jcr) /** * Set the virtualfull jobids to be consolidated */ - if (!jcr->impl_->vf_jobids) { - jcr->impl_->vf_jobids = GetPoolMemory(PM_MESSAGE); + if (!jcr->impl->vf_jobids) { + jcr->impl->vf_jobids = GetPoolMemory(PM_MESSAGE); } - PmStrcpy(jcr->impl_->vf_jobids, p); + PmStrcpy(jcr->impl->vf_jobids, p); Jmsg(jcr, M_INFO, 0, _("%s: Start new consolidation\n"), job->resource_name_); @@ -325,7 +325,7 @@ bool DoConsolidate(JobControlRecord* jcr) /** * Restore original job back to jcr. */ - jcr->impl_->res.job = tmpjob; + jcr->impl->res.job = tmpjob; jcr->setJobStatus(JS_Terminated); ConsolidateCleanup(jcr, JS_Terminated); @@ -348,7 +348,7 @@ void ConsolidateCleanup(JobControlRecord* jcr, int TermCode) UpdateJobEnd(jcr, TermCode); - if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Job record for Job report: ERR=%s"), jcr->db->strerror()); @@ -373,9 +373,9 @@ void ConsolidateCleanup(JobControlRecord* jcr, int TermCode) sprintf(term_code, _("Inappropriate term code: %c\n"), jcr->JobStatus); break; } - bstrftimes(schedt, sizeof(schedt), jcr->impl_->jr.SchedTime); - bstrftimes(sdt, sizeof(sdt), jcr->impl_->jr.StartTime); - bstrftimes(edt, sizeof(edt), jcr->impl_->jr.EndTime); + bstrftimes(schedt, sizeof(schedt), jcr->impl->jr.SchedTime); + bstrftimes(sdt, sizeof(sdt), jcr->impl->jr.StartTime); + bstrftimes(edt, sizeof(edt), jcr->impl->jr.EndTime); Jmsg(jcr, msg_type, 0, _("BAREOS " VERSION " (" LSMDATE "): %s\n" @@ -386,7 +386,7 @@ void ConsolidateCleanup(JobControlRecord* jcr, int TermCode) " End time: %s\n" " Bareos binary info: %s\n" " Termination: %s\n\n"), - edt, jcr->impl_->jr.JobId, jcr->impl_->jr.Job, schedt, sdt, edt, + edt, jcr->impl->jr.JobId, jcr->impl->jr.Job, schedt, sdt, edt, BAREOS_JOBLOG_MESSAGE, TermMsg); Dmsg0(debuglevel, "Leave ConsolidateCleanup()\n"); diff --git a/core/src/dird/dir_plugins.cc b/core/src/dird/dir_plugins.cc index cd3cad29b98..8d18959f638 100644 --- a/core/src/dird/dir_plugins.cc +++ b/core/src/dird/dir_plugins.cc @@ -420,13 +420,13 @@ void DispatchNewPluginOptions(JobControlRecord* jcr) if (!dird_plugin_list || dird_plugin_list->empty()) { return; } - if (jcr->impl_->res.job && jcr->impl_->res.job->DirPluginOptions && - jcr->impl_->res.job->DirPluginOptions->size()) { + if (jcr->impl->res.job && jcr->impl->res.job->DirPluginOptions && + jcr->impl->res.job->DirPluginOptions->size()) { eventType = bDirEventNewPluginOptions; event.eventType = eventType; foreach_alist_index (i, plugin_options, - jcr->impl_->res.job->DirPluginOptions) { + jcr->impl->res.job->DirPluginOptions) { /* * Make a private copy of plugin options. */ @@ -591,7 +591,7 @@ static bRC bareosGetValue(bpContext* ctx, brDirVariable var, void* value) NPRT(*((char**)value))); break; case bDirVarJob: - *((char**)value) = jcr->impl_->res.job->resource_name_; + *((char**)value) = jcr->impl->res.job->resource_name_; Dmsg1(debuglevel, "dir-plugin: return bDirVarJob=%s\n", NPRT(*((char**)value))); break; @@ -606,14 +606,14 @@ static bRC bareosGetValue(bpContext* ctx, brDirVariable var, void* value) jcr->getJobType()); break; case bDirVarClient: - *((char**)value) = jcr->impl_->res.client->resource_name_; + *((char**)value) = jcr->impl->res.client->resource_name_; Dmsg1(debuglevel, "dir-plugin: return bDirVarClient=%s\n", NPRT(*((char**)value))); break; case bDirVarNumVols: { PoolDbRecord pr; - bstrncpy(pr.Name, jcr->impl_->res.pool->resource_name_, + bstrncpy(pr.Name, jcr->impl->res.pool->resource_name_, sizeof(pr.Name)); if (!jcr->db->GetPoolRecord(jcr, &pr)) { retval = bRC_Error; } *((int*)value) = pr.NumVols; @@ -621,15 +621,15 @@ static bRC bareosGetValue(bpContext* ctx, brDirVariable var, void* value) break; } case bDirVarPool: - *((char**)value) = jcr->impl_->res.pool->resource_name_; + *((char**)value) = jcr->impl->res.pool->resource_name_; Dmsg1(debuglevel, "dir-plugin: return bDirVarPool=%s\n", NPRT(*((char**)value))); break; case bDirVarStorage: - if (jcr->impl_->res.write_storage) { - *((char**)value) = jcr->impl_->res.write_storage->resource_name_; - } else if (jcr->impl_->res.read_storage) { - *((char**)value) = jcr->impl_->res.read_storage->resource_name_; + if (jcr->impl->res.write_storage) { + *((char**)value) = jcr->impl->res.write_storage->resource_name_; + } else if (jcr->impl->res.read_storage) { + *((char**)value) = jcr->impl->res.read_storage->resource_name_; } else { *((char**)value) = NULL; retval = bRC_Error; @@ -638,8 +638,8 @@ static bRC bareosGetValue(bpContext* ctx, brDirVariable var, void* value) NPRT(*((char**)value))); break; case bDirVarWriteStorage: - if (jcr->impl_->res.write_storage) { - *((char**)value) = jcr->impl_->res.write_storage->resource_name_; + if (jcr->impl->res.write_storage) { + *((char**)value) = jcr->impl->res.write_storage->resource_name_; } else { *((char**)value) = NULL; retval = bRC_Error; @@ -648,8 +648,8 @@ static bRC bareosGetValue(bpContext* ctx, brDirVariable var, void* value) NPRT(*((char**)value))); break; case bDirVarReadStorage: - if (jcr->impl_->res.read_storage) { - *((char**)value) = jcr->impl_->res.read_storage->resource_name_; + if (jcr->impl->res.read_storage) { + *((char**)value) = jcr->impl->res.read_storage->resource_name_; } else { *((char**)value) = NULL; retval = bRC_Error; @@ -658,15 +658,15 @@ static bRC bareosGetValue(bpContext* ctx, brDirVariable var, void* value) NPRT(*((char**)value))); break; case bDirVarCatalog: - *((char**)value) = jcr->impl_->res.catalog->resource_name_; + *((char**)value) = jcr->impl->res.catalog->resource_name_; Dmsg1(debuglevel, "dir-plugin: return bDirVarCatalog=%s\n", NPRT(*((char**)value))); break; case bDirVarMediaType: - if (jcr->impl_->res.write_storage) { - *((char**)value) = jcr->impl_->res.write_storage->media_type; - } else if (jcr->impl_->res.read_storage) { - *((char**)value) = jcr->impl_->res.read_storage->media_type; + if (jcr->impl->res.write_storage) { + *((char**)value) = jcr->impl->res.write_storage->media_type; + } else if (jcr->impl->res.read_storage) { + *((char**)value) = jcr->impl->res.read_storage->media_type; } else { *((char**)value) = NULL; retval = bRC_Error; @@ -703,24 +703,24 @@ static bRC bareosGetValue(bpContext* ctx, brDirVariable var, void* value) jcr->JobFiles); break; case bDirVarSDJobFiles: - *((int*)value) = jcr->impl_->SDJobFiles; + *((int*)value) = jcr->impl->SDJobFiles; Dmsg1(debuglevel, "dir-plugin: return bDirVarSDFiles=%d\n", - jcr->impl_->SDJobFiles); + jcr->impl->SDJobFiles); break; case bDirVarSDErrors: - *((int*)value) = jcr->impl_->SDErrors; + *((int*)value) = jcr->impl->SDErrors; Dmsg1(debuglevel, "dir-plugin: return bDirVarSDErrors=%d\n", - jcr->impl_->SDErrors); + jcr->impl->SDErrors); break; case bDirVarFDJobStatus: - *((int*)value) = jcr->impl_->FDJobStatus; + *((int*)value) = jcr->impl->FDJobStatus; Dmsg1(debuglevel, "dir-plugin: return bDirVarFDJobStatus=%c\n", - jcr->impl_->FDJobStatus); + jcr->impl->FDJobStatus); break; case bDirVarSDJobStatus: - *((int*)value) = jcr->impl_->SDJobStatus; + *((int*)value) = jcr->impl->SDJobStatus; Dmsg1(debuglevel, "dir-plugin: return bDirVarSDJobStatus=%c\n", - jcr->impl_->SDJobStatus); + jcr->impl->SDJobStatus); break; case bDirVarLastRate: *((int*)value) = jcr->LastRate; diff --git a/core/src/dird/dird_conf.cc b/core/src/dird/dird_conf.cc index d4191f0d961..c0bfc41d38e 100644 --- a/core/src/dird/dird_conf.cc +++ b/core/src/dird/dird_conf.cc @@ -3302,25 +3302,25 @@ extern "C" char* job_code_callback_director(JobControlRecord* jcr, switch (param[0]) { case 'f': - if (jcr->impl_->res.fileset) { - return jcr->impl_->res.fileset->resource_name_; + if (jcr->impl->res.fileset) { + return jcr->impl->res.fileset->resource_name_; } break; case 'h': - if (jcr->impl_->res.client) { return jcr->impl_->res.client->address; } + if (jcr->impl->res.client) { return jcr->impl->res.client->address; } break; case 'p': - if (jcr->impl_->res.pool) { return jcr->impl_->res.pool->resource_name_; } + if (jcr->impl->res.pool) { return jcr->impl->res.pool->resource_name_; } break; case 'w': - if (jcr->impl_->res.write_storage) { - return jcr->impl_->res.write_storage->resource_name_; + if (jcr->impl->res.write_storage) { + return jcr->impl->res.write_storage->resource_name_; } break; case 'x': - return jcr->impl_->spool_data ? yes : no; + return jcr->impl->spool_data ? yes : no; case 'C': - return jcr->impl_->cloned ? yes : no; + return jcr->impl->cloned ? yes : no; case 'D': return my_name; case 'V': @@ -3329,7 +3329,7 @@ extern "C" char* job_code_callback_director(JobControlRecord* jcr, * If this is a migration/copy we need the volume name from the * mig_jcr. */ - if (jcr->impl_->mig_jcr) { jcr = jcr->impl_->mig_jcr; } + if (jcr->impl->mig_jcr) { jcr = jcr->impl->mig_jcr; } if (jcr->VolumeName) { return jcr->VolumeName; diff --git a/core/src/dird/expand.cc b/core/src/dird/expand.cc index 95e4095cad8..b84b5808547 100644 --- a/core/src/dird/expand.cc +++ b/core/src/dird/expand.cc @@ -94,7 +94,7 @@ static int job_item(JobControlRecord* jcr, switch (code) { case 1: /* Job */ - str = jcr->impl_->res.job->resource_name_; + str = jcr->impl->res.job->resource_name_; break; case 2: /* Director's name */ str = my_name; @@ -110,31 +110,31 @@ static int job_item(JobControlRecord* jcr, str = buf; break; case 6: /* Client */ - str = jcr->impl_->res.client->resource_name_; + str = jcr->impl->res.client->resource_name_; if (!str) { str = " "; } break; case 7: /* NumVols */ - Bsnprintf(buf, sizeof(buf), "%d", jcr->impl_->NumVols); + Bsnprintf(buf, sizeof(buf), "%d", jcr->impl->NumVols); str = buf; break; case 8: /* Pool */ - str = jcr->impl_->res.pool->resource_name_; + str = jcr->impl->res.pool->resource_name_; break; case 9: /* Storage */ - if (jcr->impl_->res.write_storage) { - str = jcr->impl_->res.write_storage->resource_name_; + if (jcr->impl->res.write_storage) { + str = jcr->impl->res.write_storage->resource_name_; } else { - str = jcr->impl_->res.read_storage->resource_name_; + str = jcr->impl->res.read_storage->resource_name_; } break; case 10: /* Catalog */ - str = jcr->impl_->res.catalog->resource_name_; + str = jcr->impl->res.catalog->resource_name_; break; case 11: /* MediaType */ - if (jcr->impl_->res.write_storage) { - str = jcr->impl_->res.write_storage->media_type; + if (jcr->impl->res.write_storage) { + str = jcr->impl->res.write_storage->media_type; } else { - str = jcr->impl_->res.read_storage->media_type; + str = jcr->impl->res.read_storage->media_type; } break; case 12: /* JobName */ diff --git a/core/src/dird/fd_cmds.cc b/core/src/dird/fd_cmds.cc index d3047d80a7a..021e0c50952 100644 --- a/core/src/dird/fd_cmds.cc +++ b/core/src/dird/fd_cmds.cc @@ -125,22 +125,22 @@ static bool connect_outbound_to_file_daemon(JobControlRecord* jcr, if (!IsConnectingToClientAllowed(jcr)) { Dmsg1(120, "connecting to client \"%s\" is not allowed.\n", - jcr->impl_->res.client->resource_name_); + jcr->impl->res.client->resource_name_); return false; } fd = new BareosSocketTCP; if (me->nokeepalive) { fd->ClearKeepalive(); } - heart_beat = get_heartbeat_interval(jcr->impl_->res.client); + heart_beat = get_heartbeat_interval(jcr->impl->res.client); char name[MAX_NAME_LENGTH + 100]; bstrncpy(name, _("Client: "), sizeof(name)); - bstrncat(name, jcr->impl_->res.client->resource_name_, sizeof(name)); + bstrncat(name, jcr->impl->res.client->resource_name_, sizeof(name)); fd->SetSourceAddress(me->DIRsrc_addr); if (!fd->connect(jcr, retry_interval, max_retry_time, heart_beat, name, - jcr->impl_->res.client->address, NULL, - jcr->impl_->res.client->FDport, verbose)) { + jcr->impl->res.client->address, NULL, + jcr->impl->res.client->FDport, verbose)) { delete fd; fd = NULL; jcr->setJobStatus(JS_ErrorTerminated); @@ -158,9 +158,9 @@ static void OutputMessageForConnectionTry(JobControlRecord* jcr, UaContext* ua) { std::string m; - if (jcr->impl_->res.client->connection_successful_handshake_ == + if (jcr->impl->res.client->connection_successful_handshake_ == ClientConnectionHandshakeMode::kUndefined || - jcr->impl_->res.client->connection_successful_handshake_ == + jcr->impl->res.client->connection_successful_handshake_ == ClientConnectionHandshakeMode::kFailed) { m = "Probing client protocol... (result will be saved until config reload)"; } else { @@ -188,12 +188,12 @@ static void SendInfoChosenCipher(JobControlRecord* jcr, UaContext* ua) static void SendInfoSuccess(JobControlRecord* jcr, UaContext* ua) { std::string m; - if (jcr->impl_->res.client->connection_successful_handshake_ == + if (jcr->impl->res.client->connection_successful_handshake_ == ClientConnectionHandshakeMode::kUndefined) { m += "\r\v"; } bool add_newline_in_joblog = false; - switch (jcr->impl_->connection_handshake_try_) { + switch (jcr->impl->connection_handshake_try_) { case ClientConnectionHandshakeMode::kTlsFirst: m += " Handshake: Immediate TLS,"; break; @@ -234,22 +234,22 @@ bool ConnectToFileDaemon(JobControlRecord* jcr, * in case there is a client that cannot do Tls immediately then * fall back to cleartext md5-handshake */ OutputMessageForConnectionTry(jcr, ua); - if (jcr->impl_->res.client->connection_successful_handshake_ == + if (jcr->impl->res.client->connection_successful_handshake_ == ClientConnectionHandshakeMode::kUndefined || - jcr->impl_->res.client->connection_successful_handshake_ == + jcr->impl->res.client->connection_successful_handshake_ == ClientConnectionHandshakeMode::kFailed) { - if (jcr->impl_->res.client->IsTlsConfigured()) { - jcr->impl_->connection_handshake_try_ = + if (jcr->impl->res.client->IsTlsConfigured()) { + jcr->impl->connection_handshake_try_ = ClientConnectionHandshakeMode::kTlsFirst; } else { - jcr->impl_->connection_handshake_try_ = + jcr->impl->connection_handshake_try_ = ClientConnectionHandshakeMode::kCleartextFirst; } jcr->is_passive_client_connection_probing = true; } else { /* if there is a stored mode from a previous connection then use this */ - jcr->impl_->connection_handshake_try_ = - jcr->impl_->res.client->connection_successful_handshake_; + jcr->impl->connection_handshake_try_ = + jcr->impl->res.client->connection_successful_handshake_; jcr->is_passive_client_connection_probing = false; } @@ -275,14 +275,14 @@ bool ConnectToFileDaemon(JobControlRecord* jcr, SendInfoSuccess(jcr, ua); SendInfoChosenCipher(jcr, ua); jcr->is_passive_client_connection_probing = false; - jcr->impl_->res.client->connection_successful_handshake_ = - jcr->impl_->connection_handshake_try_; + jcr->impl->res.client->connection_successful_handshake_ = + jcr->impl->connection_handshake_try_; } else { /* authentication failed due to * - tls mismatch or * - if an old client cannot do tls- before md5-handshake * */ - switch (jcr->impl_->connection_handshake_try_) { + switch (jcr->impl->connection_handshake_try_) { case ClientConnectionHandshakeMode::kTlsFirst: if (jcr->file_bsock) { jcr->file_bsock->close(); @@ -290,11 +290,11 @@ bool ConnectToFileDaemon(JobControlRecord* jcr, jcr->file_bsock = nullptr; } jcr->resetJobStatus(JS_Running); - jcr->impl_->connection_handshake_try_ = + jcr->impl->connection_handshake_try_ = ClientConnectionHandshakeMode::kCleartextFirst; break; case ClientConnectionHandshakeMode::kCleartextFirst: - jcr->impl_->connection_handshake_try_ = + jcr->impl->connection_handshake_try_ = ClientConnectionHandshakeMode::kFailed; break; case ClientConnectionHandshakeMode::kFailed: @@ -305,11 +305,11 @@ bool ConnectToFileDaemon(JobControlRecord* jcr, } } else { Jmsg(jcr, M_FATAL, 0, "\nFailed to connect to client \"%s\".\n", - jcr->impl_->res.client->resource_name_); + jcr->impl->res.client->resource_name_); } connect_tries--; } while (!tcp_connect_failed && connect_tries && !success && - jcr->impl_->connection_handshake_try_ != + jcr->impl->connection_handshake_try_ != ClientConnectionHandshakeMode::kFailed); if (!success) { jcr->setJobStatus(JS_ErrorTerminated); } @@ -323,7 +323,7 @@ int SendJobInfoToFileDaemon(JobControlRecord* jcr) if (jcr->sd_auth_key == NULL) { jcr->sd_auth_key = strdup("dummy"); } - if (jcr->impl_->res.client->connection_successful_handshake_ == + if (jcr->impl->res.client->connection_successful_handshake_ == ClientConnectionHandshakeMode::kTlsFirst) { /* client protocol onwards Bareos 18.2 */ TlsPolicy tls_policy = kBnetTlsUnknown; @@ -336,10 +336,10 @@ int SendJobInfoToFileDaemon(JobControlRecord* jcr) break; default: StorageResource* storage = nullptr; - if (jcr->impl_->res.write_storage) { - storage = jcr->impl_->res.write_storage; - } else if (jcr->impl_->res.read_storage) { - storage = jcr->impl_->res.read_storage; + if (jcr->impl->res.write_storage) { + storage = jcr->impl->res.write_storage; + } else if (jcr->impl->res.read_storage) { + storage = jcr->impl->res.read_storage; } else { Jmsg(jcr, M_FATAL, 0, _("No read or write storage defined\n")); jcr->setJobStatus(JS_ErrorTerminated); @@ -364,7 +364,7 @@ int SendJobInfoToFileDaemon(JobControlRecord* jcr) } /* if (jcr->impl_->res.client->connection_successful_handshake_ == ClientConnectionHandshakeMode::kTlsFirst) */ - if (!jcr->impl_->keep_sd_auth_key && !bstrcmp(jcr->sd_auth_key, "dummy")) { + if (!jcr->impl->keep_sd_auth_key && !bstrcmp(jcr->sd_auth_key, "dummy")) { memset(jcr->sd_auth_key, 0, strlen(jcr->sd_auth_key)); } @@ -373,17 +373,17 @@ int SendJobInfoToFileDaemon(JobControlRecord* jcr) Dmsg1(110, "msg); if (!bstrncmp(fd->msg, OKjob, strlen(OKjob))) { Jmsg(jcr, M_FATAL, 0, _("File daemon \"%s\" rejected Job command: %s\n"), - jcr->impl_->res.client->resource_name_, fd->msg); + jcr->impl->res.client->resource_name_, fd->msg); jcr->setJobStatus(JS_ErrorTerminated); return 0; } else if (jcr->db) { ClientDbRecord cr; - bstrncpy(cr.Name, jcr->impl_->res.client->resource_name_, + bstrncpy(cr.Name, jcr->impl->res.client->resource_name_, sizeof(cr.Name)); - cr.AutoPrune = jcr->impl_->res.client->AutoPrune; - cr.FileRetention = jcr->impl_->res.client->FileRetention; - cr.JobRetention = jcr->impl_->res.client->JobRetention; + cr.AutoPrune = jcr->impl->res.client->AutoPrune; + cr.FileRetention = jcr->impl->res.client->FileRetention; + cr.JobRetention = jcr->impl->res.client->JobRetention; bstrncpy(cr.Uname, fd->msg + strlen(OKjob) + 1, sizeof(cr.Uname)); if (!jcr->db->UpdateClientRecord(jcr, &cr)) { Jmsg(jcr, M_WARNING, 0, _("Error updating Client record. ERR=%s\n"), @@ -408,8 +408,8 @@ bool SendPreviousRestoreObjects(JobControlRecord* jcr) switch (JobLevel) { case L_DIFFERENTIAL: case L_INCREMENTAL: - if (jcr->impl_->previous_jr.JobId > 0) { - if (!SendRestoreObjects(jcr, jcr->impl_->previous_jr.JobId, false)) { + if (jcr->impl->previous_jr.JobId > 0) { + if (!SendRestoreObjects(jcr, jcr->impl->previous_jr.JobId, false)) { return false; } } @@ -425,7 +425,7 @@ bool SendBwlimitToFd(JobControlRecord* jcr, const char* Job) { BareosSocket* fd = jcr->file_bsock; - if (jcr->impl_->FDVersion >= FD_VERSION_4) { + if (jcr->impl->FDVersion >= FD_VERSION_4) { fd->fsend(bandwidthcmd, jcr->max_bandwidth, Job); if (!response(jcr, fd, OKBandwidth, "Bandwidth", DISPLAY_ERROR)) { jcr->max_bandwidth = 0; /* can't set bandwidth limit */ @@ -441,29 +441,29 @@ bool SendSecureEraseReqToFd(JobControlRecord* jcr) int32_t n; BareosSocket* fd = jcr->file_bsock; - if (!jcr->impl_->FDSecureEraseCmd) { - jcr->impl_->FDSecureEraseCmd = GetPoolMemory(PM_NAME); + if (!jcr->impl->FDSecureEraseCmd) { + jcr->impl->FDSecureEraseCmd = GetPoolMemory(PM_NAME); } - if (jcr->impl_->FDVersion > FD_VERSION_53) { + if (jcr->impl->FDVersion > FD_VERSION_53) { fd->fsend(getSecureEraseCmd); while ((n = BgetDirmsg(fd)) >= 0) { - jcr->impl_->FDSecureEraseCmd = - CheckPoolMemorySize(jcr->impl_->FDSecureEraseCmd, fd->message_length); - if (sscanf(fd->msg, OKgetSecureEraseCmd, jcr->impl_->FDSecureEraseCmd) == + jcr->impl->FDSecureEraseCmd = + CheckPoolMemorySize(jcr->impl->FDSecureEraseCmd, fd->message_length); + if (sscanf(fd->msg, OKgetSecureEraseCmd, jcr->impl->FDSecureEraseCmd) == 1) { Dmsg1(400, "Got FD Secure Erase Cmd: %s\n", - jcr->impl_->FDSecureEraseCmd); + jcr->impl->FDSecureEraseCmd); break; } else { Jmsg(jcr, M_WARNING, 0, _("Unexpected Client Secure Erase Cmd: %s\n"), fd->msg); - PmStrcpy(jcr->impl_->FDSecureEraseCmd, "*None*"); + PmStrcpy(jcr->impl->FDSecureEraseCmd, "*None*"); return false; } } } else { - PmStrcpy(jcr->impl_->FDSecureEraseCmd, "*None*"); + PmStrcpy(jcr->impl->FDSecureEraseCmd, "*None*"); } return true; @@ -477,7 +477,7 @@ static void SendSinceTime(JobControlRecord* jcr) stime = StrToUtime(jcr->stime); fd->fsend(levelcmd, "", NT_("since_utime "), edit_uint64(stime, ed1), 0, - NT_("prev_job="), jcr->impl_->PrevJob); + NT_("prev_job="), jcr->impl->PrevJob); while (BgetDirmsg(fd) >= 0) { /* allow him to poll us to sync clocks */ Jmsg(jcr, M_INFO, 0, "%s\n", fd->msg); @@ -538,9 +538,9 @@ bool SendLevelCommand(JobControlRecord* jcr) */ static bool SendFileset(JobControlRecord* jcr) { - FilesetResource* fileset = jcr->impl_->res.fileset; + FilesetResource* fileset = jcr->impl->res.fileset; BareosSocket* fd = jcr->file_bsock; - StorageResource* store = jcr->impl_->res.write_storage; + StorageResource* store = jcr->impl->res.write_storage; int num; bool include = true; @@ -783,8 +783,8 @@ static bool SendListItem(JobControlRecord* jcr, bool SendIncludeList(JobControlRecord* jcr) { BareosSocket* fd = jcr->file_bsock; - if (jcr->impl_->res.fileset->new_include) { - fd->fsend(filesetcmd, jcr->impl_->res.fileset->enable_vss ? " vss=1" : ""); + if (jcr->impl->res.fileset->new_include) { + fd->fsend(filesetcmd, jcr->impl->res.fileset->enable_vss ? " vss=1" : ""); return SendFileset(jcr); } return true; @@ -832,18 +832,18 @@ int SendRunscriptsCommands(JobControlRecord* jcr) /* * See if there are any runscripts that need to be ran on the client. */ - if (!HaveClientRunscripts(jcr->impl_->res.job->RunScripts)) { return 1; } + if (!HaveClientRunscripts(jcr->impl->res.job->RunScripts)) { return 1; } Dmsg0(120, "dird: sending runscripts to fd\n"); msg = GetPoolMemory(PM_FNAME); ehost = GetPoolMemory(PM_FNAME); - foreach_alist (cmd, jcr->impl_->res.job->RunScripts) { + foreach_alist (cmd, jcr->impl->res.job->RunScripts) { if (!cmd->target.empty()) { ehost = edit_job_codes(jcr, ehost, cmd->target.c_str(), ""); Dmsg2(200, "dird: runscript %s -> %s\n", cmd->target.c_str(), ehost); - if (bstrcmp(ehost, jcr->impl_->res.client->resource_name_)) { + if (bstrcmp(ehost, jcr->impl->res.client->resource_name_)) { PmStrcpy(msg, cmd->command.c_str()); BashSpaces(msg); @@ -917,15 +917,15 @@ static int RestoreObjectHandler(void* ctx, int num_fields, char** row) /* * Old File Daemon doesn't handle restore objects */ - if (jcr->impl_->FDVersion < FD_VERSION_3) { + if (jcr->impl->FDVersion < FD_VERSION_3) { Jmsg(jcr, M_WARNING, 0, _("Client \"%s\" may not be used to restore " "this job. Please upgrade your client.\n"), - jcr->impl_->res.client->resource_name_); + jcr->impl->res.client->resource_name_); return 1; } - if (jcr->impl_->FDVersion < + if (jcr->impl->FDVersion < FD_VERSION_5) { /* Old version without PluginName */ fd->fsend("restoreobject JobId=%s %s,%s,%s,%s,%s,%s\n", row[0], row[1], row[2], row[3], row[4], row[5], row[6]); @@ -973,9 +973,9 @@ bool SendPluginOptions(JobControlRecord* jcr) const char* plugin_options; POOLMEM* msg; - if (jcr->impl_->plugin_options) { + if (jcr->impl->plugin_options) { msg = GetPoolMemory(PM_FNAME); - PmStrcpy(msg, jcr->impl_->plugin_options); + PmStrcpy(msg, jcr->impl->plugin_options); BashSpaces(msg); fd->fsend(pluginoptionscmd, msg); @@ -986,11 +986,11 @@ bool SendPluginOptions(JobControlRecord* jcr) return false; } } - if (jcr->impl_->res.job && jcr->impl_->res.job->FdPluginOptions && - jcr->impl_->res.job->FdPluginOptions->size()) { + if (jcr->impl->res.job && jcr->impl->res.job->FdPluginOptions && + jcr->impl->res.job->FdPluginOptions->size()) { Dmsg2(200, "dird: sendpluginoptions found FdPluginOptions in res.job"); foreach_alist_index (i, plugin_options, - jcr->impl_->res.job->FdPluginOptions) { + jcr->impl->res.job->FdPluginOptions) { PmStrcpy(cur_plugin_options, plugin_options); BashSpaces(cur_plugin_options.c_str()); @@ -1093,8 +1093,8 @@ int GetAttributesAndPutInCatalog(JobControlRecord* jcr) PoolMem digest(PM_MESSAGE); fd = jcr->file_bsock; - jcr->impl_->jr.FirstIndex = 1; - jcr->impl_->FileIndex = 0; + jcr->impl->jr.FirstIndex = 1; + jcr->impl->FileIndex = 0; /* * Start transaction allocates jcr->attr and jcr->ar if needed @@ -1148,15 +1148,15 @@ int GetAttributesAndPutInCatalog(JobControlRecord* jcr) /* * Any cached attr is flushed so we can reuse jcr->attr and jcr->ar */ - fn = jcr->impl_->fname = - CheckPoolMemorySize(jcr->impl_->fname, fd->message_length); + fn = jcr->impl->fname = + CheckPoolMemorySize(jcr->impl->fname, fd->message_length); while (*p != 0) { *fn++ = *p++; /* copy filename */ } *fn = *p++; /* term filename and point p to attribs */ PmStrcpy(jcr->attr, p); /* save attributes */ jcr->JobFiles++; - jcr->impl_->FileIndex = file_index; + jcr->impl->FileIndex = file_index; ar->attr = jcr->attr; - ar->fname = jcr->impl_->fname; + ar->fname = jcr->impl->fname; ar->FileIndex = file_index; ar->Stream = stream; ar->link = NULL; @@ -1169,7 +1169,7 @@ int GetAttributesAndPutInCatalog(JobControlRecord* jcr) jcr->cached_attribute = true; Dmsg2(debuglevel, "dirdimpl_->fname); + jcr->impl->fname); Dmsg1(debuglevel, "dirdattr); jcr->FileId = ar->FileId; } else if (CryptoDigestStreamType(stream) != CRYPTO_DIGEST_NONE) { @@ -1181,9 +1181,9 @@ int GetAttributesAndPutInCatalog(JobControlRecord* jcr) * it (or not) When we get a new STREAM_UNIX_ATTRIBUTES, we known that we * can add file to the catalog At the end, we have to add the last file */ - if (jcr->impl_->FileIndex != (uint32_t)file_index) { + if (jcr->impl->FileIndex != (uint32_t)file_index) { Jmsg3(jcr, M_ERROR, 0, _("%s index %d not same as attributes %d\n"), - stream_to_ascii(stream), file_index, jcr->impl_->FileIndex); + stream_to_ascii(stream), file_index, jcr->impl->FileIndex); continue; } @@ -1195,8 +1195,8 @@ int GetAttributesAndPutInCatalog(JobControlRecord* jcr) Dmsg4(debuglevel, "stream=%d DigestLen=%d Digest=%s type=%d\n", stream, strlen(digest.c_str()), digest.c_str(), ar->DigestType); } - jcr->impl_->jr.JobFiles = jcr->JobFiles = file_index; - jcr->impl_->jr.LastIndex = file_index; + jcr->impl->jr.JobFiles = jcr->JobFiles = file_index; + jcr->impl->jr.LastIndex = file_index; } if (IsBnetError(fd)) { @@ -1228,7 +1228,7 @@ bool CancelFileDaemonJob(UaContext* ua, JobControlRecord* jcr) { BareosSocket* fd; - ua->jcr->impl_->res.client = jcr->impl_->res.client; + ua->jcr->impl->res.client = jcr->impl->res.client; if (!ConnectToFileDaemon(ua->jcr, 10, me->FDConnectTimeout, true, ua)) { ua->ErrorMsg(_("\nFailed to connect to File daemon.\n")); return false; @@ -1256,7 +1256,7 @@ void DoNativeClientStatus(UaContext* ua, ClientResource* client, char* cmd) /* * Connect to File daemon */ - ua->jcr->impl_->res.client = client; + ua->jcr->impl->res.client = client; /* * Try to connect for 15 seconds @@ -1305,7 +1305,7 @@ void DoClientResolve(UaContext* ua, ClientResource* client) /* * Connect to File daemon */ - ua->jcr->impl_->res.client = client; + ua->jcr->impl->res.client = client; /* * Try to connect for 15 seconds diff --git a/core/src/dird/getmsg.cc b/core/src/dird/getmsg.cc index 1887dfbd198..53a5e79678e 100644 --- a/core/src/dird/getmsg.cc +++ b/core/src/dird/getmsg.cc @@ -87,12 +87,12 @@ static void SetJcrSdJobStatus(JobControlRecord* jcr, int SDJobStatus) Dmsg0(800, "Setting wait_time\n"); jcr->wait_time = time(NULL); } - jcr->impl_->SDJobStatus = SDJobStatus; + jcr->impl->SDJobStatus = SDJobStatus; /* * Some SD Job status setting are propagated to the controlling Job. */ - switch (jcr->impl_->SDJobStatus) { + switch (jcr->impl->SDJobStatus) { case JS_Incomplete: jcr->setJobStatus(JS_Incomplete); break; diff --git a/core/src/dird/inc_conf.cc b/core/src/dird/inc_conf.cc index 75f24e28932..f98ef24039c 100644 --- a/core/src/dird/inc_conf.cc +++ b/core/src/dird/inc_conf.cc @@ -309,9 +309,9 @@ void FindUsedCompressalgos(PoolMem* compressalgos, JobControlRecord* jcr) FilesetResource* fs; struct s_fs_opt* fs_opt; - if (!jcr->impl_->res.job || !jcr->impl_->res.job->fileset) { return; } + if (!jcr->impl->res.job || !jcr->impl->res.job->fileset) { return; } - fs = jcr->impl_->res.job->fileset; + fs = jcr->impl->res.job->fileset; for (std::size_t i = 0; i < fs->include_items.size(); i++) { inc = fs->include_items[i]; diff --git a/core/src/dird/jcr_private.h b/core/src/dird/jcr_private.h index 1a8d2bb8127..d63587a5138 100644 --- a/core/src/dird/jcr_private.h +++ b/core/src/dird/jcr_private.h @@ -40,10 +40,10 @@ class CatalogResource; jcr->JobStatus == JS_WaitStoreRes || jcr->JobStatus == JS_WaitJobRes || \ jcr->JobStatus == JS_WaitClientRes || jcr->JobStatus == JS_WaitMaxJobs || \ jcr->JobStatus == JS_WaitPriority || \ - jcr->impl_->SDJobStatus == JS_WaitMedia || \ - jcr->impl_->SDJobStatus == JS_WaitMount || \ - jcr->impl_->SDJobStatus == JS_WaitDevice || \ - jcr->impl_->SDJobStatus == JS_WaitMaxJobs)) + jcr->impl->SDJobStatus == JS_WaitMedia || \ + jcr->impl->SDJobStatus == JS_WaitMount || \ + jcr->impl->SDJobStatus == JS_WaitDevice || \ + jcr->impl->SDJobStatus == JS_WaitMaxJobs)) /* clang-format off */ struct Resources { diff --git a/core/src/dird/job.cc b/core/src/dird/job.cc index 7ecc410e6bf..335d7f91bbe 100644 --- a/core/src/dird/job.cc +++ b/core/src/dird/job.cc @@ -146,7 +146,7 @@ bool SetupJob(JobControlRecord* jcr, bool suppress_output) * See if we should suppress all output. */ if (!suppress_output) { - InitMsg(jcr, jcr->impl_->res.messages, job_code_callback_director); + InitMsg(jcr, jcr->impl->res.messages, job_code_callback_director); } else { jcr->suppress_output = true; } @@ -154,19 +154,19 @@ bool SetupJob(JobControlRecord* jcr, bool suppress_output) /* * Initialize termination condition variable */ - if ((errstat = pthread_cond_init(&jcr->impl_->term_wait, NULL)) != 0) { + if ((errstat = pthread_cond_init(&jcr->impl->term_wait, NULL)) != 0) { BErrNo be; Jmsg1(jcr, M_FATAL, 0, _("Unable to init job cond variable: ERR=%s\n"), be.bstrerror(errstat)); jcr->unlock(); goto bail_out; } - jcr->impl_->term_wait_inited = true; + jcr->impl->term_wait_inited = true; /* * Initialize nextrun ready condition variable */ - if ((errstat = pthread_cond_init(&jcr->impl_->nextrun_ready, NULL)) != 0) { + if ((errstat = pthread_cond_init(&jcr->impl->nextrun_ready, NULL)) != 0) { BErrNo be; Jmsg1(jcr, M_FATAL, 0, _("Unable to init job nextrun cond variable: ERR=%s\n"), @@ -174,9 +174,9 @@ bool SetupJob(JobControlRecord* jcr, bool suppress_output) jcr->unlock(); goto bail_out; } - jcr->impl_->nextrun_ready_inited = true; + jcr->impl->nextrun_ready_inited = true; - CreateUniqueJobName(jcr, jcr->impl_->res.job->resource_name_); + CreateUniqueJobName(jcr, jcr->impl->res.job->resource_name_); jcr->setJobStatus(JS_Created); jcr->unlock(); @@ -185,37 +185,37 @@ bool SetupJob(JobControlRecord* jcr, bool suppress_output) */ Dmsg0(100, "Open database\n"); jcr->db = DbSqlGetPooledConnection( - jcr, jcr->impl_->res.catalog->db_driver, jcr->impl_->res.catalog->db_name, - jcr->impl_->res.catalog->db_user, - jcr->impl_->res.catalog->db_password.value, - jcr->impl_->res.catalog->db_address, jcr->impl_->res.catalog->db_port, - jcr->impl_->res.catalog->db_socket, - jcr->impl_->res.catalog->mult_db_connections, - jcr->impl_->res.catalog->disable_batch_insert, - jcr->impl_->res.catalog->try_reconnect, - jcr->impl_->res.catalog->exit_on_fatal); + jcr, jcr->impl->res.catalog->db_driver, jcr->impl->res.catalog->db_name, + jcr->impl->res.catalog->db_user, + jcr->impl->res.catalog->db_password.value, + jcr->impl->res.catalog->db_address, jcr->impl->res.catalog->db_port, + jcr->impl->res.catalog->db_socket, + jcr->impl->res.catalog->mult_db_connections, + jcr->impl->res.catalog->disable_batch_insert, + jcr->impl->res.catalog->try_reconnect, + jcr->impl->res.catalog->exit_on_fatal); if (jcr->db == NULL) { Jmsg(jcr, M_FATAL, 0, _("Could not open database \"%s\".\n"), - jcr->impl_->res.catalog->db_name); + jcr->impl->res.catalog->db_name); goto bail_out; } Dmsg0(150, "DB opened\n"); - if (!jcr->impl_->fname) { jcr->impl_->fname = GetPoolMemory(PM_FNAME); } + if (!jcr->impl->fname) { jcr->impl->fname = GetPoolMemory(PM_FNAME); } - if (!jcr->impl_->res.pool_source) { - jcr->impl_->res.pool_source = GetPoolMemory(PM_MESSAGE); - PmStrcpy(jcr->impl_->res.pool_source, _("unknown source")); + if (!jcr->impl->res.pool_source) { + jcr->impl->res.pool_source = GetPoolMemory(PM_MESSAGE); + PmStrcpy(jcr->impl->res.pool_source, _("unknown source")); } - if (!jcr->impl_->res.npool_source) { - jcr->impl_->res.npool_source = GetPoolMemory(PM_MESSAGE); - PmStrcpy(jcr->impl_->res.npool_source, _("unknown source")); + if (!jcr->impl->res.npool_source) { + jcr->impl->res.npool_source = GetPoolMemory(PM_MESSAGE); + PmStrcpy(jcr->impl->res.npool_source, _("unknown source")); } if (jcr->JobReads()) { - if (!jcr->impl_->res.rpool_source) { - jcr->impl_->res.rpool_source = GetPoolMemory(PM_MESSAGE); - PmStrcpy(jcr->impl_->res.rpool_source, _("unknown source")); + if (!jcr->impl->res.rpool_source) { + jcr->impl->res.rpool_source = GetPoolMemory(PM_MESSAGE); + PmStrcpy(jcr->impl->res.rpool_source, _("unknown source")); } } @@ -224,18 +224,18 @@ bool SetupJob(JobControlRecord* jcr, bool suppress_output) */ InitJcrJobRecord(jcr); - if (jcr->impl_->res.client) { + if (jcr->impl->res.client) { if (!GetOrCreateClientRecord(jcr)) { goto bail_out; } } - if (!jcr->db->CreateJobRecord(jcr, &jcr->impl_->jr)) { + if (!jcr->db->CreateJobRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); goto bail_out; } - jcr->JobId = jcr->impl_->jr.JobId; + jcr->JobId = jcr->impl->jr.JobId; Dmsg4(100, "Created job record JobId=%d Name=%s Type=%c Level=%c\n", - jcr->JobId, jcr->Job, jcr->impl_->jr.JobType, jcr->impl_->jr.JobLevel); + jcr->JobId, jcr->Job, jcr->impl->jr.JobType, jcr->impl->jr.JobLevel); NewPlugins(jcr); /* instantiate plugins for this jcr */ DispatchNewPluginOptions(jcr); @@ -243,11 +243,11 @@ bool SetupJob(JobControlRecord* jcr, bool suppress_output) if (JobCanceled(jcr)) { goto bail_out; } - if (jcr->JobReads() && !jcr->impl_->res.read_storage_list) { - if (jcr->impl_->res.job->storage) { - CopyRwstorage(jcr, jcr->impl_->res.job->storage, _("Job resource")); + if (jcr->JobReads() && !jcr->impl->res.read_storage_list) { + if (jcr->impl->res.job->storage) { + CopyRwstorage(jcr, jcr->impl->res.job->storage, _("Job resource")); } else { - CopyRwstorage(jcr, jcr->impl_->res.job->pool->storage, + CopyRwstorage(jcr, jcr->impl->res.job->pool->storage, _("Pool resource")); } } @@ -328,9 +328,9 @@ bool SetupJob(JobControlRecord* jcr, bool suppress_output) * Any non NDMP restore is not interested at the items * that were selected for restore so drop them now. */ - if (jcr->impl_->restore_tree_root) { - FreeTree(jcr->impl_->restore_tree_root); - jcr->impl_->restore_tree_root = NULL; + if (jcr->impl->restore_tree_root) { + FreeTree(jcr->impl->restore_tree_root); + jcr->impl->restore_tree_root = NULL; } if (!DoNativeRestoreInit(jcr)) { NativeRestoreCleanup(jcr, JS_ErrorTerminated); @@ -402,7 +402,7 @@ bool IsConnectingToClientAllowed(ClientResource* res) bool IsConnectingToClientAllowed(JobControlRecord* jcr) { - return IsConnectingToClientAllowed(jcr->impl_->res.client); + return IsConnectingToClientAllowed(jcr->impl->res.client); } bool IsConnectFromClientAllowed(ClientResource* res) @@ -412,7 +412,7 @@ bool IsConnectFromClientAllowed(ClientResource* res) bool IsConnectFromClientAllowed(JobControlRecord* jcr) { - return IsConnectFromClientAllowed(jcr->impl_->res.client); + return IsConnectFromClientAllowed(jcr->impl->res.client); } bool UseWaitingClient(JobControlRecord* jcr, int timeout) @@ -423,17 +423,17 @@ bool UseWaitingClient(JobControlRecord* jcr, int timeout) if (!IsConnectFromClientAllowed(jcr)) { Dmsg1(120, "Client Initiated Connection from \"%s\" is not allowed.\n", - jcr->impl_->res.client->resource_name_); + jcr->impl->res.client->resource_name_); } else { connection = - connections->remove(jcr->impl_->res.client->resource_name_, timeout); + connections->remove(jcr->impl->res.client->resource_name_, timeout); if (connection) { jcr->file_bsock = connection->bsock(); - jcr->impl_->FDVersion = connection->protocol_version(); + jcr->impl->FDVersion = connection->protocol_version(); jcr->authenticated = connection->authenticated(); delete (connection); Jmsg(jcr, M_INFO, 0, _("Using Client Initiated Connection (%s).\n"), - jcr->impl_->res.client->resource_name_); + jcr->impl->res.client->resource_name_); result = true; } } @@ -464,15 +464,15 @@ static void* job_thread(void* arg) Dmsg0(200, "=====Start Job=========\n"); jcr->setJobStatus(JS_Running); /* this will be set only if no error */ jcr->start_time = time(NULL); /* set the real start time */ - jcr->impl_->jr.StartTime = jcr->start_time; + jcr->impl->jr.StartTime = jcr->start_time; /* * Let the statistics subsystem know a new Job was started. */ stats_job_started(); - if (jcr->impl_->res.job->MaxStartDelay != 0 && - jcr->impl_->res.job->MaxStartDelay < + if (jcr->impl->res.job->MaxStartDelay != 0 && + jcr->impl->res.job->MaxStartDelay < (utime_t)(jcr->start_time - jcr->sched_time)) { jcr->setJobStatus(JS_Canceled); Jmsg(jcr, M_FATAL, 0, @@ -488,19 +488,19 @@ static void* job_thread(void* arg) /* * TODO : check if it is used somewhere */ - if (jcr->impl_->res.job->RunScripts == NULL) { + if (jcr->impl->res.job->RunScripts == NULL) { Dmsg0(200, "Warning, job->RunScripts is empty\n"); - jcr->impl_->res.job->RunScripts = new alist(10, not_owned_by_alist); + jcr->impl->res.job->RunScripts = new alist(10, not_owned_by_alist); } - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); } /* * Run any script BeforeJob on dird */ - RunScripts(jcr, jcr->impl_->res.job->RunScripts, "BeforeJob"); + RunScripts(jcr, jcr->impl->res.job->RunScripts, "BeforeJob"); /* * We re-update the job start record so that the start time is set after the @@ -512,8 +512,8 @@ static void* job_thread(void* arg) * because in that case, their date is after the start of this run. */ jcr->start_time = time(NULL); - jcr->impl_->jr.StartTime = jcr->start_time; - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { + jcr->impl->jr.StartTime = jcr->start_time; + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); } @@ -675,7 +675,7 @@ static void* job_thread(void* arg) me->subscriptions_used, me->subscriptions); } - RunScripts(jcr, jcr->impl_->res.job->RunScripts, "AfterJob"); + RunScripts(jcr, jcr->impl->res.job->RunScripts, "AfterJob"); /* * Send off any queued messages @@ -691,10 +691,10 @@ static void* job_thread(void* arg) void SdMsgThreadSendSignal(JobControlRecord* jcr, int sig) { jcr->lock(); - if (!jcr->impl_->sd_msg_thread_done && jcr->impl_->SD_msg_chan_started && - !pthread_equal(jcr->impl_->SD_msg_chan, pthread_self())) { + if (!jcr->impl->sd_msg_thread_done && jcr->impl->SD_msg_chan_started && + !pthread_equal(jcr->impl->SD_msg_chan, pthread_self())) { Dmsg1(800, "Send kill to SD msg chan jid=%d\n", jcr->JobId); - pthread_kill(jcr->impl_->SD_msg_chan, sig); + pthread_kill(jcr->impl->SD_msg_chan, sig); } jcr->unlock(); } @@ -744,14 +744,14 @@ bool CancelJob(UaContext* ua, JobControlRecord* jcr) /* * Cancel second Storage daemon for SD-SD replication. */ - if (jcr->impl_->mig_jcr && jcr->impl_->mig_jcr->store_bsock) { - if (!CancelStorageDaemonJob(ua, jcr->impl_->mig_jcr)) { return false; } + if (jcr->impl->mig_jcr && jcr->impl->mig_jcr->store_bsock) { + if (!CancelStorageDaemonJob(ua, jcr->impl->mig_jcr)) { return false; } } break; } - RunScripts(jcr, jcr->impl_->res.job->RunScripts, "AfterJob"); + RunScripts(jcr, jcr->impl->res.job->RunScripts, "AfterJob"); return true; } @@ -774,7 +774,7 @@ static void JobMonitorWatchdog(watchdog_t* self) foreach_jcr (jcr) { bool cancel = false; - if (jcr->JobId == 0 || JobCanceled(jcr) || jcr->impl_->no_maxtime) { + if (jcr->JobId == 0 || JobCanceled(jcr) || jcr->impl->no_maxtime) { Dmsg2(800, "Skipping JobControlRecord=%p Job=%s\n", jcr, jcr->Job); continue; } @@ -818,7 +818,7 @@ static void JobMonitorWatchdog(watchdog_t* self) static bool JobCheckMaxwaittime(JobControlRecord* jcr) { bool cancel = false; - JobResource* job = jcr->impl_->res.job; + JobResource* job = jcr->impl->res.job; utime_t current = 0; if (!JobWaiting(jcr)) { return false; } @@ -842,7 +842,7 @@ static bool JobCheckMaxwaittime(JobControlRecord* jcr) static bool JobCheckMaxruntime(JobControlRecord* jcr) { bool cancel = false; - JobResource* job = jcr->impl_->res.job; + JobResource* job = jcr->impl->res.job; utime_t run_time; if (JobCanceled(jcr) || !jcr->job_started) { return false; } @@ -881,10 +881,10 @@ static bool JobCheckMaxruntime(JobControlRecord* jcr) */ static bool JobCheckMaxrunschedtime(JobControlRecord* jcr) { - if (jcr->impl_->MaxRunSchedTime == 0 || JobCanceled(jcr)) { return false; } - if ((watchdog_time - jcr->initial_sched_time) < jcr->impl_->MaxRunSchedTime) { + if (jcr->impl->MaxRunSchedTime == 0 || JobCanceled(jcr)) { return false; } + if ((watchdog_time - jcr->initial_sched_time) < jcr->impl->MaxRunSchedTime) { Dmsg3(200, "Job %p (%s) with MaxRunSchedTime %d not expired\n", jcr, - jcr->Job, jcr->impl_->MaxRunSchedTime); + jcr->Job, jcr->impl->MaxRunSchedTime); return false; } @@ -905,7 +905,7 @@ DBId_t GetOrCreatePoolRecord(JobControlRecord* jcr, char* pool_name) while (!jcr->db->GetPoolRecord(jcr, &pr)) { /* get by Name */ /* Try to create the pool */ - if (CreatePool(jcr, jcr->db, jcr->impl_->res.pool, POOL_OP_CREATE) < 0) { + if (CreatePool(jcr, jcr->db, jcr->impl->res.pool, POOL_OP_CREATE) < 0) { Jmsg(jcr, M_FATAL, 0, _("Pool \"%s\" not in database. ERR=%s"), pr.Name, jcr->db->strerror()); return 0; @@ -925,7 +925,7 @@ DBId_t GetOrCreatePoolRecord(JobControlRecord* jcr, char* pool_name) bool AllowDuplicateJob(JobControlRecord* jcr) { JobControlRecord* djcr; /* possible duplicate job */ - JobResource* job = jcr->impl_->res.job; + JobResource* job = jcr->impl->res.job; bool cancel_dup = false; bool cancel_me = false; @@ -933,7 +933,7 @@ bool AllowDuplicateJob(JobControlRecord* jcr) * See if AllowDuplicateJobs is set or * if duplicate checking is disabled for this job. */ - if (job->AllowDuplicateJobs || jcr->impl_->IgnoreDuplicateJobChecking) { + if (job->AllowDuplicateJobs || jcr->impl->IgnoreDuplicateJobChecking) { return true; } @@ -953,9 +953,9 @@ bool AllowDuplicateJob(JobControlRecord* jcr) * See if this Job has the IgnoreDuplicateJobChecking flag set, ignore it * for any checking against other jobs. */ - if (djcr->impl_->IgnoreDuplicateJobChecking) { continue; } + if (djcr->impl->IgnoreDuplicateJobChecking) { continue; } - if (bstrcmp(job->resource_name_, djcr->impl_->res.job->resource_name_)) { + if (bstrcmp(job->resource_name_, djcr->impl->res.job->resource_name_)) { if (job->DuplicateJobProximity > 0) { utime_t now = (utime_t)time(NULL); if ((now - djcr->start_time) > job->DuplicateJobProximity) { @@ -1067,14 +1067,14 @@ bool GetLevelSinceTime(JobControlRecord* jcr) utime_t last_diff_time; char prev_job[MAX_NAME_LENGTH]; - jcr->impl_->since[0] = 0; + jcr->impl->since[0] = 0; /* * If job cloned and a since time already given, use it */ - if (jcr->impl_->cloned && jcr->stime && jcr->stime[0]) { - bstrncpy(jcr->impl_->since, _(", since="), sizeof(jcr->impl_->since)); - bstrncat(jcr->impl_->since, jcr->stime, sizeof(jcr->impl_->since)); + if (jcr->impl->cloned && jcr->stime && jcr->stime[0]) { + bstrncpy(jcr->impl->since, _(", since="), sizeof(jcr->impl->since)); + bstrncat(jcr->impl->since, jcr->stime, sizeof(jcr->impl->since)); return pool_updated; } @@ -1082,7 +1082,7 @@ bool GetLevelSinceTime(JobControlRecord* jcr) * Make sure stime buffer is allocated */ if (!jcr->stime) { jcr->stime = GetPoolMemory(PM_MESSAGE); } - jcr->impl_->PrevJob[0] = 0; + jcr->impl->PrevJob[0] = 0; jcr->stime[0] = 0; /* @@ -1099,18 +1099,18 @@ bool GetLevelSinceTime(JobControlRecord* jcr) * Look up start time of last Full job */ now = (utime_t)time(NULL); - jcr->impl_->jr.JobId = 0; /* flag to return since time */ + jcr->impl->jr.JobId = 0; /* flag to return since time */ /* * This is probably redundant, but some of the code below * uses jcr->stime, so don't remove unless you are sure. */ - if (!jcr->db->FindJobStartTime(jcr, &jcr->impl_->jr, jcr->stime, - jcr->impl_->PrevJob)) { + if (!jcr->db->FindJobStartTime(jcr, &jcr->impl->jr, jcr->stime, + jcr->impl->PrevJob)) { do_full = true; } - have_full = jcr->db->FindLastJobStartTime(jcr, &jcr->impl_->jr, stime, + have_full = jcr->db->FindLastJobStartTime(jcr, &jcr->impl->jr, stime, prev_job, L_FULL); if (have_full) { last_full_time = StrToUtime(stime); @@ -1125,11 +1125,11 @@ bool GetLevelSinceTime(JobControlRecord* jcr) * Make sure the last diff is recent enough */ if (have_full && JobLevel == L_INCREMENTAL && - jcr->impl_->res.job->MaxDiffInterval > 0) { + jcr->impl->res.job->MaxDiffInterval > 0) { /* * Lookup last diff job */ - if (jcr->db->FindLastJobStartTime(jcr, &jcr->impl_->jr, stime, prev_job, + if (jcr->db->FindLastJobStartTime(jcr, &jcr->impl->jr, stime, prev_job, L_DIFFERENTIAL)) { last_diff_time = StrToUtime(stime); /* @@ -1149,20 +1149,20 @@ bool GetLevelSinceTime(JobControlRecord* jcr) last_full_time); } do_diff = - ((now - last_diff_time) >= jcr->impl_->res.job->MaxDiffInterval); + ((now - last_diff_time) >= jcr->impl->res.job->MaxDiffInterval); Dmsg2(50, "do_diff=%d diffInter=%lld\n", do_diff, - jcr->impl_->res.job->MaxDiffInterval); + jcr->impl->res.job->MaxDiffInterval); } /* * Note, do_full takes precedence over do_vfull and do_diff */ - if (have_full && jcr->impl_->res.job->MaxFullInterval > 0) { + if (have_full && jcr->impl->res.job->MaxFullInterval > 0) { do_full = - ((now - last_full_time) >= jcr->impl_->res.job->MaxFullInterval); - } else if (have_full && jcr->impl_->res.job->MaxVFullInterval > 0) { + ((now - last_full_time) >= jcr->impl->res.job->MaxFullInterval); + } else if (have_full && jcr->impl->res.job->MaxVFullInterval > 0) { do_vfull = - ((now - last_full_time) >= jcr->impl_->res.job->MaxVFullInterval); + ((now - last_full_time) >= jcr->impl->res.job->MaxVFullInterval); } FreePoolMemory(stime); @@ -1174,9 +1174,9 @@ bool GetLevelSinceTime(JobControlRecord* jcr) Jmsg(jcr, M_INFO, 0, _("No prior or suitable Full backup found in catalog. Doing FULL " "backup.\n")); - Bsnprintf(jcr->impl_->since, sizeof(jcr->impl_->since), + Bsnprintf(jcr->impl->since, sizeof(jcr->impl->since), _(" (upgraded from %s)"), JobLevelToString(JobLevel)); - jcr->setJobLevel(jcr->impl_->jr.JobLevel = L_FULL); + jcr->setJobLevel(jcr->impl->jr.JobLevel = L_FULL); pool_updated = true; } else if (do_vfull) { /* @@ -1187,19 +1187,19 @@ bool GetLevelSinceTime(JobControlRecord* jcr) Jmsg(jcr, M_INFO, 0, _("No prior or suitable Full backup found in catalog. Doing " "Virtual FULL backup.\n")); - Bsnprintf(jcr->impl_->since, sizeof(jcr->impl_->since), + Bsnprintf(jcr->impl->since, sizeof(jcr->impl->since), _(" (upgraded from %s)"), JobLevelToString(jcr->getJobLevel())); - jcr->setJobLevel(jcr->impl_->jr.JobLevel = L_VIRTUAL_FULL); + jcr->setJobLevel(jcr->impl->jr.JobLevel = L_VIRTUAL_FULL); pool_updated = true; /* * If we get upgraded to a Virtual Full we will be using a read pool so * make sure we have a rpool_source. */ - if (!jcr->impl_->res.rpool_source) { - jcr->impl_->res.rpool_source = GetPoolMemory(PM_MESSAGE); - PmStrcpy(jcr->impl_->res.rpool_source, _("unknown source")); + if (!jcr->impl->res.rpool_source) { + jcr->impl->res.rpool_source = GetPoolMemory(PM_MESSAGE); + PmStrcpy(jcr->impl->res.rpool_source, _("unknown source")); } } else if (do_diff) { /* @@ -1208,39 +1208,39 @@ bool GetLevelSinceTime(JobControlRecord* jcr) Jmsg(jcr, M_INFO, 0, _("No prior or suitable Differential backup found in catalog. " "Doing Differential backup.\n")); - Bsnprintf(jcr->impl_->since, sizeof(jcr->impl_->since), + Bsnprintf(jcr->impl->since, sizeof(jcr->impl->since), _(" (upgraded from %s)"), JobLevelToString(JobLevel)); - jcr->setJobLevel(jcr->impl_->jr.JobLevel = L_DIFFERENTIAL); + jcr->setJobLevel(jcr->impl->jr.JobLevel = L_DIFFERENTIAL); pool_updated = true; } else { - if (jcr->impl_->res.job->rerun_failed_levels) { - if (jcr->db->FindFailedJobSince(jcr, &jcr->impl_->jr, jcr->stime, + if (jcr->impl->res.job->rerun_failed_levels) { + if (jcr->db->FindFailedJobSince(jcr, &jcr->impl->jr, jcr->stime, JobLevel)) { Jmsg(jcr, M_INFO, 0, _("Prior failed job found in catalog. Upgrading to %s.\n"), JobLevelToString(JobLevel)); - Bsnprintf(jcr->impl_->since, sizeof(jcr->impl_->since), + Bsnprintf(jcr->impl->since, sizeof(jcr->impl->since), _(" (upgraded from %s)"), JobLevelToString(JobLevel)); - jcr->setJobLevel(jcr->impl_->jr.JobLevel = JobLevel); - jcr->impl_->jr.JobId = jcr->JobId; + jcr->setJobLevel(jcr->impl->jr.JobLevel = JobLevel); + jcr->impl->jr.JobId = jcr->JobId; pool_updated = true; break; } } - bstrncpy(jcr->impl_->since, _(", since="), sizeof(jcr->impl_->since)); - bstrncat(jcr->impl_->since, jcr->stime, sizeof(jcr->impl_->since)); + bstrncpy(jcr->impl->since, _(", since="), sizeof(jcr->impl->since)); + bstrncat(jcr->impl->since, jcr->stime, sizeof(jcr->impl->since)); } - jcr->impl_->jr.JobId = jcr->JobId; + jcr->impl->jr.JobId = jcr->JobId; /* * Lookup the Job record of the previous Job and store it in * jcr->impl_->previous_jr. */ - if (jcr->impl_->PrevJob[0]) { - bstrncpy(jcr->impl_->previous_jr.Job, jcr->impl_->PrevJob, - sizeof(jcr->impl_->previous_jr.Job)); - if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->previous_jr)) { + if (jcr->impl->PrevJob[0]) { + bstrncpy(jcr->impl->previous_jr.Job, jcr->impl->PrevJob, + sizeof(jcr->impl->previous_jr.Job)); + if (!jcr->db->GetJobRecord(jcr, &jcr->impl->previous_jr)) { Jmsg(jcr, M_FATAL, 0, _("Could not get job record for previous Job. ERR=%s"), jcr->db->strerror()); @@ -1251,7 +1251,7 @@ bool GetLevelSinceTime(JobControlRecord* jcr) } Dmsg3(100, "Level=%c last start time=%s job=%s\n", JobLevel, jcr->stime, - jcr->impl_->PrevJob); + jcr->impl->PrevJob); return pool_updated; } @@ -1265,89 +1265,89 @@ void ApplyPoolOverrides(JobControlRecord* jcr, bool force) * If a cmdline pool override is given ignore any level pool overrides. * Unless a force is given then we always apply any overrides. */ - if (!force && jcr->impl_->IgnoreLevelPoolOverides) { return; } + if (!force && jcr->impl->IgnoreLevelPoolOverides) { return; } /* * If only a pool override and no level overrides are given in run entry * choose this pool */ - if (jcr->impl_->res.run_pool_override && - !jcr->impl_->res.run_full_pool_override && - !jcr->impl_->res.run_vfull_pool_override && - !jcr->impl_->res.run_inc_pool_override && - !jcr->impl_->res.run_diff_pool_override) { - PmStrcpy(jcr->impl_->res.pool_source, _("Run Pool override")); + if (jcr->impl->res.run_pool_override && + !jcr->impl->res.run_full_pool_override && + !jcr->impl->res.run_vfull_pool_override && + !jcr->impl->res.run_inc_pool_override && + !jcr->impl->res.run_diff_pool_override) { + PmStrcpy(jcr->impl->res.pool_source, _("Run Pool override")); Dmsg2(100, "Pool set to '%s' because of %s", - jcr->impl_->res.pool->resource_name_, _("Run Pool override\n")); + jcr->impl->res.pool->resource_name_, _("Run Pool override\n")); } else { /* * Apply any level related Pool selections */ switch (jcr->getJobLevel()) { case L_FULL: - if (jcr->impl_->res.full_pool) { - jcr->impl_->res.pool = jcr->impl_->res.full_pool; + if (jcr->impl->res.full_pool) { + jcr->impl->res.pool = jcr->impl->res.full_pool; pool_override = true; - if (jcr->impl_->res.run_full_pool_override) { - PmStrcpy(jcr->impl_->res.pool_source, _("Run FullPool override")); + if (jcr->impl->res.run_full_pool_override) { + PmStrcpy(jcr->impl->res.pool_source, _("Run FullPool override")); Dmsg2(100, "Pool set to '%s' because of %s", - jcr->impl_->res.full_pool->resource_name_, + jcr->impl->res.full_pool->resource_name_, "Run FullPool override\n"); } else { - PmStrcpy(jcr->impl_->res.pool_source, _("Job FullPool override")); + PmStrcpy(jcr->impl->res.pool_source, _("Job FullPool override")); Dmsg2(100, "Pool set to '%s' because of %s", - jcr->impl_->res.full_pool->resource_name_, + jcr->impl->res.full_pool->resource_name_, "Job FullPool override\n"); } } break; case L_VIRTUAL_FULL: - if (jcr->impl_->res.vfull_pool) { - jcr->impl_->res.pool = jcr->impl_->res.vfull_pool; + if (jcr->impl->res.vfull_pool) { + jcr->impl->res.pool = jcr->impl->res.vfull_pool; pool_override = true; - if (jcr->impl_->res.run_vfull_pool_override) { - PmStrcpy(jcr->impl_->res.pool_source, _("Run VFullPool override")); + if (jcr->impl->res.run_vfull_pool_override) { + PmStrcpy(jcr->impl->res.pool_source, _("Run VFullPool override")); Dmsg2(100, "Pool set to '%s' because of %s", - jcr->impl_->res.vfull_pool->resource_name_, + jcr->impl->res.vfull_pool->resource_name_, "Run VFullPool override\n"); } else { - PmStrcpy(jcr->impl_->res.pool_source, _("Job VFullPool override")); + PmStrcpy(jcr->impl->res.pool_source, _("Job VFullPool override")); Dmsg2(100, "Pool set to '%s' because of %s", - jcr->impl_->res.vfull_pool->resource_name_, + jcr->impl->res.vfull_pool->resource_name_, "Job VFullPool override\n"); } } break; case L_INCREMENTAL: - if (jcr->impl_->res.inc_pool) { - jcr->impl_->res.pool = jcr->impl_->res.inc_pool; + if (jcr->impl->res.inc_pool) { + jcr->impl->res.pool = jcr->impl->res.inc_pool; pool_override = true; - if (jcr->impl_->res.run_inc_pool_override) { - PmStrcpy(jcr->impl_->res.pool_source, _("Run IncPool override")); + if (jcr->impl->res.run_inc_pool_override) { + PmStrcpy(jcr->impl->res.pool_source, _("Run IncPool override")); Dmsg2(100, "Pool set to '%s' because of %s", - jcr->impl_->res.inc_pool->resource_name_, + jcr->impl->res.inc_pool->resource_name_, "Run IncPool override\n"); } else { - PmStrcpy(jcr->impl_->res.pool_source, _("Job IncPool override")); + PmStrcpy(jcr->impl->res.pool_source, _("Job IncPool override")); Dmsg2(100, "Pool set to '%s' because of %s", - jcr->impl_->res.inc_pool->resource_name_, + jcr->impl->res.inc_pool->resource_name_, "Job IncPool override\n"); } } break; case L_DIFFERENTIAL: - if (jcr->impl_->res.diff_pool) { - jcr->impl_->res.pool = jcr->impl_->res.diff_pool; + if (jcr->impl->res.diff_pool) { + jcr->impl->res.pool = jcr->impl->res.diff_pool; pool_override = true; - if (jcr->impl_->res.run_diff_pool_override) { - PmStrcpy(jcr->impl_->res.pool_source, _("Run DiffPool override")); + if (jcr->impl->res.run_diff_pool_override) { + PmStrcpy(jcr->impl->res.pool_source, _("Run DiffPool override")); Dmsg2(100, "Pool set to '%s' because of %s", - jcr->impl_->res.diff_pool->resource_name_, + jcr->impl->res.diff_pool->resource_name_, "Run DiffPool override\n"); } else { - PmStrcpy(jcr->impl_->res.pool_source, _("Job DiffPool override")); + PmStrcpy(jcr->impl->res.pool_source, _("Job DiffPool override")); Dmsg2(100, "Pool set to '%s' because of %s", - jcr->impl_->res.diff_pool->resource_name_, + jcr->impl->res.diff_pool->resource_name_, "Job DiffPool override\n"); } } @@ -1358,9 +1358,9 @@ void ApplyPoolOverrides(JobControlRecord* jcr, bool force) /* * Update catalog if pool overridden */ - if (pool_override && jcr->impl_->res.pool->catalog) { - jcr->impl_->res.catalog = jcr->impl_->res.pool->catalog; - PmStrcpy(jcr->impl_->res.catalog_source, _("Pool resource")); + if (pool_override && jcr->impl->res.pool->catalog) { + jcr->impl->res.catalog = jcr->impl->res.pool->catalog; + PmStrcpy(jcr->impl->res.catalog_source, _("Pool resource")); } } @@ -1371,12 +1371,12 @@ bool GetOrCreateClientRecord(JobControlRecord* jcr) { ClientDbRecord cr; - bstrncpy(cr.Name, jcr->impl_->res.client->resource_name_, sizeof(cr.Name)); - cr.AutoPrune = jcr->impl_->res.client->AutoPrune; - cr.FileRetention = jcr->impl_->res.client->FileRetention; - cr.JobRetention = jcr->impl_->res.client->JobRetention; + bstrncpy(cr.Name, jcr->impl->res.client->resource_name_, sizeof(cr.Name)); + cr.AutoPrune = jcr->impl->res.client->AutoPrune; + cr.FileRetention = jcr->impl->res.client->FileRetention; + cr.JobRetention = jcr->impl->res.client->JobRetention; if (!jcr->client_name) { jcr->client_name = GetPoolMemory(PM_NAME); } - PmStrcpy(jcr->client_name, jcr->impl_->res.client->resource_name_); + PmStrcpy(jcr->client_name, jcr->impl->res.client->resource_name_); if (!jcr->db->CreateClientRecord(jcr, &cr)) { Jmsg(jcr, M_FATAL, 0, _("Could not create Client record. ERR=%s\n"), jcr->db->strerror()); @@ -1385,28 +1385,28 @@ bool GetOrCreateClientRecord(JobControlRecord* jcr) /* * Only initialize quota when a Soft or Hard Limit is set. */ - if (jcr->impl_->res.client->HardQuota != 0 || - jcr->impl_->res.client->SoftQuota != 0) { + if (jcr->impl->res.client->HardQuota != 0 || + jcr->impl->res.client->SoftQuota != 0) { if (!jcr->db->GetQuotaRecord(jcr, &cr)) { if (!jcr->db->CreateQuotaRecord(jcr, &cr)) { Jmsg(jcr, M_FATAL, 0, _("Could not create Quota record. ERR=%s\n"), jcr->db->strerror()); } - jcr->impl_->res.client->QuotaLimit = 0; - jcr->impl_->res.client->GraceTime = 0; + jcr->impl->res.client->QuotaLimit = 0; + jcr->impl->res.client->GraceTime = 0; } } - jcr->impl_->jr.ClientId = cr.ClientId; - jcr->impl_->res.client->QuotaLimit = cr.QuotaLimit; - jcr->impl_->res.client->GraceTime = cr.GraceTime; + jcr->impl->jr.ClientId = cr.ClientId; + jcr->impl->res.client->QuotaLimit = cr.QuotaLimit; + jcr->impl->res.client->GraceTime = cr.GraceTime; if (cr.Uname[0]) { - if (!jcr->impl_->client_uname) { - jcr->impl_->client_uname = GetPoolMemory(PM_NAME); + if (!jcr->impl->client_uname) { + jcr->impl->client_uname = GetPoolMemory(PM_NAME); } - PmStrcpy(jcr->impl_->client_uname, cr.Uname); + PmStrcpy(jcr->impl->client_uname, cr.Uname); } Dmsg2(100, "Created Client %s record %d\n", - jcr->impl_->res.client->resource_name_, jcr->impl_->jr.ClientId); + jcr->impl->res.client->resource_name_, jcr->impl->jr.ClientId); return true; } @@ -1417,28 +1417,28 @@ bool GetOrCreateFilesetRecord(JobControlRecord* jcr) /* * Get or Create FileSet record */ - bstrncpy(fsr.FileSet, jcr->impl_->res.fileset->resource_name_, + bstrncpy(fsr.FileSet, jcr->impl->res.fileset->resource_name_, sizeof(fsr.FileSet)); - if (jcr->impl_->res.fileset->have_MD5) { + if (jcr->impl->res.fileset->have_MD5) { MD5_CTX md5c; unsigned char digest[MD5HashSize]; - memcpy(&md5c, &jcr->impl_->res.fileset->md5c, sizeof(md5c)); + memcpy(&md5c, &jcr->impl->res.fileset->md5c, sizeof(md5c)); MD5_Final(digest, &md5c); /* * Keep the flag (last arg) set to false otherwise old FileSets will * get new MD5 sums and the user will get Full backups on everything */ BinToBase64(fsr.MD5, sizeof(fsr.MD5), (char*)digest, MD5HashSize, false); - bstrncpy(jcr->impl_->res.fileset->MD5, fsr.MD5, - sizeof(jcr->impl_->res.fileset->MD5)); + bstrncpy(jcr->impl->res.fileset->MD5, fsr.MD5, + sizeof(jcr->impl->res.fileset->MD5)); } else { Jmsg(jcr, M_WARNING, 0, _("FileSet MD5 digest not found.\n")); } - if (!jcr->impl_->res.fileset->ignore_fs_changes || + if (!jcr->impl->res.fileset->ignore_fs_changes || !jcr->db->GetFilesetRecord(jcr, &fsr)) { PoolMem FileSetText(PM_MESSAGE); - jcr->impl_->res.fileset->PrintConfig(FileSetText, *my_config, false, false); + jcr->impl->res.fileset->PrintConfig(FileSetText, *my_config, false, false); fsr.FileSetText = FileSetText.c_str(); if (!jcr->db->CreateFilesetRecord(jcr, &fsr)) { @@ -1449,29 +1449,29 @@ bool GetOrCreateFilesetRecord(JobControlRecord* jcr) } } - jcr->impl_->jr.FileSetId = fsr.FileSetId; - bstrncpy(jcr->impl_->FSCreateTime, fsr.cCreateTime, - sizeof(jcr->impl_->FSCreateTime)); + jcr->impl->jr.FileSetId = fsr.FileSetId; + bstrncpy(jcr->impl->FSCreateTime, fsr.cCreateTime, + sizeof(jcr->impl->FSCreateTime)); Dmsg2(119, "Created FileSet %s record %u\n", - jcr->impl_->res.fileset->resource_name_, jcr->impl_->jr.FileSetId); + jcr->impl->res.fileset->resource_name_, jcr->impl->jr.FileSetId); return true; } void InitJcrJobRecord(JobControlRecord* jcr) { - jcr->impl_->jr.SchedTime = jcr->sched_time; - jcr->impl_->jr.StartTime = jcr->start_time; - jcr->impl_->jr.EndTime = 0; /* perhaps rescheduled, clear it */ - jcr->impl_->jr.JobType = jcr->getJobType(); - jcr->impl_->jr.JobLevel = jcr->getJobLevel(); - jcr->impl_->jr.JobStatus = jcr->JobStatus; - jcr->impl_->jr.JobId = jcr->JobId; - jcr->impl_->jr.JobSumTotalBytes = 18446744073709551615LLU; - bstrncpy(jcr->impl_->jr.Name, jcr->impl_->res.job->resource_name_, - sizeof(jcr->impl_->jr.Name)); - bstrncpy(jcr->impl_->jr.Job, jcr->Job, sizeof(jcr->impl_->jr.Job)); + jcr->impl->jr.SchedTime = jcr->sched_time; + jcr->impl->jr.StartTime = jcr->start_time; + jcr->impl->jr.EndTime = 0; /* perhaps rescheduled, clear it */ + jcr->impl->jr.JobType = jcr->getJobType(); + jcr->impl->jr.JobLevel = jcr->getJobLevel(); + jcr->impl->jr.JobStatus = jcr->JobStatus; + jcr->impl->jr.JobId = jcr->JobId; + jcr->impl->jr.JobSumTotalBytes = 18446744073709551615LLU; + bstrncpy(jcr->impl->jr.Name, jcr->impl->res.job->resource_name_, + sizeof(jcr->impl->jr.Name)); + bstrncpy(jcr->impl->jr.Job, jcr->Job, sizeof(jcr->impl->jr.Job)); } /** @@ -1479,18 +1479,18 @@ void InitJcrJobRecord(JobControlRecord* jcr) */ void UpdateJobEndRecord(JobControlRecord* jcr) { - jcr->impl_->jr.EndTime = time(NULL); - jcr->end_time = jcr->impl_->jr.EndTime; - jcr->impl_->jr.JobId = jcr->JobId; - jcr->impl_->jr.JobStatus = jcr->JobStatus; - jcr->impl_->jr.JobFiles = jcr->JobFiles; - jcr->impl_->jr.JobBytes = jcr->JobBytes; - jcr->impl_->jr.ReadBytes = jcr->ReadBytes; - jcr->impl_->jr.VolSessionId = jcr->VolSessionId; - jcr->impl_->jr.VolSessionTime = jcr->VolSessionTime; - jcr->impl_->jr.JobErrors = jcr->JobErrors; - jcr->impl_->jr.HasBase = jcr->HasBase; - if (!jcr->db->UpdateJobEndRecord(jcr, &jcr->impl_->jr)) { + jcr->impl->jr.EndTime = time(NULL); + jcr->end_time = jcr->impl->jr.EndTime; + jcr->impl->jr.JobId = jcr->JobId; + jcr->impl->jr.JobStatus = jcr->JobStatus; + jcr->impl->jr.JobFiles = jcr->JobFiles; + jcr->impl->jr.JobBytes = jcr->JobBytes; + jcr->impl->jr.ReadBytes = jcr->ReadBytes; + jcr->impl->jr.VolSessionId = jcr->VolSessionId; + jcr->impl->jr.VolSessionTime = jcr->VolSessionTime; + jcr->impl->jr.JobErrors = jcr->JobErrors; + jcr->impl->jr.HasBase = jcr->HasBase; + if (!jcr->db->UpdateJobEndRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error updating job record. %s"), jcr->db->strerror()); } @@ -1574,14 +1574,14 @@ void DirdFreeJcrPointers(JobControlRecord* jcr) BfreeAndNull(jcr->sd_auth_key); BfreeAndNull(jcr->where); - BfreeAndNull(jcr->impl_->backup_format); + BfreeAndNull(jcr->impl->backup_format); BfreeAndNull(jcr->RestoreBootstrap); BfreeAndNull(jcr->ar); FreeAndNullPoolMemory(jcr->JobIds); - FreeAndNullPoolMemory(jcr->impl_->client_uname); + FreeAndNullPoolMemory(jcr->impl->client_uname); FreeAndNullPoolMemory(jcr->attr); - FreeAndNullPoolMemory(jcr->impl_->fname); + FreeAndNullPoolMemory(jcr->impl->fname); } /** @@ -1593,21 +1593,21 @@ void DirdFreeJcr(JobControlRecord* jcr) { Dmsg0(200, "Start dird FreeJcr\n"); - if (jcr->impl_->mig_jcr) { - FreeJcr(jcr->impl_->mig_jcr); - jcr->impl_->mig_jcr = NULL; + if (jcr->impl->mig_jcr) { + FreeJcr(jcr->impl->mig_jcr); + jcr->impl->mig_jcr = NULL; } DirdFreeJcrPointers(jcr); - if (jcr->impl_->term_wait_inited) { - pthread_cond_destroy(&jcr->impl_->term_wait); - jcr->impl_->term_wait_inited = false; + if (jcr->impl->term_wait_inited) { + pthread_cond_destroy(&jcr->impl->term_wait); + jcr->impl->term_wait_inited = false; } - if (jcr->impl_->nextrun_ready_inited) { - pthread_cond_destroy(&jcr->impl_->nextrun_ready); - jcr->impl_->nextrun_ready_inited = false; + if (jcr->impl->nextrun_ready_inited) { + pthread_cond_destroy(&jcr->impl->nextrun_ready); + jcr->impl->nextrun_ready_inited = false; } if (jcr->db_batch) { @@ -1621,26 +1621,26 @@ void DirdFreeJcr(JobControlRecord* jcr) jcr->db = NULL; } - if (jcr->impl_->restore_tree_root) { - FreeTree(jcr->impl_->restore_tree_root); + if (jcr->impl->restore_tree_root) { + FreeTree(jcr->impl->restore_tree_root); } - if (jcr->impl_->bsr) { - libbareos::FreeBsr(jcr->impl_->bsr); - jcr->impl_->bsr = NULL; + if (jcr->impl->bsr) { + libbareos::FreeBsr(jcr->impl->bsr); + jcr->impl->bsr = NULL; } FreeAndNullPoolMemory(jcr->stime); - FreeAndNullPoolMemory(jcr->impl_->fname); - FreeAndNullPoolMemory(jcr->impl_->res.pool_source); - FreeAndNullPoolMemory(jcr->impl_->res.npool_source); - FreeAndNullPoolMemory(jcr->impl_->res.rpool_source); - FreeAndNullPoolMemory(jcr->impl_->res.wstore_source); - FreeAndNullPoolMemory(jcr->impl_->res.rstore_source); - FreeAndNullPoolMemory(jcr->impl_->res.catalog_source); - FreeAndNullPoolMemory(jcr->impl_->FDSecureEraseCmd); - FreeAndNullPoolMemory(jcr->impl_->SDSecureEraseCmd); - FreeAndNullPoolMemory(jcr->impl_->vf_jobids); + FreeAndNullPoolMemory(jcr->impl->fname); + FreeAndNullPoolMemory(jcr->impl->res.pool_source); + FreeAndNullPoolMemory(jcr->impl->res.npool_source); + FreeAndNullPoolMemory(jcr->impl->res.rpool_source); + FreeAndNullPoolMemory(jcr->impl->res.wstore_source); + FreeAndNullPoolMemory(jcr->impl->res.rstore_source); + FreeAndNullPoolMemory(jcr->impl->res.catalog_source); + FreeAndNullPoolMemory(jcr->impl->FDSecureEraseCmd); + FreeAndNullPoolMemory(jcr->impl->SDSecureEraseCmd); + FreeAndNullPoolMemory(jcr->impl->vf_jobids); /* * Delete lists setup to hold storage pointers @@ -1656,9 +1656,9 @@ void DirdFreeJcr(JobControlRecord* jcr) FreePlugins(jcr); /* release instantiated plugins */ - if (jcr->impl_) { - delete jcr->impl_; - jcr->impl_ = nullptr; + if (jcr->impl) { + delete jcr->impl; + jcr->impl = nullptr; } Dmsg0(200, "End dird FreeJcr\n"); @@ -1696,7 +1696,7 @@ void GetJobStorage(UnifiedStorageResource* store, JobControlRecord* NewDirectorJcr() { JobControlRecord* jcr = new_jcr(DirdFreeJcr); - jcr->impl_ = new JobControlRecordPrivate; + jcr->impl = new JobControlRecordPrivate; return jcr; } @@ -1709,7 +1709,7 @@ JobControlRecord* NewDirectorJcr() */ void SetJcrDefaults(JobControlRecord* jcr, JobResource* job) { - jcr->impl_->res.job = job; + jcr->impl->res.job = job; jcr->setJobType(job->JobType); jcr->setJobProtocol(job->Protocol); jcr->JobStatus = JS_Created; @@ -1726,18 +1726,18 @@ void SetJcrDefaults(JobControlRecord* jcr, JobResource* job) break; } - if (!jcr->impl_->fname) { jcr->impl_->fname = GetPoolMemory(PM_FNAME); } - if (!jcr->impl_->res.pool_source) { - jcr->impl_->res.pool_source = GetPoolMemory(PM_MESSAGE); - PmStrcpy(jcr->impl_->res.pool_source, _("unknown source")); + if (!jcr->impl->fname) { jcr->impl->fname = GetPoolMemory(PM_FNAME); } + if (!jcr->impl->res.pool_source) { + jcr->impl->res.pool_source = GetPoolMemory(PM_MESSAGE); + PmStrcpy(jcr->impl->res.pool_source, _("unknown source")); } - if (!jcr->impl_->res.npool_source) { - jcr->impl_->res.npool_source = GetPoolMemory(PM_MESSAGE); - PmStrcpy(jcr->impl_->res.npool_source, _("unknown source")); + if (!jcr->impl->res.npool_source) { + jcr->impl->res.npool_source = GetPoolMemory(PM_MESSAGE); + PmStrcpy(jcr->impl->res.npool_source, _("unknown source")); } - if (!jcr->impl_->res.catalog_source) { - jcr->impl_->res.catalog_source = GetPoolMemory(PM_MESSAGE); - PmStrcpy(jcr->impl_->res.catalog_source, _("unknown source")); + if (!jcr->impl->res.catalog_source) { + jcr->impl->res.catalog_source = GetPoolMemory(PM_MESSAGE); + PmStrcpy(jcr->impl->res.catalog_source, _("unknown source")); } jcr->JobPriority = job->Priority; @@ -1750,48 +1750,48 @@ void SetJcrDefaults(JobControlRecord* jcr, JobResource* job) } else if (job->pool) { CopyRwstorage(jcr, job->pool->storage, _("Pool resource")); } - jcr->impl_->res.client = job->client; + jcr->impl->res.client = job->client; - if (jcr->impl_->res.client) { + if (jcr->impl->res.client) { if (!jcr->client_name) { jcr->client_name = GetPoolMemory(PM_NAME); } - PmStrcpy(jcr->client_name, jcr->impl_->res.client->resource_name_); + PmStrcpy(jcr->client_name, jcr->impl->res.client->resource_name_); } - PmStrcpy(jcr->impl_->res.pool_source, _("Job resource")); - jcr->impl_->res.pool = job->pool; - jcr->impl_->res.full_pool = job->full_pool; - jcr->impl_->res.inc_pool = job->inc_pool; - jcr->impl_->res.diff_pool = job->diff_pool; + PmStrcpy(jcr->impl->res.pool_source, _("Job resource")); + jcr->impl->res.pool = job->pool; + jcr->impl->res.full_pool = job->full_pool; + jcr->impl->res.inc_pool = job->inc_pool; + jcr->impl->res.diff_pool = job->diff_pool; if (job->pool && job->pool->catalog) { - jcr->impl_->res.catalog = job->pool->catalog; - PmStrcpy(jcr->impl_->res.catalog_source, _("Pool resource")); + jcr->impl->res.catalog = job->pool->catalog; + PmStrcpy(jcr->impl->res.catalog_source, _("Pool resource")); } else { if (job->catalog) { - jcr->impl_->res.catalog = job->catalog; - PmStrcpy(jcr->impl_->res.catalog_source, _("Job resource")); + jcr->impl->res.catalog = job->catalog; + PmStrcpy(jcr->impl->res.catalog_source, _("Job resource")); } else { if (job->client) { - jcr->impl_->res.catalog = job->client->catalog; - PmStrcpy(jcr->impl_->res.catalog_source, _("Client resource")); + jcr->impl->res.catalog = job->client->catalog; + PmStrcpy(jcr->impl->res.catalog_source, _("Client resource")); } else { - jcr->impl_->res.catalog = + jcr->impl->res.catalog = (CatalogResource*)my_config->GetNextRes(R_CATALOG, NULL); - PmStrcpy(jcr->impl_->res.catalog_source, _("Default catalog")); + PmStrcpy(jcr->impl->res.catalog_source, _("Default catalog")); } } } - jcr->impl_->res.fileset = job->fileset; + jcr->impl->res.fileset = job->fileset; jcr->accurate = job->accurate; - jcr->impl_->res.messages = job->messages; - jcr->impl_->spool_data = job->spool_data; - jcr->impl_->spool_size = job->spool_size; - jcr->impl_->IgnoreDuplicateJobChecking = job->IgnoreDuplicateJobChecking; - jcr->impl_->MaxRunSchedTime = job->MaxRunSchedTime; + jcr->impl->res.messages = job->messages; + jcr->impl->spool_data = job->spool_data; + jcr->impl->spool_size = job->spool_size; + jcr->impl->IgnoreDuplicateJobChecking = job->IgnoreDuplicateJobChecking; + jcr->impl->MaxRunSchedTime = job->MaxRunSchedTime; - if (jcr->impl_->backup_format) { free(jcr->impl_->backup_format); } - jcr->impl_->backup_format = strdup(job->backup_format); + if (jcr->impl->backup_format) { free(jcr->impl->backup_format); } + jcr->impl->backup_format = strdup(job->backup_format); if (jcr->RestoreBootstrap) { free(jcr->RestoreBootstrap); @@ -1808,7 +1808,7 @@ void SetJcrDefaults(JobControlRecord* jcr, JobResource* job) /* * This can be overridden by Console program */ - jcr->impl_->res.verify_job = job->verify_job; + jcr->impl->res.verify_job = job->verify_job; /* * If no default level given, set one @@ -1837,12 +1837,12 @@ void CreateClones(JobControlRecord* jcr) /* * Fire off any clone jobs (run directives) */ - Dmsg2(900, "cloned=%d run_cmds=%p\n", jcr->impl_->cloned, - jcr->impl_->res.job->run_cmds); - if (!jcr->impl_->cloned && jcr->impl_->res.job->run_cmds) { + Dmsg2(900, "cloned=%d run_cmds=%p\n", jcr->impl->cloned, + jcr->impl->res.job->run_cmds); + if (!jcr->impl->cloned && jcr->impl->res.job->run_cmds) { char* runcmd = nullptr; JobId_t jobid; - JobResource* job = jcr->impl_->res.job; + JobResource* job = jcr->impl->res.job; POOLMEM* cmd = GetPoolMemory(PM_FNAME); UaContext* ua = new_ua_context(jcr); @@ -1880,24 +1880,24 @@ int CreateRestoreBootstrapFile(JobControlRecord* jcr) rx.bsr = std::make_unique(); rx.JobIds = (char*)""; - rx.bsr->JobId = jcr->impl_->previous_jr.JobId; + rx.bsr->JobId = jcr->impl->previous_jr.JobId; ua = new_ua_context(jcr); if (!AddVolumeInformationToBsr(ua, rx.bsr.get())) { files = -1; goto bail_out; } - for (uint32_t fi = 1; fi <= jcr->impl_->previous_jr.JobFiles; fi++) { + for (uint32_t fi = 1; fi <= jcr->impl->previous_jr.JobFiles; fi++) { rx.bsr->fi->Add(fi); } - jcr->impl_->ExpectedFiles = WriteBsrFile(ua, rx); - if (jcr->impl_->ExpectedFiles == 0) { + jcr->impl->ExpectedFiles = WriteBsrFile(ua, rx); + if (jcr->impl->ExpectedFiles == 0) { files = 0; goto bail_out; } FreeUaContext(ua); rx.bsr.reset(nullptr); - jcr->impl_->needs_sd = true; - return jcr->impl_->ExpectedFiles; + jcr->impl->needs_sd = true; + return jcr->impl->ExpectedFiles; bail_out: FreeUaContext(ua); diff --git a/core/src/dird/jobq.cc b/core/src/dird/jobq.cc index 2cd2860b549..0c0722192ec 100644 --- a/core/src/dird/jobq.cc +++ b/core/src/dird/jobq.cc @@ -214,17 +214,17 @@ int JobqAdd(jobq_t* jq, JobControlRecord* jcr) pthread_t id; wait_pkt* sched_pkt; - if (!jcr->impl_->term_wait_inited) { + if (!jcr->impl->term_wait_inited) { /* * Initialize termination condition variable */ - if ((status = pthread_cond_init(&jcr->impl_->term_wait, NULL)) != 0) { + if ((status = pthread_cond_init(&jcr->impl->term_wait, NULL)) != 0) { BErrNo be; Jmsg1(jcr, M_FATAL, 0, _("Unable to init job cond variable: ERR=%s\n"), be.bstrerror(status)); return status; } - jcr->impl_->term_wait_inited = true; + jcr->impl->term_wait_inited = true; } Dmsg3(2300, "JobqAdd jobid=%d jcr=0x%x UseCount=%d\n", jcr->JobId, jcr, @@ -483,12 +483,12 @@ extern "C" void* jobq_server(void* arg) * been acquired for jobs canceled before they were put into the ready * queue. */ - if (jcr->impl_->acquired_resource_locks) { + if (jcr->impl->acquired_resource_locks) { DecReadStore(jcr); DecWriteStore(jcr); DecClientConcurrency(jcr); DecJobConcurrency(jcr); - jcr->impl_->acquired_resource_locks = false; + jcr->impl->acquired_resource_locks = false; } if (RescheduleJob(jcr, jq, je)) { continue; /* go look for more work */ } @@ -498,7 +498,7 @@ extern "C" void* jobq_server(void* arg) */ Dmsg2(2300, "====== Termination job=%d use_cnt=%d\n", jcr->JobId, jcr->UseCount()); - jcr->impl_->SDJobStatus = 0; + jcr->impl->SDJobStatus = 0; V(jq->mutex); /* release internal lock */ FreeJcr(jcr); free(je); /* release job entry */ @@ -523,8 +523,8 @@ extern "C" void* jobq_server(void* arg) for (; re;) { Dmsg2( 2300, "JobId %d is also running with %s\n", re->jcr->JobId, - re->jcr->impl_->res.job->allow_mixed_priority ? "mix" : "no mix"); - if (!re->jcr->impl_->res.job->allow_mixed_priority) { + re->jcr->impl->res.job->allow_mixed_priority ? "mix" : "no mix"); + if (!re->jcr->impl->res.job->allow_mixed_priority) { running_allow_mix = false; break; } @@ -550,14 +550,14 @@ extern "C" void* jobq_server(void* arg) Dmsg4(2300, "Examining Job=%d JobPri=%d want Pri=%d (%s)\n", jcr->JobId, jcr->JobPriority, Priority, - jcr->impl_->res.job->allow_mixed_priority ? "mix" : "no mix"); + jcr->impl->res.job->allow_mixed_priority ? "mix" : "no mix"); /* * Take only jobs of correct Priority */ if (!(jcr->JobPriority == Priority || (jcr->JobPriority < Priority && - jcr->impl_->res.job->allow_mixed_priority && + jcr->impl->res.job->allow_mixed_priority && running_allow_mix))) { jcr->setJobStatus(JS_WaitPriority); break; @@ -659,18 +659,18 @@ static bool RescheduleJob(JobControlRecord* jcr, jobq_t* jq, jobq_item_t* je) /* * Basic condition is that more reschedule times remain */ - if (jcr->impl_->res.job->RescheduleTimes == 0 || - jcr->impl_->reschedule_count < jcr->impl_->res.job->RescheduleTimes) { + if (jcr->impl->res.job->RescheduleTimes == 0 || + jcr->impl->reschedule_count < jcr->impl->res.job->RescheduleTimes) { resched = /* * Check for incomplete jobs */ - (jcr->impl_->res.job->RescheduleIncompleteJobs && jcr->IsIncomplete() && + (jcr->impl->res.job->RescheduleIncompleteJobs && jcr->IsIncomplete() && jcr->is_JobType(JT_BACKUP) && !jcr->is_JobLevel(L_BASE)) || /* * Check for failed jobs */ - (jcr->impl_->res.job->RescheduleOnError && !jcr->IsTerminatedOk() && + (jcr->impl->res.job->RescheduleOnError && !jcr->IsTerminatedOk() && !jcr->is_JobStatus(JS_Canceled) && jcr->is_JobType(JT_BACKUP)); } @@ -683,19 +683,19 @@ static bool RescheduleJob(JobControlRecord* jcr, jobq_t* jq, jobq_item_t* je) * possible. */ now = time(NULL); - jcr->impl_->reschedule_count++; - jcr->sched_time = now + jcr->impl_->res.job->RescheduleInterval; + jcr->impl->reschedule_count++; + jcr->sched_time = now + jcr->impl->res.job->RescheduleInterval; bstrftime(dt, sizeof(dt), now); bstrftime(dt2, sizeof(dt2), jcr->sched_time); Dmsg4(2300, "Rescheduled Job %s to re-run in %d seconds.(now=%u,then=%u)\n", - jcr->Job, (int)jcr->impl_->res.job->RescheduleInterval, now, + jcr->Job, (int)jcr->impl->res.job->RescheduleInterval, now, jcr->sched_time); Jmsg(jcr, M_INFO, 0, _("Rescheduled Job %s at %s to re-run in %d seconds (%s).\n"), - jcr->Job, dt, (int)jcr->impl_->res.job->RescheduleInterval, dt2); + jcr->Job, dt, (int)jcr->impl->res.job->RescheduleInterval, dt2); DirdFreeJcrPointers(jcr); /* partial cleanup old stuff */ jcr->JobStatus = -1; - jcr->impl_->SDJobStatus = 0; + jcr->impl->SDJobStatus = 0; jcr->JobErrors = 0; if (!AllowDuplicateJob(jcr)) { return false; } @@ -707,7 +707,7 @@ static bool RescheduleJob(JobControlRecord* jcr, jobq_t* jq, jobq_item_t* je) UpdateJobEnd(jcr, JS_WaitStartTime); Dmsg2(2300, "Requeue job=%d use=%d\n", jcr->JobId, jcr->UseCount()); V(jq->mutex); - jcr->impl_->jr.RealEndTime = 0; + jcr->impl->jr.RealEndTime = 0; JobqAdd(jq, jcr); /* queue the job to run again */ P(jq->mutex); FreeJcr(jcr); /* release jcr */ @@ -724,42 +724,42 @@ static bool RescheduleJob(JobControlRecord* jcr, jobq_t* jq, jobq_item_t* je) */ jcr->setJobStatus(JS_WaitStartTime); njcr = NewDirectorJcr(); - SetJcrDefaults(njcr, jcr->impl_->res.job); - njcr->impl_->reschedule_count = jcr->impl_->reschedule_count; + SetJcrDefaults(njcr, jcr->impl->res.job); + njcr->impl->reschedule_count = jcr->impl->reschedule_count; njcr->sched_time = jcr->sched_time; njcr->initial_sched_time = jcr->initial_sched_time; njcr->setJobLevel(jcr->getJobLevel()); - njcr->impl_->res.pool = jcr->impl_->res.pool; - njcr->impl_->res.run_pool_override = jcr->impl_->res.run_pool_override; - njcr->impl_->res.full_pool = jcr->impl_->res.full_pool; - njcr->impl_->res.run_full_pool_override = - jcr->impl_->res.run_full_pool_override; - njcr->impl_->res.inc_pool = jcr->impl_->res.inc_pool; - njcr->impl_->res.run_inc_pool_override = - jcr->impl_->res.run_inc_pool_override; - njcr->impl_->res.diff_pool = jcr->impl_->res.diff_pool; - njcr->impl_->res.run_diff_pool_override = - jcr->impl_->res.run_diff_pool_override; - njcr->impl_->res.next_pool = jcr->impl_->res.next_pool; - njcr->impl_->res.run_next_pool_override = - jcr->impl_->res.run_next_pool_override; + njcr->impl->res.pool = jcr->impl->res.pool; + njcr->impl->res.run_pool_override = jcr->impl->res.run_pool_override; + njcr->impl->res.full_pool = jcr->impl->res.full_pool; + njcr->impl->res.run_full_pool_override = + jcr->impl->res.run_full_pool_override; + njcr->impl->res.inc_pool = jcr->impl->res.inc_pool; + njcr->impl->res.run_inc_pool_override = + jcr->impl->res.run_inc_pool_override; + njcr->impl->res.diff_pool = jcr->impl->res.diff_pool; + njcr->impl->res.run_diff_pool_override = + jcr->impl->res.run_diff_pool_override; + njcr->impl->res.next_pool = jcr->impl->res.next_pool; + njcr->impl->res.run_next_pool_override = + jcr->impl->res.run_next_pool_override; njcr->JobStatus = -1; njcr->setJobStatus(jcr->JobStatus); - if (jcr->impl_->res.read_storage) { - CopyRstorage(njcr, jcr->impl_->res.read_storage_list, + if (jcr->impl->res.read_storage) { + CopyRstorage(njcr, jcr->impl->res.read_storage_list, _("previous Job")); } else { FreeRstorage(njcr); } - if (jcr->impl_->res.write_storage) { - CopyWstorage(njcr, jcr->impl_->res.write_storage_list, + if (jcr->impl->res.write_storage) { + CopyWstorage(njcr, jcr->impl->res.write_storage_list, _("previous Job")); } else { FreeWstorage(njcr); } - njcr->impl_->res.messages = jcr->impl_->res.messages; - njcr->impl_->spool_data = jcr->impl_->spool_data; + njcr->impl->res.messages = jcr->impl->res.messages; + njcr->impl->spool_data = jcr->impl->spool_data; Dmsg0(2300, "Call to run new job\n"); V(jq->mutex); RunJob(njcr); /* This creates a "new" job */ @@ -784,7 +784,7 @@ static bool AcquireResources(JobControlRecord* jcr) /* * Set that we didn't acquire any resourse locks yet. */ - jcr->impl_->acquired_resource_locks = false; + jcr->impl->acquired_resource_locks = false; /* * Some Job Types are excluded from the client and storage concurrency @@ -798,11 +798,11 @@ static bool AcquireResources(JobControlRecord* jcr) * Migration/Copy and Consolidation jobs are not counted for client * concurrency as they do not touch the client at all */ - jcr->impl_->IgnoreClientConcurrency = true; + jcr->impl->IgnoreClientConcurrency = true; Dmsg1(200, "Skipping migrate/copy Job %s for client concurrency\n", jcr->Job); - if (jcr->impl_->MigrateJobId == 0) { + if (jcr->impl->MigrateJobId == 0) { /* * Migration/Copy control jobs are not counted for storage concurrency * as they do not touch the storage at all @@ -810,14 +810,14 @@ static bool AcquireResources(JobControlRecord* jcr) Dmsg1(200, "Skipping migrate/copy Control Job %s for storage concurrency\n", jcr->Job); - jcr->impl_->IgnoreStorageConcurrency = true; + jcr->impl->IgnoreStorageConcurrency = true; } break; default: break; } - if (jcr->impl_->res.read_storage) { + if (jcr->impl->res.read_storage) { if (!IncReadStore(jcr)) { jcr->setJobStatus(JS_WaitStoreRes); @@ -825,7 +825,7 @@ static bool AcquireResources(JobControlRecord* jcr) } } - if (jcr->impl_->res.write_storage) { + if (jcr->impl->res.write_storage) { if (!IncWriteStore(jcr)) { DecReadStore(jcr); jcr->setJobStatus(JS_WaitStoreRes); @@ -857,23 +857,23 @@ static bool AcquireResources(JobControlRecord* jcr) return false; } - jcr->impl_->acquired_resource_locks = true; + jcr->impl->acquired_resource_locks = true; return true; } static bool IncClientConcurrency(JobControlRecord* jcr) { - if (!jcr->impl_->res.client || jcr->impl_->IgnoreClientConcurrency) { + if (!jcr->impl->res.client || jcr->impl->IgnoreClientConcurrency) { return true; } P(mutex); - if (jcr->impl_->res.client->rcs->NumConcurrentJobs < - jcr->impl_->res.client->MaxConcurrentJobs) { - jcr->impl_->res.client->rcs->NumConcurrentJobs++; - Dmsg2(50, "Inc Client=%s rncj=%d\n", jcr->impl_->res.client->resource_name_, - jcr->impl_->res.client->rcs->NumConcurrentJobs); + if (jcr->impl->res.client->rcs->NumConcurrentJobs < + jcr->impl->res.client->MaxConcurrentJobs) { + jcr->impl->res.client->rcs->NumConcurrentJobs++; + Dmsg2(50, "Inc Client=%s rncj=%d\n", jcr->impl->res.client->resource_name_, + jcr->impl->res.client->rcs->NumConcurrentJobs); V(mutex); return true; @@ -886,13 +886,13 @@ static bool IncClientConcurrency(JobControlRecord* jcr) static void DecClientConcurrency(JobControlRecord* jcr) { - if (jcr->impl_->IgnoreClientConcurrency) { return; } + if (jcr->impl->IgnoreClientConcurrency) { return; } P(mutex); - if (jcr->impl_->res.client) { - jcr->impl_->res.client->rcs->NumConcurrentJobs--; - Dmsg2(50, "Dec Client=%s rncj=%d\n", jcr->impl_->res.client->resource_name_, - jcr->impl_->res.client->rcs->NumConcurrentJobs); + if (jcr->impl->res.client) { + jcr->impl->res.client->rcs->NumConcurrentJobs--; + Dmsg2(50, "Dec Client=%s rncj=%d\n", jcr->impl->res.client->resource_name_, + jcr->impl->res.client->rcs->NumConcurrentJobs); } V(mutex); } @@ -900,11 +900,11 @@ static void DecClientConcurrency(JobControlRecord* jcr) static bool IncJobConcurrency(JobControlRecord* jcr) { P(mutex); - if (jcr->impl_->res.job->rjs->NumConcurrentJobs < - jcr->impl_->res.job->MaxConcurrentJobs) { - jcr->impl_->res.job->rjs->NumConcurrentJobs++; - Dmsg2(50, "Inc Job=%s rncj=%d\n", jcr->impl_->res.job->resource_name_, - jcr->impl_->res.job->rjs->NumConcurrentJobs); + if (jcr->impl->res.job->rjs->NumConcurrentJobs < + jcr->impl->res.job->MaxConcurrentJobs) { + jcr->impl->res.job->rjs->NumConcurrentJobs++; + Dmsg2(50, "Inc Job=%s rncj=%d\n", jcr->impl->res.job->resource_name_, + jcr->impl->res.job->rjs->NumConcurrentJobs); V(mutex); return true; @@ -918,9 +918,9 @@ static bool IncJobConcurrency(JobControlRecord* jcr) static void DecJobConcurrency(JobControlRecord* jcr) { P(mutex); - jcr->impl_->res.job->rjs->NumConcurrentJobs--; - Dmsg2(50, "Dec Job=%s rncj=%d\n", jcr->impl_->res.job->resource_name_, - jcr->impl_->res.job->rjs->NumConcurrentJobs); + jcr->impl->res.job->rjs->NumConcurrentJobs--; + Dmsg2(50, "Dec Job=%s rncj=%d\n", jcr->impl->res.job->resource_name_, + jcr->impl->res.job->rjs->NumConcurrentJobs); V(mutex); } @@ -930,17 +930,17 @@ static void DecJobConcurrency(JobControlRecord* jcr) */ bool IncReadStore(JobControlRecord* jcr) { - if (jcr->impl_->IgnoreStorageConcurrency) { return true; } + if (jcr->impl->IgnoreStorageConcurrency) { return true; } P(mutex); - if (jcr->impl_->res.read_storage->runtime_storage_status->NumConcurrentJobs < - jcr->impl_->res.read_storage->MaxConcurrentJobs) { - jcr->impl_->res.read_storage->runtime_storage_status + if (jcr->impl->res.read_storage->runtime_storage_status->NumConcurrentJobs < + jcr->impl->res.read_storage->MaxConcurrentJobs) { + jcr->impl->res.read_storage->runtime_storage_status ->NumConcurrentReadJobs++; - jcr->impl_->res.read_storage->runtime_storage_status->NumConcurrentJobs++; + jcr->impl->res.read_storage->runtime_storage_status->NumConcurrentJobs++; Dmsg2(50, "Inc Rstore=%s rncj=%d\n", - jcr->impl_->res.read_storage->resource_name_, - jcr->impl_->res.read_storage->runtime_storage_status + jcr->impl->res.read_storage->resource_name_, + jcr->impl->res.read_storage->runtime_storage_status ->NumConcurrentJobs); V(mutex); @@ -950,37 +950,37 @@ bool IncReadStore(JobControlRecord* jcr) Dmsg2( 50, "Fail to acquire Rstore=%s rncj=%d\n", - jcr->impl_->res.read_storage->resource_name_, - jcr->impl_->res.read_storage->runtime_storage_status->NumConcurrentJobs); + jcr->impl->res.read_storage->resource_name_, + jcr->impl->res.read_storage->runtime_storage_status->NumConcurrentJobs); return false; } void DecReadStore(JobControlRecord* jcr) { - if (jcr->impl_->res.read_storage && !jcr->impl_->IgnoreStorageConcurrency) { + if (jcr->impl->res.read_storage && !jcr->impl->IgnoreStorageConcurrency) { P(mutex); - jcr->impl_->res.read_storage->runtime_storage_status + jcr->impl->res.read_storage->runtime_storage_status ->NumConcurrentReadJobs--; - jcr->impl_->res.read_storage->runtime_storage_status->NumConcurrentJobs--; + jcr->impl->res.read_storage->runtime_storage_status->NumConcurrentJobs--; Dmsg2(50, "Dec Rstore=%s rncj=%d\n", - jcr->impl_->res.read_storage->resource_name_, - jcr->impl_->res.read_storage->runtime_storage_status + jcr->impl->res.read_storage->resource_name_, + jcr->impl->res.read_storage->runtime_storage_status ->NumConcurrentJobs); - if (jcr->impl_->res.read_storage->runtime_storage_status + if (jcr->impl->res.read_storage->runtime_storage_status ->NumConcurrentReadJobs < 0) { Jmsg(jcr, M_FATAL, 0, _("NumConcurrentReadJobs Dec Rstore=%s rncj=%d\n"), - jcr->impl_->res.read_storage->resource_name_, - jcr->impl_->res.read_storage->runtime_storage_status + jcr->impl->res.read_storage->resource_name_, + jcr->impl->res.read_storage->runtime_storage_status ->NumConcurrentReadJobs); } - if (jcr->impl_->res.read_storage->runtime_storage_status + if (jcr->impl->res.read_storage->runtime_storage_status ->NumConcurrentJobs < 0) { Jmsg(jcr, M_FATAL, 0, _("NumConcurrentJobs Dec Rstore=%s rncj=%d\n"), - jcr->impl_->res.read_storage->resource_name_, - jcr->impl_->res.read_storage->runtime_storage_status + jcr->impl->res.read_storage->resource_name_, + jcr->impl->res.read_storage->runtime_storage_status ->NumConcurrentJobs); } V(mutex); @@ -989,15 +989,15 @@ void DecReadStore(JobControlRecord* jcr) static bool IncWriteStore(JobControlRecord* jcr) { - if (jcr->impl_->IgnoreStorageConcurrency) { return true; } + if (jcr->impl->IgnoreStorageConcurrency) { return true; } P(mutex); - if (jcr->impl_->res.write_storage->runtime_storage_status->NumConcurrentJobs < - jcr->impl_->res.write_storage->MaxConcurrentJobs) { - jcr->impl_->res.write_storage->runtime_storage_status->NumConcurrentJobs++; + if (jcr->impl->res.write_storage->runtime_storage_status->NumConcurrentJobs < + jcr->impl->res.write_storage->MaxConcurrentJobs) { + jcr->impl->res.write_storage->runtime_storage_status->NumConcurrentJobs++; Dmsg2(50, "Inc Wstore=%s wncj=%d\n", - jcr->impl_->res.write_storage->resource_name_, - jcr->impl_->res.write_storage->runtime_storage_status + jcr->impl->res.write_storage->resource_name_, + jcr->impl->res.write_storage->runtime_storage_status ->NumConcurrentJobs); V(mutex); @@ -1007,27 +1007,27 @@ static bool IncWriteStore(JobControlRecord* jcr) Dmsg2( 50, "Fail to acquire Wstore=%s wncj=%d\n", - jcr->impl_->res.write_storage->resource_name_, - jcr->impl_->res.write_storage->runtime_storage_status->NumConcurrentJobs); + jcr->impl->res.write_storage->resource_name_, + jcr->impl->res.write_storage->runtime_storage_status->NumConcurrentJobs); return false; } static void DecWriteStore(JobControlRecord* jcr) { - if (jcr->impl_->res.write_storage && !jcr->impl_->IgnoreStorageConcurrency) { + if (jcr->impl->res.write_storage && !jcr->impl->IgnoreStorageConcurrency) { P(mutex); - jcr->impl_->res.write_storage->runtime_storage_status->NumConcurrentJobs--; + jcr->impl->res.write_storage->runtime_storage_status->NumConcurrentJobs--; Dmsg2(50, "Dec Wstore=%s wncj=%d\n", - jcr->impl_->res.write_storage->resource_name_, - jcr->impl_->res.write_storage->runtime_storage_status + jcr->impl->res.write_storage->resource_name_, + jcr->impl->res.write_storage->runtime_storage_status ->NumConcurrentJobs); - if (jcr->impl_->res.write_storage->runtime_storage_status + if (jcr->impl->res.write_storage->runtime_storage_status ->NumConcurrentJobs < 0) { Jmsg(jcr, M_FATAL, 0, _("NumConcurrentJobs Dec Wstore=%s wncj=%d\n"), - jcr->impl_->res.write_storage->resource_name_, - jcr->impl_->res.write_storage->runtime_storage_status + jcr->impl->res.write_storage->resource_name_, + jcr->impl->res.write_storage->runtime_storage_status ->NumConcurrentJobs); } V(mutex); diff --git a/core/src/dird/migrate.cc b/core/src/dird/migrate.cc index 467cc0ccfc5..50f632420d0 100644 --- a/core/src/dird/migrate.cc +++ b/core/src/dird/migrate.cc @@ -294,7 +294,7 @@ static inline bool SetMigrationNextPool(JobControlRecord* jcr, * Get the PoolId used with the original job. Then * find the pool name from the database record. */ - pr.PoolId = jcr->impl_->jr.PoolId; + pr.PoolId = jcr->impl->jr.PoolId; if (!jcr->db->GetPoolRecord(jcr, &pr)) { Jmsg(jcr, M_FATAL, 0, _("Pool for JobId %s not in database. ERR=%s\n"), edit_int64(pr.PoolId, ed1), jcr->db->strerror()); @@ -314,26 +314,26 @@ static inline bool SetMigrationNextPool(JobControlRecord* jcr, /* * See if there is a next pool override. */ - if (jcr->impl_->res.run_next_pool_override) { - PmStrcpy(jcr->impl_->res.npool_source, _("Run NextPool override")); - PmStrcpy(jcr->impl_->res.pool_source, _("Run NextPool override")); + if (jcr->impl->res.run_next_pool_override) { + PmStrcpy(jcr->impl->res.npool_source, _("Run NextPool override")); + PmStrcpy(jcr->impl->res.pool_source, _("Run NextPool override")); storage_source = _("Storage from Run NextPool override"); } else { /* * See if there is a next pool override in the Job definition. */ - if (jcr->impl_->res.job->next_pool) { - jcr->impl_->res.next_pool = jcr->impl_->res.job->next_pool; - PmStrcpy(jcr->impl_->res.npool_source, _("Job's NextPool resource")); - PmStrcpy(jcr->impl_->res.pool_source, _("Job's NextPool resource")); + if (jcr->impl->res.job->next_pool) { + jcr->impl->res.next_pool = jcr->impl->res.job->next_pool; + PmStrcpy(jcr->impl->res.npool_source, _("Job's NextPool resource")); + PmStrcpy(jcr->impl->res.pool_source, _("Job's NextPool resource")); storage_source = _("Storage from Job's NextPool resource"); } else { /* * Fall back to the pool's NextPool definition. */ - jcr->impl_->res.next_pool = pool->NextPool; - PmStrcpy(jcr->impl_->res.npool_source, _("Job Pool's NextPool resource")); - PmStrcpy(jcr->impl_->res.pool_source, _("Job Pool's NextPool resource")); + jcr->impl->res.next_pool = pool->NextPool; + PmStrcpy(jcr->impl->res.npool_source, _("Job Pool's NextPool resource")); + PmStrcpy(jcr->impl->res.pool_source, _("Job Pool's NextPool resource")); storage_source = _("Storage from Pool's NextPool resource"); } } @@ -343,21 +343,21 @@ static inline bool SetMigrationNextPool(JobControlRecord* jcr, * record exists in the database. Note, in this case, we * will be migrating from pool to pool->NextPool. */ - if (jcr->impl_->res.next_pool) { - jcr->impl_->jr.PoolId = - GetOrCreatePoolRecord(jcr, jcr->impl_->res.next_pool->resource_name_); - if (jcr->impl_->jr.PoolId == 0) { return false; } + if (jcr->impl->res.next_pool) { + jcr->impl->jr.PoolId = + GetOrCreatePoolRecord(jcr, jcr->impl->res.next_pool->resource_name_); + if (jcr->impl->jr.PoolId == 0) { return false; } } - if (!SetMigrationWstorage(jcr, pool, jcr->impl_->res.next_pool, + if (!SetMigrationWstorage(jcr, pool, jcr->impl->res.next_pool, storage_source)) { return false; } - jcr->impl_->res.pool = jcr->impl_->res.next_pool; + jcr->impl->res.pool = jcr->impl->res.next_pool; Dmsg2(dbglevel, "Write pool=%s read rpool=%s\n", - jcr->impl_->res.pool->resource_name_, - jcr->impl_->res.rpool->resource_name_); + jcr->impl->res.pool->resource_name_, + jcr->impl->res.rpool->resource_name_); return true; } @@ -369,8 +369,8 @@ static inline bool SameStorage(JobControlRecord* jcr) { StorageResource *read_store, *write_store; - read_store = (StorageResource*)jcr->impl_->res.read_storage_list->first(); - write_store = (StorageResource*)jcr->impl_->res.write_storage_list->first(); + read_store = (StorageResource*)jcr->impl->res.read_storage_list->first(); + write_store = (StorageResource*)jcr->impl->res.write_storage_list->first(); if (!read_store->autochanger && !write_store->autochanger && bstrcmp(read_store->resource_name_, write_store->resource_name_)) { @@ -390,27 +390,27 @@ static inline void StartNewMigrationJob(JobControlRecord* jcr) ua = new_ua_context(jcr); ua->batch = true; Mmsg(ua->cmd, "run job=\"%s\" jobid=%s ignoreduplicatecheck=yes", - jcr->impl_->res.job->resource_name_, - edit_uint64(jcr->impl_->MigrateJobId, ed1)); + jcr->impl->res.job->resource_name_, + edit_uint64(jcr->impl->MigrateJobId, ed1)); /* * Make sure we have something to compare against. */ - if (jcr->impl_->res.pool) { + if (jcr->impl->res.pool) { /* * See if there was actually a pool override. */ - if (jcr->impl_->res.pool != jcr->impl_->res.job->pool) { - Mmsg(cmd, " pool=\"%s\"", jcr->impl_->res.pool->resource_name_); + if (jcr->impl->res.pool != jcr->impl->res.job->pool) { + Mmsg(cmd, " pool=\"%s\"", jcr->impl->res.pool->resource_name_); PmStrcat(ua->cmd, cmd.c_str()); } /* * See if there was actually a next pool override. */ - if (jcr->impl_->res.next_pool && - jcr->impl_->res.next_pool != jcr->impl_->res.pool->NextPool) { - Mmsg(cmd, " nextpool=\"%s\"", jcr->impl_->res.next_pool->resource_name_); + if (jcr->impl->res.next_pool && + jcr->impl->res.next_pool != jcr->impl->res.pool->NextPool) { + Mmsg(cmd, " nextpool=\"%s\"", jcr->impl->res.next_pool->resource_name_); PmStrcat(ua->cmd, cmd.c_str()); } } @@ -608,7 +608,7 @@ static bool find_mediaid_then_jobids(JobControlRecord* jcr, /* * Basic query for MediaId */ - Mmsg(query, query1, jcr->impl_->res.rpool->resource_name_); + Mmsg(query, query1, jcr->impl->res.rpool->resource_name_); if (!jcr->db->SqlQuery(query.c_str(), UniqueDbidHandler, (void*)ids)) { Jmsg(jcr, M_FATAL, 0, _("SQL failed. ERR=%s\n"), jcr->db->strerror()); goto bail_out; @@ -655,9 +655,9 @@ static inline bool FindJobidsOfPoolUncopiedJobs(JobControlRecord* jcr, } Dmsg1(dbglevel, "copy selection pattern=%s\n", - jcr->impl_->res.rpool->resource_name_); + jcr->impl->res.rpool->resource_name_); Mmsg(query, sql_jobids_of_pool_uncopied_jobs, - jcr->impl_->res.rpool->resource_name_); + jcr->impl->res.rpool->resource_name_); Dmsg1(dbglevel, "get uncopied jobs query=%s\n", query.c_str()); if (!jcr->db->SqlQuery(query.c_str(), UniqueDbidHandler, (void*)ids)) { Jmsg(jcr, M_FATAL, 0, _("SQL to get uncopied jobs failed. ERR=%s\n"), @@ -686,18 +686,18 @@ static bool regex_find_jobids(JobControlRecord* jcr, PoolMem query(PM_MESSAGE); item_chain = new dlist(item, &item->link); - if (!jcr->impl_->res.job->selection_pattern) { + if (!jcr->impl->res.job->selection_pattern) { Jmsg(jcr, M_FATAL, 0, _("No %s %s selection pattern specified.\n"), jcr->get_OperationName(), type); goto bail_out; } Dmsg1(dbglevel, "regex-sel-pattern=%s\n", - jcr->impl_->res.job->selection_pattern); + jcr->impl->res.job->selection_pattern); /* * Basic query for names */ - Mmsg(query, query1, jcr->impl_->res.rpool->resource_name_); + Mmsg(query, query1, jcr->impl->res.rpool->resource_name_); Dmsg1(dbglevel, "get name query1=%s\n", query.c_str()); if (!jcr->db->SqlQuery(query.c_str(), UniqueNameHandler, (void*)item_chain)) { Jmsg(jcr, M_FATAL, 0, _("SQL to get %s failed. ERR=%s\n"), type, @@ -707,19 +707,19 @@ static bool regex_find_jobids(JobControlRecord* jcr, Dmsg1(dbglevel, "query1 returned %d names\n", item_chain->size()); if (item_chain->size() == 0) { Jmsg(jcr, M_INFO, 0, _("Query of Pool \"%s\" returned no Jobs to %s.\n"), - jcr->impl_->res.rpool->resource_name_, jcr->get_ActionName()); + jcr->impl->res.rpool->resource_name_, jcr->get_ActionName()); ok = true; goto bail_out; /* skip regex match */ } else { /* * Compile regex expression */ - rc = regcomp(&preg, jcr->impl_->res.job->selection_pattern, REG_EXTENDED); + rc = regcomp(&preg, jcr->impl->res.job->selection_pattern, REG_EXTENDED); if (rc != 0) { regerror(rc, &preg, prbuf, sizeof(prbuf)); Jmsg(jcr, M_FATAL, 0, _("Could not compile regex pattern \"%s\" ERR=%s\n"), - jcr->impl_->res.job->selection_pattern, prbuf); + jcr->impl->res.job->selection_pattern, prbuf); goto bail_out; } @@ -765,7 +765,7 @@ static bool regex_find_jobids(JobControlRecord* jcr, ids->count = 0; foreach_dlist (item, item_chain) { Dmsg2(dbglevel, "Got %s: %s\n", type, item->item); - Mmsg(query, query2, item->item, jcr->impl_->res.rpool->resource_name_); + Mmsg(query, query2, item->item, jcr->impl->res.rpool->resource_name_); Dmsg1(dbglevel, "get id from name query2=%s\n", query.c_str()); if (!jcr->db->SqlQuery(query.c_str(), UniqueDbidHandler, (void*)ids)) { Jmsg(jcr, M_FATAL, 0, _("SQL failed. ERR=%s\n"), jcr->db->strerror()); @@ -820,7 +820,7 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr) mid.list = NULL; jids.list = NULL; - switch (jcr->impl_->res.job->selection_type) { + switch (jcr->impl->res.job->selection_type) { case MT_JOB: if (!regex_find_jobids(jcr, &ids, sql_job, sql_jobids_from_job, "Job")) { goto bail_out; @@ -839,13 +839,13 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr) } break; case MT_SQLQUERY: - if (!jcr->impl_->res.job->selection_pattern) { + if (!jcr->impl->res.job->selection_pattern) { Jmsg(jcr, M_FATAL, 0, _("No %s SQL selection pattern specified.\n"), jcr->get_OperationName()); goto bail_out; } - Dmsg1(dbglevel, "SQL=%s\n", jcr->impl_->res.job->selection_pattern); - if (!jcr->db->SqlQuery(jcr->impl_->res.job->selection_pattern, + Dmsg1(dbglevel, "SQL=%s\n", jcr->impl->res.job->selection_pattern); + if (!jcr->db->SqlQuery(jcr->impl->res.job->selection_pattern, UniqueDbidHandler, (void*)&ids)) { Jmsg(jcr, M_FATAL, 0, _("SQL failed. ERR=%s\n"), jcr->db->strerror()); goto bail_out; @@ -878,7 +878,7 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr) /* * Find count of bytes in pool */ - Mmsg(query, sql_pool_bytes, jcr->impl_->res.rpool->resource_name_); + Mmsg(query, sql_pool_bytes, jcr->impl->res.rpool->resource_name_); if (!jcr->db->SqlQuery(query.c_str(), db_int64_handler, (void*)&ctx)) { Jmsg(jcr, M_FATAL, 0, _("SQL failed. ERR=%s\n"), jcr->db->strerror()); @@ -894,9 +894,9 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr) pool_bytes = ctx.value; Dmsg2(dbglevel, "highbytes=%lld pool=%lld\n", - jcr->impl_->res.rpool->MigrationHighBytes, pool_bytes); + jcr->impl->res.rpool->MigrationHighBytes, pool_bytes); - if (pool_bytes < (int64_t)jcr->impl_->res.rpool->MigrationHighBytes) { + if (pool_bytes < (int64_t)jcr->impl->res.rpool->MigrationHighBytes) { Jmsg(jcr, M_INFO, 0, _("No Volumes found to %s.\n"), jcr->get_ActionName()); retval = true; @@ -909,7 +909,7 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr) /* * Find a list of MediaIds that could be migrated */ - Mmsg(query, sql_mediaids, jcr->impl_->res.rpool->resource_name_); + Mmsg(query, sql_mediaids, jcr->impl->res.rpool->resource_name_); Dmsg1(dbglevel, "query=%s\n", query.c_str()); if (!jcr->db->SqlQuery(query.c_str(), UniqueDbidHandler, (void*)&ids)) { @@ -963,10 +963,10 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr) Dmsg2(dbglevel, "Total %s Job bytes=%s\n", jcr->get_ActionName(), edit_int64_with_commas(ctx.value, ed1)); Dmsg2(dbglevel, "lowbytes=%s poolafter=%s\n", - edit_int64_with_commas(jcr->impl_->res.rpool->MigrationLowBytes, + edit_int64_with_commas(jcr->impl->res.rpool->MigrationLowBytes, ed1), edit_int64_with_commas(pool_bytes, ed2)); - if (pool_bytes <= (int64_t)jcr->impl_->res.rpool->MigrationLowBytes) { + if (pool_bytes <= (int64_t)jcr->impl->res.rpool->MigrationLowBytes) { Dmsg0(dbglevel, "We should be done.\n"); break; } @@ -984,11 +984,11 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr) time_t ttime; char dt[MAX_TIME_LENGTH]; - ttime = time(NULL) - (time_t)jcr->impl_->res.rpool->MigrationTime; + ttime = time(NULL) - (time_t)jcr->impl->res.rpool->MigrationTime; bstrutime(dt, sizeof(dt), ttime); ids.count = 0; - Mmsg(query, sql_pool_time, jcr->impl_->res.rpool->resource_name_, dt); + Mmsg(query, sql_pool_time, jcr->impl->res.rpool->resource_name_, dt); Dmsg1(dbglevel, "query=%s\n", query.c_str()); if (!jcr->db->SqlQuery(query.c_str(), UniqueDbidHandler, (void*)&ids)) { @@ -1030,8 +1030,8 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr) /* * Note: to not over load the system, limit the number of new jobs started. */ - if (jcr->impl_->res.job->MaxConcurrentCopies) { - limit = jcr->impl_->res.job->MaxConcurrentCopies; + if (jcr->impl->res.job->MaxConcurrentCopies) { + limit = jcr->impl->res.job->MaxConcurrentCopies; apply_limit = true; } @@ -1049,7 +1049,7 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr) retval = true; goto bail_out; } - jcr->impl_->MigrateJobId = JobId; + jcr->impl->MigrateJobId = JobId; if (apply_limit) { /* @@ -1063,7 +1063,7 @@ static inline bool getJobs_to_migrate(JobControlRecord* jcr) Dmsg0(dbglevel, "Back from StartNewMigrationJob\n"); } - jcr->impl_->HasSelectedJobs = true; + jcr->impl->HasSelectedJobs = true; retval = true; bail_out: @@ -1097,9 +1097,9 @@ bool DoMigrationInit(JobControlRecord* jcr) if (!AllowDuplicateJob(jcr)) { return false; } - jcr->impl_->jr.PoolId = - GetOrCreatePoolRecord(jcr, jcr->impl_->res.pool->resource_name_); - if (jcr->impl_->jr.PoolId == 0) { + jcr->impl->jr.PoolId = + GetOrCreatePoolRecord(jcr, jcr->impl->res.pool->resource_name_); + if (jcr->impl->jr.PoolId == 0) { Dmsg1(dbglevel, "JobId=%d no PoolId\n", (int)jcr->JobId); Jmsg(jcr, M_FATAL, 0, _("Could not get or create a Pool record.\n")); return false; @@ -1111,10 +1111,10 @@ bool DoMigrationInit(JobControlRecord* jcr) * pool will be changed to point to the write pool, * which comes from pool->NextPool. */ - jcr->impl_->res.rpool = jcr->impl_->res.pool; /* save read pool */ - PmStrcpy(jcr->impl_->res.rpool_source, jcr->impl_->res.pool_source); + jcr->impl->res.rpool = jcr->impl->res.pool; /* save read pool */ + PmStrcpy(jcr->impl->res.rpool_source, jcr->impl->res.pool_source); Dmsg2(dbglevel, "Read pool=%s (From %s)\n", - jcr->impl_->res.rpool->resource_name_, jcr->impl_->res.rpool_source); + jcr->impl->res.rpool->resource_name_, jcr->impl->res.rpool_source); /* * See if this is a control job e.g. the one that selects the Jobs to Migrate @@ -1122,39 +1122,39 @@ bool DoMigrationInit(JobControlRecord* jcr) * jcr->impl_->MigrateJobId is set we know that its an actual Migration or * Copy Job. */ - if (jcr->impl_->MigrateJobId != 0) { + if (jcr->impl->MigrateJobId != 0) { Dmsg1(dbglevel, "At Job start previous jobid=%u\n", - jcr->impl_->MigrateJobId); + jcr->impl->MigrateJobId); - jcr->impl_->previous_jr.JobId = jcr->impl_->MigrateJobId; - Dmsg1(dbglevel, "Previous jobid=%d\n", (int)jcr->impl_->previous_jr.JobId); + jcr->impl->previous_jr.JobId = jcr->impl->MigrateJobId; + Dmsg1(dbglevel, "Previous jobid=%d\n", (int)jcr->impl->previous_jr.JobId); - if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->previous_jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl->previous_jr)) { Jmsg(jcr, M_FATAL, 0, _("Could not get job record for JobId %s to %s. ERR=%s"), - edit_int64(jcr->impl_->previous_jr.JobId, ed1), + edit_int64(jcr->impl->previous_jr.JobId, ed1), jcr->get_ActionName(), jcr->db->strerror()); return false; } Jmsg(jcr, M_INFO, 0, _("%s using JobId=%s Job=%s\n"), jcr->get_OperationName(), - edit_int64(jcr->impl_->previous_jr.JobId, ed1), - jcr->impl_->previous_jr.Job); + edit_int64(jcr->impl->previous_jr.JobId, ed1), + jcr->impl->previous_jr.Job); Dmsg4(dbglevel, "%s JobId=%d using JobId=%s Job=%s\n", jcr->get_OperationName(), jcr->JobId, - edit_int64(jcr->impl_->previous_jr.JobId, ed1), - jcr->impl_->previous_jr.Job); + edit_int64(jcr->impl->previous_jr.JobId, ed1), + jcr->impl->previous_jr.Job); if (CreateRestoreBootstrapFile(jcr) < 0) { Jmsg(jcr, M_FATAL, 0, _("Create bootstrap file failed.\n")); return false; } - if (jcr->impl_->previous_jr.JobId == 0 || jcr->impl_->ExpectedFiles == 0) { + if (jcr->impl->previous_jr.JobId == 0 || jcr->impl->ExpectedFiles == 0) { jcr->setJobStatus(JS_Terminated); Dmsg1(dbglevel, "JobId=%d expected files == 0\n", (int)jcr->JobId); - if (jcr->impl_->previous_jr.JobId == 0) { + if (jcr->impl->previous_jr.JobId == 0) { Jmsg(jcr, M_INFO, 0, _("No previous Job found to %s.\n"), jcr->get_ActionName()); } else { @@ -1166,22 +1166,22 @@ bool DoMigrationInit(JobControlRecord* jcr) } Dmsg5(dbglevel, "JobId=%d: Current: Name=%s JobId=%d Type=%c Level=%c\n", - (int)jcr->JobId, jcr->impl_->jr.Name, (int)jcr->impl_->jr.JobId, - jcr->impl_->jr.JobType, jcr->impl_->jr.JobLevel); + (int)jcr->JobId, jcr->impl->jr.Name, (int)jcr->impl->jr.JobId, + jcr->impl->jr.JobType, jcr->impl->jr.JobLevel); - job = (JobResource*)my_config->GetResWithName(R_JOB, jcr->impl_->jr.Name); + job = (JobResource*)my_config->GetResWithName(R_JOB, jcr->impl->jr.Name); prev_job = (JobResource*)my_config->GetResWithName( - R_JOB, jcr->impl_->previous_jr.Name); + R_JOB, jcr->impl->previous_jr.Name); if (!job) { Jmsg(jcr, M_FATAL, 0, _("Job resource not found for \"%s\".\n"), - jcr->impl_->jr.Name); + jcr->impl->jr.Name); return false; } if (!prev_job) { Jmsg(jcr, M_FATAL, 0, _("Previous Job resource not found for \"%s\".\n"), - jcr->impl_->previous_jr.Name); + jcr->impl->previous_jr.Name); return false; } @@ -1196,33 +1196,33 @@ bool DoMigrationInit(JobControlRecord* jcr) * If the current Job has no explicit client set use the client setting of * the previous Job. */ - if (!jcr->impl_->res.client && prev_job->client) { - jcr->impl_->res.client = prev_job->client; + if (!jcr->impl->res.client && prev_job->client) { + jcr->impl->res.client = prev_job->client; if (!jcr->client_name) { jcr->client_name = GetPoolMemory(PM_NAME); } - PmStrcpy(jcr->client_name, jcr->impl_->res.client->resource_name_); + PmStrcpy(jcr->client_name, jcr->impl->res.client->resource_name_); } /* * If the current Job has no explicit fileset set use the client setting of * the previous Job. */ - if (!jcr->impl_->res.fileset) { - jcr->impl_->res.fileset = prev_job->fileset; + if (!jcr->impl->res.fileset) { + jcr->impl->res.fileset = prev_job->fileset; } /* * See if spooling data is not enabled yet. If so turn on spooling if * requested in job */ - if (!jcr->impl_->spool_data) { jcr->impl_->spool_data = job->spool_data; } + if (!jcr->impl->spool_data) { jcr->impl->spool_data = job->spool_data; } /* * Create a migration jcr */ mig_jcr = NewDirectorJcr(); - jcr->impl_->mig_jcr = mig_jcr; - memcpy(&mig_jcr->impl_->previous_jr, &jcr->impl_->previous_jr, - sizeof(mig_jcr->impl_->previous_jr)); + jcr->impl->mig_jcr = mig_jcr; + memcpy(&mig_jcr->impl->previous_jr, &jcr->impl->previous_jr, + sizeof(mig_jcr->impl->previous_jr)); /* * Turn the mig_jcr into a "real" job that takes on the aspects of @@ -1240,19 +1240,19 @@ bool DoMigrationInit(JobControlRecord* jcr) /* * Don't let Watchdog checks Max*Time value on this Job */ - mig_jcr->impl_->no_maxtime = true; + mig_jcr->impl->no_maxtime = true; /* * Don't check for duplicates on migration and copy jobs */ - mig_jcr->impl_->IgnoreDuplicateJobChecking = true; + mig_jcr->impl->IgnoreDuplicateJobChecking = true; /* * Copy some overwrites back from the Control Job to the migration and copy * job. */ - mig_jcr->impl_->spool_data = jcr->impl_->spool_data; - mig_jcr->impl_->spool_size = jcr->impl_->spool_size; + mig_jcr->impl->spool_data = jcr->impl->spool_data; + mig_jcr->impl->spool_size = jcr->impl->spool_size; if (!SetupJob(mig_jcr, true)) { @@ -1268,14 +1268,14 @@ bool DoMigrationInit(JobControlRecord* jcr) /* * Now reset the job record from the previous job */ - memcpy(&mig_jcr->impl_->jr, &jcr->impl_->previous_jr, - sizeof(mig_jcr->impl_->jr)); + memcpy(&mig_jcr->impl->jr, &jcr->impl->previous_jr, + sizeof(mig_jcr->impl->jr)); /* * Update the jr to reflect the new values of PoolId and JobId. */ - mig_jcr->impl_->jr.PoolId = jcr->impl_->jr.PoolId; - mig_jcr->impl_->jr.JobId = mig_jcr->JobId; + mig_jcr->impl->jr.PoolId = jcr->impl->jr.PoolId; + mig_jcr->impl->jr.JobId = mig_jcr->JobId; if (SetMigrationNextPool(jcr, &pool)) { /* @@ -1284,9 +1284,9 @@ bool DoMigrationInit(JobControlRecord* jcr) CopyRstorage(mig_jcr, pool->storage, _("Pool resource")); CopyRstorage(jcr, pool->storage, _("Pool resource")); - mig_jcr->impl_->res.pool = jcr->impl_->res.pool; - mig_jcr->impl_->res.next_pool = jcr->impl_->res.next_pool; - mig_jcr->impl_->jr.PoolId = jcr->impl_->jr.PoolId; + mig_jcr->impl->res.pool = jcr->impl->res.pool; + mig_jcr->impl->res.next_pool = jcr->impl->res.next_pool; + mig_jcr->impl->jr.PoolId = jcr->impl->jr.PoolId; } /* @@ -1294,7 +1294,7 @@ bool DoMigrationInit(JobControlRecord* jcr) * This only happens when the original pool used doesn't have an explicit * storage. */ - if (!jcr->impl_->res.read_storage_list) { + if (!jcr->impl->res.read_storage_list) { CopyRstorage(jcr, prev_job->storage, _("previous Job")); } @@ -1304,18 +1304,18 @@ bool DoMigrationInit(JobControlRecord* jcr) * otherwise we open a connection to the reading SD and a second * one to the writing SD. */ - jcr->impl_->remote_replicate = !IsSameStorageDaemon( - jcr->impl_->res.read_storage, jcr->impl_->res.write_storage); + jcr->impl->remote_replicate = !IsSameStorageDaemon( + jcr->impl->res.read_storage, jcr->impl->res.write_storage); /* * set the JobLevel to what the original job was */ - mig_jcr->setJobLevel(mig_jcr->impl_->previous_jr.JobLevel); + mig_jcr->setJobLevel(mig_jcr->impl->previous_jr.JobLevel); Dmsg4(dbglevel, "mig_jcr: Name=%s JobId=%d Type=%c Level=%c\n", - mig_jcr->impl_->jr.Name, (int)mig_jcr->impl_->jr.JobId, - mig_jcr->impl_->jr.JobType, mig_jcr->impl_->jr.JobLevel); + mig_jcr->impl->jr.Name, (int)mig_jcr->impl->jr.JobId, + mig_jcr->impl->jr.JobType, mig_jcr->impl->jr.JobLevel); } return true; @@ -1353,18 +1353,18 @@ static inline bool DoActualMigration(JobControlRecord* jcr) { char ed1[100]; bool retval = false; - JobControlRecord* mig_jcr = jcr->impl_->mig_jcr; + JobControlRecord* mig_jcr = jcr->impl->mig_jcr; ASSERT(mig_jcr); /* * Make sure this job was not already migrated */ - if (jcr->impl_->previous_jr.JobType != JT_BACKUP && - jcr->impl_->previous_jr.JobType != JT_JOB_COPY) { + if (jcr->impl->previous_jr.JobType != JT_BACKUP && + jcr->impl->previous_jr.JobType != JT_JOB_COPY) { Jmsg(jcr, M_INFO, 0, _("JobId %s already %s probably by another Job. %s stopped.\n"), - edit_int64(jcr->impl_->previous_jr.JobId, ed1), + edit_int64(jcr->impl->previous_jr.JobId, ed1), jcr->get_ActionName(true), jcr->get_OperationName()); jcr->setJobStatus(JS_Terminated); MigrationCleanup(jcr, jcr->JobStatus); @@ -1374,7 +1374,7 @@ static inline bool DoActualMigration(JobControlRecord* jcr) if (SameStorage(jcr)) { Jmsg(jcr, M_FATAL, 0, _("JobId %s cannot %s using the same read and write storage.\n"), - edit_int64(jcr->impl_->previous_jr.JobId, ed1), + edit_int64(jcr->impl->previous_jr.JobId, ed1), jcr->get_OperationName()); jcr->setJobStatus(JS_Terminated); MigrationCleanup(jcr, jcr->JobStatus); @@ -1394,12 +1394,12 @@ static inline bool DoActualMigration(JobControlRecord* jcr) if (HasPairedStorage(jcr)) { SetPairedStorage(jcr); } Dmsg2(dbglevel, "Read store=%s, write store=%s\n", - ((StorageResource*)jcr->impl_->res.read_storage_list->first()) + ((StorageResource*)jcr->impl->res.read_storage_list->first()) ->resource_name_, - ((StorageResource*)jcr->impl_->res.write_storage_list->first()) + ((StorageResource*)jcr->impl->res.write_storage_list->first()) ->resource_name_); - if (jcr->impl_->remote_replicate) { + if (jcr->impl->remote_replicate) { alist* write_storage_list; /* @@ -1409,12 +1409,12 @@ static inline bool DoActualMigration(JobControlRecord* jcr) * - Writing Storage Daemon bandwidth limiting * - Reading Storage Daemon bandwidth limiting */ - if (jcr->impl_->res.job->max_bandwidth > 0) { - jcr->max_bandwidth = jcr->impl_->res.job->max_bandwidth; - } else if (jcr->impl_->res.write_storage->max_bandwidth > 0) { - jcr->max_bandwidth = jcr->impl_->res.write_storage->max_bandwidth; - } else if (jcr->impl_->res.read_storage->max_bandwidth > 0) { - jcr->max_bandwidth = jcr->impl_->res.read_storage->max_bandwidth; + if (jcr->impl->res.job->max_bandwidth > 0) { + jcr->max_bandwidth = jcr->impl->res.job->max_bandwidth; + } else if (jcr->impl->res.write_storage->max_bandwidth > 0) { + jcr->max_bandwidth = jcr->impl->res.write_storage->max_bandwidth; + } else if (jcr->impl->res.read_storage->max_bandwidth > 0) { + jcr->max_bandwidth = jcr->impl->res.read_storage->max_bandwidth; } /* @@ -1427,15 +1427,15 @@ static inline bool DoActualMigration(JobControlRecord* jcr) * the jcr is connected to the reading storage daemon and the * mig_jcr to the writing storage daemon. */ - mig_jcr->impl_->res.write_storage = jcr->impl_->res.write_storage; - jcr->impl_->res.write_storage = NULL; + mig_jcr->impl->res.write_storage = jcr->impl->res.write_storage; + jcr->impl->res.write_storage = NULL; /* * Swap the write_storage_list between the jcr and the mig_jcr. */ - write_storage_list = mig_jcr->impl_->res.write_storage_list; - mig_jcr->impl_->res.write_storage_list = jcr->impl_->res.write_storage_list; - jcr->impl_->res.write_storage_list = write_storage_list; + write_storage_list = mig_jcr->impl->res.write_storage_list; + mig_jcr->impl->res.write_storage_list = jcr->impl->res.write_storage_list; + jcr->impl->res.write_storage_list = write_storage_list; /* * Start conversation with Reading Storage daemon @@ -1461,7 +1461,7 @@ static inline bool DoActualMigration(JobControlRecord* jcr) /* * Now start a job with the Reading Storage daemon */ - if (!StartStorageDaemonJob(jcr, jcr->impl_->res.read_storage_list, NULL, + if (!StartStorageDaemonJob(jcr, jcr->impl->res.read_storage_list, NULL, /* send_bsr */ true)) { goto bail_out; } @@ -1473,7 +1473,7 @@ static inline bool DoActualMigration(JobControlRecord* jcr) */ if (!StartStorageDaemonJob(mig_jcr, NULL, - mig_jcr->impl_->res.write_storage_list, + mig_jcr->impl->res.write_storage_list, /* send_bsr */ false)) { goto bail_out; } @@ -1500,8 +1500,8 @@ static inline bool DoActualMigration(JobControlRecord* jcr) /* * Now start a job with the Storage daemon */ - if (!StartStorageDaemonJob(jcr, jcr->impl_->res.read_storage_list, - jcr->impl_->res.write_storage_list, + if (!StartStorageDaemonJob(jcr, jcr->impl->res.read_storage_list, + jcr->impl->res.write_storage_list, /* send_bsr */ true)) { FreePairedStorage(jcr); return false; @@ -1521,14 +1521,14 @@ static inline bool DoActualMigration(JobControlRecord* jcr) * is after the start of this run. */ jcr->start_time = time(NULL); - jcr->impl_->jr.StartTime = jcr->start_time; - jcr->impl_->jr.JobTDate = jcr->start_time; + jcr->impl->jr.StartTime = jcr->start_time; + jcr->impl->jr.JobTDate = jcr->start_time; jcr->setJobStatus(JS_Running); /* * Update job start record for this migration control job */ - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); goto bail_out; } @@ -1539,30 +1539,30 @@ static inline bool DoActualMigration(JobControlRecord* jcr) jcr->setJobStarted(); mig_jcr->start_time = time(NULL); - mig_jcr->impl_->jr.StartTime = mig_jcr->start_time; - mig_jcr->impl_->jr.JobTDate = mig_jcr->start_time; + mig_jcr->impl->jr.StartTime = mig_jcr->start_time; + mig_jcr->impl->jr.JobTDate = mig_jcr->start_time; mig_jcr->setJobStatus(JS_Running); /* * Update job start record for the real migration backup job */ - if (!mig_jcr->db->UpdateJobStartRecord(mig_jcr, &mig_jcr->impl_->jr)) { + if (!mig_jcr->db->UpdateJobStartRecord(mig_jcr, &mig_jcr->impl->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", mig_jcr->db->strerror()); goto bail_out; } Dmsg4(dbglevel, "mig_jcr: Name=%s JobId=%d Type=%c Level=%c\n", - mig_jcr->impl_->jr.Name, (int)mig_jcr->impl_->jr.JobId, - mig_jcr->impl_->jr.JobType, mig_jcr->impl_->jr.JobLevel); + mig_jcr->impl->jr.Name, (int)mig_jcr->impl->jr.JobId, + mig_jcr->impl->jr.JobType, mig_jcr->impl->jr.JobLevel); /* * If we are connected to two different SDs tell the writing one * to be ready to receive the data and tell the reading one * to replicate to the other. */ - if (jcr->impl_->remote_replicate) { - StorageResource* write_storage = mig_jcr->impl_->res.write_storage; - StorageResource* read_storage = jcr->impl_->res.read_storage; + if (jcr->impl->remote_replicate) { + StorageResource* write_storage = mig_jcr->impl->res.write_storage; + StorageResource* read_storage = jcr->impl->res.read_storage; PoolMem command(PM_MESSAGE); uint32_t tls_need = 0; @@ -1627,27 +1627,27 @@ static inline bool DoActualMigration(JobControlRecord* jcr) * mig_jcr->JobFiles/ReadBytes/JobBytes/JobErrors when replicating to * a remote storage daemon. */ - if (jcr->impl_->remote_replicate) { + if (jcr->impl->remote_replicate) { WaitForStorageDaemonTermination(jcr); WaitForStorageDaemonTermination(mig_jcr); - jcr->setJobStatus(jcr->impl_->SDJobStatus); + jcr->setJobStatus(jcr->impl->SDJobStatus); mig_jcr->db_batch->WriteBatchFileRecords(mig_jcr); } else { WaitForStorageDaemonTermination(jcr); - jcr->setJobStatus(jcr->impl_->SDJobStatus); + jcr->setJobStatus(jcr->impl->SDJobStatus); jcr->db_batch->WriteBatchFileRecords(jcr); } bail_out: - if (jcr->impl_->remote_replicate && mig_jcr) { + if (jcr->impl->remote_replicate && mig_jcr) { alist* write_storage_list; /* * Swap the write_storage_list between the jcr and the mig_jcr. */ - write_storage_list = mig_jcr->impl_->res.write_storage_list; - mig_jcr->impl_->res.write_storage_list = jcr->impl_->res.write_storage_list; - jcr->impl_->res.write_storage_list = write_storage_list; + write_storage_list = mig_jcr->impl->res.write_storage_list; + mig_jcr->impl->res.write_storage_list = jcr->impl->res.write_storage_list; + jcr->impl->res.write_storage_list = write_storage_list; /* * Undo the clear of the write_storage in the jcr and assign the mig_jcr @@ -1657,8 +1657,8 @@ static inline bool DoActualMigration(JobControlRecord* jcr) * the ConnectToStorageDaemon function will do the right thing e.g. connect * the jcrs in the way we want them to. */ - jcr->impl_->res.write_storage = mig_jcr->impl_->res.write_storage; - mig_jcr->impl_->res.write_storage = NULL; + jcr->impl->res.write_storage = mig_jcr->impl->res.write_storage; + mig_jcr->impl->res.write_storage = NULL; } FreePairedStorage(jcr); @@ -1697,7 +1697,7 @@ bool DoMigration(JobControlRecord* jcr) * or Copy or one of the worker Jobs that do the actual Migration or Copy. If * jcr->impl_->MigrateJobId is unset we know that its the control job. */ - if (jcr->impl_->MigrateJobId == 0) { + if (jcr->impl->MigrateJobId == 0) { return DoMigrationSelection(jcr); } else { return DoActualMigration(jcr); @@ -1711,7 +1711,7 @@ static inline void GenerateMigrateSummary(JobControlRecord* jcr, { double kbps; utime_t RunTime; - JobControlRecord* mig_jcr = jcr->impl_->mig_jcr; + JobControlRecord* mig_jcr = jcr->impl->mig_jcr; char term_code[100], sd_term_msg[100]; char sdt[MAX_TIME_LENGTH], edt[MAX_TIME_LENGTH]; char ec1[30], ec2[30], ec3[30], ec4[30], ec5[30], elapsed[50]; @@ -1719,19 +1719,19 @@ static inline void GenerateMigrateSummary(JobControlRecord* jcr, Bsnprintf(term_code, sizeof(term_code), TermMsg, jcr->get_OperationName(), jcr->get_ActionName()); - bstrftimes(sdt, sizeof(sdt), jcr->impl_->jr.StartTime); - bstrftimes(edt, sizeof(edt), jcr->impl_->jr.EndTime); - RunTime = jcr->impl_->jr.EndTime - jcr->impl_->jr.StartTime; + bstrftimes(sdt, sizeof(sdt), jcr->impl->jr.StartTime); + bstrftimes(edt, sizeof(edt), jcr->impl->jr.EndTime); + RunTime = jcr->impl->jr.EndTime - jcr->impl->jr.StartTime; - JobstatusToAscii(jcr->impl_->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); - if (jcr->impl_->previous_jr.JobId != 0) { + JobstatusToAscii(jcr->impl->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); + if (jcr->impl->previous_jr.JobId != 0) { /* * Copy/Migrate worker Job. */ if (RunTime <= 0) { kbps = 0; } else { - kbps = (double)jcr->impl_->SDJobBytes / (1000 * RunTime); + kbps = (double)jcr->impl->SDJobBytes / (1000 * RunTime); } Jmsg(jcr, msg_type, 0, @@ -1767,37 +1767,37 @@ static inline void GenerateMigrateSummary(JobControlRecord* jcr, " Bareos binary info: %s\n" " Termination: %s\n\n"), BAREOS, my_name, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER, - edit_uint64(jcr->impl_->previous_jr.JobId, ec6), - jcr->impl_->previous_jr.Job, - mig_jcr ? edit_uint64(mig_jcr->impl_->jr.JobId, ec7) : _("*None*"), - edit_uint64(jcr->impl_->jr.JobId, ec8), jcr->impl_->jr.Job, + edit_uint64(jcr->impl->previous_jr.JobId, ec6), + jcr->impl->previous_jr.Job, + mig_jcr ? edit_uint64(mig_jcr->impl->jr.JobId, ec7) : _("*None*"), + edit_uint64(jcr->impl->jr.JobId, ec8), jcr->impl->jr.Job, JobLevelToString(jcr->getJobLevel()), - jcr->impl_->res.client ? jcr->impl_->res.client->resource_name_ + jcr->impl->res.client ? jcr->impl->res.client->resource_name_ : _("*None*"), - jcr->impl_->res.fileset ? jcr->impl_->res.fileset->resource_name_ + jcr->impl->res.fileset ? jcr->impl->res.fileset->resource_name_ : _("*None*"), - jcr->impl_->res.rpool->resource_name_, jcr->impl_->res.rpool_source, - jcr->impl_->res.read_storage - ? jcr->impl_->res.read_storage->resource_name_ + jcr->impl->res.rpool->resource_name_, jcr->impl->res.rpool_source, + jcr->impl->res.read_storage + ? jcr->impl->res.read_storage->resource_name_ : _("*None*"), - NPRT(jcr->impl_->res.rstore_source), - jcr->impl_->res.pool->resource_name_, jcr->impl_->res.pool_source, - jcr->impl_->res.write_storage - ? jcr->impl_->res.write_storage->resource_name_ + NPRT(jcr->impl->res.rstore_source), + jcr->impl->res.pool->resource_name_, jcr->impl->res.pool_source, + jcr->impl->res.write_storage + ? jcr->impl->res.write_storage->resource_name_ : _("*None*"), - NPRT(jcr->impl_->res.wstore_source), - jcr->impl_->res.next_pool ? jcr->impl_->res.next_pool->resource_name_ + NPRT(jcr->impl->res.wstore_source), + jcr->impl->res.next_pool ? jcr->impl->res.next_pool->resource_name_ : _("*None*"), - NPRT(jcr->impl_->res.npool_source), - jcr->impl_->res.catalog->resource_name_, - jcr->impl_->res.catalog_source, sdt, edt, + NPRT(jcr->impl->res.npool_source), + jcr->impl->res.catalog->resource_name_, + jcr->impl->res.catalog_source, sdt, edt, edit_utime(RunTime, elapsed, sizeof(elapsed)), jcr->JobPriority, - edit_uint64_with_commas(jcr->impl_->SDJobFiles, ec1), - edit_uint64_with_commas(jcr->impl_->SDJobBytes, ec2), - edit_uint64_with_suffix(jcr->impl_->SDJobBytes, ec3), (float)kbps, + edit_uint64_with_commas(jcr->impl->SDJobFiles, ec1), + edit_uint64_with_commas(jcr->impl->SDJobBytes, ec2), + edit_uint64_with_suffix(jcr->impl->SDJobBytes, ec3), (float)kbps, mig_jcr ? mig_jcr->VolumeName : _("*None*"), jcr->VolSessionId, jcr->VolSessionTime, edit_uint64_with_commas(mr->VolBytes, ec4), - edit_uint64_with_suffix(mr->VolBytes, ec5), jcr->impl_->SDErrors, + edit_uint64_with_suffix(mr->VolBytes, ec5), jcr->impl->SDErrors, sd_term_msg, BAREOS_JOBLOG_MESSAGE, term_code); } else { /* @@ -1816,9 +1816,9 @@ static inline void GenerateMigrateSummary(JobControlRecord* jcr, " Bareos binary info: %s\n" " Termination: %s\n\n"), BAREOS, my_name, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER, - edit_uint64(jcr->impl_->jr.JobId, ec8), jcr->impl_->jr.Job, - jcr->impl_->res.catalog->resource_name_, - jcr->impl_->res.catalog_source, sdt, edt, + edit_uint64(jcr->impl->jr.JobId, ec8), jcr->impl->jr.Job, + jcr->impl->res.catalog->resource_name_, + jcr->impl->res.catalog_source, sdt, edt, edit_utime(RunTime, elapsed, sizeof(elapsed)), jcr->JobPriority, BAREOS_JOBLOG_MESSAGE, term_code); } @@ -1833,7 +1833,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) const char* TermMsg; int msg_type = M_INFO; MediaDbRecord mr; - JobControlRecord* mig_jcr = jcr->impl_->mig_jcr; + JobControlRecord* mig_jcr = jcr->impl->mig_jcr; PoolMem query(PM_MESSAGE); Dmsg2(100, "Enter migrate_cleanup %d %c\n", TermCode, TermCode); @@ -1846,28 +1846,28 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) if (mig_jcr) { char old_jobid[50], new_jobid[50]; - edit_uint64(jcr->impl_->previous_jr.JobId, old_jobid); - edit_uint64(mig_jcr->impl_->jr.JobId, new_jobid); + edit_uint64(jcr->impl->previous_jr.JobId, old_jobid); + edit_uint64(mig_jcr->impl->jr.JobId, new_jobid); /* * See if we used a remote SD if so the mig_jcr contains * the jobfiles and jobbytes and the new volsessionid * and volsessiontime as the writing SD generates this info. */ - if (jcr->impl_->remote_replicate) { - mig_jcr->JobFiles = jcr->JobFiles = mig_jcr->impl_->SDJobFiles; - mig_jcr->JobBytes = jcr->JobBytes = mig_jcr->impl_->SDJobBytes; + if (jcr->impl->remote_replicate) { + mig_jcr->JobFiles = jcr->JobFiles = mig_jcr->impl->SDJobFiles; + mig_jcr->JobBytes = jcr->JobBytes = mig_jcr->impl->SDJobBytes; } else { - mig_jcr->JobFiles = jcr->JobFiles = jcr->impl_->SDJobFiles; - mig_jcr->JobBytes = jcr->JobBytes = jcr->impl_->SDJobBytes; + mig_jcr->JobFiles = jcr->JobFiles = jcr->impl->SDJobFiles; + mig_jcr->JobBytes = jcr->JobBytes = jcr->impl->SDJobBytes; mig_jcr->VolSessionId = jcr->VolSessionId; mig_jcr->VolSessionTime = jcr->VolSessionTime; } - mig_jcr->impl_->jr.RealEndTime = 0; - mig_jcr->impl_->jr.PriorJobId = jcr->impl_->previous_jr.JobId; + mig_jcr->impl->jr.RealEndTime = 0; + mig_jcr->impl->jr.PriorJobId = jcr->impl->previous_jr.JobId; if (jcr->is_JobStatus(JS_Terminated) && - (jcr->JobErrors || jcr->impl_->SDErrors)) { + (jcr->JobErrors || jcr->impl->SDErrors)) { TermCode = JS_Warnings; } @@ -1879,8 +1879,8 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) Mmsg(query, "UPDATE Job SET StartTime='%s',EndTime='%s'," "JobTDate=%s WHERE JobId=%s", - jcr->impl_->previous_jr.cStartTime, jcr->impl_->previous_jr.cEndTime, - edit_uint64(jcr->impl_->previous_jr.JobTDate, ec1), new_jobid); + jcr->impl->previous_jr.cStartTime, jcr->impl->previous_jr.cEndTime, + edit_uint64(jcr->impl->previous_jr.JobTDate, ec1), new_jobid); jcr->db->SqlQuery(query.c_str()); if (jcr->IsTerminatedOk()) { @@ -1913,7 +1913,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) * storage daemon we need to add data normally send to the director * via the FHDB interface here. */ - switch (jcr->impl_->res.client->Protocol) { + switch (jcr->impl->res.client->Protocol) { case APT_NDMPV2: case APT_NDMPV3: case APT_NDMPV4: @@ -1926,7 +1926,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) } ua = new_ua_context(jcr); - if (jcr->impl_->res.job->PurgeMigrateJob) { + if (jcr->impl->res.job->PurgeMigrateJob) { /* * Purge old Job record */ @@ -1960,7 +1960,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) * storage daemon we need to add data normally send to the director * via the FHDB interface here. */ - switch (jcr->impl_->res.client->Protocol) { + switch (jcr->impl->res.client->Protocol) { case APT_NDMPV2: case APT_NDMPV3: case APT_NDMPV4: @@ -1981,7 +1981,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) } } - if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Job record for Job report: ERR=%s"), jcr->db->strerror()); @@ -1990,7 +1990,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) UpdateBootstrapFile(mig_jcr); - if (!mig_jcr->db->GetJobVolumeNames(mig_jcr, mig_jcr->impl_->jr.JobId, + if (!mig_jcr->db->GetJobVolumeNames(mig_jcr, mig_jcr->impl->jr.JobId, mig_jcr->VolumeName)) { /* * Note, if the job has failed, most likely it did not write any @@ -1998,7 +1998,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) * it is normal. Or look at it the other way, only for a * normal exit should we complain about this error. */ - if (jcr->IsTerminatedOk() && jcr->impl_->jr.JobBytes) { + if (jcr->IsTerminatedOk() && jcr->impl->jr.JobBytes) { Jmsg(jcr, M_ERROR, 0, "%s", mig_jcr->db->strerror()); } mig_jcr->VolumeName[0] = 0; /* none */ @@ -2053,8 +2053,8 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) */ if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->impl_->SD_msg_chan_started) { - pthread_cancel(jcr->impl_->SD_msg_chan); + if (jcr->impl->SD_msg_chan_started) { + pthread_cancel(jcr->impl->SD_msg_chan); } } @@ -2063,8 +2063,8 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) */ if (mig_jcr->store_bsock) { mig_jcr->store_bsock->signal(BNET_TERMINATE); - if (mig_jcr->impl_->SD_msg_chan_started) { - pthread_cancel(mig_jcr->impl_->SD_msg_chan); + if (mig_jcr->impl->SD_msg_chan_started) { + pthread_cancel(mig_jcr->impl->SD_msg_chan); } } break; @@ -2072,7 +2072,7 @@ void MigrationCleanup(JobControlRecord* jcr, int TermCode) TermMsg = _("Inappropriate %s term code"); break; } - } else if (jcr->impl_->HasSelectedJobs) { + } else if (jcr->impl->HasSelectedJobs) { switch (jcr->JobStatus) { case JS_Terminated: TermMsg = _("%s OK"); diff --git a/core/src/dird/msgchan.cc b/core/src/dird/msgchan.cc index 177b9012636..e2c55b4ea8b 100644 --- a/core/src/dird/msgchan.cc +++ b/core/src/dird/msgchan.cc @@ -111,9 +111,9 @@ static inline bool SendBootstrapFileToSd(JobControlRecord* jcr, while (fgets(buf, sizeof(buf), bs)) { sd->fsend("%s", buf); } sd->signal(BNET_EOD); fclose(bs); - if (jcr->impl_->unlink_bsr) { + if (jcr->impl->unlink_bsr) { SecureErase(jcr, jcr->RestoreBootstrap); - jcr->impl_->unlink_bsr = false; + jcr->impl->unlink_bsr = false; } return true; } @@ -151,32 +151,32 @@ bool StartStorageDaemonJob(JobControlRecord* jcr, /* * Now send JobId and permissions, and get back the authorization key. */ - PmStrcpy(job_name, jcr->impl_->res.job->resource_name_); + PmStrcpy(job_name, jcr->impl->res.job->resource_name_); BashSpaces(job_name); - if (jcr->impl_->res.client) { - PmStrcpy(client_name, jcr->impl_->res.client->resource_name_); + if (jcr->impl->res.client) { + PmStrcpy(client_name, jcr->impl->res.client->resource_name_); } else { PmStrcpy(client_name, "**None**"); } BashSpaces(client_name); - if (jcr->impl_->res.fileset) { - PmStrcpy(fileset_name, jcr->impl_->res.fileset->resource_name_); + if (jcr->impl->res.fileset) { + PmStrcpy(fileset_name, jcr->impl->res.fileset->resource_name_); } else { PmStrcpy(fileset_name, "**None**"); } BashSpaces(fileset_name); - PmStrcpy(backup_format, jcr->impl_->backup_format); + PmStrcpy(backup_format, jcr->impl->backup_format); BashSpaces(backup_format); - if (jcr->impl_->res.fileset && jcr->impl_->res.fileset->MD5[0] == 0) { - bstrncpy(jcr->impl_->res.fileset->MD5, "**Dummy**", - sizeof(jcr->impl_->res.fileset->MD5)); - fileset_md5 = jcr->impl_->res.fileset->MD5; - } else if (jcr->impl_->res.fileset) { - fileset_md5 = jcr->impl_->res.fileset->MD5; + if (jcr->impl->res.fileset && jcr->impl->res.fileset->MD5[0] == 0) { + bstrncpy(jcr->impl->res.fileset->MD5, "**Dummy**", + sizeof(jcr->impl->res.fileset->MD5)); + fileset_md5 = jcr->impl->res.fileset->MD5; + } else if (jcr->impl->res.fileset) { + fileset_md5 = jcr->impl->res.fileset->MD5; } else { fileset_md5 = "**Dummy**"; } @@ -187,7 +187,7 @@ bool StartStorageDaemonJob(JobControlRecord* jcr, * If we do not cancel it the SD will not accept a new connection * for the same jobid. */ - if (jcr->impl_->reschedule_count) { + if (jcr->impl->reschedule_count) { sd->fsend("cancel Job=%s\n", jcr->Job); while (sd->recv() >= 0) { continue; } } @@ -200,10 +200,10 @@ bool StartStorageDaemonJob(JobControlRecord* jcr, sd->fsend(jobcmd, edit_int64(jcr->JobId, ed1), jcr->Job, job_name.c_str(), client_name.c_str(), jcr->getJobType(), jcr->getJobLevel(), - fileset_name.c_str(), !jcr->impl_->res.pool->catalog_files, - jcr->impl_->res.job->SpoolAttributes, fileset_md5, - jcr->impl_->spool_data, jcr->impl_->res.job->PreferMountedVolumes, - edit_int64(jcr->impl_->spool_size, ed2), jcr->rerunning, + fileset_name.c_str(), !jcr->impl->res.pool->catalog_files, + jcr->impl->res.job->SpoolAttributes, fileset_md5, + jcr->impl->spool_data, jcr->impl->res.job->PreferMountedVolumes, + edit_int64(jcr->impl->spool_size, ed2), jcr->rerunning, jcr->VolSessionId, jcr->VolSessionTime, remainingquota, jcr->getJobProtocol(), backup_format.c_str()); @@ -255,11 +255,11 @@ bool StartStorageDaemonJob(JobControlRecord* jcr, /* For the moment, only migrate, copy and vbackup have rpool */ if (jcr->is_JobType(JT_MIGRATE) || jcr->is_JobType(JT_COPY) || (jcr->is_JobType(JT_BACKUP) && jcr->is_JobLevel(L_VIRTUAL_FULL))) { - PmStrcpy(pool_type, jcr->impl_->res.rpool->pool_type); - PmStrcpy(pool_name, jcr->impl_->res.rpool->resource_name_); + PmStrcpy(pool_type, jcr->impl->res.rpool->pool_type); + PmStrcpy(pool_name, jcr->impl->res.rpool->resource_name_); } else { - PmStrcpy(pool_type, jcr->impl_->res.pool->pool_type); - PmStrcpy(pool_name, jcr->impl_->res.pool->resource_name_); + PmStrcpy(pool_type, jcr->impl->res.pool->pool_type); + PmStrcpy(pool_name, jcr->impl->res.pool->resource_name_); } BashSpaces(pool_type); BashSpaces(pool_name); @@ -298,8 +298,8 @@ bool StartStorageDaemonJob(JobControlRecord* jcr, /* Do write side of storage daemon */ if (ok && write_storage) { - PmStrcpy(pool_type, jcr->impl_->res.pool->pool_type); - PmStrcpy(pool_name, jcr->impl_->res.pool->resource_name_); + PmStrcpy(pool_type, jcr->impl->res.pool->pool_type); + PmStrcpy(pool_name, jcr->impl->res.pool->resource_name_); BashSpaces(pool_type); BashSpaces(pool_name); foreach_alist (storage, write_storage) { @@ -362,8 +362,8 @@ bool StartStorageDaemonMessageThread(JobControlRecord* jcr) pthread_t thid; jcr->IncUseCount(); /* mark in use by msg thread */ - jcr->impl_->sd_msg_thread_done = false; - jcr->impl_->SD_msg_chan_started = false; + jcr->impl->sd_msg_thread_done = false; + jcr->impl->SD_msg_chan_started = false; Dmsg0(100, "Start SD msg_thread.\n"); if ((status = pthread_create(&thid, NULL, msg_thread, (void*)jcr)) != 0) { BErrNo be; @@ -371,9 +371,9 @@ bool StartStorageDaemonMessageThread(JobControlRecord* jcr) be.bstrerror(status)); } /* Wait for thread to start */ - while (!jcr->impl_->SD_msg_chan_started) { + while (!jcr->impl->SD_msg_chan_started) { Bmicrosleep(0, 50); - if (JobCanceled(jcr) || jcr->impl_->sd_msg_thread_done) { return false; } + if (JobCanceled(jcr) || jcr->impl->sd_msg_thread_done) { return false; } } Dmsg1(100, "SD msg_thread started. use=%d\n", jcr->UseCount()); return true; @@ -385,13 +385,13 @@ extern "C" void MsgThreadCleanup(void* arg) jcr->db->EndTransaction(jcr); /* Terminate any open transaction */ jcr->lock(); - jcr->impl_->sd_msg_thread_done = true; - jcr->impl_->SD_msg_chan_started = false; + jcr->impl->sd_msg_thread_done = true; + jcr->impl->SD_msg_chan_started = false; jcr->unlock(); pthread_cond_broadcast( - &jcr->impl_->nextrun_ready); /* wakeup any waiting threads */ + &jcr->impl->nextrun_ready); /* wakeup any waiting threads */ pthread_cond_broadcast( - &jcr->impl_->term_wait); /* wakeup any waiting threads */ + &jcr->impl->term_wait); /* wakeup any waiting threads */ Dmsg2(100, "=== End msg_thread. JobId=%d usecnt=%d\n", jcr->JobId, jcr->UseCount()); jcr->db->ThreadCleanup(); /* remove thread specific data */ @@ -415,8 +415,8 @@ extern "C" void* msg_thread(void* arg) pthread_detach(pthread_self()); SetJcrInThreadSpecificData(jcr); - jcr->impl_->SD_msg_chan = pthread_self(); - jcr->impl_->SD_msg_chan_started = true; + jcr->impl->SD_msg_chan = pthread_self(); + jcr->impl->SD_msg_chan_started = true; pthread_cleanup_push(MsgThreadCleanup, arg); sd = jcr->store_bsock; @@ -435,7 +435,7 @@ extern "C" void* msg_thread(void* arg) if (jcr->sd_auth_key) { free(jcr->sd_auth_key); } jcr->sd_auth_key = strdup(auth_key); pthread_cond_broadcast( - &jcr->impl_->nextrun_ready); /* wakeup any waiting threads */ + &jcr->impl->nextrun_ready); /* wakeup any waiting threads */ continue; } @@ -450,10 +450,10 @@ extern "C" void* msg_thread(void* arg) */ if (sscanf(sd->msg, Job_end, Job, &JobStatus, &JobFiles, &JobBytes, &JobErrors) == 5) { - jcr->impl_->SDJobStatus = JobStatus; /* termination status */ - jcr->impl_->SDJobFiles = JobFiles; - jcr->impl_->SDJobBytes = JobBytes; - jcr->impl_->SDErrors = JobErrors; + jcr->impl->SDJobStatus = JobStatus; /* termination status */ + jcr->impl->SDJobFiles = JobFiles; + jcr->impl->SDJobBytes = JobBytes; + jcr->impl->SDErrors = JobErrors; break; } Dmsg1(400, "end loop use=%d\n", jcr->UseCount()); @@ -467,7 +467,7 @@ extern "C" void* msg_thread(void* arg) */ Qmsg(jcr, M_FATAL, 0, _("Director's comm line to SD dropped.\n")); } - if (IsBnetError(sd)) { jcr->impl_->SDJobStatus = JS_ErrorTerminated; } + if (IsBnetError(sd)) { jcr->impl->SDJobStatus = JS_ErrorTerminated; } pthread_cleanup_pop(1); /* remove and execute the handler */ return NULL; } @@ -476,7 +476,7 @@ void WaitForStorageDaemonTermination(JobControlRecord* jcr) { int cancel_count = 0; /* Now wait for Storage daemon to Terminate our message thread */ - while (!jcr->impl_->sd_msg_thread_done) { + while (!jcr->impl->sd_msg_thread_done) { struct timeval tv; struct timezone tz; struct timespec timeout; @@ -486,10 +486,10 @@ void WaitForStorageDaemonTermination(JobControlRecord* jcr) timeout.tv_sec = tv.tv_sec + 5; /* wait 5 seconds */ Dmsg0(400, "I'm waiting for message thread termination.\n"); P(mutex); - pthread_cond_timedwait(&jcr->impl_->term_wait, &mutex, &timeout); + pthread_cond_timedwait(&jcr->impl->term_wait, &mutex, &timeout); V(mutex); if (jcr->IsCanceled()) { - if (jcr->impl_->SD_msg_chan_started) { + if (jcr->impl->SD_msg_chan_started) { jcr->store_bsock->SetTimedOut(); jcr->store_bsock->SetTerminated(); SdMsgThreadSendSignal(jcr, TIMEOUT_SIGNAL); diff --git a/core/src/dird/ndmp_dma_backup_NDMP_BAREOS.cc b/core/src/dird/ndmp_dma_backup_NDMP_BAREOS.cc index 2e67d4ff9f4..f211885e5e9 100644 --- a/core/src/dird/ndmp_dma_backup_NDMP_BAREOS.cc +++ b/core/src/dird/ndmp_dma_backup_NDMP_BAREOS.cc @@ -110,7 +110,7 @@ static inline bool extract_post_backup_stats(JobControlRecord* jcr, ndm_ee = sess->control_acb->job.result_env_tab.head; while (ndm_ee) { if (!jcr->db->CreateNdmpEnvironmentString( - jcr, &jcr->impl_->jr, ndm_ee->pval.name, ndm_ee->pval.value)) { + jcr, &jcr->impl->jr, ndm_ee->pval.name, ndm_ee->pval.value)) { break; } ndm_ee = ndm_ee->next; @@ -121,7 +121,7 @@ static inline bool extract_post_backup_stats(JobControlRecord* jcr, * level. */ if (nbf_options && nbf_options->uses_level) { - jcr->db->UpdateNdmpLevelMapping(jcr, &jcr->impl_->jr, filesystem, + jcr->db->UpdateNdmpLevelMapping(jcr, &jcr->impl->jr, filesystem, sess->control_acb->job.bu_level); } @@ -137,13 +137,13 @@ bool DoNdmpBackupInit(JobControlRecord* jcr) if (!AllowDuplicateJob(jcr)) { return false; } - jcr->impl_->jr.PoolId = - GetOrCreatePoolRecord(jcr, jcr->impl_->res.pool->resource_name_); - if (jcr->impl_->jr.PoolId == 0) { return false; } + jcr->impl->jr.PoolId = + GetOrCreatePoolRecord(jcr, jcr->impl->res.pool->resource_name_); + if (jcr->impl->jr.PoolId == 0) { return false; } jcr->start_time = time(NULL); - jcr->impl_->jr.StartTime = jcr->start_time; - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { + jcr->impl->jr.StartTime = jcr->start_time; + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); return false; } @@ -151,9 +151,9 @@ bool DoNdmpBackupInit(JobControlRecord* jcr) /* * If pool storage specified, use it instead of job storage */ - CopyWstorage(jcr, jcr->impl_->res.pool->storage, _("Pool resource")); + CopyWstorage(jcr, jcr->impl->res.pool->storage, _("Pool resource")); - if (!jcr->impl_->res.write_storage_list) { + if (!jcr->impl->res.write_storage_list) { Jmsg(jcr, M_FATAL, 0, _("No Storage specification found in Job or Pool.\n")); return false; @@ -199,7 +199,7 @@ bool DoNdmpBackup(JobControlRecord* jcr) int NdmpLoglevel; NdmpLoglevel = - std::max(jcr->impl_->res.client->ndmp_loglevel, me->ndmp_loglevel); + std::max(jcr->impl->res.client->ndmp_loglevel, me->ndmp_loglevel); /* * Print Job Start message @@ -208,9 +208,9 @@ bool DoNdmpBackup(JobControlRecord* jcr) edit_uint64(jcr->JobId, ed1), jcr->Job); jcr->setJobStatus(JS_Running); - Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->impl_->jr.JobId, - jcr->impl_->jr.JobLevel); - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { + Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->impl->jr.JobId, + jcr->impl->jr.JobLevel); + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); return false; } @@ -235,7 +235,7 @@ bool DoNdmpBackup(JobControlRecord* jcr) * data mover which moves the data from the NDMP DATA AGENT to the NDMP * TAPE AGENT. */ - if (jcr->impl_->res.write_storage->paired_storage) { + if (jcr->impl->res.write_storage->paired_storage) { SetPairedStorage(jcr); jcr->setJobStatus(JS_WaitSD); @@ -246,7 +246,7 @@ bool DoNdmpBackup(JobControlRecord* jcr) /* * Now start a job with the Storage daemon */ - if (!StartStorageDaemonJob(jcr, NULL, jcr->impl_->res.write_storage_list)) { + if (!StartStorageDaemonJob(jcr, NULL, jcr->impl->res.write_storage_list)) { return false; } @@ -273,8 +273,8 @@ bool DoNdmpBackup(JobControlRecord* jcr) * and reuse the job definition for each separate sub-backup we perform as * part of the whole job. We only free the env_table between every sub-backup. */ - if (!NdmpBuildClientJob(jcr, jcr->impl_->res.client, - jcr->impl_->res.paired_read_write_storage, + if (!NdmpBuildClientJob(jcr, jcr->impl->res.client, + jcr->impl->res.paired_read_write_storage, NDM_JOB_OP_BACKUP, &ndmp_job)) { goto bail_out; } @@ -287,7 +287,7 @@ bool DoNdmpBackup(JobControlRecord* jcr) * included fileset. */ cnt = 0; - fileset = jcr->impl_->res.fileset; + fileset = jcr->impl->res.fileset; for (i = 0; i < fileset->include_items.size(); i++) { @@ -312,7 +312,7 @@ bool DoNdmpBackup(JobControlRecord* jcr) if (jcr->store_bsock && cnt > 0) { jcr->store_bsock->fsend("nextrun"); P(mutex); - pthread_cond_wait(&jcr->impl_->nextrun_ready, &mutex); + pthread_cond_wait(&jcr->impl->nextrun_ready, &mutex); V(mutex); } @@ -333,8 +333,8 @@ bool DoNdmpBackup(JobControlRecord* jcr) nis->filesystem = item; nis->FileIndex = cnt + 1; nis->jcr = jcr; - nis->save_filehist = jcr->impl_->res.job->SaveFileHist; - nis->filehist_size = jcr->impl_->res.job->FileHistSize; + nis->save_filehist = jcr->impl->res.job->SaveFileHist; + nis->filehist_size = jcr->impl->res.job->FileHistSize; ndmp_sess.param->log.ctx = nis; ndmp_sess.param->log_tag = strdup("DIR-NDMP"); @@ -369,9 +369,9 @@ bool DoNdmpBackup(JobControlRecord* jcr) * the individual file records to it. So we allocate it here once so its * available during the whole NDMP session. */ - if (Bstrcasecmp(jcr->impl_->backup_format, "dump")) { + if (Bstrcasecmp(jcr->impl->backup_format, "dump")) { Mmsg(virtual_filename, "/@NDMP%s%%%d", nis->filesystem, - jcr->impl_->DumpLevel); + jcr->impl->DumpLevel); } else { Mmsg(virtual_filename, "/@NDMP%s", nis->filesystem); } @@ -405,7 +405,7 @@ bool DoNdmpBackup(JobControlRecord* jcr) /* * See if there were any errors during the backup. */ - jcr->impl_->jr.FileIndex = cnt + 1; + jcr->impl->jr.FileIndex = cnt + 1; if (!extract_post_backup_stats(jcr, item, &ndmp_sess)) { goto cleanup; } UnregisterCallbackHooks(&ndmp_sess.control_acb->job.index_log); diff --git a/core/src/dird/ndmp_dma_backup_NDMP_NATIVE.cc b/core/src/dird/ndmp_dma_backup_NDMP_NATIVE.cc index 6ada0f9ed8d..964f8ddf557 100644 --- a/core/src/dird/ndmp_dma_backup_NDMP_NATIVE.cc +++ b/core/src/dird/ndmp_dma_backup_NDMP_NATIVE.cc @@ -91,12 +91,12 @@ int NdmpLoadNext(struct ndm_session* sess) bool prune = false; struct ndmmedia* media; int index = 1; - StorageResource* store = jcr->impl_->res.write_storage; + StorageResource* store = jcr->impl->res.write_storage; /* * get the poolid for pool name */ - mr.PoolId = jcr->impl_->jr.PoolId; + mr.PoolId = jcr->impl->jr.PoolId; if (FindNextVolumeForAppend(jcr, &mr, index, unwanted_volumes, create, @@ -183,7 +183,7 @@ bool DoNdmpBackupNdmpNative(JobControlRecord* jcr) char* item; ndmp_log_level = - std::max(jcr->impl_->res.client->ndmp_loglevel, me->ndmp_loglevel); + std::max(jcr->impl->res.client->ndmp_loglevel, me->ndmp_loglevel); struct ndmca_media_callbacks media_callbacks; @@ -203,21 +203,21 @@ bool DoNdmpBackupNdmpNative(JobControlRecord* jcr) edit_uint64(jcr->JobId, ed1), jcr->Job); jcr->setJobStatus(JS_Running); - Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->impl_->jr.JobId, - jcr->impl_->jr.JobLevel); - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { + Dmsg2(100, "JobId=%d JobLevel=%c\n", jcr->impl->jr.JobId, + jcr->impl->jr.JobLevel); + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); return false; } status = 0; - StorageResource* store = jcr->impl_->res.write_storage; + StorageResource* store = jcr->impl->res.write_storage; PoolMem virtual_filename(PM_FNAME); IncludeExcludeItem* ie; - if (!NdmpBuildClientAndStorageJob(jcr, jcr->impl_->res.write_storage, - jcr->impl_->res.client, + if (!NdmpBuildClientAndStorageJob(jcr, jcr->impl->res.write_storage, + jcr->impl->res.client, true, /* init_tape */ true, /* init_robot */ NDM_JOB_OP_BACKUP, &ndmp_job)) { @@ -238,7 +238,7 @@ bool DoNdmpBackupNdmpNative(JobControlRecord* jcr) * Only one include set of the fileset is allowed in NATIVE mode as * in NDMP also per job only one filesystem can be backed up */ - fileset = jcr->impl_->res.fileset; + fileset = jcr->impl->res.fileset; if (fileset->include_items.size() > 1) { Jmsg(jcr, M_ERROR, 0, @@ -277,8 +277,8 @@ bool DoNdmpBackupNdmpNative(JobControlRecord* jcr) nis->filesystem = item; nis->FileIndex = 1; nis->jcr = jcr; - nis->save_filehist = jcr->impl_->res.job->SaveFileHist; - nis->filehist_size = jcr->impl_->res.job->FileHistSize; + nis->save_filehist = jcr->impl->res.job->SaveFileHist; + nis->filehist_size = jcr->impl->res.job->FileHistSize; ndmp_sess.param->log.ctx = nis; ndmp_sess.param->log_tag = strdup("DIR-NDMP"); @@ -315,9 +315,9 @@ bool DoNdmpBackupNdmpNative(JobControlRecord* jcr) * individual file records to it. So we allocate it here once so its available * during the whole NDMP session. */ - if (Bstrcasecmp(jcr->impl_->backup_format, "dump")) { + if (Bstrcasecmp(jcr->impl->backup_format, "dump")) { Mmsg(virtual_filename, "/@NDMP%s%%%d", nis->filesystem, - jcr->impl_->DumpLevel); + jcr->impl->DumpLevel); } else { Mmsg(virtual_filename, "/@NDMP%s", nis->filesystem); } @@ -358,7 +358,7 @@ bool DoNdmpBackupNdmpNative(JobControlRecord* jcr) /* * See if there were any errors during the backup. */ - jcr->impl_->jr.FileIndex = 1; + jcr->impl->jr.FileIndex = 1; if (!extract_post_backup_stats_ndmp_native(jcr, item, &ndmp_sess)) { goto cleanup; } @@ -472,13 +472,13 @@ bool DoNdmpBackupInitNdmpNative(JobControlRecord* jcr) if (!AllowDuplicateJob(jcr)) { return false; } - jcr->impl_->jr.PoolId = - GetOrCreatePoolRecord(jcr, jcr->impl_->res.pool->resource_name_); - if (jcr->impl_->jr.PoolId == 0) { return false; } + jcr->impl->jr.PoolId = + GetOrCreatePoolRecord(jcr, jcr->impl->res.pool->resource_name_); + if (jcr->impl->jr.PoolId == 0) { return false; } jcr->start_time = time(NULL); - jcr->impl_->jr.StartTime = jcr->start_time; - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { + jcr->impl->jr.StartTime = jcr->start_time; + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); return false; } @@ -486,9 +486,9 @@ bool DoNdmpBackupInitNdmpNative(JobControlRecord* jcr) /* * If pool storage specified, use it instead of job storage */ - CopyWstorage(jcr, jcr->impl_->res.pool->storage, _("Pool resource")); + CopyWstorage(jcr, jcr->impl->res.pool->storage, _("Pool resource")); - if (!jcr->impl_->res.write_storage_list) { + if (!jcr->impl->res.write_storage_list) { Jmsg(jcr, M_FATAL, 0, _("No Storage specification found in Job or Pool.\n")); return false; @@ -538,7 +538,7 @@ static inline bool extract_post_backup_stats_ndmp_native( */ media->slot_addr = GetBareosSlotNumberByElementAddress( - &jcr->impl_->res.write_storage->runtime_storage_status->storage_mapping, + &jcr->impl->res.write_storage->runtime_storage_status->storage_mapping, slot_type_t::kSlotTypeStorage, media->slot_addr); #if 0 Jmsg(jcr, M_INFO, 0, _("Physical Slot is %d\n"), media->slot_addr); @@ -587,7 +587,7 @@ static inline bool extract_post_backup_stats_ndmp_native( ndm_ee = sess->control_acb->job.result_env_tab.head; while (ndm_ee) { if (!jcr->db->CreateNdmpEnvironmentString( - jcr, &jcr->impl_->jr, ndm_ee->pval.name, ndm_ee->pval.value)) { + jcr, &jcr->impl->jr, ndm_ee->pval.name, ndm_ee->pval.value)) { break; } ndm_ee = ndm_ee->next; @@ -598,7 +598,7 @@ static inline bool extract_post_backup_stats_ndmp_native( * level. */ if (nbf_options && nbf_options->uses_level) { - jcr->db->UpdateNdmpLevelMapping(jcr, &jcr->impl_->jr, filesystem, + jcr->db->UpdateNdmpLevelMapping(jcr, &jcr->impl->jr, filesystem, sess->control_acb->job.bu_level); } diff --git a/core/src/dird/ndmp_dma_backup_common.cc b/core/src/dird/ndmp_dma_backup_common.cc index 34a4508f6ee..79043006866 100644 --- a/core/src/dird/ndmp_dma_backup_common.cc +++ b/core/src/dird/ndmp_dma_backup_common.cc @@ -97,8 +97,8 @@ bool FillBackupEnvironment(JobControlRecord* jcr, /* * Set the dump level for the backup. */ - jcr->impl_->DumpLevel = NativeToNdmpLevel(jcr, filesystem); - job->bu_level = jcr->impl_->DumpLevel; + jcr->impl->DumpLevel = NativeToNdmpLevel(jcr, filesystem); + job->bu_level = jcr->impl->DumpLevel; if (job->bu_level == -1) { return false; } pv.name = ndmp_env_keywords[NDMP_ENV_KW_LEVEL]; @@ -189,7 +189,7 @@ bool FillBackupEnvironment(JobControlRecord* jcr, if (jcr->store_bsock) { if (nbf_options && nbf_options->uses_level) { Mmsg(tape_device, "%s@%s%%%d", jcr->sd_auth_key, filesystem, - jcr->impl_->DumpLevel); + jcr->impl->DumpLevel); } else { Mmsg(tape_device, "%s@%s", jcr->sd_auth_key, filesystem); } @@ -207,7 +207,7 @@ int NativeToNdmpLevel(JobControlRecord* jcr, char* filesystem) { int level = -1; - if (!jcr->db->CreateNdmpLevelMapping(jcr, &jcr->impl_->jr, filesystem)) { + if (!jcr->db->CreateNdmpLevelMapping(jcr, &jcr->impl->jr, filesystem)) { return -1; } @@ -219,7 +219,7 @@ int NativeToNdmpLevel(JobControlRecord* jcr, char* filesystem) level = 1; break; case L_INCREMENTAL: - level = jcr->db->GetNdmpLevelMapping(jcr, &jcr->impl_->jr, filesystem); + level = jcr->db->GetNdmpLevelMapping(jcr, &jcr->impl->jr, filesystem); break; default: Jmsg(jcr, M_FATAL, 0, _("Illegal Job Level %c for NDMP Job\n"), @@ -248,7 +248,7 @@ void RegisterCallbackHooks(struct ndmlog* ixlog) #ifdef HAVE_LMDB NIS* nis = (NIS*)ixlog->ctx; - if (nis->jcr->impl_->res.client->ndmp_use_lmdb) { + if (nis->jcr->impl->res.client->ndmp_use_lmdb) { NdmpFhdbLmdbRegister(ixlog); } else { NdmpFhdbMemRegister(ixlog); @@ -263,7 +263,7 @@ void UnregisterCallbackHooks(struct ndmlog* ixlog) #ifdef HAVE_LMDB NIS* nis = (NIS*)ixlog->ctx; - if (nis->jcr->impl_->res.client->ndmp_use_lmdb) { + if (nis->jcr->impl->res.client->ndmp_use_lmdb) { NdmpFhdbLmdbUnregister(ixlog); } else { NdmpFhdbMemUnregister(ixlog); @@ -278,7 +278,7 @@ void ProcessFhdb(struct ndmlog* ixlog) #ifdef HAVE_LMDB NIS* nis = (NIS*)ixlog->ctx; - if (nis->jcr->impl_->res.client->ndmp_use_lmdb) { + if (nis->jcr->impl->res.client->ndmp_use_lmdb) { NdmpFhdbLmdbProcessDb(ixlog); } else { NdmpFhdbMemProcessDb(ixlog); @@ -301,20 +301,20 @@ void NdmpBackupCleanup(JobControlRecord* jcr, int TermCode) Dmsg2(100, "Enter NdmpBackupCleanup %d %c\n", TermCode, TermCode); if (jcr->is_JobStatus(JS_Terminated) && - (jcr->JobErrors || jcr->impl_->SDErrors || jcr->JobWarnings)) { + (jcr->JobErrors || jcr->impl->SDErrors || jcr->JobWarnings)) { TermCode = JS_Warnings; } UpdateJobEnd(jcr, TermCode); - if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Job record for Job report: ERR=%s"), jcr->db->strerror()); jcr->setJobStatus(JS_ErrorTerminated); } - bstrncpy(cr.Name, jcr->impl_->res.client->resource_name_, sizeof(cr.Name)); + bstrncpy(cr.Name, jcr->impl->res.client->resource_name_, sizeof(cr.Name)); if (!jcr->db->GetClientRecord(jcr, &cr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Client record for Job report: ERR=%s"), @@ -336,8 +336,8 @@ void NdmpBackupCleanup(JobControlRecord* jcr, int TermCode) msg_type = M_ERROR; /* Generate error message */ if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->impl_->SD_msg_chan_started) { - pthread_cancel(jcr->impl_->SD_msg_chan); + if (jcr->impl->SD_msg_chan_started) { + pthread_cancel(jcr->impl->SD_msg_chan); } } break; @@ -345,8 +345,8 @@ void NdmpBackupCleanup(JobControlRecord* jcr, int TermCode) TermMsg = _("Backup Canceled"); if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->impl_->SD_msg_chan_started) { - pthread_cancel(jcr->impl_->SD_msg_chan); + if (jcr->impl->SD_msg_chan_started) { + pthread_cancel(jcr->impl->SD_msg_chan); } } break; diff --git a/core/src/dird/ndmp_dma_generic.cc b/core/src/dird/ndmp_dma_generic.cc index 7ffc105713e..b91b9a0be8a 100644 --- a/core/src/dird/ndmp_dma_generic.cc +++ b/core/src/dird/ndmp_dma_generic.cc @@ -91,15 +91,15 @@ ndmp_backup_format_option* ndmp_lookup_backup_format_options( */ bool NdmpValidateClient(JobControlRecord* jcr) { - switch (jcr->impl_->res.client->Protocol) { + switch (jcr->impl->res.client->Protocol) { case APT_NDMPV2: case APT_NDMPV3: case APT_NDMPV4: - if (jcr->impl_->res.client->password_.encoding != p_encoding_clear) { + if (jcr->impl->res.client->password_.encoding != p_encoding_clear) { Jmsg(jcr, M_FATAL, 0, _("Client %s, has incompatible password encoding for running NDMP " "backup.\n"), - jcr->impl_->res.client->resource_name_); + jcr->impl->res.client->resource_name_); return false; } break; @@ -108,8 +108,8 @@ bool NdmpValidateClient(JobControlRecord* jcr) jcr, M_FATAL, 0, _("Client %s, with backup protocol %s not compatible for running " "NDMP backup.\n"), - jcr->impl_->res.client->resource_name_, - AuthenticationProtocolTypeToString(jcr->impl_->res.client->Protocol)); + jcr->impl->res.client->resource_name_, + AuthenticationProtocolTypeToString(jcr->impl->res.client->Protocol)); return false; } @@ -146,12 +146,12 @@ bool NdmpValidateStorage(JobControlRecord* jcr) { StorageResource* store = nullptr; - if (jcr->impl_->res.write_storage_list) { - foreach_alist (store, jcr->impl_->res.write_storage_list) { + if (jcr->impl->res.write_storage_list) { + foreach_alist (store, jcr->impl->res.write_storage_list) { if (!NdmpValidateStorage(jcr, store)) { return false; } } } else { - foreach_alist (store, jcr->impl_->res.read_storage_list) { + foreach_alist (store, jcr->impl->res.read_storage_list) { if (!NdmpValidateStorage(jcr, store)) { return false; } } } @@ -327,7 +327,7 @@ bool NdmpBuildClientJob(JobControlRecord* jcr, memset(job, 0, sizeof(struct ndm_job_param)); job->operation = operation; - job->bu_type = jcr->impl_->backup_format; + job->bu_type = jcr->impl->backup_format; /* * For NDMP the backupformat is a prerequite abort the backup job when @@ -358,32 +358,32 @@ bool NdmpBuildClientJob(JobControlRecord* jcr, goto bail_out; } - if (Bstrcasecmp(jcr->impl_->backup_format, "smtape")) { + if (Bstrcasecmp(jcr->impl->backup_format, "smtape")) { /* * SMTAPE only wants certain blocksizes. */ - if (jcr->impl_->res.client->ndmp_blocksize < SMTAPE_MIN_BLOCKSIZE || - jcr->impl_->res.client->ndmp_blocksize > SMTAPE_MAX_BLOCKSIZE) { + if (jcr->impl->res.client->ndmp_blocksize < SMTAPE_MIN_BLOCKSIZE || + jcr->impl->res.client->ndmp_blocksize > SMTAPE_MAX_BLOCKSIZE) { Jmsg(jcr, M_FATAL, 0, _("For SMTAPE NDMP jobs the NDMP blocksize needs to be between %d " "and %d, but is set to %d\n"), SMTAPE_MIN_BLOCKSIZE, SMTAPE_MAX_BLOCKSIZE, - jcr->impl_->res.client->ndmp_blocksize); + jcr->impl->res.client->ndmp_blocksize); goto bail_out; } - if ((jcr->impl_->res.client->ndmp_blocksize % + if ((jcr->impl->res.client->ndmp_blocksize % SMTAPE_BLOCKSIZE_INCREMENTS) != 0) { Jmsg(jcr, M_FATAL, 0, _("For SMTAPE NDMP jobs the NDMP blocksize needs to be in " "increments of %d bytes, but is set to %d\n"), - SMTAPE_BLOCKSIZE_INCREMENTS, jcr->impl_->res.client->ndmp_blocksize); + SMTAPE_BLOCKSIZE_INCREMENTS, jcr->impl->res.client->ndmp_blocksize); goto bail_out; } - job->record_size = jcr->impl_->res.client->ndmp_blocksize; + job->record_size = jcr->impl->res.client->ndmp_blocksize; } else { - job->record_size = jcr->impl_->res.client->ndmp_blocksize; + job->record_size = jcr->impl->res.client->ndmp_blocksize; } return true; @@ -403,7 +403,7 @@ bool NdmpBuildStorageJob(JobControlRecord* jcr, memset(job, 0, sizeof(struct ndm_job_param)); job->operation = operation; - job->bu_type = jcr->impl_->backup_format; + job->bu_type = jcr->impl->backup_format; if (!fill_ndmp_agent_config(jcr, &job->data_agent, store->Protocol, store->AuthType, store->address, store->SDport, diff --git a/core/src/dird/ndmp_dma_restore_NDMP_BAREOS.cc b/core/src/dird/ndmp_dma_restore_NDMP_BAREOS.cc index 8609034d778..10a4b2fc1f8 100644 --- a/core/src/dird/ndmp_dma_restore_NDMP_BAREOS.cc +++ b/core/src/dird/ndmp_dma_restore_NDMP_BAREOS.cc @@ -71,7 +71,7 @@ static inline char* lookup_fileindex(JobControlRecord* jcr, int32_t FileIndex) TREE_NODE *node, *parent; PoolMem restore_pathname, tmp; - node = FirstTreeNode(jcr->impl_->restore_tree_root); + node = FirstTreeNode(jcr->impl->restore_tree_root); while (node) { /* * See if this is the wanted FileIndex. @@ -112,7 +112,7 @@ static inline int set_files_to_restore(JobControlRecord* jcr, TREE_NODE *node, *parent; PoolMem restore_pathname, tmp; - node = FirstTreeNode(jcr->impl_->restore_tree_root); + node = FirstTreeNode(jcr->impl->restore_tree_root); while (node) { /* * See if this is the wanted FileIndex and the user asked to extract it. @@ -253,7 +253,7 @@ static inline bool fill_restore_environment(JobControlRecord* jcr, /* * Lookup any meta tags that need to be added. */ - fileset = jcr->impl_->res.fileset; + fileset = jcr->impl->res.fileset; for (IncludeExcludeItem* ie : fileset->include_items) { /* * Loop over each file = entry of the fileset. @@ -284,7 +284,7 @@ static inline bool fill_restore_environment(JobControlRecord* jcr, if (jcr->where) { restore_prefix = jcr->where; } else { - restore_prefix = jcr->impl_->res.job->RestoreWhere; + restore_prefix = jcr->impl->res.job->RestoreWhere; } if (!restore_prefix) { return false; } @@ -363,7 +363,7 @@ bool DoNdmpRestoreInit(JobControlRecord* jcr) { FreeWstorage(jcr); /* we don't write */ - if (!jcr->impl_->restore_tree_root) { + if (!jcr->impl->restore_tree_root) { Jmsg(jcr, M_FATAL, 0, _("Cannot NDMP restore without a file selection.\n")); return false; } @@ -380,10 +380,10 @@ static inline int NdmpWaitForJobTermination(JobControlRecord* jcr) * so that we let the SD despool. */ Dmsg4(100, "cancel=%d FDJS=%d JS=%d SDJS=%d\n", jcr->IsCanceled(), - jcr->impl_->FDJobStatus, jcr->JobStatus, jcr->impl_->SDJobStatus); - if (jcr->IsCanceled() || (!jcr->impl_->res.job->RescheduleIncompleteJobs)) { - Dmsg3(100, "FDJS=%d JS=%d SDJS=%d\n", jcr->impl_->FDJobStatus, - jcr->JobStatus, jcr->impl_->SDJobStatus); + jcr->impl->FDJobStatus, jcr->JobStatus, jcr->impl->SDJobStatus); + if (jcr->IsCanceled() || (!jcr->impl->res.job->RescheduleIncompleteJobs)) { + Dmsg3(100, "FDJS=%d JS=%d SDJS=%d\n", jcr->impl->FDJobStatus, + jcr->JobStatus, jcr->impl->SDJobStatus); CancelStorageDaemonJob(jcr); } @@ -392,12 +392,12 @@ static inline int NdmpWaitForJobTermination(JobControlRecord* jcr) */ WaitForStorageDaemonTermination(jcr); - jcr->impl_->FDJobStatus = JS_Terminated; + jcr->impl->FDJobStatus = JS_Terminated; if (jcr->JobStatus != JS_Terminated) { return jcr->JobStatus; } - if (jcr->impl_->FDJobStatus != JS_Terminated) { - return jcr->impl_->FDJobStatus; + if (jcr->impl->FDJobStatus != JS_Terminated) { + return jcr->impl->FDJobStatus; } - return jcr->impl_->SDJobStatus; + return jcr->impl->SDJobStatus; } /** @@ -425,8 +425,8 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr) bool retval = false; int NdmpLoglevel; - if (jcr->impl_->res.client->ndmp_loglevel > me->ndmp_loglevel) { - NdmpLoglevel = jcr->impl_->res.client->ndmp_loglevel; + if (jcr->impl->res.client->ndmp_loglevel > me->ndmp_loglevel) { + NdmpLoglevel = jcr->impl->res.client->ndmp_loglevel; } else { NdmpLoglevel = me->ndmp_loglevel; } @@ -434,8 +434,8 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr) /* * We first parse the BootStrapRecord ourself so we know what to restore. */ - jcr->impl_->bsr = libbareos::parse_bsr(jcr, jcr->RestoreBootstrap); - if (!jcr->impl_->bsr) { + jcr->impl->bsr = libbareos::parse_bsr(jcr, jcr->RestoreBootstrap); + if (!jcr->impl->bsr) { Jmsg(jcr, M_FATAL, 0, _("Error parsing bootstrap file.\n")); goto bail_out; } @@ -444,11 +444,11 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr) * Setup all paired read storage. */ SetPairedStorage(jcr); - if (!jcr->impl_->res.paired_read_write_storage) { + if (!jcr->impl->res.paired_read_write_storage) { Jmsg(jcr, M_FATAL, 0, _("Read storage %s doesn't point to storage definition with paired " "storage option.\n"), - jcr->impl_->res.read_storage->resource_name_); + jcr->impl->res.read_storage->resource_name_); goto bail_out; } @@ -463,7 +463,7 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr) /* * Read the bootstrap file */ - bsr = jcr->impl_->bsr; + bsr = jcr->impl->bsr; while (!feof(info.bs)) { if (!SelectNextRstore(jcr, info)) { goto cleanup; } @@ -473,8 +473,8 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr) * we perform as part of the whole job. We only free the env_table between * every sub-restore. */ - if (!NdmpBuildClientJob(jcr, jcr->impl_->res.client, - jcr->impl_->res.paired_read_write_storage, + if (!NdmpBuildClientJob(jcr, jcr->impl->res.client, + jcr->impl->res.paired_read_write_storage, NDM_JOB_OP_EXTRACT, &ndmp_job)) { goto cleanup; } @@ -499,7 +499,7 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr) /* * Now start a job with the Storage daemon */ - if (!StartStorageDaemonJob(jcr, jcr->impl_->res.read_storage_list, NULL)) { + if (!StartStorageDaemonJob(jcr, jcr->impl->res.read_storage_list, NULL)) { goto cleanup; } @@ -536,13 +536,13 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr) bool first_run = true; bool next_sessid = true; bool next_fi = true; - int first_fi = jcr->impl_->bsr->FileIndex->findex; - int last_fi = jcr->impl_->bsr->FileIndex->findex2; - VolumeSessionInfo current_session{jcr->impl_->bsr->sessid->sessid, - jcr->impl_->bsr->sesstime->sesstime}; + int first_fi = jcr->impl->bsr->FileIndex->findex; + int last_fi = jcr->impl->bsr->FileIndex->findex2; + VolumeSessionInfo current_session{jcr->impl->bsr->sessid->sessid, + jcr->impl->bsr->sesstime->sesstime}; cnt = 0; - for (bsr = jcr->impl_->bsr; bsr; bsr = bsr->next) { + for (bsr = jcr->impl->bsr; bsr; bsr = bsr->next) { if (current_session.id != bsr->sessid->sessid) { current_session = {bsr->sessid->sessid, bsr->sesstime->sesstime}; first_run = true; @@ -592,7 +592,7 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr) if (jcr->store_bsock && cnt > 0) { jcr->store_bsock->fsend("nextrun"); P(mutex); - pthread_cond_wait(&jcr->impl_->nextrun_ready, &mutex); + pthread_cond_wait(&jcr->impl->nextrun_ready, &mutex); V(mutex); } @@ -623,7 +623,7 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr) /* * Copy the actual job to perform. */ - jcr->impl_->jr.FileIndex = current_fi; + jcr->impl->jr.FileIndex = current_fi; memcpy(&ndmp_sess.control_acb->job, &ndmp_job, sizeof(struct ndm_job_param)); @@ -762,8 +762,8 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord* jcr) CloseBootstrapFile(info); bail_out: - FreeTree(jcr->impl_->restore_tree_root); - jcr->impl_->restore_tree_root = NULL; + FreeTree(jcr->impl->restore_tree_root); + jcr->impl->restore_tree_root = NULL; return retval; } @@ -775,14 +775,14 @@ bool DoNdmpRestore(JobControlRecord* jcr) { int status; - jcr->impl_->jr.JobLevel = L_FULL; /* Full restore */ - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { + jcr->impl->jr.JobLevel = L_FULL; /* Full restore */ + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); goto bail_out; } Dmsg0(20, "Updated job start record\n"); - Dmsg1(20, "RestoreJobId=%d\n", jcr->impl_->res.job->RestoreJobId); + Dmsg1(20, "RestoreJobId=%d\n", jcr->impl->res.job->RestoreJobId); /* * Validate the Job to have a NDMP client. diff --git a/core/src/dird/ndmp_dma_restore_NDMP_NATIVE.cc b/core/src/dird/ndmp_dma_restore_NDMP_NATIVE.cc index 6d97c1ff03c..f7d1a63c22e 100644 --- a/core/src/dird/ndmp_dma_restore_NDMP_NATIVE.cc +++ b/core/src/dird/ndmp_dma_restore_NDMP_NATIVE.cc @@ -108,7 +108,7 @@ static inline bool fill_restore_environment_ndmp_native( if (jcr->where) { restore_prefix = jcr->where; } else { - restore_prefix = jcr->impl_->res.job->RestoreWhere; + restore_prefix = jcr->impl->res.job->RestoreWhere; } if (!restore_prefix) { return false; } @@ -177,7 +177,7 @@ int SetFilesToRestoreNdmpNative(JobControlRecord* jcr, TREE_NODE *node, *parent; PoolMem restore_pathname, tmp; - node = FirstTreeNode(jcr->impl_->restore_tree_root); + node = FirstTreeNode(jcr->impl->restore_tree_root); while (node) { /* * node->extract_dir means that only the directory should be selected for @@ -254,7 +254,7 @@ static bool DoNdmpNativeRestore(JobControlRecord* jcr) slot_number_t ndmp_slot; StorageResource* store = NULL; - store = jcr->impl_->res.read_storage; + store = jcr->impl->res.read_storage; memset(&ndmp_sess, 0, sizeof(ndmp_sess)); @@ -262,9 +262,9 @@ static bool DoNdmpNativeRestore(JobControlRecord* jcr) memset(nis, 0, sizeof(NIS)); NdmpLoglevel = - std::max(jcr->impl_->res.client->ndmp_loglevel, me->ndmp_loglevel); + std::max(jcr->impl->res.client->ndmp_loglevel, me->ndmp_loglevel); - if (!NdmpBuildClientAndStorageJob(jcr, store, jcr->impl_->res.client, + if (!NdmpBuildClientAndStorageJob(jcr, store, jcr->impl->res.client, true, /* init_tape */ true, /* init_robot */ NDM_JOB_OP_EXTRACT, &ndmp_job)) { @@ -451,8 +451,8 @@ static bool DoNdmpNativeRestore(JobControlRecord* jcr) cleanup: free(nis); - FreeTree(jcr->impl_->restore_tree_root); - jcr->impl_->restore_tree_root = NULL; + FreeTree(jcr->impl->restore_tree_root); + jcr->impl->restore_tree_root = NULL; return retval; } @@ -463,14 +463,14 @@ bool DoNdmpRestoreNdmpNative(JobControlRecord* jcr) { int status; - jcr->impl_->jr.JobLevel = L_FULL; /* Full restore */ - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { + jcr->impl->jr.JobLevel = L_FULL; /* Full restore */ + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); goto bail_out; } Dmsg0(20, "Updated job start record\n"); - Dmsg1(20, "RestoreJobId=%d\n", jcr->impl_->res.job->RestoreJobId); + Dmsg1(20, "RestoreJobId=%d\n", jcr->impl->res.job->RestoreJobId); /* * Validate the Job to have a NDMP client. diff --git a/core/src/dird/ndmp_dma_restore_common.cc b/core/src/dird/ndmp_dma_restore_common.cc index 4624dbf200b..6a01fd8967d 100644 --- a/core/src/dird/ndmp_dma_restore_common.cc +++ b/core/src/dird/ndmp_dma_restore_common.cc @@ -189,16 +189,16 @@ void NdmpRestoreCleanup(JobControlRecord* jcr, int TermCode) Dmsg0(20, "In NdmpRestoreCleanup\n"); UpdateJobEnd(jcr, TermCode); - if (jcr->impl_->unlink_bsr && jcr->RestoreBootstrap) { + if (jcr->impl->unlink_bsr && jcr->RestoreBootstrap) { SecureErase(jcr, jcr->RestoreBootstrap); - jcr->impl_->unlink_bsr = false; + jcr->impl->unlink_bsr = false; } if (JobCanceled(jcr)) { CancelStorageDaemonJob(jcr); } switch (TermCode) { case JS_Terminated: - if (jcr->impl_->ExpectedFiles > jcr->impl_->jr.JobFiles) { + if (jcr->impl->ExpectedFiles > jcr->impl->jr.JobFiles) { TermMsg = _("Restore OK -- warning file count mismatch"); } else { TermMsg = _("Restore OK"); @@ -213,8 +213,8 @@ void NdmpRestoreCleanup(JobControlRecord* jcr, int TermCode) msg_type = M_ERROR; /* Generate error message */ if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->impl_->SD_msg_chan_started) { - pthread_cancel(jcr->impl_->SD_msg_chan); + if (jcr->impl->SD_msg_chan_started) { + pthread_cancel(jcr->impl->SD_msg_chan); } } break; @@ -222,8 +222,8 @@ void NdmpRestoreCleanup(JobControlRecord* jcr, int TermCode) TermMsg = _("Restore Canceled"); if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->impl_->SD_msg_chan_started) { - pthread_cancel(jcr->impl_->SD_msg_chan); + if (jcr->impl->SD_msg_chan_started) { + pthread_cancel(jcr->impl->SD_msg_chan); } } break; diff --git a/core/src/dird/ndmp_dma_storage.cc b/core/src/dird/ndmp_dma_storage.cc index d4b876f1570..af421d21bd9 100644 --- a/core/src/dird/ndmp_dma_storage.cc +++ b/core/src/dird/ndmp_dma_storage.cc @@ -72,10 +72,10 @@ int get_tape_info_cb(struct ndm_session* sess, } if (jcr->is_JobType(JT_BACKUP)) { - store = jcr->impl_->res.write_storage; + store = jcr->impl->res.write_storage; } else if (jcr->is_JobType(JT_RESTORE)) { - store = jcr->impl_->res.read_storage; + store = jcr->impl->res.read_storage; } else { return -1; @@ -188,7 +188,7 @@ void DoNdmpNativeStorageStatus(UaContext* ua, StorageResource* store, char* cmd) { struct ndm_job_param ndmp_job; - ua->jcr->impl_->res.write_storage = store; + ua->jcr->impl->res.write_storage = store; if (!NdmpBuildStorageJob(ua->jcr, store, true, /* Query Tape Agent */ true, /* Query Robot Agent */ @@ -1141,7 +1141,7 @@ bool ndmp_native_setup_robot_and_tape_for_native_backup_job( * unload tape if tape is in drive */ ndmp_job.auto_remedy = 1; - ndmp_job.record_size = jcr->impl_->res.client->ndmp_blocksize; + ndmp_job.record_size = jcr->impl->res.client->ndmp_blocksize; Jmsg(jcr, M_INFO, 0, _("Using Data host %s\n"), ndmp_job.data_agent.host); Jmsg(jcr, M_INFO, 0, _("Using Tape host:device:address %s:%s:@%d\n"), diff --git a/core/src/dird/newvol.cc b/core/src/dird/newvol.cc index d3a87deabe3..cc941be8b89 100644 --- a/core/src/dird/newvol.cc +++ b/core/src/dird/newvol.cc @@ -78,7 +78,7 @@ bool newVolume(JobControlRecord* jcr, MediaDbRecord* mr, StorageResource* store) *mr = MediaDbRecord{}; SetPoolDbrDefaultsInMediaDbr(mr, &pr); jcr->VolumeName[0] = 0; - bstrncpy(mr->MediaType, jcr->impl_->res.write_storage->media_type, + bstrncpy(mr->MediaType, jcr->impl->res.write_storage->media_type, sizeof(mr->MediaType)); GeneratePluginEvent(jcr, bDirEventNewVolume); /* return void... */ if (jcr->VolumeName[0] && IsVolumeNameLegal(NULL, jcr->VolumeName)) { @@ -181,7 +181,7 @@ static bool PerformFullNameSubstitution(JobControlRecord* jcr, bool ok = false; POOLMEM* label = GetPoolMemory(PM_FNAME); - jcr->impl_->NumVols = pr->NumVols; + jcr->impl->NumVols = pr->NumVols; if (VariableExpansion(jcr, pr->LabelFormat, label)) { bstrncpy(mr->VolumeName, label, sizeof(mr->VolumeName)); ok = true; diff --git a/core/src/dird/next_vol.cc b/core/src/dird/next_vol.cc index fae7b9690ee..7ed929c1707 100644 --- a/core/src/dird/next_vol.cc +++ b/core/src/dird/next_vol.cc @@ -78,7 +78,7 @@ int FindNextVolumeForAppend(JobControlRecord* jcr, int retry = 0; bool ok; bool InChanger; - StorageResource* store = jcr->impl_->res.write_storage; + StorageResource* store = jcr->impl->res.write_storage; bstrncpy(mr->MediaType, store->media_type, sizeof(mr->MediaType)); Dmsg3(debuglevel, @@ -172,12 +172,12 @@ int FindNextVolumeForAppend(JobControlRecord* jcr, /* * Look at more drastic ways to find an Appendable Volume */ - if (!ok && (jcr->impl_->res.pool->purge_oldest_volume || - jcr->impl_->res.pool->recycle_oldest_volume)) { + if (!ok && (jcr->impl->res.pool->purge_oldest_volume || + jcr->impl->res.pool->recycle_oldest_volume)) { Dmsg2(debuglevel, "No next volume found. PurgeOldest=%d\n RecyleOldest=%d", - jcr->impl_->res.pool->purge_oldest_volume, - jcr->impl_->res.pool->recycle_oldest_volume); + jcr->impl->res.pool->purge_oldest_volume, + jcr->impl->res.pool->recycle_oldest_volume); /* * Find oldest volume to recycle @@ -193,11 +193,11 @@ int FindNextVolumeForAppend(JobControlRecord* jcr, * 7. Try to purging oldest volume only if not UA calling us. */ ua = new_ua_context(jcr); - if (jcr->impl_->res.pool->purge_oldest_volume && create) { + if (jcr->impl->res.pool->purge_oldest_volume && create) { Jmsg(jcr, M_INFO, 0, _("Purging oldest volume \"%s\"\n"), mr->VolumeName); ok = PurgeJobsFromVolume(ua, mr); - } else if (jcr->impl_->res.pool->recycle_oldest_volume) { + } else if (jcr->impl->res.pool->recycle_oldest_volume) { /* * 8. Try recycling the oldest volume */ @@ -264,7 +264,7 @@ bool HasVolumeExpired(JobControlRecord* jcr, MediaDbRecord* mr) edit_uint64_with_commas(mr->MaxVolBytes, ed1), mr->VolumeName); bstrncpy(mr->VolStatus, "Full", sizeof(mr->VolStatus)); expired = true; - } else if (mr->VolBytes > 0 && jcr->impl_->res.pool->use_volume_once) { + } else if (mr->VolBytes > 0 && jcr->impl->res.pool->use_volume_once) { /* * Volume should only be used once */ @@ -397,7 +397,7 @@ void CheckIfVolumeValidOrRecyclable(JobControlRecord* jcr, * try to catch close calls ... */ if ((mr->LastWritten + mr->VolRetention - 60) < (utime_t)time(NULL) && - jcr->impl_->res.pool->recycle_current_volume && + jcr->impl->res.pool->recycle_current_volume && (bstrcmp(mr->VolStatus, "Full") || bstrcmp(mr->VolStatus, "Used"))) { /* * Attempt prune of current volume to see if we can recycle it for use. @@ -486,7 +486,7 @@ bool GetScratchVolume(JobControlRecord* jcr, * add a Volume. */ PoolDbRecord pr; - bstrncpy(pr.Name, jcr->impl_->res.pool->resource_name_, sizeof(pr.Name)); + bstrncpy(pr.Name, jcr->impl->res.pool->resource_name_, sizeof(pr.Name)); if (!jcr->db->GetPoolRecord(jcr, &pr)) { Jmsg(jcr, M_WARNING, 0, _("Unable to get Pool record: ERR=%s"), @@ -500,7 +500,7 @@ bool GetScratchVolume(JobControlRecord* jcr, if (pr.MaxVols > 0 && pr.NumVols >= pr.MaxVols) { Jmsg(jcr, M_WARNING, 0, _("Unable add Scratch Volume, Pool \"%s\" full MaxVols=%d\n"), - jcr->impl_->res.pool->resource_name_, pr.MaxVols); + jcr->impl->res.pool->resource_name_, pr.MaxVols); goto bail_out; } diff --git a/core/src/dird/quota.cc b/core/src/dird/quota.cc index ce6e42c85f0..8e8637410aa 100644 --- a/core/src/dird/quota.cc +++ b/core/src/dird/quota.cc @@ -48,47 +48,47 @@ uint64_t FetchRemainingQuotas(JobControlRecord* jcr) /* * Quotas not being used ? */ - if (!jcr->impl_->HasQuota) { return 0; } + if (!jcr->impl->HasQuota) { return 0; } Dmsg2(debuglevel, "JobSumTotalBytes for JobId %d is %llu\n", jcr->JobId, - jcr->impl_->jr.JobSumTotalBytes); + jcr->impl->jr.JobSumTotalBytes); Dmsg1(debuglevel, "Fetching remaining quotas for JobId %d\n", jcr->JobId); /* * If strict quotas on and grace exceeded, enforce the softquota */ - if (jcr->impl_->res.client->StrictQuotas && - jcr->impl_->res.client->SoftQuota && - jcr->impl_->res.client->GraceTime > 0 && - (now - (uint64_t)jcr->impl_->res.client->GraceTime) > - (uint64_t)jcr->impl_->res.client->SoftQuotaGracePeriod && - jcr->impl_->res.client->SoftQuotaGracePeriod > 0) { + if (jcr->impl->res.client->StrictQuotas && + jcr->impl->res.client->SoftQuota && + jcr->impl->res.client->GraceTime > 0 && + (now - (uint64_t)jcr->impl->res.client->GraceTime) > + (uint64_t)jcr->impl->res.client->SoftQuotaGracePeriod && + jcr->impl->res.client->SoftQuotaGracePeriod > 0) { remaining = - jcr->impl_->res.client->SoftQuota - jcr->impl_->jr.JobSumTotalBytes; - } else if (!jcr->impl_->res.client->StrictQuotas && - jcr->impl_->res.client->SoftQuota && - jcr->impl_->res.client->GraceTime > 0 && - jcr->impl_->res.client->SoftQuotaGracePeriod > 0 && - (now - (uint64_t)jcr->impl_->res.client->GraceTime) > - (uint64_t)jcr->impl_->res.client->SoftQuotaGracePeriod) { + jcr->impl->res.client->SoftQuota - jcr->impl->jr.JobSumTotalBytes; + } else if (!jcr->impl->res.client->StrictQuotas && + jcr->impl->res.client->SoftQuota && + jcr->impl->res.client->GraceTime > 0 && + jcr->impl->res.client->SoftQuotaGracePeriod > 0 && + (now - (uint64_t)jcr->impl->res.client->GraceTime) > + (uint64_t)jcr->impl->res.client->SoftQuotaGracePeriod) { /* * If strict quotas turned off and grace exceeded use the last known limit */ - if (jcr->impl_->res.client->QuotaLimit > - jcr->impl_->res.client->SoftQuota) { + if (jcr->impl->res.client->QuotaLimit > + jcr->impl->res.client->SoftQuota) { remaining = - jcr->impl_->res.client->QuotaLimit - jcr->impl_->jr.JobSumTotalBytes; + jcr->impl->res.client->QuotaLimit - jcr->impl->jr.JobSumTotalBytes; } else { remaining = - jcr->impl_->res.client->SoftQuota - jcr->impl_->jr.JobSumTotalBytes; + jcr->impl->res.client->SoftQuota - jcr->impl->jr.JobSumTotalBytes; } - } else if (jcr->impl_->jr.JobSumTotalBytes < - jcr->impl_->res.client->HardQuota) { + } else if (jcr->impl->jr.JobSumTotalBytes < + jcr->impl->res.client->HardQuota) { /* * If within the hardquota. */ remaining = - jcr->impl_->res.client->HardQuota - jcr->impl_->jr.JobSumTotalBytes; + jcr->impl->res.client->HardQuota - jcr->impl->jr.JobSumTotalBytes; } else { /* * If just over quota return 0. This shouldnt happen because quotas @@ -99,8 +99,8 @@ uint64_t FetchRemainingQuotas(JobControlRecord* jcr) Dmsg4(debuglevel, "Quota for %s is %llu. Remainder is %llu, QuotaLimit: %llu\n", - jcr->impl_->jr.Name, jcr->impl_->jr.JobSumTotalBytes, remaining, - jcr->impl_->res.client->QuotaLimit); + jcr->impl->jr.Name, jcr->impl->jr.JobSumTotalBytes, remaining, + jcr->impl->res.client->QuotaLimit); return remaining; } @@ -121,35 +121,35 @@ bool CheckHardquotas(JobControlRecord* jcr) /* * Do not check if hardquota is not set */ - if (jcr->impl_->res.client->HardQuota == 0) { goto bail_out; } + if (jcr->impl->res.client->HardQuota == 0) { goto bail_out; } Dmsg1(debuglevel, "Checking hard quotas for JobId %d\n", jcr->JobId); - if (!jcr->impl_->HasQuota) { - if (jcr->impl_->res.client->QuotaIncludeFailedJobs) { - if (!jcr->db->get_quota_jobbytes(jcr, &jcr->impl_->jr, - jcr->impl_->res.client->JobRetention)) { + if (!jcr->impl->HasQuota) { + if (jcr->impl->res.client->QuotaIncludeFailedJobs) { + if (!jcr->db->get_quota_jobbytes(jcr, &jcr->impl->jr, + jcr->impl->res.client->JobRetention)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Quota value: ERR=%s"), jcr->db->strerror()); goto bail_out; } } else { if (!jcr->db->get_quota_jobbytes_nofailed( - jcr, &jcr->impl_->jr, jcr->impl_->res.client->JobRetention)) { + jcr, &jcr->impl->jr, jcr->impl->res.client->JobRetention)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Quota value: ERR=%s"), jcr->db->strerror()); goto bail_out; } } - jcr->impl_->HasQuota = true; + jcr->impl->HasQuota = true; } - if (jcr->impl_->jr.JobSumTotalBytes > jcr->impl_->res.client->HardQuota) { + if (jcr->impl->jr.JobSumTotalBytes > jcr->impl->res.client->HardQuota) { retval = true; goto bail_out; } - Dmsg2(debuglevel, "Quota for JobID: %d is %llu\n", jcr->impl_->jr.JobId, - jcr->impl_->jr.JobSumTotalBytes); + Dmsg2(debuglevel, "Quota for JobID: %d is %llu\n", jcr->impl->jr.JobId, + jcr->impl->jr.JobSumTotalBytes); bail_out: return retval; @@ -179,13 +179,13 @@ bool CheckSoftquotas(JobControlRecord* jcr) /* * Do not check if the softquota is not set */ - if (jcr->impl_->res.client->SoftQuota == 0) { goto bail_out; } + if (jcr->impl->res.client->SoftQuota == 0) { goto bail_out; } Dmsg1(debuglevel, "Checking soft quotas for JobId %d\n", jcr->JobId); - if (!jcr->impl_->HasQuota) { - if (jcr->impl_->res.client->QuotaIncludeFailedJobs) { - if (!jcr->db->get_quota_jobbytes(jcr, &jcr->impl_->jr, - jcr->impl_->res.client->JobRetention)) { + if (!jcr->impl->HasQuota) { + if (jcr->impl->res.client->QuotaIncludeFailedJobs) { + if (!jcr->db->get_quota_jobbytes(jcr, &jcr->impl->jr, + jcr->impl->res.client->JobRetention)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Quota value: ERR=%s"), jcr->db->strerror()); goto bail_out; @@ -193,70 +193,70 @@ bool CheckSoftquotas(JobControlRecord* jcr) Dmsg0(debuglevel, "Quota Includes Failed Jobs\n"); } else { if (!jcr->db->get_quota_jobbytes_nofailed( - jcr, &jcr->impl_->jr, jcr->impl_->res.client->JobRetention)) { + jcr, &jcr->impl->jr, jcr->impl->res.client->JobRetention)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Quota value: ERR=%s"), jcr->db->strerror()); goto bail_out; } Jmsg(jcr, M_INFO, 0, _("Quota does NOT include Failed Jobs\n")); } - jcr->impl_->HasQuota = true; + jcr->impl->HasQuota = true; } - Dmsg2(debuglevel, "Quota for %s is %llu\n", jcr->impl_->jr.Name, - jcr->impl_->jr.JobSumTotalBytes); - Dmsg2(debuglevel, "QuotaLimit for %s is %llu\n", jcr->impl_->jr.Name, - jcr->impl_->res.client->QuotaLimit); - Dmsg2(debuglevel, "HardQuota for %s is %llu\n", jcr->impl_->jr.Name, - jcr->impl_->res.client->HardQuota); - Dmsg2(debuglevel, "SoftQuota for %s is %llu\n", jcr->impl_->jr.Name, - jcr->impl_->res.client->SoftQuota); + Dmsg2(debuglevel, "Quota for %s is %llu\n", jcr->impl->jr.Name, + jcr->impl->jr.JobSumTotalBytes); + Dmsg2(debuglevel, "QuotaLimit for %s is %llu\n", jcr->impl->jr.Name, + jcr->impl->res.client->QuotaLimit); + Dmsg2(debuglevel, "HardQuota for %s is %llu\n", jcr->impl->jr.Name, + jcr->impl->res.client->HardQuota); + Dmsg2(debuglevel, "SoftQuota for %s is %llu\n", jcr->impl->jr.Name, + jcr->impl->res.client->SoftQuota); Dmsg2(debuglevel, "SoftQuota Grace Period for %s is %d\n", - jcr->impl_->jr.Name, jcr->impl_->res.client->SoftQuotaGracePeriod); - Dmsg2(debuglevel, "SoftQuota Grace Time for %s is %d\n", jcr->impl_->jr.Name, - jcr->impl_->res.client->GraceTime); + jcr->impl->jr.Name, jcr->impl->res.client->SoftQuotaGracePeriod); + Dmsg2(debuglevel, "SoftQuota Grace Time for %s is %d\n", jcr->impl->jr.Name, + jcr->impl->res.client->GraceTime); - if ((jcr->impl_->jr.JobSumTotalBytes + jcr->impl_->SDJobBytes) > - jcr->impl_->res.client->SoftQuota) { + if ((jcr->impl->jr.JobSumTotalBytes + jcr->impl->SDJobBytes) > + jcr->impl->res.client->SoftQuota) { /* * Only warn once about softquotas in the job * Check if gracetime has been set */ - if (jcr->impl_->res.client->GraceTime == 0 && - jcr->impl_->res.client->SoftQuotaGracePeriod) { + if (jcr->impl->res.client->GraceTime == 0 && + jcr->impl->res.client->SoftQuotaGracePeriod) { Dmsg1(debuglevel, "UpdateQuotaGracetime: %d\n", now); - if (!jcr->db->UpdateQuotaGracetime(jcr, &jcr->impl_->jr)) { + if (!jcr->db->UpdateQuotaGracetime(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error setting Quota gracetime: ERR=%s"), jcr->db->strerror()); } else { Jmsg(jcr, M_ERROR, 0, _("Softquota Exceeded, Grace Period starts now.\n")); } - jcr->impl_->res.client->GraceTime = now; + jcr->impl->res.client->GraceTime = now; goto bail_out; - } else if (jcr->impl_->res.client->SoftQuotaGracePeriod && - (now - (uint64_t)jcr->impl_->res.client->GraceTime) < - (uint64_t)jcr->impl_->res.client->SoftQuotaGracePeriod) { + } else if (jcr->impl->res.client->SoftQuotaGracePeriod && + (now - (uint64_t)jcr->impl->res.client->GraceTime) < + (uint64_t)jcr->impl->res.client->SoftQuotaGracePeriod) { Jmsg(jcr, M_ERROR, 0, _("Softquota Exceeded, will be enforced after Grace Period " "expires.\n")); - } else if (jcr->impl_->res.client->SoftQuotaGracePeriod && - (now - (uint64_t)jcr->impl_->res.client->GraceTime) > - (uint64_t)jcr->impl_->res.client->SoftQuotaGracePeriod) { + } else if (jcr->impl->res.client->SoftQuotaGracePeriod && + (now - (uint64_t)jcr->impl->res.client->GraceTime) > + (uint64_t)jcr->impl->res.client->SoftQuotaGracePeriod) { /* * If gracetime has expired update else check more if not set softlimit * yet then set and bail out. */ - if (jcr->impl_->res.client->QuotaLimit < 1) { - if (!jcr->db->UpdateQuotaSoftlimit(jcr, &jcr->impl_->jr)) { + if (jcr->impl->res.client->QuotaLimit < 1) { + if (!jcr->db->UpdateQuotaSoftlimit(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error setting Quota Softlimit: ERR=%s"), jcr->db->strerror()); } Jmsg(jcr, M_WARNING, 0, _("Softquota Exceeded and Grace Period expired.\n")); Jmsg(jcr, M_INFO, 0, _("Setting Burst Quota to %d Bytes.\n"), - jcr->impl_->jr.JobSumTotalBytes); - jcr->impl_->res.client->QuotaLimit = jcr->impl_->jr.JobSumTotalBytes; + jcr->impl->jr.JobSumTotalBytes); + jcr->impl->res.client->QuotaLimit = jcr->impl->jr.JobSumTotalBytes; retval = true; goto bail_out; } else { @@ -264,33 +264,33 @@ bool CheckSoftquotas(JobControlRecord* jcr) * If gracetime has expired update else check more if not set softlimit * yet then set and bail out. */ - if (jcr->impl_->res.client->QuotaLimit < 1) { - if (!jcr->db->UpdateQuotaSoftlimit(jcr, &jcr->impl_->jr)) { + if (jcr->impl->res.client->QuotaLimit < 1) { + if (!jcr->db->UpdateQuotaSoftlimit(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error setting Quota Softlimit: ERR=%s"), jcr->db->strerror()); } Jmsg(jcr, M_WARNING, 0, _("Soft Quota exceeded and Grace Period expired.\n")); Jmsg(jcr, M_INFO, 0, _("Setting Burst Quota to %d Bytes.\n"), - jcr->impl_->jr.JobSumTotalBytes); - jcr->impl_->res.client->QuotaLimit = jcr->impl_->jr.JobSumTotalBytes; + jcr->impl->jr.JobSumTotalBytes); + jcr->impl->res.client->QuotaLimit = jcr->impl->jr.JobSumTotalBytes; retval = true; goto bail_out; } else { /* * If we use strict quotas enforce the pure soft quota limit. */ - if (jcr->impl_->res.client->StrictQuotas) { - if (jcr->impl_->jr.JobSumTotalBytes > - jcr->impl_->res.client->SoftQuota) { + if (jcr->impl->res.client->StrictQuotas) { + if (jcr->impl->jr.JobSumTotalBytes > + jcr->impl->res.client->SoftQuota) { Dmsg0(debuglevel, "Soft Quota exceeded, enforcing Strict Quota Limit.\n"); retval = true; goto bail_out; } } else { - if (jcr->impl_->jr.JobSumTotalBytes >= - jcr->impl_->res.client->QuotaLimit) { + if (jcr->impl->jr.JobSumTotalBytes >= + jcr->impl->res.client->QuotaLimit) { /* * If strict quotas turned off use the last known limit */ @@ -303,17 +303,17 @@ bool CheckSoftquotas(JobControlRecord* jcr) } } } - } else if (jcr->impl_->res.client->GraceTime != 0) { + } else if (jcr->impl->res.client->GraceTime != 0) { /* * Reset softquota */ ClientDbRecord cr; - cr.ClientId = jcr->impl_->jr.ClientId; + cr.ClientId = jcr->impl->jr.ClientId; if (!jcr->db->ResetQuotaRecord(jcr, &cr)) { Jmsg(jcr, M_WARNING, 0, _("Error setting Quota gracetime: ERR=%s\n"), jcr->db->strerror()); } else { - jcr->impl_->res.client->GraceTime = 0; + jcr->impl->res.client->GraceTime = 0; Jmsg(jcr, M_INFO, 0, _("Soft Quota reset, Grace Period ends now.\n")); } } diff --git a/core/src/dird/recycle.cc b/core/src/dird/recycle.cc index bcf02f1467a..89173231bba 100644 --- a/core/src/dird/recycle.cc +++ b/core/src/dird/recycle.cc @@ -47,8 +47,8 @@ bool FindRecycledVolume(JobControlRecord* jcr, bstrncpy(mr->VolStatus, "Recycle", sizeof(mr->VolStatus)); SetStorageidInMr(store, mr); if (jcr->db->FindNextVolume(jcr, 1, InChanger, mr, unwanted_volumes)) { - jcr->impl_->MediaId = mr->MediaId; - Dmsg1(20, "Find_next_vol MediaId=%u\n", jcr->impl_->MediaId); + jcr->impl->MediaId = mr->MediaId; + Dmsg1(20, "Find_next_vol MediaId=%u\n", jcr->impl->MediaId); PmStrcpy(jcr->VolumeName, mr->VolumeName); SetStorageidInMr(store, mr); diff --git a/core/src/dird/restore.cc b/core/src/dird/restore.cc index 4a18b3c69c2..715e6445188 100644 --- a/core/src/dird/restore.cc +++ b/core/src/dird/restore.cc @@ -83,10 +83,10 @@ static void BuildRestoreCommand(JobControlRecord* jcr, PoolMem& ret) /* * Build the restore command */ - if (jcr->impl_->replace != 0) { - replace = jcr->impl_->replace; - } else if (jcr->impl_->res.job->replace != 0) { - replace = jcr->impl_->res.job->replace; + if (jcr->impl->replace != 0) { + replace = jcr->impl->replace; + } else if (jcr->impl->res.job->replace != 0) { + replace = jcr->impl->res.job->replace; } else { replace = REPLACE_ALWAYS; /* always replace */ } @@ -94,21 +94,21 @@ static void BuildRestoreCommand(JobControlRecord* jcr, PoolMem& ret) if (jcr->RegexWhere) { where = jcr->RegexWhere; /* override */ cmd = restorecmdR; - } else if (jcr->impl_->res.job->RegexWhere) { - where = jcr->impl_->res.job->RegexWhere; /* no override take from job */ + } else if (jcr->impl->res.job->RegexWhere) { + where = jcr->impl->res.job->RegexWhere; /* no override take from job */ cmd = restorecmdR; } else if (jcr->where) { where = jcr->where; /* override */ cmd = restorecmd; - } else if (jcr->impl_->res.job->RestoreWhere) { - where = jcr->impl_->res.job->RestoreWhere; /* no override take from job */ + } else if (jcr->impl->res.job->RestoreWhere) { + where = jcr->impl->res.job->RestoreWhere; /* no override take from job */ cmd = restorecmd; } else { /* nothing was specified */ where = ∅ /* use default */ cmd = restorecmd; } - jcr->prefix_links = jcr->impl_->res.job->PrefixLinks; + jcr->prefix_links = jcr->impl->res.job->PrefixLinks; BashSpaces(where); Mmsg(ret, cmd, replace, jcr->prefix_links, where); @@ -136,7 +136,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) PoolMem RestoreCmd(PM_MESSAGE); char* connection_target_address; - client = jcr->impl_->res.client; + client = jcr->impl->res.client; /* * This command is used for each part */ @@ -153,7 +153,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) jcr->passive_client = client->passive; while (!feof(info.bs)) { if (!SelectNextRstore(jcr, info)) { goto bail_out; } - store = jcr->impl_->res.read_storage; + store = jcr->impl->res.read_storage; /** * Open a message channel connection with the Storage @@ -175,7 +175,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) /* * Now start a job with the Storage daemon */ - if (!StartStorageDaemonJob(jcr, jcr->impl_->res.read_storage_list, NULL)) { + if (!StartStorageDaemonJob(jcr, jcr->impl->res.read_storage_list, NULL)) { goto bail_out; } @@ -184,7 +184,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) * Start conversation with File daemon */ jcr->setJobStatus(JS_WaitFD); - jcr->impl_->keep_sd_auth_key = true; /* don't clear the sd_auth_key now */ + jcr->impl->keep_sd_auth_key = true; /* don't clear the sd_auth_key now */ if (!ConnectToFileDaemon(jcr, 10, me->FDConnectTimeout, true)) { goto bail_out; @@ -199,11 +199,11 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) /* * Check if the file daemon supports passive client mode. */ - if (jcr->passive_client && jcr->impl_->FDVersion < FD_VERSION_51) { + if (jcr->passive_client && jcr->impl->FDVersion < FD_VERSION_51) { Jmsg(jcr, M_FATAL, 0, _("Client \"%s\" doesn't support passive client mode. " "Please upgrade your client or disable compat mode.\n"), - jcr->impl_->res.client->resource_name_); + jcr->impl->res.client->resource_name_); goto bail_out; } } @@ -248,7 +248,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) */ TlsPolicy tls_policy; - if (jcr->impl_->res.client->connection_successful_handshake_ != + if (jcr->impl->res.client->connection_successful_handshake_ != ClientConnectionHandshakeMode::kTlsFirst) { tls_policy = store->GetPolicy(); } else { @@ -284,7 +284,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) TlsPolicy tls_policy; - if (jcr->impl_->res.client->connection_successful_handshake_ != + if (jcr->impl->res.client->connection_successful_handshake_ != ClientConnectionHandshakeMode::kTlsFirst) { tls_policy = client->GetPolicy(); } else { @@ -333,7 +333,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) /* * Only FD version 52 and later understand the sending of plugin options. */ - if (jcr->impl_->FDVersion >= FD_VERSION_52) { + if (jcr->impl->FDVersion >= FD_VERSION_52) { if (!SendPluginOptions(jcr)) { Dmsg0(000, "FAIL: Send plugin options\n"); goto bail_out; @@ -343,11 +343,11 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) * Plugin options specified and not a FD that understands the new * protocol keyword. */ - if (jcr->impl_->plugin_options) { + if (jcr->impl->plugin_options) { Jmsg(jcr, M_FATAL, 0, _("Client \"%s\" doesn't support plugin option passing. " "Please upgrade your client or disable compat mode.\n"), - jcr->impl_->res.client->resource_name_); + jcr->impl->res.client->resource_name_); goto bail_out; } } @@ -364,7 +364,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) goto bail_out; } - if (jcr->impl_->FDVersion < FD_VERSION_2) { /* Old FD */ + if (jcr->impl->FDVersion < FD_VERSION_2) { /* Old FD */ break; /* we do only one loop */ } else { if (!response(jcr, fd, OKstoreend, "Store end", DISPLAY_ERROR)) { @@ -374,7 +374,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord* jcr) } } /* the whole boostrap has been send */ - if (fd && jcr->impl_->FDVersion >= FD_VERSION_2) { fd->fsend("endrestore"); } + if (fd && jcr->impl->FDVersion >= FD_VERSION_2) { fd->fsend("endrestore"); } CloseBootstrapFile(info); return true; @@ -414,14 +414,14 @@ bool DoNativeRestore(JobControlRecord* jcr) { int status; - jcr->impl_->jr.JobLevel = L_FULL; /* Full restore */ - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { + jcr->impl->jr.JobLevel = L_FULL; /* Full restore */ + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); goto bail_out; } Dmsg0(20, "Updated job start record\n"); - Dmsg1(20, "RestoreJobId=%d\n", jcr->impl_->res.job->RestoreJobId); + Dmsg1(20, "RestoreJobId=%d\n", jcr->impl->res.job->RestoreJobId); if (!jcr->RestoreBootstrap) { Jmsg(jcr, M_FATAL, 0, @@ -465,16 +465,16 @@ void NativeRestoreCleanup(JobControlRecord* jcr, int TermCode) Dmsg0(20, "In NativeRestoreCleanup\n"); UpdateJobEnd(jcr, TermCode); - if (jcr->impl_->unlink_bsr && jcr->RestoreBootstrap) { + if (jcr->impl->unlink_bsr && jcr->RestoreBootstrap) { SecureErase(jcr, jcr->RestoreBootstrap); - jcr->impl_->unlink_bsr = false; + jcr->impl->unlink_bsr = false; } if (JobCanceled(jcr)) { CancelStorageDaemonJob(jcr); } switch (TermCode) { case JS_Terminated: - if (jcr->impl_->ExpectedFiles > jcr->impl_->jr.JobFiles) { + if (jcr->impl->ExpectedFiles > jcr->impl->jr.JobFiles) { TermMsg = _("Restore OK -- warning file count mismatch"); } else { TermMsg = _("Restore OK"); @@ -489,8 +489,8 @@ void NativeRestoreCleanup(JobControlRecord* jcr, int TermCode) msg_type = M_ERROR; /* Generate error message */ if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->impl_->SD_msg_chan_started) { - pthread_cancel(jcr->impl_->SD_msg_chan); + if (jcr->impl->SD_msg_chan_started) { + pthread_cancel(jcr->impl->SD_msg_chan); } } break; @@ -498,8 +498,8 @@ void NativeRestoreCleanup(JobControlRecord* jcr, int TermCode) TermMsg = _("Restore Canceled"); if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->impl_->SD_msg_chan_started) { - pthread_cancel(jcr->impl_->SD_msg_chan); + if (jcr->impl->SD_msg_chan_started) { + pthread_cancel(jcr->impl->SD_msg_chan); } } break; @@ -531,18 +531,18 @@ void GenerateRestoreSummary(JobControlRecord* jcr, double kbps; PoolMem temp, secure_erase_status; - bstrftimes(sdt, sizeof(sdt), jcr->impl_->jr.StartTime); - bstrftimes(edt, sizeof(edt), jcr->impl_->jr.EndTime); - RunTime = jcr->impl_->jr.EndTime - jcr->impl_->jr.StartTime; + bstrftimes(sdt, sizeof(sdt), jcr->impl->jr.StartTime); + bstrftimes(edt, sizeof(edt), jcr->impl->jr.EndTime); + RunTime = jcr->impl->jr.EndTime - jcr->impl->jr.StartTime; if (RunTime <= 0) { kbps = 0; } else { - kbps = ((double)jcr->impl_->jr.JobBytes) / (1000.0 * (double)RunTime); + kbps = ((double)jcr->impl->jr.JobBytes) / (1000.0 * (double)RunTime); } if (kbps < 0.05) { kbps = 0; } - JobstatusToAscii(jcr->impl_->FDJobStatus, fd_term_msg, sizeof(fd_term_msg)); - JobstatusToAscii(jcr->impl_->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); + JobstatusToAscii(jcr->impl->FDJobStatus, fd_term_msg, sizeof(fd_term_msg)); + JobstatusToAscii(jcr->impl->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); switch (jcr->getJobProtocol()) { case PT_NDMP_BAREOS: @@ -564,12 +564,12 @@ void GenerateRestoreSummary(JobControlRecord* jcr, " Bareos binary info: %s\n" " Termination: %s\n\n"), BAREOS, my_name, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER, - jcr->impl_->jr.JobId, jcr->impl_->jr.Job, - jcr->impl_->res.client->resource_name_, sdt, edt, + jcr->impl->jr.JobId, jcr->impl->jr.Job, + jcr->impl->res.client->resource_name_, sdt, edt, edit_utime(RunTime, elapsed, sizeof(elapsed)), - edit_uint64_with_commas((uint64_t)jcr->impl_->ExpectedFiles, ec1), - edit_uint64_with_commas((uint64_t)jcr->impl_->jr.JobFiles, ec2), - edit_uint64_with_commas(jcr->impl_->jr.JobBytes, ec3), (float)kbps, + edit_uint64_with_commas((uint64_t)jcr->impl->ExpectedFiles, ec1), + edit_uint64_with_commas((uint64_t)jcr->impl->jr.JobFiles, ec2), + edit_uint64_with_commas(jcr->impl->jr.JobBytes, ec3), (float)kbps, sd_term_msg, BAREOS_JOBLOG_MESSAGE, TermMsg); break; default: @@ -577,14 +577,14 @@ void GenerateRestoreSummary(JobControlRecord* jcr, Mmsg(temp, " Dir Secure Erase Cmd: %s\n", me->secure_erase_cmdline); PmStrcat(secure_erase_status, temp.c_str()); } - if (!bstrcmp(jcr->impl_->FDSecureEraseCmd, "*None*")) { + if (!bstrcmp(jcr->impl->FDSecureEraseCmd, "*None*")) { Mmsg(temp, " FD Secure Erase Cmd: %s\n", - jcr->impl_->FDSecureEraseCmd); + jcr->impl->FDSecureEraseCmd); PmStrcat(secure_erase_status, temp.c_str()); } - if (!bstrcmp(jcr->impl_->SDSecureEraseCmd, "*None*")) { + if (!bstrcmp(jcr->impl->SDSecureEraseCmd, "*None*")) { Mmsg(temp, " SD Secure Erase Cmd: %s\n", - jcr->impl_->SDSecureEraseCmd); + jcr->impl->SDSecureEraseCmd); PmStrcat(secure_erase_status, temp.c_str()); } @@ -608,12 +608,12 @@ void GenerateRestoreSummary(JobControlRecord* jcr, " Bareos binary info: %s\n" " Termination: %s\n\n"), BAREOS, my_name, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER, - jcr->impl_->jr.JobId, jcr->impl_->jr.Job, - jcr->impl_->res.client->resource_name_, sdt, edt, + jcr->impl->jr.JobId, jcr->impl->jr.Job, + jcr->impl->res.client->resource_name_, sdt, edt, edit_utime(RunTime, elapsed, sizeof(elapsed)), - edit_uint64_with_commas((uint64_t)jcr->impl_->ExpectedFiles, ec1), - edit_uint64_with_commas((uint64_t)jcr->impl_->jr.JobFiles, ec2), - edit_uint64_with_commas(jcr->impl_->jr.JobBytes, ec3), (float)kbps, + edit_uint64_with_commas((uint64_t)jcr->impl->ExpectedFiles, ec1), + edit_uint64_with_commas((uint64_t)jcr->impl->jr.JobFiles, ec2), + edit_uint64_with_commas(jcr->impl->jr.JobBytes, ec3), (float)kbps, jcr->JobErrors, fd_term_msg, sd_term_msg, secure_erase_status.c_str(), BAREOS_JOBLOG_MESSAGE, TermMsg); break; diff --git a/core/src/dird/scheduler.cc b/core/src/dird/scheduler.cc index 606ce327865..374c1790df7 100644 --- a/core/src/dird/scheduler.cc +++ b/core/src/dird/scheduler.cc @@ -188,34 +188,34 @@ JobControlRecord* wait_for_next_job(char* one_shot_job_to_run) if (run->level) { jcr->setJobLevel(run->level); /* override run level */ } if (run->pool) { - jcr->impl_->res.pool = run->pool; /* override pool */ - jcr->impl_->res.run_pool_override = true; + jcr->impl->res.pool = run->pool; /* override pool */ + jcr->impl->res.run_pool_override = true; } if (run->full_pool) { - jcr->impl_->res.full_pool = run->full_pool; /* override full pool */ - jcr->impl_->res.run_full_pool_override = true; + jcr->impl->res.full_pool = run->full_pool; /* override full pool */ + jcr->impl->res.run_full_pool_override = true; } if (run->vfull_pool) { - jcr->impl_->res.vfull_pool = + jcr->impl->res.vfull_pool = run->vfull_pool; /* override virtual full pool */ - jcr->impl_->res.run_vfull_pool_override = true; + jcr->impl->res.run_vfull_pool_override = true; } if (run->inc_pool) { - jcr->impl_->res.inc_pool = run->inc_pool; /* override inc pool */ - jcr->impl_->res.run_inc_pool_override = true; + jcr->impl->res.inc_pool = run->inc_pool; /* override inc pool */ + jcr->impl->res.run_inc_pool_override = true; } if (run->diff_pool) { - jcr->impl_->res.diff_pool = run->diff_pool; /* override diff pool */ - jcr->impl_->res.run_diff_pool_override = true; + jcr->impl->res.diff_pool = run->diff_pool; /* override diff pool */ + jcr->impl->res.run_diff_pool_override = true; } if (run->next_pool) { - jcr->impl_->res.next_pool = run->next_pool; /* override next pool */ - jcr->impl_->res.run_next_pool_override = true; + jcr->impl->res.next_pool = run->next_pool; /* override next pool */ + jcr->impl->res.run_next_pool_override = true; } if (run->storage) { @@ -226,19 +226,19 @@ JobControlRecord* wait_for_next_job(char* one_shot_job_to_run) } if (run->msgs) { - jcr->impl_->res.messages = run->msgs; /* override messages */ + jcr->impl->res.messages = run->msgs; /* override messages */ } if (run->Priority) { jcr->JobPriority = run->Priority; } - if (run->spool_data_set) { jcr->impl_->spool_data = run->spool_data; } + if (run->spool_data_set) { jcr->impl->spool_data = run->spool_data; } if (run->accurate_set) { jcr->accurate = run->accurate; /* overwrite accurate mode */ } if (run->MaxRunSchedTime_set) { - jcr->impl_->MaxRunSchedTime = run->MaxRunSchedTime; + jcr->impl->MaxRunSchedTime = run->MaxRunSchedTime; } Dmsg0(debuglevel, "Leave wait_for_next_job()\n"); diff --git a/core/src/dird/sd_cmds.cc b/core/src/dird/sd_cmds.cc index 5f316363364..3207e61ba23 100644 --- a/core/src/dird/sd_cmds.cc +++ b/core/src/dird/sd_cmds.cc @@ -94,10 +94,10 @@ bool ConnectToStorageDaemon(JobControlRecord* jcr, if (jcr->store_bsock) { return true; /* already connected */ } StorageResource* store; - if (jcr->impl_->res.write_storage) { - store = jcr->impl_->res.write_storage; + if (jcr->impl->res.write_storage) { + store = jcr->impl->res.write_storage; } else { - store = jcr->impl_->res.read_storage; + store = jcr->impl->res.read_storage; } if (!store) { @@ -154,7 +154,7 @@ bool ConnectToStorageDaemon(JobControlRecord* jcr, BareosSocket* open_sd_bsock(UaContext* ua) { - StorageResource* store = ua->jcr->impl_->res.write_storage; + StorageResource* store = ua->jcr->impl->res.write_storage; if (!store) { Dmsg0(200, "open_sd_bsock: No storage resource pointer set\n"); @@ -183,12 +183,12 @@ char* get_volume_name_from_SD(UaContext* ua, drive_number_t drive) { BareosSocket* sd; - StorageResource* store = ua->jcr->impl_->res.write_storage; + StorageResource* store = ua->jcr->impl->res.write_storage; char dev_name[MAX_NAME_LENGTH]; char* VolName = nullptr; int rtn_slot; - ua->jcr->impl_->res.write_storage = store; + ua->jcr->impl->res.write_storage = store; if (!(sd = open_sd_bsock(ua))) { ua->ErrorMsg(_("Could not open SD socket.\n")); return nullptr; @@ -267,7 +267,7 @@ dlist* native_get_vol_list(UaContext* ua, dlist* vol_list; BareosSocket* sd = nullptr; - ua->jcr->impl_->res.write_storage = store; + ua->jcr->impl->res.write_storage = store; if (!(sd = open_sd_bsock(ua))) { return nullptr; } bstrncpy(dev_name, store->dev_name(), sizeof(dev_name)); @@ -548,7 +548,7 @@ slot_number_t NativeGetNumSlots(UaContext* ua, StorageResource* store) BareosSocket* sd; slot_number_t slots = 0; - ua->jcr->impl_->res.write_storage = store; + ua->jcr->impl->res.write_storage = store; if (!(sd = open_sd_bsock(ua))) { return 0; } bstrncpy(dev_name, store->dev_name(), sizeof(dev_name)); @@ -580,7 +580,7 @@ drive_number_t NativeGetNumDrives(UaContext* ua, StorageResource* store) BareosSocket* sd; drive_number_t drives = 0; - ua->jcr->impl_->res.write_storage = store; + ua->jcr->impl->res.write_storage = store; if (!(sd = open_sd_bsock(ua))) { return 0; } bstrncpy(dev_name, store->dev_name(), sizeof(dev_name)); @@ -614,7 +614,7 @@ bool CancelStorageDaemonJob(UaContext* ua, StorageResource* store, char* JobId) control_jcr = new_control_jcr("*JobCancel*", JT_SYSTEM); - control_jcr->impl_->res.write_storage = store; + control_jcr->impl->res.write_storage = store; /* the next call will set control_jcr->store_bsock */ if (!ConnectToStorageDaemon(control_jcr, 10, me->SDConnectTimeout, true)) { @@ -642,20 +642,20 @@ bool CancelStorageDaemonJob(UaContext* ua, JobControlRecord* jcr, bool interactive) { - if (!ua->jcr->impl_->res.write_storage_list) { - if (jcr->impl_->res.read_storage_list) { - CopyWstorage(ua->jcr, jcr->impl_->res.read_storage_list, + if (!ua->jcr->impl->res.write_storage_list) { + if (jcr->impl->res.read_storage_list) { + CopyWstorage(ua->jcr, jcr->impl->res.read_storage_list, _("Job resource")); } else { - CopyWstorage(ua->jcr, jcr->impl_->res.write_storage_list, + CopyWstorage(ua->jcr, jcr->impl->res.write_storage_list, _("Job resource")); } } else { UnifiedStorageResource store; - if (jcr->impl_->res.read_storage_list) { - store.store = jcr->impl_->res.read_storage; + if (jcr->impl->res.read_storage_list) { + store.store = jcr->impl->res.read_storage; } else { - store.store = jcr->impl_->res.write_storage; + store.store = jcr->impl->res.write_storage; } if (!store.store) { Dmsg0(200, "CancelStorageDaemonJob: No storage resource pointer set\n"); @@ -684,7 +684,7 @@ bool CancelStorageDaemonJob(UaContext* ua, TerminateAndCloseJcrStoreSocket(ua->jcr); - if (!interactive) { jcr->impl_->sd_canceled = true; } + if (!interactive) { jcr->impl->sd_canceled = true; } SdMsgThreadSendSignal(jcr, TIMEOUT_SIGNAL); @@ -695,7 +695,7 @@ bool CancelStorageDaemonJob(UaContext* ua, void CancelStorageDaemonJob(JobControlRecord* jcr) { - if (jcr->impl_->sd_canceled) { return; /* cancel only once */ } + if (jcr->impl->sd_canceled) { return; /* cancel only once */ } UaContext* ua = new_ua_context(jcr); JobControlRecord* control_jcr = new_control_jcr("*JobCancel*", JT_SYSTEM); @@ -779,7 +779,7 @@ bool NativeTransferVolume(UaContext* ua, bool retval = true; char dev_name[MAX_NAME_LENGTH]; - ua->jcr->impl_->res.write_storage = store; + ua->jcr->impl->res.write_storage = store; if (!(sd = open_sd_bsock(ua))) { return false; } bstrncpy(dev_name, store->dev_name(), sizeof(dev_name)); @@ -826,7 +826,7 @@ bool NativeAutochangerVolumeOperation(UaContext* ua, bool retval = true; char dev_name[MAX_NAME_LENGTH]; - ua->jcr->impl_->res.write_storage = store; + ua->jcr->impl->res.write_storage = store; if (!(sd = open_sd_bsock(ua))) { return false; } bstrncpy(dev_name, store->dev_name(), sizeof(dev_name)); @@ -863,21 +863,21 @@ bool SendSecureEraseReqToSd(JobControlRecord* jcr) int32_t n; BareosSocket* sd = jcr->store_bsock; - if (!jcr->impl_->SDSecureEraseCmd) { - jcr->impl_->SDSecureEraseCmd = GetPoolMemory(PM_NAME); + if (!jcr->impl->SDSecureEraseCmd) { + jcr->impl->SDSecureEraseCmd = GetPoolMemory(PM_NAME); } sd->fsend(getSecureEraseCmd); while ((n = BgetDirmsg(sd)) >= 0) { - jcr->impl_->SDSecureEraseCmd = - CheckPoolMemorySize(jcr->impl_->SDSecureEraseCmd, sd->message_length); - if (sscanf(sd->msg, OKSecureEraseCmd, jcr->impl_->SDSecureEraseCmd) == 1) { - Dmsg1(421, "Got SD Secure Erase Cmd: %s\n", jcr->impl_->SDSecureEraseCmd); + jcr->impl->SDSecureEraseCmd = + CheckPoolMemorySize(jcr->impl->SDSecureEraseCmd, sd->message_length); + if (sscanf(sd->msg, OKSecureEraseCmd, jcr->impl->SDSecureEraseCmd) == 1) { + Dmsg1(421, "Got SD Secure Erase Cmd: %s\n", jcr->impl->SDSecureEraseCmd); break; } else { Jmsg(jcr, M_WARNING, 0, _("Unexpected SD Secure Erase Cmd: %s\n"), sd->msg); - PmStrcpy(jcr->impl_->SDSecureEraseCmd, "*None*"); + PmStrcpy(jcr->impl->SDSecureEraseCmd, "*None*"); return false; } } @@ -907,7 +907,7 @@ bool DoStorageResolve(UaContext* ua, StorageResource* store) PmStrcpy(lstore.store_source, _("unknown source")); SetWstorage(ua->jcr, &lstore); - ua->jcr->impl_->res.write_storage = store; + ua->jcr->impl->res.write_storage = store; if (!(sd = open_sd_bsock(ua))) { return false; } for (int i = 1; i < ua->argc; i++) { @@ -929,10 +929,10 @@ bool SendStoragePluginOptions(JobControlRecord* jcr) const char* plugin_options; BareosSocket* sd = jcr->store_bsock; - if (jcr->impl_->res.job && jcr->impl_->res.job->SdPluginOptions && - jcr->impl_->res.job->SdPluginOptions->size()) { + if (jcr->impl->res.job && jcr->impl->res.job->SdPluginOptions && + jcr->impl->res.job->SdPluginOptions->size()) { foreach_alist_index (i, plugin_options, - jcr->impl_->res.job->SdPluginOptions) { + jcr->impl->res.job->SdPluginOptions) { PmStrcpy(cur_plugin_options, plugin_options); BashSpaces(cur_plugin_options.c_str()); diff --git a/core/src/dird/stats.cc b/core/src/dird/stats.cc index 3bf60dd7c4b..56884b8c074 100644 --- a/core/src/dird/stats.cc +++ b/core/src/dird/stats.cc @@ -131,21 +131,21 @@ extern "C" void* statistics_thread(void* arg) jcr = new_control_jcr("*StatisticsCollector*", JT_SYSTEM); - jcr->impl_->res.catalog = + jcr->impl->res.catalog = (CatalogResource*)my_config->GetNextRes(R_CATALOG, NULL); jcr->db = DbSqlGetPooledConnection( - jcr, jcr->impl_->res.catalog->db_driver, jcr->impl_->res.catalog->db_name, - jcr->impl_->res.catalog->db_user, - jcr->impl_->res.catalog->db_password.value, - jcr->impl_->res.catalog->db_address, jcr->impl_->res.catalog->db_port, - jcr->impl_->res.catalog->db_socket, - jcr->impl_->res.catalog->mult_db_connections, - jcr->impl_->res.catalog->disable_batch_insert, - jcr->impl_->res.catalog->try_reconnect, - jcr->impl_->res.catalog->exit_on_fatal); + jcr, jcr->impl->res.catalog->db_driver, jcr->impl->res.catalog->db_name, + jcr->impl->res.catalog->db_user, + jcr->impl->res.catalog->db_password.value, + jcr->impl->res.catalog->db_address, jcr->impl->res.catalog->db_port, + jcr->impl->res.catalog->db_socket, + jcr->impl->res.catalog->mult_db_connections, + jcr->impl->res.catalog->disable_batch_insert, + jcr->impl->res.catalog->try_reconnect, + jcr->impl->res.catalog->exit_on_fatal); if (jcr->db == NULL) { Jmsg(jcr, M_FATAL, 0, _("Could not open database \"%s\".\n"), - jcr->impl_->res.catalog->db_name); + jcr->impl->res.catalog->db_name); goto bail_out; } @@ -202,7 +202,7 @@ extern "C" void* statistics_thread(void* arg) continue; } - jcr->impl_->res.read_storage = store; + jcr->impl->res.read_storage = store; if (!ConnectToStorageDaemon(jcr, 2, 1, false)) { UnlockRes(my_config); continue; diff --git a/core/src/dird/storage.cc b/core/src/dird/storage.cc index 8d1842ee7fb..0207f1d4420 100644 --- a/core/src/dird/storage.cc +++ b/core/src/dird/storage.cc @@ -84,20 +84,20 @@ void CopyRstorage(JobControlRecord* jcr, alist* storage, const char* where) { if (storage) { StorageResource* store = nullptr; - if (jcr->impl_->res.read_storage_list) { - delete jcr->impl_->res.read_storage_list; + if (jcr->impl->res.read_storage_list) { + delete jcr->impl->res.read_storage_list; } - jcr->impl_->res.read_storage_list = new alist(10, not_owned_by_alist); + jcr->impl->res.read_storage_list = new alist(10, not_owned_by_alist); foreach_alist (store, storage) { - jcr->impl_->res.read_storage_list->append(store); + jcr->impl->res.read_storage_list->append(store); } - if (!jcr->impl_->res.rstore_source) { - jcr->impl_->res.rstore_source = GetPoolMemory(PM_MESSAGE); + if (!jcr->impl->res.rstore_source) { + jcr->impl->res.rstore_source = GetPoolMemory(PM_MESSAGE); } - PmStrcpy(jcr->impl_->res.rstore_source, where); - if (jcr->impl_->res.read_storage_list) { - jcr->impl_->res.read_storage = - (StorageResource*)jcr->impl_->res.read_storage_list->first(); + PmStrcpy(jcr->impl->res.rstore_source, where); + if (jcr->impl->res.read_storage_list) { + jcr->impl->res.read_storage = + (StorageResource*)jcr->impl->res.read_storage_list->first(); } } } @@ -111,29 +111,29 @@ void SetRstorage(JobControlRecord* jcr, UnifiedStorageResource* store) StorageResource* storage = nullptr; if (!store->store) { return; } - if (jcr->impl_->res.read_storage_list) { FreeRstorage(jcr); } - if (!jcr->impl_->res.read_storage_list) { - jcr->impl_->res.read_storage_list = new alist(10, not_owned_by_alist); + if (jcr->impl->res.read_storage_list) { FreeRstorage(jcr); } + if (!jcr->impl->res.read_storage_list) { + jcr->impl->res.read_storage_list = new alist(10, not_owned_by_alist); } - jcr->impl_->res.read_storage = store->store; - if (!jcr->impl_->res.rstore_source) { - jcr->impl_->res.rstore_source = GetPoolMemory(PM_MESSAGE); + jcr->impl->res.read_storage = store->store; + if (!jcr->impl->res.rstore_source) { + jcr->impl->res.rstore_source = GetPoolMemory(PM_MESSAGE); } - PmStrcpy(jcr->impl_->res.rstore_source, store->store_source); - foreach_alist (storage, jcr->impl_->res.read_storage_list) { + PmStrcpy(jcr->impl->res.rstore_source, store->store_source); + foreach_alist (storage, jcr->impl->res.read_storage_list) { if (store->store == storage) { return; } } /* Store not in list, so add it */ - jcr->impl_->res.read_storage_list->prepend(store->store); + jcr->impl->res.read_storage_list->prepend(store->store); } void FreeRstorage(JobControlRecord* jcr) { - if (jcr->impl_->res.read_storage_list) { - delete jcr->impl_->res.read_storage_list; - jcr->impl_->res.read_storage_list = NULL; + if (jcr->impl->res.read_storage_list) { + delete jcr->impl->res.read_storage_list; + jcr->impl->res.read_storage_list = NULL; } - jcr->impl_->res.read_storage = NULL; + jcr->impl->res.read_storage = NULL; } /** @@ -143,24 +143,24 @@ void CopyWstorage(JobControlRecord* jcr, alist* storage, const char* where) { if (storage) { StorageResource* st = nullptr; - if (jcr->impl_->res.write_storage_list) { - delete jcr->impl_->res.write_storage_list; + if (jcr->impl->res.write_storage_list) { + delete jcr->impl->res.write_storage_list; } - jcr->impl_->res.write_storage_list = new alist(10, not_owned_by_alist); + jcr->impl->res.write_storage_list = new alist(10, not_owned_by_alist); foreach_alist (st, storage) { Dmsg1(100, "write_storage_list=%s\n", st->resource_name_); - jcr->impl_->res.write_storage_list->append(st); + jcr->impl->res.write_storage_list->append(st); } - if (!jcr->impl_->res.wstore_source) { - jcr->impl_->res.wstore_source = GetPoolMemory(PM_MESSAGE); + if (!jcr->impl->res.wstore_source) { + jcr->impl->res.wstore_source = GetPoolMemory(PM_MESSAGE); } - PmStrcpy(jcr->impl_->res.wstore_source, where); - if (jcr->impl_->res.write_storage_list) { - jcr->impl_->res.write_storage = - (StorageResource*)jcr->impl_->res.write_storage_list->first(); + PmStrcpy(jcr->impl->res.wstore_source, where); + if (jcr->impl->res.write_storage_list) { + jcr->impl->res.write_storage = + (StorageResource*)jcr->impl->res.write_storage_list->first(); Dmsg2(100, "write_storage=%s where=%s\n", - jcr->impl_->res.write_storage->resource_name_, - jcr->impl_->res.wstore_source); + jcr->impl->res.write_storage->resource_name_, + jcr->impl->res.wstore_source); } } } @@ -174,35 +174,35 @@ void SetWstorage(JobControlRecord* jcr, UnifiedStorageResource* store) StorageResource* storage = nullptr; if (!store->store) { return; } - if (jcr->impl_->res.write_storage_list) { FreeWstorage(jcr); } - if (!jcr->impl_->res.write_storage_list) { - jcr->impl_->res.write_storage_list = new alist(10, not_owned_by_alist); + if (jcr->impl->res.write_storage_list) { FreeWstorage(jcr); } + if (!jcr->impl->res.write_storage_list) { + jcr->impl->res.write_storage_list = new alist(10, not_owned_by_alist); } - jcr->impl_->res.write_storage = store->store; - if (!jcr->impl_->res.wstore_source) { - jcr->impl_->res.wstore_source = GetPoolMemory(PM_MESSAGE); + jcr->impl->res.write_storage = store->store; + if (!jcr->impl->res.wstore_source) { + jcr->impl->res.wstore_source = GetPoolMemory(PM_MESSAGE); } - PmStrcpy(jcr->impl_->res.wstore_source, store->store_source); + PmStrcpy(jcr->impl->res.wstore_source, store->store_source); Dmsg2(50, "write_storage=%s where=%s\n", - jcr->impl_->res.write_storage->resource_name_, - jcr->impl_->res.wstore_source); - foreach_alist (storage, jcr->impl_->res.write_storage_list) { + jcr->impl->res.write_storage->resource_name_, + jcr->impl->res.wstore_source); + foreach_alist (storage, jcr->impl->res.write_storage_list) { if (store->store == storage) { return; } } /* * Store not in list, so add it */ - jcr->impl_->res.write_storage_list->prepend(store->store); + jcr->impl->res.write_storage_list->prepend(store->store); } void FreeWstorage(JobControlRecord* jcr) { - if (jcr->impl_->res.write_storage_list) { - delete jcr->impl_->res.write_storage_list; - jcr->impl_->res.write_storage_list = NULL; + if (jcr->impl->res.write_storage_list) { + delete jcr->impl->res.write_storage_list; + jcr->impl->res.write_storage_list = NULL; } - jcr->impl_->res.write_storage = NULL; + jcr->impl->res.write_storage = NULL; } /** @@ -220,21 +220,21 @@ void SetPairedStorage(JobControlRecord* jcr) /* * For a backup we look at the write storage. */ - if (jcr->impl_->res.write_storage_list) { + if (jcr->impl->res.write_storage_list) { /* * Setup the jcr->impl_->res.write_storage_list to point to all * paired_storage entries of all the storage currently in the * jcrres.->write_storage_list. Save the original list under * jcr->impl_->res.paired_read_write_storage_list. */ - jcr->impl_->res.paired_read_write_storage_list = - jcr->impl_->res.write_storage_list; - jcr->impl_->res.write_storage_list = new alist(10, not_owned_by_alist); - foreach_alist (store, jcr->impl_->res.paired_read_write_storage_list) { + jcr->impl->res.paired_read_write_storage_list = + jcr->impl->res.write_storage_list; + jcr->impl->res.write_storage_list = new alist(10, not_owned_by_alist); + foreach_alist (store, jcr->impl->res.paired_read_write_storage_list) { if (store->paired_storage) { Dmsg1(100, "write_storage_list=%s\n", store->paired_storage->resource_name_); - jcr->impl_->res.write_storage_list->append(store->paired_storage); + jcr->impl->res.write_storage_list->append(store->paired_storage); } } @@ -244,10 +244,10 @@ void SetPairedStorage(JobControlRecord* jcr) * paired_read_write_storage which is for restore in the * FreePairedStorage() function. */ - store = jcr->impl_->res.write_storage; + store = jcr->impl->res.write_storage; if (store->paired_storage) { - jcr->impl_->res.write_storage = store->paired_storage; - jcr->impl_->res.paired_read_write_storage = store; + jcr->impl->res.write_storage = store->paired_storage; + jcr->impl->res.paired_read_write_storage = store; } } else { Jmsg(jcr, M_FATAL, 0, @@ -258,16 +258,16 @@ void SetPairedStorage(JobControlRecord* jcr) /* * For a restores we look at the read storage. */ - if (jcr->impl_->res.read_storage_list) { + if (jcr->impl->res.read_storage_list) { /* * Setup the jcr->impl_->res.paired_read_write_storage_list to point to * all paired_storage entries of all the storage currently in the * jcr->impl_->res.read_storage_list. */ - jcr->impl_->res.paired_read_write_storage_list = + jcr->impl->res.paired_read_write_storage_list = new alist(10, not_owned_by_alist); foreach_alist (paired_read_write_storage, - jcr->impl_->res.read_storage_list) { + jcr->impl->res.read_storage_list) { store = (StorageResource*)my_config->GetNextRes(R_STORAGE, NULL); while (store) { if (store->paired_storage == paired_read_write_storage) { break; } @@ -281,15 +281,15 @@ void SetPairedStorage(JobControlRecord* jcr) * paired_read_write_storage as its paired storage. */ if (store) { - jcr->impl_->res.paired_read_write_storage_list->append(store); + jcr->impl->res.paired_read_write_storage_list->append(store); /* * If the current processed paired_read_write_storage is also the * current entry in jcr->impl_->res.read_storage update the * jcr->paired_read_write_storage to point to this storage entry. */ - if (paired_read_write_storage == jcr->impl_->res.read_storage) { - jcr->impl_->res.paired_read_write_storage = store; + if (paired_read_write_storage == jcr->impl->res.read_storage) { + jcr->impl->res.paired_read_write_storage = store; } } } @@ -303,21 +303,21 @@ void SetPairedStorage(JobControlRecord* jcr) /* * For a migrate or copy we look at the read storage. */ - if (jcr->impl_->res.read_storage_list) { + if (jcr->impl->res.read_storage_list) { /* * Setup the jcr->impl_->res.read_storage_list to point to all * paired_storage entries of all the storage currently in the * jcr->impl_->res.read_storage_list. Save the original list under * jcr->impl_->res.paired_read_write_storage_list. */ - jcr->impl_->res.paired_read_write_storage_list = - jcr->impl_->res.read_storage_list; - jcr->impl_->res.read_storage_list = new alist(10, not_owned_by_alist); - foreach_alist (store, jcr->impl_->res.paired_read_write_storage_list) { + jcr->impl->res.paired_read_write_storage_list = + jcr->impl->res.read_storage_list; + jcr->impl->res.read_storage_list = new alist(10, not_owned_by_alist); + foreach_alist (store, jcr->impl->res.paired_read_write_storage_list) { if (store->paired_storage) { Dmsg1(100, "read_storage_list=%s\n", store->paired_storage->resource_name_); - jcr->impl_->res.read_storage_list->append(store->paired_storage); + jcr->impl->res.read_storage_list->append(store->paired_storage); } } @@ -327,10 +327,10 @@ void SetPairedStorage(JobControlRecord* jcr) * paired_read_write_storage which is for restore in the * FreePairedStorage() function. */ - store = jcr->impl_->res.read_storage; + store = jcr->impl->res.read_storage; if (store->paired_storage) { - jcr->impl_->res.read_storage = store->paired_storage; - jcr->impl_->res.paired_read_write_storage = store; + jcr->impl->res.read_storage = store->paired_storage; + jcr->impl->res.paired_read_write_storage = store; } } else { Jmsg(jcr, M_FATAL, 0, @@ -352,25 +352,25 @@ void SetPairedStorage(JobControlRecord* jcr) */ void FreePairedStorage(JobControlRecord* jcr) { - if (jcr->impl_->res.paired_read_write_storage_list) { + if (jcr->impl->res.paired_read_write_storage_list) { switch (jcr->getJobType()) { case JT_BACKUP: /* * For a backup we look at the write storage. */ - if (jcr->impl_->res.write_storage_list) { + if (jcr->impl->res.write_storage_list) { /* * The jcr->impl_->res.write_storage_list contain a set of paired * storages. We just delete it content and swap back to the real * master storage. */ - delete jcr->impl_->res.write_storage_list; - jcr->impl_->res.write_storage_list = - jcr->impl_->res.paired_read_write_storage_list; - jcr->impl_->res.paired_read_write_storage_list = NULL; - jcr->impl_->res.write_storage = - jcr->impl_->res.paired_read_write_storage; - jcr->impl_->res.paired_read_write_storage = NULL; + delete jcr->impl->res.write_storage_list; + jcr->impl->res.write_storage_list = + jcr->impl->res.paired_read_write_storage_list; + jcr->impl->res.paired_read_write_storage_list = NULL; + jcr->impl->res.write_storage = + jcr->impl->res.paired_read_write_storage; + jcr->impl->res.paired_read_write_storage = NULL; } break; case JT_RESTORE: @@ -379,28 +379,28 @@ void FreePairedStorage(JobControlRecord* jcr) * storages. For the read we created a list of alternative storage which * we can just drop now. */ - delete jcr->impl_->res.paired_read_write_storage_list; - jcr->impl_->res.paired_read_write_storage_list = NULL; - jcr->impl_->res.paired_read_write_storage = NULL; + delete jcr->impl->res.paired_read_write_storage_list; + jcr->impl->res.paired_read_write_storage_list = NULL; + jcr->impl->res.paired_read_write_storage = NULL; break; case JT_MIGRATE: case JT_COPY: /* * For a migrate or copy we look at the read storage. */ - if (jcr->impl_->res.read_storage_list) { + if (jcr->impl->res.read_storage_list) { /* * The jcr->impl_->res.read_storage_list contains a set of paired * storages. We just delete it content and swap back to the real * master storage. */ - delete jcr->impl_->res.read_storage_list; - jcr->impl_->res.read_storage_list = - jcr->impl_->res.paired_read_write_storage_list; - jcr->impl_->res.paired_read_write_storage_list = NULL; - jcr->impl_->res.read_storage = - jcr->impl_->res.paired_read_write_storage; - jcr->impl_->res.paired_read_write_storage = NULL; + delete jcr->impl->res.read_storage_list; + jcr->impl->res.read_storage_list = + jcr->impl->res.paired_read_write_storage_list; + jcr->impl->res.paired_read_write_storage_list = NULL; + jcr->impl->res.read_storage = + jcr->impl->res.paired_read_write_storage; + jcr->impl->res.paired_read_write_storage = NULL; } break; default: @@ -424,8 +424,8 @@ bool HasPairedStorage(JobControlRecord* jcr) /* * For a backup we look at the write storage. */ - if (jcr->impl_->res.write_storage_list) { - foreach_alist (store, jcr->impl_->res.write_storage_list) { + if (jcr->impl->res.write_storage_list) { + foreach_alist (store, jcr->impl->res.write_storage_list) { if (!store->paired_storage) { return false; } } } else { @@ -438,8 +438,8 @@ bool HasPairedStorage(JobControlRecord* jcr) case JT_RESTORE: case JT_MIGRATE: case JT_COPY: - if (jcr->impl_->res.read_storage_list) { - foreach_alist (store, jcr->impl_->res.read_storage_list) { + if (jcr->impl->res.read_storage_list) { + foreach_alist (store, jcr->impl->res.read_storage_list) { if (!store->paired_storage) { return false; } } } else { @@ -468,7 +468,7 @@ bool SelectNextRstore(JobControlRecord* jcr, bootstrap_info& info) { UnifiedStorageResource ustore; - if (bstrcmp(jcr->impl_->res.read_storage->resource_name_, info.storage)) { + if (bstrcmp(jcr->impl->res.read_storage->resource_name_, info.storage)) { return true; /* Same SD nothing to change */ } diff --git a/core/src/dird/testfind.cc b/core/src/dird/testfind.cc index 210b02b3689..fa953877c20 100644 --- a/core/src/dird/testfind.cc +++ b/core/src/dird/testfind.cc @@ -142,10 +142,10 @@ int main(int argc, char* const* argv) } jcr = NewDirectorJcr(); // Ueb: null - jcr->impl_->res.fileset = + jcr->impl->res.fileset = (FilesetResource*)my_config->GetResWithName(R_FILESET, fileset_name); - if (jcr->impl_->res.fileset == NULL) { + if (jcr->impl->res.fileset == NULL) { fprintf(stderr, "%s: Fileset not found\n", fileset_name); FilesetResource* var; @@ -413,7 +413,7 @@ static void CountFiles(FindFilesPacket* ar) static bool CopyFileset(FindFilesPacket* ff, JobControlRecord* jcr) { - FilesetResource* jcr_fileset = jcr->impl_->res.fileset; + FilesetResource* jcr_fileset = jcr->impl->res.fileset; int num; bool include = true; diff --git a/core/src/dird/ua_cmds.cc b/core/src/dird/ua_cmds.cc index 93a54b4d454..3085cbbe2f9 100644 --- a/core/src/dird/ua_cmds.cc +++ b/core/src/dird/ua_cmds.cc @@ -571,9 +571,9 @@ bool Do_a_command(UaContext* ua) Dmsg1(900, "Command: %s\n", ua->argk[0]); if (ua->argc == 0) { return false; } - while (ua->jcr->impl_->res.write_storage_list && - ua->jcr->impl_->res.write_storage_list->size()) { - ua->jcr->impl_->res.write_storage_list->remove(0); + while (ua->jcr->impl->res.write_storage_list && + ua->jcr->impl->res.write_storage_list->size()) { + ua->jcr->impl->res.write_storage_list->remove(0); } len = strlen(ua->argk[0]); @@ -897,7 +897,7 @@ static inline bool SetbwlimitFiled(UaContext* ua, /* * Connect to File daemon */ - ua->jcr->impl_->res.client = client; + ua->jcr->impl->res.client = client; ua->jcr->max_bandwidth = limit; /* @@ -922,7 +922,7 @@ static inline bool SetbwlimitFiled(UaContext* ua, ua->jcr->file_bsock->close(); delete ua->jcr->file_bsock; ua->jcr->file_bsock = NULL; - ua->jcr->impl_->res.client = NULL; + ua->jcr->impl->res.client = NULL; ua->jcr->max_bandwidth = 0; return true; @@ -951,7 +951,7 @@ static inline bool setbwlimit_stored(UaContext* ua, /* * Connect to Storage daemon */ - ua->jcr->impl_->res.write_storage = store; + ua->jcr->impl->res.write_storage = store; ua->jcr->max_bandwidth = limit; /* @@ -976,7 +976,7 @@ static inline bool setbwlimit_stored(UaContext* ua, ua->jcr->store_bsock->close(); delete ua->jcr->store_bsock; ua->jcr->store_bsock = NULL; - ua->jcr->impl_->res.write_storage = NULL; + ua->jcr->impl->res.write_storage = NULL; ua->jcr->max_bandwidth = 0; return true; @@ -1018,10 +1018,10 @@ static bool SetbwlimitCmd(UaContext* ua, const char* cmd) switch (jcr->getJobType()) { case JT_COPY: case JT_MIGRATE: - store = jcr->impl_->res.read_storage; + store = jcr->impl->res.read_storage; break; default: - client = jcr->impl_->res.client; + client = jcr->impl->res.client; break; } FreeJcr(jcr); @@ -1231,7 +1231,7 @@ static void DoClientSetdebug(UaContext* ua, /* * Connect to File daemon */ - ua->jcr->impl_->res.client = client; + ua->jcr->impl->res.client = client; /* * Try to connect for 15 seconds @@ -1246,7 +1246,7 @@ static void DoClientSetdebug(UaContext* ua, Dmsg0(120, "Connected to file daemon\n"); fd = ua->jcr->file_bsock; - if (ua->jcr->impl_->FDVersion >= FD_VERSION_53) { + if (ua->jcr->impl->FDVersion >= FD_VERSION_53) { fd->fsend("setdebug=%d trace=%d hangup=%d timestamp=%d\n", level, trace_flag, hangup_flag, timestamp_flag); } else { @@ -1795,8 +1795,8 @@ static bool EstimateCmd(UaContext* ua, const char* cmd) return false; } - jcr->impl_->res.client = client; - jcr->impl_->res.fileset = fileset; + jcr->impl->res.client = client; + jcr->impl->res.fileset = fileset; CloseDb(ua); switch (client->Protocol) { @@ -1815,7 +1815,7 @@ static bool EstimateCmd(UaContext* ua, const char* cmd) if (!OpenDb(ua)) { return false; } - jcr->impl_->res.job = job; + jcr->impl->res.job = job; jcr->setJobType(JT_BACKUP); jcr->start_time = time(NULL); InitJcrJobRecord(jcr); @@ -1827,8 +1827,8 @@ static bool EstimateCmd(UaContext* ua, const char* cmd) GetLevelSinceTime(jcr); ua->SendMsg(_("Connecting to Client %s at %s:%d\n"), - jcr->impl_->res.client->resource_name_, - jcr->impl_->res.client->address, jcr->impl_->res.client->FDport); + jcr->impl->res.client->resource_name_, + jcr->impl->res.client->address, jcr->impl->res.client->FDport); if (!ConnectToFileDaemon(jcr, 1, 15, false)) { ua->ErrorMsg(_("Failed to connect to Client.\n")); return false; @@ -2119,14 +2119,14 @@ static bool DoTruncate(UaContext* ua, MediaDbRecord& mr) /* * Choose storage */ - ua->jcr->impl_->res.write_storage = ua->GetStoreResWithName(storage_dbr.Name); - if (!ua->jcr->impl_->res.write_storage) { + ua->jcr->impl->res.write_storage = ua->GetStoreResWithName(storage_dbr.Name); + if (!ua->jcr->impl->res.write_storage) { ua->ErrorMsg("failed to determine storage resource by name %s\n", storage_dbr.Name); goto bail_out; } - if (SendLabelRequest(ua, ua->jcr->impl_->res.write_storage, &mr, &mr, + if (SendLabelRequest(ua, ua->jcr->impl->res.write_storage, &mr, &mr, &pool_dbr, /* bool media_record_exists */ true, @@ -2141,7 +2141,7 @@ static bool DoTruncate(UaContext* ua, MediaDbRecord& mr) } bail_out: - ua->jcr->impl_->res.write_storage = NULL; + ua->jcr->impl->res.write_storage = NULL; return retval; } @@ -2440,7 +2440,7 @@ static void DoMountCmd(UaContext* ua, const char* cmd) if (!do_alldrives) { DoAutochangerVolumeOperation(ua, store.store, cmd, drive, slot); } else { - nr_drives = GetNumDrives(ua, ua->jcr->impl_->res.write_storage); + nr_drives = GetNumDrives(ua, ua->jcr->impl->res.write_storage); for (drive_number_t i = 0; i < nr_drives; i++) { DoAutochangerVolumeOperation(ua, store.store, cmd, i, slot); } diff --git a/core/src/dird/ua_db.cc b/core/src/dird/ua_db.cc index e01958fcd1e..96c58335f6b 100644 --- a/core/src/dird/ua_db.cc +++ b/core/src/dird/ua_db.cc @@ -146,7 +146,7 @@ bool OpenDb(UaContext* ua, bool use_private) mult_db_conn = ua->catalog->mult_db_connections; if (use_private) { mult_db_conn = true; } - ua->jcr->impl_->res.catalog = ua->catalog; + ua->jcr->impl->res.catalog = ua->catalog; Dmsg0(100, "UA Open database\n"); ua->db = DbSqlGetPooledConnection( ua->jcr, ua->catalog->db_driver, ua->catalog->db_name, diff --git a/core/src/dird/ua_dotcmds.cc b/core/src/dird/ua_dotcmds.cc index 1cb39b2aa72..36b2bf51942 100644 --- a/core/src/dird/ua_dotcmds.cc +++ b/core/src/dird/ua_dotcmds.cc @@ -742,7 +742,7 @@ static void DoClientCmd(UaContext* ua, ClientResource* client, const char* cmd) /* Connect to File daemon */ - ua->jcr->impl_->res.client = client; + ua->jcr->impl->res.client = client; /* Try to connect for 15 seconds */ ua->SendMsg(_("Connecting to Client %s at %s:%d\n"), client->resource_name_, client->address, client->FDport); diff --git a/core/src/dird/ua_label.cc b/core/src/dird/ua_label.cc index 3378d831e6f..6bf84cc7ca4 100644 --- a/core/src/dird/ua_label.cc +++ b/core/src/dird/ua_label.cc @@ -68,7 +68,7 @@ static inline bool update_database(UaContext* ua, * Update existing media record. */ mr->InChanger = mr->Slot > 0; /* If slot give assume in changer */ - SetStorageidInMr(ua->jcr->impl_->res.write_storage, mr); + SetStorageidInMr(ua->jcr->impl->res.write_storage, mr); if (!ua->db->UpdateMediaRecord(ua->jcr, mr)) { ua->ErrorMsg("%s", ua->db->strerror()); retval = false; @@ -80,7 +80,7 @@ static inline bool update_database(UaContext* ua, SetPoolDbrDefaultsInMediaDbr(mr, pr); mr->InChanger = mr->Slot > 0; /* If slot give assume in changer */ mr->Enabled = 1; - SetStorageidInMr(ua->jcr->impl_->res.write_storage, mr); + SetStorageidInMr(ua->jcr->impl->res.write_storage, mr); if (ua->db->CreateMediaRecord(ua->jcr, mr)) { ua->InfoMsg(_("Catalog record for Volume \"%s\", Slot %hd successfully " @@ -120,7 +120,7 @@ static inline bool native_send_label_request(UaContext* ua, if (!(sd = open_sd_bsock(ua))) { return false; } - bstrncpy(dev_name, ua->jcr->impl_->res.write_storage->dev_name(), + bstrncpy(dev_name, ua->jcr->impl->res.write_storage->dev_name(), sizeof(dev_name)); BashSpaces(dev_name); BashSpaces(mr->VolumeName); @@ -290,19 +290,19 @@ static inline bool IsCleaningTape(UaContext* ua, /* * Find Pool resource */ - ua->jcr->impl_->res.pool = ua->GetPoolResWithName(pr->Name, false); - if (!ua->jcr->impl_->res.pool) { + ua->jcr->impl->res.pool = ua->GetPoolResWithName(pr->Name, false); + if (!ua->jcr->impl->res.pool) { ua->ErrorMsg(_("Pool \"%s\" resource not found for volume \"%s\"!\n"), pr->Name, mr->VolumeName); return false; } - retval = bstrncmp(mr->VolumeName, ua->jcr->impl_->res.pool->cleaning_prefix, - strlen(ua->jcr->impl_->res.pool->cleaning_prefix)); + retval = bstrncmp(mr->VolumeName, ua->jcr->impl->res.pool->cleaning_prefix, + strlen(ua->jcr->impl->res.pool->cleaning_prefix)); Dmsg4(100, "CLNprefix=%s: Vol=%s: len=%d bstrncmp=%s\n", - ua->jcr->impl_->res.pool->cleaning_prefix, mr->VolumeName, - strlen(ua->jcr->impl_->res.pool->cleaning_prefix), + ua->jcr->impl->res.pool->cleaning_prefix, mr->VolumeName, + strlen(ua->jcr->impl->res.pool->cleaning_prefix), retval ? "true" : "false"); return retval; @@ -318,7 +318,7 @@ static void label_from_barcodes(UaContext* ua, bool label_encrypt, bool yes) { - StorageResource* store = ua->jcr->impl_->res.write_storage; + StorageResource* store = ua->jcr->impl->res.write_storage; PoolDbRecord pr; MediaDbRecord mr; vol_list_t* vl; @@ -328,7 +328,7 @@ static void label_from_barcodes(UaContext* ua, int max_slots; - max_slots = GetNumSlots(ua, ua->jcr->impl_->res.write_storage); + max_slots = GetNumSlots(ua, ua->jcr->impl->res.write_storage); if (max_slots <= 0) { ua->WarningMsg(_("No slots in changer to scan.\n")); return; diff --git a/core/src/dird/ua_output.cc b/core/src/dird/ua_output.cc index 2ad019027ce..9df2478453c 100644 --- a/core/src/dird/ua_output.cc +++ b/core/src/dird/ua_output.cc @@ -1296,17 +1296,17 @@ static bool ListNextvol(UaContext* ua, int ndays) found = false; goto get_out; } - if (!jcr->impl_->jr.PoolId) { + if (!jcr->impl->jr.PoolId) { ua->ErrorMsg(_("Could not find Pool for Job %s\n"), job->resource_name_); continue; } PoolDbRecord pr; - pr.PoolId = jcr->impl_->jr.PoolId; + pr.PoolId = jcr->impl->jr.PoolId; if (!ua->db->GetPoolRecord(jcr, &pr)) { bstrncpy(pr.Name, "*UnknownPool*", sizeof(pr.Name)); } MediaDbRecord mr; - mr.PoolId = jcr->impl_->jr.PoolId; + mr.PoolId = jcr->impl->jr.PoolId; GetJobStorage(&store, job, run); SetStorageidInMr(store.store, &mr); /* no need to set ScratchPoolId, since we use fnv_no_create_vol */ @@ -1420,7 +1420,7 @@ bool CompleteJcrForJob(JobControlRecord* jcr, PoolResource* pool) { SetJcrDefaults(jcr, job); - if (pool) { jcr->impl_->res.pool = pool; /* override */ } + if (pool) { jcr->impl->res.pool = pool; /* override */ } if (jcr->db) { Dmsg0(100, "complete_jcr close db\n"); DbSqlClosePooledConnection(jcr, jcr->db); @@ -1429,25 +1429,25 @@ bool CompleteJcrForJob(JobControlRecord* jcr, Dmsg0(100, "complete_jcr open db\n"); jcr->db = DbSqlGetPooledConnection( - jcr, jcr->impl_->res.catalog->db_driver, jcr->impl_->res.catalog->db_name, - jcr->impl_->res.catalog->db_user, - jcr->impl_->res.catalog->db_password.value, - jcr->impl_->res.catalog->db_address, jcr->impl_->res.catalog->db_port, - jcr->impl_->res.catalog->db_socket, - jcr->impl_->res.catalog->mult_db_connections, - jcr->impl_->res.catalog->disable_batch_insert, - jcr->impl_->res.catalog->try_reconnect, - jcr->impl_->res.catalog->exit_on_fatal); + jcr, jcr->impl->res.catalog->db_driver, jcr->impl->res.catalog->db_name, + jcr->impl->res.catalog->db_user, + jcr->impl->res.catalog->db_password.value, + jcr->impl->res.catalog->db_address, jcr->impl->res.catalog->db_port, + jcr->impl->res.catalog->db_socket, + jcr->impl->res.catalog->mult_db_connections, + jcr->impl->res.catalog->disable_batch_insert, + jcr->impl->res.catalog->try_reconnect, + jcr->impl->res.catalog->exit_on_fatal); if (jcr->db == NULL) { Jmsg(jcr, M_FATAL, 0, _("Could not open database \"%s\".\n"), - jcr->impl_->res.catalog->db_name); + jcr->impl->res.catalog->db_name); return false; } PoolDbRecord pr; - bstrncpy(pr.Name, jcr->impl_->res.pool->resource_name_, sizeof(pr.Name)); + bstrncpy(pr.Name, jcr->impl->res.pool->resource_name_, sizeof(pr.Name)); while (!jcr->db->GetPoolRecord(jcr, &pr)) { /* get by Name */ /* Try to create the pool */ - if (CreatePool(jcr, jcr->db, jcr->impl_->res.pool, POOL_OP_CREATE) < 0) { + if (CreatePool(jcr, jcr->db, jcr->impl->res.pool, POOL_OP_CREATE) < 0) { Jmsg(jcr, M_FATAL, 0, _("Pool %s not in database. %s"), pr.Name, jcr->db->strerror()); if (jcr->db) { @@ -1459,7 +1459,7 @@ bool CompleteJcrForJob(JobControlRecord* jcr, Jmsg(jcr, M_INFO, 0, _("Pool %s created in database.\n"), pr.Name); } } - jcr->impl_->jr.PoolId = pr.PoolId; + jcr->impl->jr.PoolId = pr.PoolId; return true; } diff --git a/core/src/dird/ua_purge.cc b/core/src/dird/ua_purge.cc index bc6e9f2b3da..666ed6a11aa 100644 --- a/core/src/dird/ua_purge.cc +++ b/core/src/dird/ua_purge.cc @@ -756,7 +756,7 @@ static bool ActionOnPurgeCmd(UaContext* ua, const char* cmd) /* * Choose storage */ - ua->jcr->impl_->res.write_storage = store = get_storage_resource(ua); + ua->jcr->impl->res.write_storage = store = get_storage_resource(ua); if (!store) { goto bail_out; } switch (store->Protocol) { @@ -835,7 +835,7 @@ static bool ActionOnPurgeCmd(UaContext* ua, const char* cmd) bail_out: CloseDb(ua); if (sd) { CloseSdBsock(ua); } - ua->jcr->impl_->res.write_storage = NULL; + ua->jcr->impl->res.write_storage = NULL; if (results) { free(results); } return true; diff --git a/core/src/dird/ua_restore.cc b/core/src/dird/ua_restore.cc index 344ff82742e..3f99672d3d9 100644 --- a/core/src/dird/ua_restore.cc +++ b/core/src/dird/ua_restore.cc @@ -1229,7 +1229,7 @@ static bool BuildDirectoryTree(UaContext* ua, RestoreContext* rx) * For NDMP restores its used in the DMA to know what to restore. * The tree is freed by the DMA when its done. */ - ua->jcr->impl_->restore_tree_root = tree.root; + ua->jcr->impl->restore_tree_root = tree.root; return OK; } diff --git a/core/src/dird/ua_run.cc b/core/src/dird/ua_run.cc index f9e852320b7..3953b4bb9c4 100644 --- a/core/src/dird/ua_run.cc +++ b/core/src/dird/ua_run.cc @@ -393,9 +393,9 @@ int DoRunCmd(UaContext* ua, const char* cmd) if (!jcr) { jcr = NewDirectorJcr(); SetJcrDefaults(jcr, rc.job); - jcr->impl_->unlink_bsr = - ua->jcr->impl_->unlink_bsr; /* copy unlink flag from caller */ - ua->jcr->impl_->unlink_bsr = false; + jcr->impl->unlink_bsr = + ua->jcr->impl->unlink_bsr; /* copy unlink flag from caller */ + ua->jcr->impl->unlink_bsr = false; } /* @@ -409,9 +409,9 @@ int DoRunCmd(UaContext* ua, const char* cmd) /* * Transfer selected restore tree to new restore Job */ - if (ua->jcr->impl_->restore_tree_root) { - jcr->impl_->restore_tree_root = ua->jcr->impl_->restore_tree_root; - ua->jcr->impl_->restore_tree_root = NULL; + if (ua->jcr->impl->restore_tree_root) { + jcr->impl->restore_tree_root = ua->jcr->impl->restore_tree_root; + ua->jcr->impl->restore_tree_root = NULL; } try_again: @@ -505,22 +505,22 @@ int DoRunCmd(UaContext* ua, const char* cmd) * For interactive runs we set IgnoreLevelPoolOverrides as we already * performed the actual overrrides. */ - jcr->impl_->IgnoreLevelPoolOverides = true; + jcr->impl->IgnoreLevelPoolOverides = true; if (ua->cmd[0] == 0 || bstrncasecmp(ua->cmd, NT_("yes"), strlen(ua->cmd)) || bstrncasecmp(ua->cmd, _("yes"), strlen(ua->cmd))) { JobId_t JobId; - Dmsg1(800, "Calling RunJob job=%x\n", jcr->impl_->res.job); + Dmsg1(800, "Calling RunJob job=%x\n", jcr->impl->res.job); start_job: Dmsg3(100, "JobId=%u using pool %s priority=%d\n", (int)jcr->JobId, - jcr->impl_->res.pool->resource_name_, jcr->JobPriority); - Dmsg1(900, "Running a job; its spool_data = %d\n", jcr->impl_->spool_data); + jcr->impl->res.pool->resource_name_, jcr->JobPriority); + Dmsg1(900, "Running a job; its spool_data = %d\n", jcr->impl->spool_data); JobId = RunJob(jcr); Dmsg4(100, "JobId=%u NewJobId=%d using pool %s priority=%d\n", - (int)jcr->JobId, JobId, jcr->impl_->res.pool->resource_name_, + (int)jcr->JobId, JobId, jcr->impl->res.pool->resource_name_, jcr->JobPriority); FreeJcr(jcr); /* release jcr */ @@ -604,7 +604,7 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc) case JT_BACKUP: if (!rc.pool_override && !jcr->is_JobLevel(L_VIRTUAL_FULL)) { ApplyPoolOverrides(jcr, true); - rc.pool = jcr->impl_->res.pool; + rc.pool = jcr->impl->res.pool; rc.level_override = true; } break; @@ -625,7 +625,7 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc) /* Job */ rc.job = select_job_resource(ua); if (rc.job) { - jcr->impl_->res.job = rc.job; + jcr->impl->res.job = rc.job; SetJcrDefaults(jcr, rc.job); goto try_again; } @@ -634,7 +634,7 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc) /* FileSet */ rc.fileset = select_fileset_resource(ua); if (rc.fileset) { - jcr->impl_->res.fileset = rc.fileset; + jcr->impl->res.fileset = rc.fileset; goto try_again; } break; @@ -642,18 +642,18 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc) /* Client */ rc.client = select_client_resource(ua); if (rc.client) { - jcr->impl_->res.client = rc.client; + jcr->impl->res.client = rc.client; goto try_again; } break; case 5: /* Backup Format */ if (GetCmd(ua, _("Please enter Backup Format: "))) { - if (jcr->impl_->backup_format) { - free(jcr->impl_->backup_format); - jcr->impl_->backup_format = NULL; + if (jcr->impl->backup_format) { + free(jcr->impl->backup_format); + jcr->impl->backup_format = NULL; } - jcr->impl_->backup_format = strdup(ua->cmd); + jcr->impl->backup_format = strdup(ua->cmd); goto try_again; } break; @@ -691,11 +691,11 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc) jcr->is_JobType(JT_VERIFY)) { /* Pool */ rc.pool = select_pool_resource(ua); if (rc.pool) { - jcr->impl_->res.pool = rc.pool; + jcr->impl->res.pool = rc.pool; rc.level_override = false; rc.pool_override = true; Dmsg1(100, "Set new pool=%s\n", - jcr->impl_->res.pool->resource_name_); + jcr->impl->res.pool->resource_name_); goto try_again; } } else { @@ -731,14 +731,14 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc) jcr->is_JobLevel(L_VIRTUAL_FULL))) { /* NextPool */ rc.next_pool = select_pool_resource(ua); if (rc.next_pool) { - jcr->impl_->res.next_pool = rc.next_pool; + jcr->impl->res.next_pool = rc.next_pool; Dmsg1(100, "Set new next_pool=%s\n", - jcr->impl_->res.next_pool->resource_name_); + jcr->impl->res.next_pool->resource_name_); goto try_again; } } else if (jcr->is_JobType(JT_VERIFY)) { /* Verify Job */ rc.verify_job = select_job_resource(ua); - if (rc.verify_job) { jcr->impl_->res.verify_job = rc.verify_job; } + if (rc.verify_job) { jcr->impl->res.verify_job = rc.verify_job; } goto try_again; } else if (jcr->is_JobType(JT_RESTORE)) { /* Where */ if (GetCmd(ua, _("Please enter the full path prefix for restore (/ " @@ -759,11 +759,11 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc) } } else { /* Plugin Options */ if (GetCmd(ua, _("Please enter Plugin Options string: "))) { - if (jcr->impl_->plugin_options) { - free(jcr->impl_->plugin_options); - jcr->impl_->plugin_options = NULL; + if (jcr->impl->plugin_options) { + free(jcr->impl->plugin_options); + jcr->impl->plugin_options = NULL; } - jcr->impl_->plugin_options = strdup(ua->cmd); + jcr->impl->plugin_options = strdup(ua->cmd); goto try_again; } } @@ -775,11 +775,11 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc) goto try_again; } else if (jcr->is_JobType(JT_BACKUP)) { if (GetCmd(ua, _("Please enter Plugin Options string: "))) { - if (jcr->impl_->plugin_options) { - free(jcr->impl_->plugin_options); - jcr->impl_->plugin_options = NULL; + if (jcr->impl->plugin_options) { + free(jcr->impl->plugin_options); + jcr->impl->plugin_options = NULL; } - jcr->impl_->plugin_options = strdup(ua->cmd); + jcr->impl->plugin_options = strdup(ua->cmd); goto try_again; } } @@ -793,13 +793,13 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc) opt = DoPrompt(ua, "", _("Select replace option"), NULL, 0); if (opt >= 0) { rc.replace = ReplaceOptions[opt].name; - jcr->impl_->replace = ReplaceOptions[opt].token; + jcr->impl->replace = ReplaceOptions[opt].token; } goto try_again; case 12: /* JobId */ rc.jid = NULL; /* force reprompt */ - jcr->impl_->RestoreJobId = 0; + jcr->impl->RestoreJobId = 0; if (jcr->RestoreBootstrap) { ua->SendMsg( _("You must set the bootstrap file to NULL to be able to specify " @@ -809,11 +809,11 @@ int ModifyJobParameters(UaContext* ua, JobControlRecord* jcr, RunContext& rc) case 13: /* Plugin Options */ if (GetCmd(ua, _("Please enter Plugin Options string: "))) { - if (jcr->impl_->plugin_options) { - free(jcr->impl_->plugin_options); - jcr->impl_->plugin_options = NULL; + if (jcr->impl->plugin_options) { + free(jcr->impl->plugin_options); + jcr->impl->plugin_options = NULL; } - jcr->impl_->plugin_options = strdup(ua->cmd); + jcr->impl->plugin_options = strdup(ua->cmd); goto try_again; } break; @@ -842,10 +842,10 @@ static bool ResetRestoreContext(UaContext* ua, JobControlRecord* jcr, RunContext& rc) { - jcr->impl_->res.verify_job = rc.verify_job; - jcr->impl_->res.previous_job = rc.previous_job; - jcr->impl_->res.pool = rc.pool; - jcr->impl_->res.next_pool = rc.next_pool; + jcr->impl->res.verify_job = rc.verify_job; + jcr->impl->res.previous_job = rc.previous_job; + jcr->impl->res.pool = rc.pool; + jcr->impl->res.next_pool = rc.next_pool; /* * See if an explicit pool override was performed. @@ -854,32 +854,32 @@ static bool ResetRestoreContext(UaContext* ua, * overrides are ignored. */ if (rc.pool_name) { - PmStrcpy(jcr->impl_->res.pool_source, _("command line")); - jcr->impl_->IgnoreLevelPoolOverides = true; + PmStrcpy(jcr->impl->res.pool_source, _("command line")); + jcr->impl->IgnoreLevelPoolOverides = true; } else if (!rc.level_override && - jcr->impl_->res.pool != jcr->impl_->res.job->pool) { - PmStrcpy(jcr->impl_->res.pool_source, _("user input")); + jcr->impl->res.pool != jcr->impl->res.job->pool) { + PmStrcpy(jcr->impl->res.pool_source, _("user input")); } SetRwstorage(jcr, rc.store); if (rc.next_pool_name) { - PmStrcpy(jcr->impl_->res.npool_source, _("command line")); - jcr->impl_->res.run_next_pool_override = true; - } else if (jcr->impl_->res.next_pool != jcr->impl_->res.pool->NextPool) { - PmStrcpy(jcr->impl_->res.npool_source, _("user input")); - jcr->impl_->res.run_next_pool_override = true; + PmStrcpy(jcr->impl->res.npool_source, _("command line")); + jcr->impl->res.run_next_pool_override = true; + } else if (jcr->impl->res.next_pool != jcr->impl->res.pool->NextPool) { + PmStrcpy(jcr->impl->res.npool_source, _("user input")); + jcr->impl->res.run_next_pool_override = true; } - jcr->impl_->res.client = rc.client; - if (jcr->impl_->res.client) { + jcr->impl->res.client = rc.client; + if (jcr->impl->res.client) { PmStrcpy(jcr->client_name, rc.client->resource_name_); } - jcr->impl_->res.fileset = rc.fileset; - jcr->impl_->ExpectedFiles = rc.files; + jcr->impl->res.fileset = rc.fileset; + jcr->impl->ExpectedFiles = rc.files; if (rc.catalog) { - jcr->impl_->res.catalog = rc.catalog; - PmStrcpy(jcr->impl_->res.catalog_source, _("user input")); + jcr->impl->res.catalog = rc.catalog; + PmStrcpy(jcr->impl->res.catalog_source, _("user input")); } PmStrcpy(jcr->comment, rc.comment); @@ -912,26 +912,26 @@ static bool ResetRestoreContext(UaContext* ua, } if (rc.plugin_options) { - if (jcr->impl_->plugin_options) { free(jcr->impl_->plugin_options); } - jcr->impl_->plugin_options = strdup(rc.plugin_options); + if (jcr->impl->plugin_options) { free(jcr->impl->plugin_options); } + jcr->impl->plugin_options = strdup(rc.plugin_options); rc.plugin_options = NULL; } if (rc.replace) { - jcr->impl_->replace = 0; + jcr->impl->replace = 0; for (int i = 0; ReplaceOptions[i].name; i++) { if (Bstrcasecmp(rc.replace, ReplaceOptions[i].name)) { - jcr->impl_->replace = ReplaceOptions[i].token; + jcr->impl->replace = ReplaceOptions[i].token; } } - if (!jcr->impl_->replace) { + if (!jcr->impl->replace) { ua->SendMsg(_("Invalid replace option: %s\n"), rc.replace); return false; } } else if (rc.job->replace) { - jcr->impl_->replace = rc.job->replace; + jcr->impl->replace = rc.job->replace; } else { - jcr->impl_->replace = REPLACE_ALWAYS; + jcr->impl->replace = REPLACE_ALWAYS; } rc.replace = NULL; @@ -947,7 +947,7 @@ static bool ResetRestoreContext(UaContext* ua, } if (rc.cloned) { - jcr->impl_->cloned = rc.cloned; + jcr->impl->cloned = rc.cloned; rc.cloned = false; } @@ -963,7 +963,7 @@ static bool ResetRestoreContext(UaContext* ua, } rc.replace = ReplaceOptions[0].name; for (int i = 0; ReplaceOptions[i].name; i++) { - if (ReplaceOptions[i].token == jcr->impl_->replace) { + if (ReplaceOptions[i].token == jcr->impl->replace) { rc.replace = ReplaceOptions[i].name; } } @@ -978,22 +978,22 @@ static bool ResetRestoreContext(UaContext* ua, if (rc.jid) { if (jcr->is_JobType(JT_BACKUP) && jcr->is_JobLevel(L_VIRTUAL_FULL)) { - if (!jcr->impl_->vf_jobids) { - jcr->impl_->vf_jobids = GetPoolMemory(PM_MESSAGE); + if (!jcr->impl->vf_jobids) { + jcr->impl->vf_jobids = GetPoolMemory(PM_MESSAGE); } - PmStrcpy(jcr->impl_->vf_jobids, rc.jid); + PmStrcpy(jcr->impl->vf_jobids, rc.jid); } else { /* * Note, this is also MigrateJobId and a VerifyJobId */ - jcr->impl_->RestoreJobId = str_to_int64(rc.jid); + jcr->impl->RestoreJobId = str_to_int64(rc.jid); } rc.jid = NULL; } if (rc.backup_format) { - if (jcr->impl_->backup_format) { free(jcr->impl_->backup_format); } - jcr->impl_->backup_format = strdup(rc.backup_format); + if (jcr->impl->backup_format) { free(jcr->impl->backup_format); } + jcr->impl->backup_format = strdup(rc.backup_format); rc.backup_format = NULL; } @@ -1001,7 +1001,7 @@ static bool ResetRestoreContext(UaContext* ua, * Some options are not available through the menu * TODO: Add an advanced menu? */ - if (rc.spool_data_set) { jcr->impl_->spool_data = rc.spool_data; } + if (rc.spool_data_set) { jcr->impl->spool_data = rc.spool_data; } if (rc.accurate_set) { jcr->accurate = rc.accurate; } @@ -1010,7 +1010,7 @@ static bool ResetRestoreContext(UaContext* ua, * but can run at the same time */ if (rc.ignoreduplicatecheck_set) { - jcr->impl_->IgnoreDuplicateJobChecking = rc.ignoreduplicatecheck; + jcr->impl->IgnoreDuplicateJobChecking = rc.ignoreduplicatecheck; } return true; @@ -1238,10 +1238,10 @@ static bool DisplayJobParameters(UaContext* ua, "Storage: %s\n" "When: %s\n" "Priority: %d\n", - job->resource_name_, jcr->impl_->res.fileset->resource_name_, - NPRT(jcr->impl_->res.client->resource_name_), - jcr->impl_->res.write_storage - ? jcr->impl_->res.write_storage->resource_name_ + job->resource_name_, jcr->impl->res.fileset->resource_name_, + NPRT(jcr->impl->res.client->resource_name_), + jcr->impl->res.write_storage + ? jcr->impl->res.write_storage->resource_name_ : _("*None*"), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } else { @@ -1253,10 +1253,10 @@ static bool DisplayJobParameters(UaContext* ua, "Storage: %s\n" "When: %s\n" "Priority: %d\n"), - job->resource_name_, jcr->impl_->res.fileset->resource_name_, - NPRT(jcr->impl_->res.client->resource_name_), - jcr->impl_->res.write_storage - ? jcr->impl_->res.write_storage->resource_name_ + job->resource_name_, jcr->impl->res.fileset->resource_name_, + NPRT(jcr->impl->res.client->resource_name_), + jcr->impl->res.write_storage + ? jcr->impl->res.write_storage->resource_name_ : _("*None*"), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } @@ -1274,10 +1274,10 @@ static bool DisplayJobParameters(UaContext* ua, "Storage: %s\n" "When: %s\n" "Priority: %d\n", - job->resource_name_, jcr->impl_->res.fileset->resource_name_, - NPRT(jcr->impl_->res.client->resource_name_), - jcr->impl_->res.write_storage - ? jcr->impl_->res.write_storage->resource_name_ + job->resource_name_, jcr->impl->res.fileset->resource_name_, + NPRT(jcr->impl->res.client->resource_name_), + jcr->impl->res.write_storage + ? jcr->impl->res.write_storage->resource_name_ : _("*None*"), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } else { @@ -1289,10 +1289,10 @@ static bool DisplayJobParameters(UaContext* ua, "Storage: %s\n" "When: %s\n" "Priority: %d\n"), - job->resource_name_, jcr->impl_->res.fileset->resource_name_, - NPRT(jcr->impl_->res.client->resource_name_), - jcr->impl_->res.write_storage - ? jcr->impl_->res.write_storage->resource_name_ + job->resource_name_, jcr->impl->res.fileset->resource_name_, + NPRT(jcr->impl->res.client->resource_name_), + jcr->impl->res.write_storage + ? jcr->impl->res.write_storage->resource_name_ : _("*None*"), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } @@ -1310,10 +1310,10 @@ static bool DisplayJobParameters(UaContext* ua, "Storage: %s\n" "When: %s\n" "Priority: %d\n", - job->resource_name_, jcr->impl_->res.fileset->resource_name_, - NPRT(jcr->impl_->res.client->resource_name_), - jcr->impl_->res.write_storage - ? jcr->impl_->res.write_storage->resource_name_ + job->resource_name_, jcr->impl->res.fileset->resource_name_, + NPRT(jcr->impl->res.client->resource_name_), + jcr->impl->res.write_storage + ? jcr->impl->res.write_storage->resource_name_ : _("*None*"), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } else { @@ -1325,10 +1325,10 @@ static bool DisplayJobParameters(UaContext* ua, "Storage: %s\n" "When: %s\n" "Priority: %d\n"), - job->resource_name_, jcr->impl_->res.fileset->resource_name_, - NPRT(jcr->impl_->res.client->resource_name_), - jcr->impl_->res.write_storage - ? jcr->impl_->res.write_storage->resource_name_ + job->resource_name_, jcr->impl->res.fileset->resource_name_, + NPRT(jcr->impl->res.client->resource_name_), + jcr->impl->res.write_storage + ? jcr->impl->res.write_storage->resource_name_ : _("*None*"), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } @@ -1356,22 +1356,22 @@ static bool DisplayJobParameters(UaContext* ua, "Priority: %d\n" "%s%s%s", job->resource_name_, JobLevelToString(jcr->getJobLevel()), - jcr->impl_->res.client->resource_name_, jcr->impl_->backup_format, - jcr->impl_->res.fileset->resource_name_, - NPRT(jcr->impl_->res.pool->resource_name_), + jcr->impl->res.client->resource_name_, jcr->impl->backup_format, + jcr->impl->res.fileset->resource_name_, + NPRT(jcr->impl->res.pool->resource_name_), is_virtual ? "NextPool: " : "", - is_virtual ? (jcr->impl_->res.next_pool - ? jcr->impl_->res.next_pool->resource_name_ + is_virtual ? (jcr->impl->res.next_pool + ? jcr->impl->res.next_pool->resource_name_ : _("*None*")) : "", is_virtual ? "\n" : "", - jcr->impl_->res.write_storage - ? jcr->impl_->res.write_storage->resource_name_ + jcr->impl->res.write_storage + ? jcr->impl->res.write_storage->resource_name_ : _("*None*"), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority, - jcr->impl_->plugin_options ? "Plugin Options: " : "", - jcr->impl_->plugin_options ? jcr->impl_->plugin_options : "", - jcr->impl_->plugin_options ? "\n" : ""); + jcr->impl->plugin_options ? "Plugin Options: " : "", + jcr->impl->plugin_options ? jcr->impl->plugin_options : "", + jcr->impl->plugin_options ? "\n" : ""); } else { ua->SendMsg( _("Run Backup job\n" @@ -1387,35 +1387,35 @@ static bool DisplayJobParameters(UaContext* ua, "Priority: %d\n" "%s%s%s"), job->resource_name_, JobLevelToString(jcr->getJobLevel()), - jcr->impl_->res.client->resource_name_, jcr->impl_->backup_format, - jcr->impl_->res.fileset->resource_name_, - NPRT(jcr->impl_->res.pool->resource_name_), - jcr->impl_->res.pool_source, is_virtual ? "NextPool: " : "", - is_virtual ? (jcr->impl_->res.next_pool - ? jcr->impl_->res.next_pool->resource_name_ + jcr->impl->res.client->resource_name_, jcr->impl->backup_format, + jcr->impl->res.fileset->resource_name_, + NPRT(jcr->impl->res.pool->resource_name_), + jcr->impl->res.pool_source, is_virtual ? "NextPool: " : "", + is_virtual ? (jcr->impl->res.next_pool + ? jcr->impl->res.next_pool->resource_name_ : _("*None*")) : "", is_virtual ? " (From " : "", - is_virtual ? jcr->impl_->res.npool_source : "", + is_virtual ? jcr->impl->res.npool_source : "", is_virtual ? ")\n" : "", - jcr->impl_->res.write_storage - ? jcr->impl_->res.write_storage->resource_name_ + jcr->impl->res.write_storage + ? jcr->impl->res.write_storage->resource_name_ : _("*None*"), - jcr->impl_->res.wstore_source, + jcr->impl->res.wstore_source, bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority, - jcr->impl_->plugin_options ? "Plugin Options: " : "", - jcr->impl_->plugin_options ? jcr->impl_->plugin_options : "", - jcr->impl_->plugin_options ? "\n" : ""); + jcr->impl->plugin_options ? "Plugin Options: " : "", + jcr->impl->plugin_options ? jcr->impl->plugin_options : "", + jcr->impl->plugin_options ? "\n" : ""); } } else { /* JT_VERIFY */ JobDbRecord jr; const char* Name; - if (jcr->impl_->res.verify_job) { - Name = jcr->impl_->res.verify_job->resource_name_; - } else if (jcr->impl_ + if (jcr->impl->res.verify_job) { + Name = jcr->impl->res.verify_job->resource_name_; + } else if (jcr->impl ->RestoreJobId) { /* Display job name if jobid requested */ - jr.JobId = jcr->impl_->RestoreJobId; + jr.JobId = jcr->impl->RestoreJobId; if (!ua->db->GetJobRecord(jcr, &jr)) { ua->ErrorMsg( _("Could not get job record for selected JobId. ERR=%s"), @@ -1444,12 +1444,12 @@ static bool DisplayJobParameters(UaContext* ua, "When: %s\n" "Priority: %d\n", job->resource_name_, JobLevelToString(jcr->getJobLevel()), - jcr->impl_->res.client->resource_name_, - jcr->impl_->res.fileset->resource_name_, - NPRT(jcr->impl_->res.pool->resource_name_), - jcr->impl_->res.pool_source, - jcr->impl_->res.read_storage->resource_name_, - jcr->impl_->res.rstore_source, Name, verify_list, + jcr->impl->res.client->resource_name_, + jcr->impl->res.fileset->resource_name_, + NPRT(jcr->impl->res.pool->resource_name_), + jcr->impl->res.pool_source, + jcr->impl->res.read_storage->resource_name_, + jcr->impl->res.rstore_source, Name, verify_list, bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } else { ua->SendMsg(_("Run Verify Job\n" @@ -1464,31 +1464,31 @@ static bool DisplayJobParameters(UaContext* ua, "When: %s\n" "Priority: %d\n"), job->resource_name_, JobLevelToString(jcr->getJobLevel()), - jcr->impl_->res.client->resource_name_, - jcr->impl_->res.fileset->resource_name_, - NPRT(jcr->impl_->res.pool->resource_name_), - jcr->impl_->res.pool_source, - jcr->impl_->res.read_storage->resource_name_, - jcr->impl_->res.rstore_source, Name, verify_list, + jcr->impl->res.client->resource_name_, + jcr->impl->res.fileset->resource_name_, + NPRT(jcr->impl->res.pool->resource_name_), + jcr->impl->res.pool_source, + jcr->impl->res.read_storage->resource_name_, + jcr->impl->res.rstore_source, Name, verify_list, bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } } break; case JT_RESTORE: - if (jcr->impl_->RestoreJobId == 0 && !jcr->RestoreBootstrap) { + if (jcr->impl->RestoreJobId == 0 && !jcr->RestoreBootstrap) { if (rc.jid) { - jcr->impl_->RestoreJobId = str_to_int64(rc.jid); + jcr->impl->RestoreJobId = str_to_int64(rc.jid); } else { if (!GetPint(ua, _("Please enter a JobId for restore: "))) { return false; } - jcr->impl_->RestoreJobId = ua->int64_val; + jcr->impl->RestoreJobId = ua->int64_val; } } jcr->setJobLevel(L_FULL); /* default level */ - Dmsg1(800, "JobId to restore=%d\n", jcr->impl_->RestoreJobId); - if (jcr->impl_->RestoreJobId == 0) { + Dmsg1(800, "JobId to restore=%d\n", jcr->impl->RestoreJobId); + if (jcr->impl->RestoreJobId == 0) { /* RegexWhere is take before RestoreWhere */ if (jcr->RegexWhere || (job->RegexWhere && !jcr->where)) { if (ua->api) { @@ -1511,13 +1511,13 @@ static bool DisplayJobParameters(UaContext* ua, "Plugin Options: %s\n", job->resource_name_, NPRT(jcr->RestoreBootstrap), jcr->RegexWhere ? jcr->RegexWhere : job->RegexWhere, rc.replace, - jcr->impl_->res.fileset->resource_name_, rc.client_name, - jcr->impl_->res.client->resource_name_, - jcr->impl_->backup_format, - jcr->impl_->res.read_storage->resource_name_, + jcr->impl->res.fileset->resource_name_, rc.client_name, + jcr->impl->res.client->resource_name_, + jcr->impl->backup_format, + jcr->impl->res.read_storage->resource_name_, bstrutime(dt, sizeof(dt), jcr->sched_time), - jcr->impl_->res.catalog->resource_name_, jcr->JobPriority, - NPRT(jcr->impl_->plugin_options)); + jcr->impl->res.catalog->resource_name_, jcr->JobPriority, + NPRT(jcr->impl->plugin_options)); } else { ua->SendMsg(_("Run Restore job\n" "JobName: %s\n" @@ -1535,13 +1535,13 @@ static bool DisplayJobParameters(UaContext* ua, "Plugin Options: %s\n"), job->resource_name_, NPRT(jcr->RestoreBootstrap), jcr->RegexWhere ? jcr->RegexWhere : job->RegexWhere, - rc.replace, jcr->impl_->res.fileset->resource_name_, - rc.client_name, jcr->impl_->res.client->resource_name_, - jcr->impl_->backup_format, - jcr->impl_->res.read_storage->resource_name_, + rc.replace, jcr->impl->res.fileset->resource_name_, + rc.client_name, jcr->impl->res.client->resource_name_, + jcr->impl->backup_format, + jcr->impl->res.read_storage->resource_name_, bstrutime(dt, sizeof(dt), jcr->sched_time), - jcr->impl_->res.catalog->resource_name_, - jcr->JobPriority, NPRT(jcr->impl_->plugin_options)); + jcr->impl->res.catalog->resource_name_, + jcr->JobPriority, NPRT(jcr->impl->plugin_options)); } } else { if (ua->api) { @@ -1564,13 +1564,13 @@ static bool DisplayJobParameters(UaContext* ua, "Plugin Options: %s\n", job->resource_name_, NPRT(jcr->RestoreBootstrap), jcr->where ? jcr->where : NPRT(job->RestoreWhere), rc.replace, - jcr->impl_->res.fileset->resource_name_, rc.client_name, - jcr->impl_->res.client->resource_name_, - jcr->impl_->backup_format, - jcr->impl_->res.read_storage->resource_name_, + jcr->impl->res.fileset->resource_name_, rc.client_name, + jcr->impl->res.client->resource_name_, + jcr->impl->backup_format, + jcr->impl->res.read_storage->resource_name_, bstrutime(dt, sizeof(dt), jcr->sched_time), - jcr->impl_->res.catalog->resource_name_, jcr->JobPriority, - NPRT(jcr->impl_->plugin_options)); + jcr->impl->res.catalog->resource_name_, jcr->JobPriority, + NPRT(jcr->impl->plugin_options)); } else { ua->SendMsg(_("Run Restore job\n" "JobName: %s\n" @@ -1588,13 +1588,13 @@ static bool DisplayJobParameters(UaContext* ua, "Plugin Options: %s\n"), job->resource_name_, NPRT(jcr->RestoreBootstrap), jcr->where ? jcr->where : NPRT(job->RestoreWhere), - rc.replace, jcr->impl_->res.fileset->resource_name_, - rc.client_name, jcr->impl_->res.client->resource_name_, - jcr->impl_->backup_format, - jcr->impl_->res.read_storage->resource_name_, + rc.replace, jcr->impl->res.fileset->resource_name_, + rc.client_name, jcr->impl->res.client->resource_name_, + jcr->impl->backup_format, + jcr->impl->res.read_storage->resource_name_, bstrutime(dt, sizeof(dt), jcr->sched_time), - jcr->impl_->res.catalog->resource_name_, - jcr->JobPriority, NPRT(jcr->impl_->plugin_options)); + jcr->impl->res.catalog->resource_name_, + jcr->JobPriority, NPRT(jcr->impl->plugin_options)); } } @@ -1624,15 +1624,15 @@ static bool DisplayJobParameters(UaContext* ua, "Catalog: %s\n" "Priority: %d\n" "Plugin Options: %s\n"), - rc.replace, jcr->impl_->res.client->resource_name_, - jcr->impl_->backup_format, - jcr->impl_->res.read_storage->resource_name_, - (jcr->impl_->RestoreJobId == 0) + rc.replace, jcr->impl->res.client->resource_name_, + jcr->impl->backup_format, + jcr->impl->res.read_storage->resource_name_, + (jcr->impl->RestoreJobId == 0) ? _("*None*") - : edit_uint64(jcr->impl_->RestoreJobId, ec1), + : edit_uint64(jcr->impl->RestoreJobId, ec1), bstrutime(dt, sizeof(dt), jcr->sched_time), - jcr->impl_->res.catalog->resource_name_, jcr->JobPriority, - NPRT(jcr->impl_->plugin_options)); + jcr->impl->res.catalog->resource_name_, jcr->JobPriority, + NPRT(jcr->impl->plugin_options)); } break; case JT_COPY: @@ -1660,21 +1660,21 @@ static bool DisplayJobParameters(UaContext* ua, "Catalog: %s\n" "Priority: %d\n", prt_type, job->resource_name_, NPRT(jcr->RestoreBootstrap), - jcr->impl_->res.read_storage - ? jcr->impl_->res.read_storage->resource_name_ + jcr->impl->res.read_storage + ? jcr->impl->res.read_storage->resource_name_ : _("*None*"), - NPRT(jcr->impl_->res.pool->resource_name_), - jcr->impl_->res.next_pool - ? jcr->impl_->res.next_pool->resource_name_ + NPRT(jcr->impl->res.pool->resource_name_), + jcr->impl->res.next_pool + ? jcr->impl->res.next_pool->resource_name_ : _("*None*"), - jcr->impl_->res.write_storage - ? jcr->impl_->res.write_storage->resource_name_ + jcr->impl->res.write_storage + ? jcr->impl->res.write_storage->resource_name_ : _("*None*"), - (jcr->impl_->MigrateJobId == 0) + (jcr->impl->MigrateJobId == 0) ? _("*None*") - : edit_uint64(jcr->impl_->MigrateJobId, ec1), + : edit_uint64(jcr->impl->MigrateJobId, ec1), bstrutime(dt, sizeof(dt), jcr->sched_time), - jcr->impl_->res.catalog->resource_name_, jcr->JobPriority); + jcr->impl->res.catalog->resource_name_, jcr->JobPriority); } else { if (jcr->is_JobType(JT_COPY)) { prt_type = _("Run Copy job\n"); @@ -1693,25 +1693,25 @@ static bool DisplayJobParameters(UaContext* ua, "Catalog: %s\n" "Priority: %d\n"), prt_type, job->resource_name_, NPRT(jcr->RestoreBootstrap), - jcr->impl_->res.read_storage - ? jcr->impl_->res.read_storage->resource_name_ + jcr->impl->res.read_storage + ? jcr->impl->res.read_storage->resource_name_ : _("*None*"), - jcr->impl_->res.rstore_source, - NPRT(jcr->impl_->res.pool->resource_name_), - jcr->impl_->res.pool_source, - jcr->impl_->res.write_storage - ? jcr->impl_->res.write_storage->resource_name_ + jcr->impl->res.rstore_source, + NPRT(jcr->impl->res.pool->resource_name_), + jcr->impl->res.pool_source, + jcr->impl->res.write_storage + ? jcr->impl->res.write_storage->resource_name_ : _("*None*"), - jcr->impl_->res.wstore_source, - jcr->impl_->res.next_pool - ? jcr->impl_->res.next_pool->resource_name_ + jcr->impl->res.wstore_source, + jcr->impl->res.next_pool + ? jcr->impl->res.next_pool->resource_name_ : _("*None*"), - NPRT(jcr->impl_->res.npool_source), - jcr->impl_->MigrateJobId == 0 + NPRT(jcr->impl->res.npool_source), + jcr->impl->MigrateJobId == 0 ? _("*None*") - : edit_uint64(jcr->impl_->MigrateJobId, ec1), + : edit_uint64(jcr->impl->MigrateJobId, ec1), bstrutime(dt, sizeof(dt), jcr->sched_time), - jcr->impl_->res.catalog->resource_name_, jcr->JobPriority); + jcr->impl->res.catalog->resource_name_, jcr->JobPriority); } break; default: diff --git a/core/src/dird/ua_select.cc b/core/src/dird/ua_select.cc index 7a1c93f6596..401708674c5 100644 --- a/core/src/dird/ua_select.cc +++ b/core/src/dird/ua_select.cc @@ -1203,7 +1203,7 @@ StorageResource* get_storage_resource(UaContext* ua, ua->ErrorMsg(_("JobId %s is not running.\n"), edit_int64(jobid, ed1)); return NULL; } - store = jcr->impl_->res.write_storage; + store = jcr->impl->res.write_storage; FreeJcr(jcr); break; } else if (Bstrcasecmp(ua->argk[i], NT_("job")) || @@ -1216,7 +1216,7 @@ StorageResource* get_storage_resource(UaContext* ua, ua->ErrorMsg(_("Job \"%s\" is not running.\n"), ua->argv[i]); return NULL; } - store = jcr->impl_->res.write_storage; + store = jcr->impl->res.write_storage; FreeJcr(jcr); break; } else if (Bstrcasecmp(ua->argk[i], NT_("ujobid"))) { @@ -1228,7 +1228,7 @@ StorageResource* get_storage_resource(UaContext* ua, ua->ErrorMsg(_("Job \"%s\" is not running.\n"), ua->argv[i]); return NULL; } - store = jcr->impl_->res.write_storage; + store = jcr->impl->res.write_storage; FreeJcr(jcr); break; } @@ -1493,8 +1493,8 @@ alist* select_jobs(UaContext* ua, const char* reason) } if (jcr) { - if (jcr->impl_->res.job && - !ua->AclAccessOk(Job_ACL, jcr->impl_->res.job->resource_name_, + if (jcr->impl->res.job && + !ua->AclAccessOk(Job_ACL, jcr->impl->res.job->resource_name_, true)) { ua->ErrorMsg(_("Unauthorized command from this console.\n")); goto bail_out; @@ -1524,7 +1524,7 @@ alist* select_jobs(UaContext* ua, const char* reason) continue; } tjobs++; /* Count of all jobs */ - if (!ua->AclAccessOk(Job_ACL, jcr->impl_->res.job->resource_name_)) { + if (!ua->AclAccessOk(Job_ACL, jcr->impl->res.job->resource_name_)) { continue; /* Skip not authorized */ } njobs++; /* Count of authorized jobs */ @@ -1583,7 +1583,7 @@ alist* select_jobs(UaContext* ua, const char* reason) continue; } - if (!ua->AclAccessOk(Job_ACL, jcr->impl_->res.job->resource_name_)) { + if (!ua->AclAccessOk(Job_ACL, jcr->impl->res.job->resource_name_)) { continue; /* Skip not authorized */ } @@ -1640,7 +1640,7 @@ alist* select_jobs(UaContext* ua, const char* reason) if (jcr->JobId == 0) { /* This is us */ continue; } - if (!ua->AclAccessOk(Job_ACL, jcr->impl_->res.job->resource_name_)) { + if (!ua->AclAccessOk(Job_ACL, jcr->impl->res.job->resource_name_)) { continue; /* Skip not authorized */ } Bsnprintf(buf, sizeof(buf), _("JobId=%s Job=%s"), diff --git a/core/src/dird/ua_server.cc b/core/src/dird/ua_server.cc index 25d016b17a3..5402cd4b874 100644 --- a/core/src/dird/ua_server.cc +++ b/core/src/dird/ua_server.cc @@ -63,8 +63,8 @@ JobControlRecord* new_control_jcr(const char* base_name, int job_type) * everything is correctly initialized. */ LockRes(my_config); - jcr->impl_->res.job = (JobResource*)my_config->GetNextRes(R_JOB, NULL); - SetJcrDefaults(jcr, jcr->impl_->res.job); + jcr->impl->res.job = (JobResource*)my_config->GetNextRes(R_JOB, NULL); + SetJcrDefaults(jcr, jcr->impl->res.job); UnlockRes(my_config); jcr->sd_auth_key = strdup("dummy"); /* dummy Storage daemon key */ diff --git a/core/src/dird/ua_status.cc b/core/src/dird/ua_status.cc index 5a88a301571..ca24c2824ff 100644 --- a/core/src/dird/ua_status.cc +++ b/core/src/dird/ua_status.cc @@ -108,7 +108,7 @@ bool DotStatusCmd(UaContext* ua, const char* cmd) ua->SendMsg(OKdotstatus, ua->argk[2]); foreach_jcr (njcr) { if (njcr->JobId != 0 && - ua->AclAccessOk(Job_ACL, njcr->impl_->res.job->resource_name_)) { + ua->AclAccessOk(Job_ACL, njcr->impl->res.job->resource_name_)) { ua->SendMsg(DotStatusJob, edit_int64(njcr->JobId, ed1), njcr->JobStatus, njcr->JobErrors); } @@ -777,12 +777,12 @@ static void PrtRuntime(UaContext* ua, sched_pkt* sp) if (sp->job->JobType == JT_BACKUP) { jcr->db = NULL; ok = CompleteJcrForJob(jcr, sp->job, sp->pool); - Dmsg1(250, "Using pool=%s\n", jcr->impl_->res.pool->resource_name_); + Dmsg1(250, "Using pool=%s\n", jcr->impl->res.pool->resource_name_); if (jcr->db) { CloseDb = true; /* new db opened, remember to close it */ } if (ok) { - mr.PoolId = jcr->impl_->jr.PoolId; - jcr->impl_->res.write_storage = sp->store; - SetStorageidInMr(jcr->impl_->res.write_storage, &mr); + mr.PoolId = jcr->impl->jr.PoolId; + jcr->impl->res.write_storage = sp->store; + SetStorageidInMr(jcr->impl->res.write_storage, &mr); Dmsg0(250, "call FindNextVolumeForAppend\n"); /* no need to set ScratchPoolId, since we use fnv_no_create_vol */ ok = FindNextVolumeForAppend(jcr, &mr, 1, NULL, fnv_no_create_vol, @@ -953,7 +953,7 @@ static void ListRunningJobs(UaContext* ua) } foreach_jcr (jcr) { if (jcr->JobId == 0 || - !ua->AclAccessOk(Job_ACL, jcr->impl_->res.job->resource_name_)) { + !ua->AclAccessOk(Job_ACL, jcr->impl->res.job->resource_name_)) { continue; } njobs++; @@ -990,23 +990,23 @@ static void ListRunningJobs(UaContext* ua) break; case JS_WaitFD: emsg = (char*)GetPoolMemory(PM_FNAME); - if (!jcr->impl_->res.client) { + if (!jcr->impl->res.client) { Mmsg(emsg, _("is waiting on Client")); } else { Mmsg(emsg, _("is waiting on Client %s"), - jcr->impl_->res.client->resource_name_); + jcr->impl->res.client->resource_name_); } pool_mem = true; msg = emsg; break; case JS_WaitSD: emsg = (char*)GetPoolMemory(PM_FNAME); - if (jcr->impl_->res.write_storage) { + if (jcr->impl->res.write_storage) { Mmsg(emsg, _("is waiting on Storage \"%s\""), - jcr->impl_->res.write_storage->resource_name_); - } else if (jcr->impl_->res.read_storage) { + jcr->impl->res.write_storage->resource_name_); + } else if (jcr->impl->res.read_storage) { Mmsg(emsg, _("is waiting on Storage \"%s\""), - jcr->impl_->res.read_storage->resource_name_); + jcr->impl->res.read_storage->resource_name_); } else { Mmsg(emsg, _("is waiting on Storage")); } @@ -1063,7 +1063,7 @@ static void ListRunningJobs(UaContext* ua) /* * Now report Storage daemon status code */ - switch (jcr->impl_->SDJobStatus) { + switch (jcr->impl->SDJobStatus) { case JS_WaitMount: if (pool_mem) { FreePoolMemory(emsg); @@ -1089,12 +1089,12 @@ static void ListRunningJobs(UaContext* ua) */ Mmsg(emsg, _("is waiting for Client to connect (Client Initiated " "Connection)")); - } else if (!jcr->impl_->res.client || !jcr->impl_->res.write_storage) { + } else if (!jcr->impl->res.client || !jcr->impl->res.write_storage) { Mmsg(emsg, _("is waiting for Client to connect to Storage daemon")); } else { Mmsg(emsg, _("is waiting for Client %s to connect to Storage %s"), - jcr->impl_->res.client->resource_name_, - jcr->impl_->res.write_storage->resource_name_); + jcr->impl->res.client->resource_name_, + jcr->impl->res.write_storage->resource_name_); } msg = emsg; break; @@ -1590,7 +1590,7 @@ static void StatusSlots(UaContext* ua, StorageResource* store) slot_number_t max_slots; changer_vol_list_t* vol_list = NULL; - ua->jcr->impl_->res.write_storage = store; + ua->jcr->impl->res.write_storage = store; /* * Slot | Volume | Status | MediaType | Pool diff --git a/core/src/dird/ua_update.cc b/core/src/dird/ua_update.cc index 9e88a052206..1ac8a36cb6e 100644 --- a/core/src/dird/ua_update.cc +++ b/core/src/dird/ua_update.cc @@ -1041,7 +1041,7 @@ static void UpdateSlots(UaContext* ua) have_enabled = false; } - max_slots = GetNumSlots(ua, ua->jcr->impl_->res.write_storage); + max_slots = GetNumSlots(ua, ua->jcr->impl->res.write_storage); Dmsg1(100, "max_slots=%d\n", max_slots); if (max_slots <= 0) { ua->WarningMsg(_("No slots in changer to scan.\n")); diff --git a/core/src/dird/vbackup.cc b/core/src/dird/vbackup.cc index 0e76cd72a2d..2d3cd62f3b2 100644 --- a/core/src/dird/vbackup.cc +++ b/core/src/dird/vbackup.cc @@ -76,9 +76,9 @@ bool DoNativeVbackupInit(JobControlRecord* jcr) if (!AllowDuplicateJob(jcr)) { return false; } - jcr->impl_->jr.PoolId = - GetOrCreatePoolRecord(jcr, jcr->impl_->res.pool->resource_name_); - if (jcr->impl_->jr.PoolId == 0) { + jcr->impl->jr.PoolId = + GetOrCreatePoolRecord(jcr, jcr->impl->res.pool->resource_name_); + if (jcr->impl->jr.PoolId == 0) { Dmsg1(dbglevel, "JobId=%d no PoolId\n", (int)jcr->JobId); Jmsg(jcr, M_FATAL, 0, _("Could not get or create a Pool record.\n")); return false; @@ -90,46 +90,46 @@ bool DoNativeVbackupInit(JobControlRecord* jcr) * pool will be changed to point to the write pool, * which comes from pool->NextPool. */ - jcr->impl_->res.rpool = jcr->impl_->res.pool; /* save read pool */ - PmStrcpy(jcr->impl_->res.rpool_source, jcr->impl_->res.pool_source); + jcr->impl->res.rpool = jcr->impl->res.pool; /* save read pool */ + PmStrcpy(jcr->impl->res.rpool_source, jcr->impl->res.pool_source); /* * If pool storage specified, use it for restore */ - CopyRstorage(jcr, jcr->impl_->res.pool->storage, _("Pool resource")); + CopyRstorage(jcr, jcr->impl->res.pool->storage, _("Pool resource")); Dmsg2(dbglevel, "Read pool=%s (From %s)\n", - jcr->impl_->res.rpool->resource_name_, jcr->impl_->res.rpool_source); + jcr->impl->res.rpool->resource_name_, jcr->impl->res.rpool_source); jcr->start_time = time(NULL); - jcr->impl_->jr.StartTime = jcr->start_time; - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { + jcr->impl->jr.StartTime = jcr->start_time; + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); } /* * See if there is a next pool override. */ - if (jcr->impl_->res.run_next_pool_override) { - PmStrcpy(jcr->impl_->res.npool_source, _("Run NextPool override")); - PmStrcpy(jcr->impl_->res.pool_source, _("Run NextPool override")); + if (jcr->impl->res.run_next_pool_override) { + PmStrcpy(jcr->impl->res.npool_source, _("Run NextPool override")); + PmStrcpy(jcr->impl->res.pool_source, _("Run NextPool override")); storage_source = _("Storage from Run NextPool override"); } else { /* * See if there is a next pool override in the Job definition. */ - if (jcr->impl_->res.job->next_pool) { - jcr->impl_->res.next_pool = jcr->impl_->res.job->next_pool; - PmStrcpy(jcr->impl_->res.npool_source, _("Job's NextPool resource")); - PmStrcpy(jcr->impl_->res.pool_source, _("Job's NextPool resource")); + if (jcr->impl->res.job->next_pool) { + jcr->impl->res.next_pool = jcr->impl->res.job->next_pool; + PmStrcpy(jcr->impl->res.npool_source, _("Job's NextPool resource")); + PmStrcpy(jcr->impl->res.pool_source, _("Job's NextPool resource")); storage_source = _("Storage from Job's NextPool resource"); } else { /* * Fall back to the pool's NextPool definition. */ - jcr->impl_->res.next_pool = jcr->impl_->res.pool->NextPool; - PmStrcpy(jcr->impl_->res.npool_source, _("Job Pool's NextPool resource")); - PmStrcpy(jcr->impl_->res.pool_source, _("Job Pool's NextPool resource")); + jcr->impl->res.next_pool = jcr->impl->res.pool->NextPool; + PmStrcpy(jcr->impl->res.npool_source, _("Job Pool's NextPool resource")); + PmStrcpy(jcr->impl->res.pool_source, _("Job Pool's NextPool resource")); storage_source = _("Storage from Pool's NextPool resource"); } } @@ -139,22 +139,22 @@ bool DoNativeVbackupInit(JobControlRecord* jcr) * record exists in the database. Note, in this case, we * will be migrating from pool to pool->NextPool. */ - if (jcr->impl_->res.next_pool) { - jcr->impl_->jr.PoolId = - GetOrCreatePoolRecord(jcr, jcr->impl_->res.next_pool->resource_name_); - if (jcr->impl_->jr.PoolId == 0) { return false; } + if (jcr->impl->res.next_pool) { + jcr->impl->jr.PoolId = + GetOrCreatePoolRecord(jcr, jcr->impl->res.next_pool->resource_name_); + if (jcr->impl->jr.PoolId == 0) { return false; } } - if (!SetMigrationWstorage(jcr, jcr->impl_->res.pool, - jcr->impl_->res.next_pool, storage_source)) { + if (!SetMigrationWstorage(jcr, jcr->impl->res.pool, + jcr->impl->res.next_pool, storage_source)) { return false; } - jcr->impl_->res.pool = jcr->impl_->res.next_pool; + jcr->impl->res.pool = jcr->impl->res.next_pool; Dmsg2(dbglevel, "Write pool=%s read rpool=%s\n", - jcr->impl_->res.pool->resource_name_, - jcr->impl_->res.rpool->resource_name_); + jcr->impl->res.pool->resource_name_, + jcr->impl->res.rpool->resource_name_); // CreateClones(jcr); @@ -176,22 +176,22 @@ bool DoNativeVbackup(JobControlRecord* jcr) char ed1[100]; int JobLevel_of_first_job; - if (!jcr->impl_->res.read_storage_list) { + if (!jcr->impl->res.read_storage_list) { Jmsg(jcr, M_FATAL, 0, _("No storage for reading given.\n")); return false; } - if (!jcr->impl_->res.write_storage_list) { + if (!jcr->impl->res.write_storage_list) { Jmsg(jcr, M_FATAL, 0, _("No storage for writing given.\n")); return false; } Dmsg2(100, "read_storage_list=%p write_storage_list=%p\n", - jcr->impl_->res.read_storage_list, jcr->impl_->res.write_storage_list); + jcr->impl->res.read_storage_list, jcr->impl->res.write_storage_list); Dmsg2(100, "Read store=%s, write store=%s\n", - ((StorageResource*)jcr->impl_->res.read_storage_list->first()) + ((StorageResource*)jcr->impl->res.read_storage_list->first()) ->resource_name_, - ((StorageResource*)jcr->impl_->res.write_storage_list->first()) + ((StorageResource*)jcr->impl->res.write_storage_list->first()) ->resource_name_); /* @@ -209,13 +209,13 @@ bool DoNativeVbackup(JobControlRecord* jcr) /* * See if we already got a list of jobids to use. */ - if (jcr->impl_->vf_jobids) { - Dmsg1(10, "jobids=%s\n", jcr->impl_->vf_jobids); - jobids = strdup(jcr->impl_->vf_jobids); + if (jcr->impl->vf_jobids) { + Dmsg1(10, "jobids=%s\n", jcr->impl->vf_jobids); + jobids = strdup(jcr->impl->vf_jobids); } else { db_list_ctx jobids_ctx; - jcr->db->AccurateGetJobids(jcr, &jcr->impl_->jr, &jobids_ctx); + jcr->db->AccurateGetJobids(jcr, &jcr->impl->jr, &jobids_ctx); Dmsg1(10, "consolidate candidates: %s.\n", jobids_ctx.list); if (jobids_ctx.count == 0) { @@ -233,8 +233,8 @@ bool DoNativeVbackup(JobControlRecord* jcr) */ p = strchr(jobids, ','); /* find oldest jobid */ if (p) { *p = '\0'; } - jcr->impl_->previous_jr = JobDbRecord{}; - jcr->impl_->previous_jr.JobId = str_to_int64(jobids); + jcr->impl->previous_jr = JobDbRecord{}; + jcr->impl->previous_jr.JobId = str_to_int64(jobids); Dmsg1(10, "Previous JobId=%s\n", jobids); /* @@ -242,15 +242,15 @@ bool DoNativeVbackup(JobControlRecord* jcr) */ if (p) { *p = ','; } - if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->previous_jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl->previous_jr)) { Jmsg(jcr, M_FATAL, 0, _("Error getting Job record for first Job: ERR=%s"), jcr->db->strerror()); goto bail_out; } - JobLevel_of_first_job = jcr->impl_->previous_jr.JobLevel; + JobLevel_of_first_job = jcr->impl->previous_jr.JobLevel; Dmsg2(10, "Level of first consolidated job %d: %s\n", - jcr->impl_->previous_jr.JobId, job_level_to_str(JobLevel_of_first_job)); + jcr->impl->previous_jr.JobId, job_level_to_str(JobLevel_of_first_job)); /* * Now we find the newest job that ran and store its info in @@ -265,11 +265,11 @@ bool DoNativeVbackup(JobControlRecord* jcr) p = jobids; } - jcr->impl_->previous_jr = JobDbRecord{}; - jcr->impl_->previous_jr.JobId = str_to_int64(p); + jcr->impl->previous_jr = JobDbRecord{}; + jcr->impl->previous_jr.JobId = str_to_int64(p); Dmsg1(10, "Previous JobId=%s\n", p); - if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->previous_jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl->previous_jr)) { Jmsg(jcr, M_FATAL, 0, _("Error getting Job record for previous Job: ERR=%s"), jcr->db->strerror()); @@ -299,8 +299,8 @@ bool DoNativeVbackup(JobControlRecord* jcr) /* * Now start a job with the Storage daemon */ - if (!StartStorageDaemonJob(jcr, jcr->impl_->res.read_storage_list, - jcr->impl_->res.write_storage_list, + if (!StartStorageDaemonJob(jcr, jcr->impl->res.read_storage_list, + jcr->impl->res.write_storage_list, /* send_bsr */ true)) { goto bail_out; } @@ -317,14 +317,14 @@ bool DoNativeVbackup(JobControlRecord* jcr) * is after the start of this run. */ jcr->start_time = time(NULL); - jcr->impl_->jr.StartTime = jcr->start_time; - jcr->impl_->jr.JobTDate = jcr->start_time; + jcr->impl->jr.StartTime = jcr->start_time; + jcr->impl->jr.JobTDate = jcr->start_time; jcr->setJobStatus(JS_Running); /* * Update job start record */ - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); goto bail_out; } @@ -353,7 +353,7 @@ bool DoNativeVbackup(JobControlRecord* jcr) * Note, the SD stores in jcr->JobFiles/ReadBytes/JobBytes/JobErrors */ WaitForStorageDaemonTermination(jcr); - jcr->setJobStatus(jcr->impl_->SDJobStatus); + jcr->setJobStatus(jcr->impl->SDJobStatus); jcr->db_batch->WriteBatchFileRecords( jcr); /* used by bulk batch file insert */ if (!jcr->is_JobStatus(JS_Terminated)) { goto bail_out; } @@ -363,8 +363,8 @@ bool DoNativeVbackup(JobControlRecord* jcr) /* * Remove the successfully consolidated jobids from the database */ - if (jcr->impl_->res.job->AlwaysIncremental && - jcr->impl_->res.job->AlwaysIncrementalJobRetention) { + if (jcr->impl->res.job->AlwaysIncremental && + jcr->impl->res.job->AlwaysIncrementalJobRetention) { UaContext* ua; ua = new_ua_context(jcr); PurgeJobsFromCatalog(ua, jobids); @@ -398,7 +398,7 @@ void NativeVbackupCleanup(JobControlRecord* jcr, int TermCode, int JobLevel) switch (jcr->JobStatus) { case JS_Terminated: case JS_Warnings: - jcr->impl_->jr.JobLevel = JobLevel; /* We want this to appear as what the + jcr->impl->jr.JobLevel = JobLevel; /* We want this to appear as what the first consolidated job was */ Jmsg(jcr, M_INFO, 0, _("Joblevel was set to joblevel of first consolidated job: %s\n"), @@ -408,11 +408,11 @@ void NativeVbackupCleanup(JobControlRecord* jcr, int TermCode, int JobLevel) break; } - jcr->JobFiles = jcr->impl_->SDJobFiles; - jcr->JobBytes = jcr->impl_->SDJobBytes; + jcr->JobFiles = jcr->impl->SDJobFiles; + jcr->JobBytes = jcr->impl->SDJobBytes; if (jcr->getJobStatus() == JS_Terminated && - (jcr->JobErrors || jcr->impl_->SDErrors)) { + (jcr->JobErrors || jcr->impl->SDErrors)) { TermCode = JS_Warnings; } @@ -424,22 +424,22 @@ void NativeVbackupCleanup(JobControlRecord* jcr, int TermCode, int JobLevel) Mmsg(query, "UPDATE Job SET StartTime='%s',EndTime='%s'," "JobTDate=%s WHERE JobId=%s", - jcr->impl_->previous_jr.cStartTime, jcr->impl_->previous_jr.cEndTime, - edit_uint64(jcr->impl_->previous_jr.JobTDate, ec1), + jcr->impl->previous_jr.cStartTime, jcr->impl->previous_jr.cEndTime, + edit_uint64(jcr->impl->previous_jr.JobTDate, ec1), edit_uint64(jcr->JobId, ec2)); jcr->db->SqlQuery(query.c_str()); /* * Get the fully updated job record */ - if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->jr)) { + if (!jcr->db->GetJobRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Job record for Job report: ERR=%s"), jcr->db->strerror()); jcr->setJobStatus(JS_ErrorTerminated); } - bstrncpy(cr.Name, jcr->impl_->res.client->resource_name_, sizeof(cr.Name)); + bstrncpy(cr.Name, jcr->impl->res.client->resource_name_, sizeof(cr.Name)); if (!jcr->db->GetClientRecord(jcr, &cr)) { Jmsg(jcr, M_WARNING, 0, _("Error getting Client record for Job report: ERR=%s"), @@ -461,8 +461,8 @@ void NativeVbackupCleanup(JobControlRecord* jcr, int TermCode, int JobLevel) msg_type = M_ERROR; /* Generate error message */ if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->impl_->SD_msg_chan_started) { - pthread_cancel(jcr->impl_->SD_msg_chan); + if (jcr->impl->SD_msg_chan_started) { + pthread_cancel(jcr->impl->SD_msg_chan); } } break; @@ -470,8 +470,8 @@ void NativeVbackupCleanup(JobControlRecord* jcr, int TermCode, int JobLevel) TermMsg = _("Backup Canceled"); if (jcr->store_bsock) { jcr->store_bsock->signal(BNET_TERMINATE); - if (jcr->impl_->SD_msg_chan_started) { - pthread_cancel(jcr->impl_->SD_msg_chan); + if (jcr->impl->SD_msg_chan_started) { + pthread_cancel(jcr->impl->SD_msg_chan); } } break; @@ -530,12 +530,12 @@ static bool CreateBootstrapFile(JobControlRecord* jcr, char* jobids) } AddVolumeInformationToBsr(ua, rx.bsr.get()); - jcr->impl_->ExpectedFiles = WriteBsrFile(ua, rx); + jcr->impl->ExpectedFiles = WriteBsrFile(ua, rx); if (debug_level >= 10) { - Dmsg1(000, "Found %d files to consolidate.\n", jcr->impl_->ExpectedFiles); + Dmsg1(000, "Found %d files to consolidate.\n", jcr->impl->ExpectedFiles); } FreeUaContext(ua); rx.bsr.reset(nullptr); - return jcr->impl_->ExpectedFiles != 0; + return jcr->impl->ExpectedFiles != 0; } } /* namespace directordaemon */ diff --git a/core/src/dird/verify.cc b/core/src/dird/verify.cc index be72942f702..cab68e46456 100644 --- a/core/src/dird/verify.cc +++ b/core/src/dird/verify.cc @@ -120,7 +120,7 @@ bool DoVerify(JobControlRecord* jcr) FreeWstorage(jcr); /* we don't write */ - new (&jcr->impl_->previous_jr) + new (&jcr->impl->previous_jr) JobDbRecord(); // placement new instead of memset /* @@ -140,11 +140,11 @@ bool DoVerify(JobControlRecord* jcr) case L_VERIFY_CATALOG: case L_VERIFY_VOLUME_TO_CATALOG: case L_VERIFY_DISK_TO_CATALOG: - jr = jcr->impl_->jr; - if (jcr->impl_->res.verify_job && + jr = jcr->impl->jr; + if (jcr->impl->res.verify_job && (JobLevel == L_VERIFY_VOLUME_TO_CATALOG || JobLevel == L_VERIFY_DISK_TO_CATALOG)) { - Name = jcr->impl_->res.verify_job->resource_name_; + Name = jcr->impl->res.verify_job->resource_name_; } else { Name = NULL; } @@ -153,8 +153,8 @@ bool DoVerify(JobControlRecord* jcr) /* * See if user supplied a jobid= as run argument or from menu */ - if (jcr->impl_->VerifyJobId) { - verify_jobid = jcr->impl_->VerifyJobId; + if (jcr->impl->VerifyJobId) { + verify_jobid = jcr->impl->VerifyJobId; Dmsg1(100, "Supplied jobid=%d\n", verify_jobid); } else { @@ -178,22 +178,22 @@ bool DoVerify(JobControlRecord* jcr) * Now get the job record for the previous backup that interests * us. We use the verify_jobid that we found above. */ - jcr->impl_->previous_jr.JobId = verify_jobid; - if (!jcr->db->GetJobRecord(jcr, &jcr->impl_->previous_jr)) { + jcr->impl->previous_jr.JobId = verify_jobid; + if (!jcr->db->GetJobRecord(jcr, &jcr->impl->previous_jr)) { Jmsg(jcr, M_FATAL, 0, _("Could not get job record for previous Job. ERR=%s"), jcr->db->strerror()); return false; } - if (!(jcr->impl_->previous_jr.JobStatus == JS_Terminated || - jcr->impl_->previous_jr.JobStatus == JS_Warnings)) { + if (!(jcr->impl->previous_jr.JobStatus == JS_Terminated || + jcr->impl->previous_jr.JobStatus == JS_Warnings)) { Jmsg(jcr, M_FATAL, 0, _("Last Job %d did not Terminate normally. JobStatus=%c\n"), - verify_jobid, jcr->impl_->previous_jr.JobStatus); + verify_jobid, jcr->impl->previous_jr.JobStatus); return false; } Jmsg(jcr, M_INFO, 0, _("Verifying against JobId=%d Job=%s\n"), - jcr->impl_->previous_jr.JobId, jcr->impl_->previous_jr.Job); + jcr->impl->previous_jr.JobId, jcr->impl->previous_jr.Job); } /* @@ -217,8 +217,8 @@ bool DoVerify(JobControlRecord* jcr) return true; /* get out */ } - if (jcr->impl_->res.verify_job) { - jcr->impl_->res.fileset = jcr->impl_->res.verify_job->fileset; + if (jcr->impl->res.verify_job) { + jcr->impl->res.fileset = jcr->impl->res.verify_job->fileset; } break; default: @@ -226,10 +226,10 @@ bool DoVerify(JobControlRecord* jcr) break; } - Dmsg2(100, "ClientId=%u JobLevel=%c\n", jcr->impl_->previous_jr.ClientId, + Dmsg2(100, "ClientId=%u JobLevel=%c\n", jcr->impl->previous_jr.ClientId, JobLevel); - if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl_->jr)) { + if (!jcr->db->UpdateJobStartRecord(jcr, &jcr->impl->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", jcr->db->strerror()); return false; } @@ -254,12 +254,12 @@ bool DoVerify(JobControlRecord* jcr) /* * Now start a job with the Storage daemon */ - if (!StartStorageDaemonJob(jcr, jcr->impl_->res.read_storage_list, NULL, + if (!StartStorageDaemonJob(jcr, jcr->impl->res.read_storage_list, NULL, /* send_bsr */ true)) { return false; } - jcr->passive_client = jcr->impl_->res.client->passive; + jcr->passive_client = jcr->impl->res.client->passive; if (!jcr->passive_client) { /* * Start the Job in the SD. @@ -286,11 +286,11 @@ bool DoVerify(JobControlRecord* jcr) /* * Check if the file daemon supports passive client mode. */ - if (jcr->passive_client && jcr->impl_->FDVersion < FD_VERSION_51) { + if (jcr->passive_client && jcr->impl->FDVersion < FD_VERSION_51) { Jmsg(jcr, M_FATAL, 0, _("Client \"%s\" doesn't support passive client mode. " "Please upgrade your client or disable compat mode.\n"), - jcr->impl_->res.client->resource_name_); + jcr->impl->res.client->resource_name_); goto bail_out; } break; @@ -333,7 +333,7 @@ bool DoVerify(JobControlRecord* jcr) } if (!jcr->passive_client) { - StorageResource* store = jcr->impl_->res.read_storage; + StorageResource* store = jcr->impl->res.read_storage; /* * Send Storage daemon address to the File daemon @@ -341,7 +341,7 @@ bool DoVerify(JobControlRecord* jcr) if (store->SDDport == 0) { store->SDDport = store->SDport; } TlsPolicy tls_policy; - if (jcr->impl_->res.client->connection_successful_handshake_ != + if (jcr->impl->res.client->connection_successful_handshake_ != ClientConnectionHandshakeMode::kTlsFirst) { tls_policy = store->GetPolicy(); } else { @@ -357,10 +357,10 @@ bool DoVerify(JobControlRecord* jcr) goto bail_out; } } else { - ClientResource* client = jcr->impl_->res.client; + ClientResource* client = jcr->impl->res.client; TlsPolicy tls_policy; - if (jcr->impl_->res.client->connection_successful_handshake_ != + if (jcr->impl->res.client->connection_successful_handshake_ != ClientConnectionHandshakeMode::kTlsFirst) { tls_policy = client->GetPolicy(); } else { @@ -426,36 +426,36 @@ bool DoVerify(JobControlRecord* jcr) * Verify from catalog */ Dmsg0(10, "Verify level=catalog\n"); - jcr->impl_->sd_msg_thread_done = + jcr->impl->sd_msg_thread_done = true; /* no SD msg thread, so it is done */ - jcr->impl_->SDJobStatus = JS_Terminated; - GetAttributesAndCompareToCatalog(jcr, jcr->impl_->previous_jr.JobId); + jcr->impl->SDJobStatus = JS_Terminated; + GetAttributesAndCompareToCatalog(jcr, jcr->impl->previous_jr.JobId); break; case L_VERIFY_VOLUME_TO_CATALOG: /* * Verify Volume to catalog entries */ Dmsg0(10, "Verify level=volume\n"); - GetAttributesAndCompareToCatalog(jcr, jcr->impl_->previous_jr.JobId); + GetAttributesAndCompareToCatalog(jcr, jcr->impl->previous_jr.JobId); break; case L_VERIFY_DISK_TO_CATALOG: /* * Verify Disk attributes to catalog */ Dmsg0(10, "Verify level=disk_to_catalog\n"); - jcr->impl_->sd_msg_thread_done = + jcr->impl->sd_msg_thread_done = true; /* no SD msg thread, so it is done */ - jcr->impl_->SDJobStatus = JS_Terminated; - GetAttributesAndCompareToCatalog(jcr, jcr->impl_->previous_jr.JobId); + jcr->impl->SDJobStatus = JS_Terminated; + GetAttributesAndCompareToCatalog(jcr, jcr->impl->previous_jr.JobId); break; case L_VERIFY_INIT: /* * Build catalog */ Dmsg0(10, "Verify level=init\n"); - jcr->impl_->sd_msg_thread_done = + jcr->impl->sd_msg_thread_done = true; /* no SD msg thread, so it is done */ - jcr->impl_->SDJobStatus = JS_Terminated; + jcr->impl->SDJobStatus = JS_Terminated; GetAttributesAndPutInCatalog(jcr); jcr->db->EndTransaction(jcr); /* Terminate any open transaction */ jcr->db_batch->WriteBatchFileRecords(jcr); @@ -497,9 +497,9 @@ void VerifyCleanup(JobControlRecord* jcr, int TermCode) JobLevel = jcr->getJobLevel(); Dmsg3(900, "JobLevel=%c Expected=%u JobFiles=%u\n", JobLevel, - jcr->impl_->ExpectedFiles, jcr->JobFiles); + jcr->impl->ExpectedFiles, jcr->JobFiles); if (JobLevel == L_VERIFY_VOLUME_TO_CATALOG && - jcr->impl_->ExpectedFiles != jcr->JobFiles) { + jcr->impl->ExpectedFiles != jcr->JobFiles) { TermCode = JS_ErrorTerminated; } @@ -507,9 +507,9 @@ void VerifyCleanup(JobControlRecord* jcr, int TermCode) if (JobCanceled(jcr)) { CancelStorageDaemonJob(jcr); } - if (jcr->impl_->unlink_bsr && jcr->RestoreBootstrap) { + if (jcr->impl->unlink_bsr && jcr->RestoreBootstrap) { SecureErase(jcr, jcr->RestoreBootstrap); - jcr->impl_->unlink_bsr = false; + jcr->impl->unlink_bsr = false; } msg_type = M_INFO; /* By default INFO message */ @@ -537,18 +537,18 @@ void VerifyCleanup(JobControlRecord* jcr, int TermCode) _("Inappropriate term code: %d %c\n"), TermCode, TermCode); break; } - bstrftimes(sdt, sizeof(sdt), jcr->impl_->jr.StartTime); - bstrftimes(edt, sizeof(edt), jcr->impl_->jr.EndTime); - if (jcr->impl_->res.verify_job) { - Name = jcr->impl_->res.verify_job->resource_name_; + bstrftimes(sdt, sizeof(sdt), jcr->impl->jr.StartTime); + bstrftimes(edt, sizeof(edt), jcr->impl->jr.EndTime); + if (jcr->impl->res.verify_job) { + Name = jcr->impl->res.verify_job->resource_name_; } else { Name = ""; } - JobstatusToAscii(jcr->impl_->FDJobStatus, fd_term_msg, sizeof(fd_term_msg)); + JobstatusToAscii(jcr->impl->FDJobStatus, fd_term_msg, sizeof(fd_term_msg)); switch (JobLevel) { case L_VERIFY_VOLUME_TO_CATALOG: - JobstatusToAscii(jcr->impl_->SDJobStatus, sd_term_msg, + JobstatusToAscii(jcr->impl->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); Jmsg(jcr, msg_type, 0, _("%s %s %s (%s):\n" @@ -570,11 +570,11 @@ void VerifyCleanup(JobControlRecord* jcr, int TermCode) " Bareos binary info: %s\n" " Termination: %s\n\n"), BAREOS, my_name, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER, - jcr->impl_->jr.JobId, jcr->impl_->jr.Job, - jcr->impl_->res.fileset->resource_name_, JobLevelToString(JobLevel), - jcr->impl_->res.client->resource_name_, - jcr->impl_->previous_jr.JobId, Name, sdt, edt, - edit_uint64_with_commas(jcr->impl_->ExpectedFiles, ec1), + jcr->impl->jr.JobId, jcr->impl->jr.Job, + jcr->impl->res.fileset->resource_name_, JobLevelToString(JobLevel), + jcr->impl->res.client->resource_name_, + jcr->impl->previous_jr.JobId, Name, sdt, edt, + edit_uint64_with_commas(jcr->impl->ExpectedFiles, ec1), edit_uint64_with_commas(jcr->JobFiles, ec2), jcr->JobErrors, fd_term_msg, sd_term_msg, BAREOS_JOBLOG_MESSAGE, TermMsg); break; @@ -597,10 +597,10 @@ void VerifyCleanup(JobControlRecord* jcr, int TermCode) " Bareos binary info: %s\n" " Termination: %s\n\n"), BAREOS, my_name, VERSION, LSMDATE, HOST_OS, DISTNAME, DISTVER, - jcr->impl_->jr.JobId, jcr->impl_->jr.Job, - jcr->impl_->res.fileset->resource_name_, JobLevelToString(JobLevel), - jcr->impl_->res.client->resource_name_, - jcr->impl_->previous_jr.JobId, Name, sdt, edt, + jcr->impl->jr.JobId, jcr->impl->jr.Job, + jcr->impl->res.fileset->resource_name_, JobLevelToString(JobLevel), + jcr->impl->res.client->resource_name_, + jcr->impl->previous_jr.JobId, Name, sdt, edt, edit_uint64_with_commas(jcr->JobFiles, ec1), jcr->JobErrors, fd_term_msg, BAREOS_JOBLOG_MESSAGE, TermMsg); break; @@ -626,7 +626,7 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId) fd = jcr->file_bsock; fdbr.JobId = JobId; - jcr->impl_->FileIndex = 0; + jcr->impl->FileIndex = 0; Dmsg0(20, "dir: waiting to receive file attributes\n"); /* @@ -646,8 +646,8 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId) if (JobCanceled(jcr)) { goto bail_out; } fname = CheckPoolMemorySize(fname, fd->message_length); - jcr->impl_->fname = - CheckPoolMemorySize(jcr->impl_->fname, fd->message_length); + jcr->impl->fname = + CheckPoolMemorySize(jcr->impl->fname, fd->message_length); Dmsg1(200, "Atts+Digest=%s\n", fd->msg); if ((len = sscanf(fd->msg, "%ld %d %100s", &file_index, &stream, fname)) != 3) { @@ -683,16 +683,16 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId) int32_t LinkFIf, LinkFIc; Dmsg2(400, "file_index=%d attr=%s\n", file_index, attr); jcr->JobFiles++; - jcr->impl_->FileIndex = file_index; /* remember attribute file_index */ - jcr->impl_->previous_jr.FileIndex = file_index; + jcr->impl->FileIndex = file_index; /* remember attribute file_index */ + jcr->impl->previous_jr.FileIndex = file_index; DecodeStat(attr, &statf, sizeof(statf), &LinkFIf); /* decode file stat packet */ do_Digest = CRYPTO_DIGEST_NONE; - jcr->impl_->fn_printed = false; - PmStrcpy(jcr->impl_->fname, + jcr->impl->fn_printed = false; + PmStrcpy(jcr->impl->fname, fname); /* move filename into JobControlRecord */ - Dmsg2(040, "dirdimpl_->fname); + Dmsg2(040, "dirdimpl->fname); Dmsg1(020, "dirddb->GetFileAttributesRecord( - jcr, jcr->impl_->fname, &jcr->impl_->previous_jr, &fdbr)) { - Jmsg(jcr, M_INFO, 0, _("New file: %s\n"), jcr->impl_->fname); - Dmsg1(020, _("File not in catalog: %s\n"), jcr->impl_->fname); + jcr, jcr->impl->fname, &jcr->impl->previous_jr, &fdbr)) { + Jmsg(jcr, M_INFO, 0, _("New file: %s\n"), jcr->impl->fname); + Dmsg1(020, _("File not in catalog: %s\n"), jcr->impl->fname); jcr->setJobStatus(JS_Differences); continue; } else { @@ -713,7 +713,7 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId) jcr->db->MarkFileRecord(jcr, fdbr.FileId, jcr->JobId); } - Dmsg3(400, "Found %s in catalog. inx=%d Opts=%s\n", jcr->impl_->fname, + Dmsg3(400, "Found %s in catalog. inx=%d Opts=%s\n", jcr->impl->fname, file_index, Opts_Digest.c_str()); DecodeStat(fdbr.LStat, &statc, sizeof(statc), &LinkFIc); /* decode catalog stat */ @@ -812,7 +812,7 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId) } break; case '5': /* compare MD5 */ - Dmsg1(500, "set Do_MD5 for %s\n", jcr->impl_->fname); + Dmsg1(500, "set Do_MD5 for %s\n", jcr->impl->fname); do_Digest = CRYPTO_DIGEST_MD5; break; case '1': /* compare SHA1 */ @@ -827,7 +827,7 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId) break; case STREAM_RESTORE_OBJECT: - Dmsg1(400, "RESTORE_OBJECT %s\n", jcr->impl_->fname); + Dmsg1(400, "RESTORE_OBJECT %s\n", jcr->impl->fname); break; default: @@ -842,10 +842,10 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId) * When ever we get a digest it MUST have been * preceded by an attributes record, which sets attr_file_index */ - if (jcr->impl_->FileIndex != (uint32_t)file_index) { + if (jcr->impl->FileIndex != (uint32_t)file_index) { Jmsg2(jcr, M_FATAL, 0, _("MD5/SHA1 index %d not same as attributes %d\n"), - file_index, jcr->impl_->FileIndex); + file_index, jcr->impl->FileIndex); goto bail_out; } if (do_Digest != CRYPTO_DIGEST_NONE) { @@ -876,7 +876,7 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId) /* Now find all the files that are missing -- i.e. all files in * the database where the MarkId != current JobId */ - jcr->impl_->fn_printed = false; + jcr->impl->fn_printed = false; Mmsg(buf, "SELECT Path.Path,File.Name FROM File,Path " "WHERE File.JobId=%d AND File.FileIndex > 0 " @@ -884,7 +884,7 @@ void GetAttributesAndCompareToCatalog(JobControlRecord* jcr, JobId_t JobId) JobId, jcr->JobId); /* MissingHandler is called for each file found */ jcr->db->SqlQuery(buf.c_str(), MissingHandler, (void*)jcr); - if (jcr->impl_->fn_printed) { jcr->setJobStatus(JS_Differences); } + if (jcr->impl->fn_printed) { jcr->setJobStatus(JS_Differences); } bail_out: FreePoolMemory(fname); @@ -901,12 +901,12 @@ static int MissingHandler(void* ctx, int num_fields, char** row) JobControlRecord* jcr = (JobControlRecord*)ctx; if (JobCanceled(jcr)) { return 1; } - if (!jcr->impl_->fn_printed) { + if (!jcr->impl->fn_printed) { Qmsg(jcr, M_WARNING, 0, _("The following files are in the Catalog but not on %s:\n"), jcr->getJobLevel() == L_VERIFY_VOLUME_TO_CATALOG ? "the Volume(s)" : "disk"); - jcr->impl_->fn_printed = true; + jcr->impl->fn_printed = true; } Qmsg(jcr, M_INFO, 0, " %s%s\n", row[0] ? row[0] : "", row[1] ? row[1] : ""); @@ -918,9 +918,9 @@ static int MissingHandler(void* ctx, int num_fields, char** row) */ static void PrtFname(JobControlRecord* jcr) { - if (!jcr->impl_->fn_printed) { - Jmsg(jcr, M_INFO, 0, _("File: %s\n"), jcr->impl_->fname); - jcr->impl_->fn_printed = true; + if (!jcr->impl->fn_printed) { + Jmsg(jcr, M_INFO, 0, _("File: %s\n"), jcr->impl->fname); + jcr->impl->fn_printed = true; } } } /* namespace directordaemon */ diff --git a/core/src/filed/accurate.cc b/core/src/filed/accurate.cc index e31c5fc42cb..42dba3383af 100644 --- a/core/src/filed/accurate.cc +++ b/core/src/filed/accurate.cc @@ -39,11 +39,11 @@ bool AccurateMarkFileAsSeen(JobControlRecord* jcr, char* fname) { accurate_payload* temp; - if (!jcr->accurate || !jcr->impl_->file_list) { return false; } + if (!jcr->accurate || !jcr->impl->file_list) { return false; } - temp = jcr->impl_->file_list->lookup_payload(fname); + temp = jcr->impl->file_list->lookup_payload(fname); if (temp) { - jcr->impl_->file_list->MarkFileAsSeen(temp); + jcr->impl->file_list->MarkFileAsSeen(temp); Dmsg1(debuglevel, "marked <%s> as seen\n", fname); } else { Dmsg1(debuglevel, "<%s> not found to be marked as seen\n", fname); @@ -56,11 +56,11 @@ bool accurate_unMarkFileAsSeen(JobControlRecord* jcr, char* fname) { accurate_payload* temp; - if (!jcr->accurate || !jcr->impl_->file_list) { return false; } + if (!jcr->accurate || !jcr->impl->file_list) { return false; } - temp = jcr->impl_->file_list->lookup_payload(fname); + temp = jcr->impl->file_list->lookup_payload(fname); if (temp) { - jcr->impl_->file_list->UnmarkFileAsSeen(temp); + jcr->impl->file_list->UnmarkFileAsSeen(temp); Dmsg1(debuglevel, "unmarked <%s> as seen\n", fname); } else { Dmsg1(debuglevel, "<%s> not found to be unmarked as seen\n", fname); @@ -71,17 +71,17 @@ bool accurate_unMarkFileAsSeen(JobControlRecord* jcr, char* fname) bool AccurateMarkAllFilesAsSeen(JobControlRecord* jcr) { - if (!jcr->accurate || !jcr->impl_->file_list) { return false; } + if (!jcr->accurate || !jcr->impl->file_list) { return false; } - jcr->impl_->file_list->MarkAllFilesAsSeen(); + jcr->impl->file_list->MarkAllFilesAsSeen(); return true; } bool accurate_unMarkAllFilesAsSeen(JobControlRecord* jcr) { - if (!jcr->accurate || !jcr->impl_->file_list) { return false; } + if (!jcr->accurate || !jcr->impl->file_list) { return false; } - jcr->impl_->file_list->UnmarkAllFilesAsSeen(); + jcr->impl->file_list->UnmarkAllFilesAsSeen(); return true; } @@ -91,7 +91,7 @@ static inline bool AccurateLookup(JobControlRecord* jcr, { bool found = false; - *payload = jcr->impl_->file_list->lookup_payload(fname); + *payload = jcr->impl->file_list->lookup_payload(fname); if (*payload) { found = true; Dmsg1(debuglevel, "lookup <%s> ok\n", fname); @@ -102,9 +102,9 @@ static inline bool AccurateLookup(JobControlRecord* jcr, void AccurateFree(JobControlRecord* jcr) { - if (jcr->impl_->file_list) { - delete jcr->impl_->file_list; - jcr->impl_->file_list = NULL; + if (jcr->impl->file_list) { + delete jcr->impl->file_list; + jcr->impl->file_list = NULL; } } @@ -120,19 +120,19 @@ bool AccurateFinish(JobControlRecord* jcr) return retval; } - if (jcr->accurate && jcr->impl_->file_list) { + if (jcr->accurate && jcr->impl->file_list) { if (jcr->is_JobLevel(L_FULL)) { if (!jcr->rerunning) { - retval = jcr->impl_->file_list->SendBaseFileList(); + retval = jcr->impl->file_list->SendBaseFileList(); } } else { - retval = jcr->impl_->file_list->SendDeletedList(); + retval = jcr->impl->file_list->SendDeletedList(); } AccurateFree(jcr); if (jcr->is_JobLevel(L_FULL)) { Jmsg(jcr, M_INFO, 0, _("Space saved with Base jobs: %lld MB\n"), - jcr->impl_->base_size / (1024 * 1024)); + jcr->impl->base_size / (1024 * 1024)); } } @@ -162,7 +162,7 @@ bool AccurateCheckFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt) if (!jcr->accurate && !jcr->rerunning) { return true; } - if (!jcr->impl_->file_list) { return true; /** Not initialized properly */ } + if (!jcr->impl->file_list) { return true; /** Not initialized properly */ } /** * Apply path stripping for lookup in accurate data. @@ -324,11 +324,11 @@ bool AccurateCheckFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt) /** * Compute space saved with basefile. */ - jcr->impl_->base_size += ff_pkt->statp.st_size; - jcr->impl_->file_list->MarkFileAsSeen(payload); + jcr->impl->base_size += ff_pkt->statp.st_size; + jcr->impl->file_list->MarkFileAsSeen(payload); } } else { - jcr->impl_->file_list->MarkFileAsSeen(payload); + jcr->impl->file_list->MarkFileAsSeen(payload); } bail_out: @@ -353,18 +353,18 @@ bool AccurateCmd(JobControlRecord* jcr) #ifdef HAVE_LMDB if (me->always_use_lmdb || (me->lmdb_threshold > 0 && number_of_previous_files >= me->lmdb_threshold)) { - jcr->impl_->file_list = + jcr->impl->file_list = new BareosAccurateFilelistLmdb(jcr, number_of_previous_files); } else { - jcr->impl_->file_list = + jcr->impl->file_list = new BareosAccurateFilelistHtable(jcr, number_of_previous_files); } #else - jcr->impl_->file_list = + jcr->impl->file_list = new BareosAccurateFilelistHtable(jcr, number_of_previous_files); #endif - if (!jcr->impl_->file_list->init()) { return false; } + if (!jcr->impl->file_list->init()) { return false; } jcr->accurate = true; @@ -399,11 +399,11 @@ bool AccurateCmd(JobControlRecord* jcr) } } - jcr->impl_->file_list->AddFile(fname, fname_length, lstat, lstat_length, + jcr->impl->file_list->AddFile(fname, fname_length, lstat, lstat_length, chksum, chksum_length, delta_seq); } - if (!jcr->impl_->file_list->EndLoad()) { return false; } + if (!jcr->impl->file_list->EndLoad()) { return false; } return true; } diff --git a/core/src/filed/authenticate.cc b/core/src/filed/authenticate.cc index a887ac31064..0790849ec1d 100644 --- a/core/src/filed/authenticate.cc +++ b/core/src/filed/authenticate.cc @@ -149,7 +149,7 @@ bool AuthenticateDirector(JobControlRecord* jcr) return false; } - jcr->impl_->director = director; + jcr->impl->director = director; return dir->fsend("%s", (me->compatible) ? OK_hello_compat : OK_hello); } diff --git a/core/src/filed/backup.cc b/core/src/filed/backup.cc index 7542ceacd4c..09ef9b5108d 100644 --- a/core/src/filed/backup.cc +++ b/core/src/filed/backup.cc @@ -131,53 +131,53 @@ bool BlastDataToStorageDaemon(JobControlRecord* jcr, if (!CryptoSessionStart(jcr, cipher)) { return false; } - SetFindOptions((FindFilesPacket*)jcr->impl_->ff, jcr->impl_->incremental, - jcr->impl_->mtime); + SetFindOptions((FindFilesPacket*)jcr->impl->ff, jcr->impl->incremental, + jcr->impl->mtime); /** * In accurate mode, we overload the find_one check function */ if (jcr->accurate) { - SetFindChangedFunction((FindFilesPacket*)jcr->impl_->ff, AccurateCheckFile); + SetFindChangedFunction((FindFilesPacket*)jcr->impl->ff, AccurateCheckFile); } StartHeartbeatMonitor(jcr); if (have_acl) { - jcr->impl_->acl_data = (acl_data_t*)malloc(sizeof(acl_data_t)); - memset(jcr->impl_->acl_data, 0, sizeof(acl_data_t)); - jcr->impl_->acl_data->u.build = + jcr->impl->acl_data = (acl_data_t*)malloc(sizeof(acl_data_t)); + memset(jcr->impl->acl_data, 0, sizeof(acl_data_t)); + jcr->impl->acl_data->u.build = (acl_build_data_t*)malloc(sizeof(acl_build_data_t)); - memset(jcr->impl_->acl_data->u.build, 0, sizeof(acl_build_data_t)); - jcr->impl_->acl_data->u.build->content = GetPoolMemory(PM_MESSAGE); + memset(jcr->impl->acl_data->u.build, 0, sizeof(acl_build_data_t)); + jcr->impl->acl_data->u.build->content = GetPoolMemory(PM_MESSAGE); } if (have_xattr) { - jcr->impl_->xattr_data = (xattr_data_t*)malloc(sizeof(xattr_data_t)); - memset(jcr->impl_->xattr_data, 0, sizeof(xattr_data_t)); - jcr->impl_->xattr_data->u.build = + jcr->impl->xattr_data = (xattr_data_t*)malloc(sizeof(xattr_data_t)); + memset(jcr->impl->xattr_data, 0, sizeof(xattr_data_t)); + jcr->impl->xattr_data->u.build = (xattr_build_data_t*)malloc(sizeof(xattr_build_data_t)); - memset(jcr->impl_->xattr_data->u.build, 0, sizeof(xattr_build_data_t)); - jcr->impl_->xattr_data->u.build->content = GetPoolMemory(PM_MESSAGE); + memset(jcr->impl->xattr_data->u.build, 0, sizeof(xattr_build_data_t)); + jcr->impl->xattr_data->u.build->content = GetPoolMemory(PM_MESSAGE); } /** * Subroutine SaveFile() is called for each file */ - if (!FindFiles(jcr, (FindFilesPacket*)jcr->impl_->ff, SaveFile, PluginSave)) { + if (!FindFiles(jcr, (FindFilesPacket*)jcr->impl->ff, SaveFile, PluginSave)) { ok = false; /* error */ jcr->setJobStatus(JS_ErrorTerminated); } - if (have_acl && jcr->impl_->acl_data->u.build->nr_errors > 0) { + if (have_acl && jcr->impl->acl_data->u.build->nr_errors > 0) { Jmsg(jcr, M_WARNING, 0, _("Encountered %ld acl errors while doing backup\n"), - jcr->impl_->acl_data->u.build->nr_errors); + jcr->impl->acl_data->u.build->nr_errors); } - if (have_xattr && jcr->impl_->xattr_data->u.build->nr_errors > 0) { + if (have_xattr && jcr->impl->xattr_data->u.build->nr_errors > 0) { Jmsg(jcr, M_WARNING, 0, _("Encountered %ld xattr errors while doing backup\n"), - jcr->impl_->xattr_data->u.build->nr_errors); + jcr->impl->xattr_data->u.build->nr_errors); } CloseVssBackupSession(jcr); @@ -188,23 +188,23 @@ bool BlastDataToStorageDaemon(JobControlRecord* jcr, sd->signal(BNET_EOD); /* end of sending data */ - if (have_acl && jcr->impl_->acl_data) { - FreePoolMemory(jcr->impl_->acl_data->u.build->content); - free(jcr->impl_->acl_data->u.build); - free(jcr->impl_->acl_data); - jcr->impl_->acl_data = NULL; + if (have_acl && jcr->impl->acl_data) { + FreePoolMemory(jcr->impl->acl_data->u.build->content); + free(jcr->impl->acl_data->u.build); + free(jcr->impl->acl_data); + jcr->impl->acl_data = NULL; } - if (have_xattr && jcr->impl_->xattr_data) { - FreePoolMemory(jcr->impl_->xattr_data->u.build->content); - free(jcr->impl_->xattr_data->u.build); - free(jcr->impl_->xattr_data); - jcr->impl_->xattr_data = NULL; + if (have_xattr && jcr->impl->xattr_data) { + FreePoolMemory(jcr->impl->xattr_data->u.build->content); + free(jcr->impl->xattr_data->u.build); + free(jcr->impl->xattr_data); + jcr->impl->xattr_data = NULL; } - if (jcr->impl_->big_buf) { - free(jcr->impl_->big_buf); - jcr->impl_->big_buf = NULL; + if (jcr->impl->big_buf) { + free(jcr->impl->big_buf); + jcr->impl->big_buf = NULL; } CleanupCompression(jcr); @@ -325,7 +325,7 @@ static inline bool SetupEncryptionDigests(b_save_ctx& bsctx) /* TODO landonf: We should really only calculate the digest once, for * both verification and signing. */ - if (bsctx.jcr->impl_->crypto.pki_sign) { + if (bsctx.jcr->impl->crypto.pki_sign) { bsctx.signing_digest = crypto_digest_new(bsctx.jcr, signing_algorithm); /* @@ -343,7 +343,7 @@ static inline bool SetupEncryptionDigests(b_save_ctx& bsctx) /* * Enable encryption */ - if (bsctx.jcr->impl_->crypto.pki_encrypt) { + if (bsctx.jcr->impl->crypto.pki_encrypt) { SetBit(FO_ENCRYPT, bsctx.ff_pkt->flags); } retval = true; @@ -369,7 +369,7 @@ static inline bool TerminateSigningDigest(b_save_ctx& bsctx) } if (!CryptoSignAddSigner(signature, bsctx.signing_digest, - bsctx.jcr->impl_->crypto.pki_keypair)) { + bsctx.jcr->impl->crypto.pki_keypair)) { Jmsg(bsctx.jcr, M_FATAL, 0, _("An error occurred while signing the stream.\n")); goto bail_out; @@ -463,13 +463,13 @@ static inline bool DoBackupAcl(JobControlRecord* jcr, FindFilesPacket* ff_pkt) { bacl_exit_code retval; - jcr->impl_->acl_data->filetype = ff_pkt->type; - jcr->impl_->acl_data->last_fname = jcr->impl_->last_fname; + jcr->impl->acl_data->filetype = ff_pkt->type; + jcr->impl->acl_data->last_fname = jcr->impl->last_fname; if (jcr->IsPlugin()) { - retval = PluginBuildAclStreams(jcr, jcr->impl_->acl_data, ff_pkt); + retval = PluginBuildAclStreams(jcr, jcr->impl->acl_data, ff_pkt); } else { - retval = BuildAclStreams(jcr, jcr->impl_->acl_data, ff_pkt); + retval = BuildAclStreams(jcr, jcr->impl->acl_data, ff_pkt); } switch (retval) { @@ -477,7 +477,7 @@ static inline bool DoBackupAcl(JobControlRecord* jcr, FindFilesPacket* ff_pkt) return false; case bacl_exit_error: Jmsg(jcr, M_ERROR, 0, "%s", jcr->errmsg); - jcr->impl_->acl_data->u.build->nr_errors++; + jcr->impl->acl_data->u.build->nr_errors++; break; case bacl_exit_ok: break; @@ -490,12 +490,12 @@ static inline bool DoBackupXattr(JobControlRecord* jcr, FindFilesPacket* ff_pkt) { BxattrExitCode retval; - jcr->impl_->xattr_data->last_fname = jcr->impl_->last_fname; + jcr->impl->xattr_data->last_fname = jcr->impl->last_fname; if (jcr->IsPlugin()) { - retval = PluginBuildXattrStreams(jcr, jcr->impl_->xattr_data, ff_pkt); + retval = PluginBuildXattrStreams(jcr, jcr->impl->xattr_data, ff_pkt); } else { - retval = BuildXattrStreams(jcr, jcr->impl_->xattr_data, ff_pkt); + retval = BuildXattrStreams(jcr, jcr->impl->xattr_data, ff_pkt); } switch (retval) { @@ -506,7 +506,7 @@ static inline bool DoBackupXattr(JobControlRecord* jcr, FindFilesPacket* ff_pkt) break; case BxattrExitCode::kError: Jmsg(jcr, M_ERROR, 0, "%s", jcr->errmsg); - jcr->impl_->xattr_data->u.build->nr_errors++; + jcr->impl->xattr_data->u.build->nr_errors++; break; case BxattrExitCode::kSuccess: break; @@ -539,7 +539,7 @@ int SaveFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool top_level) if (jcr->IsCanceled() || jcr->IsIncomplete()) { return 0; } - jcr->impl_->num_files_examined++; /* bump total file count */ + jcr->impl->num_files_examined++; /* bump total file count */ switch (ff_pkt->type) { case FT_LNKSAVED: /* Hard linked, file already saved */ @@ -564,7 +564,7 @@ int SaveFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool top_level) Dmsg1(100, "FT_PLUGIN_CONFIG saving: %s\n", ff_pkt->fname); break; case FT_DIRBEGIN: - jcr->impl_->num_files_examined--; /* correct file count */ + jcr->impl->num_files_examined--; /* correct file count */ return 1; /* not used */ case FT_NORECURSE: Jmsg(jcr, M_INFO, 1, @@ -700,7 +700,7 @@ int SaveFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool top_level) Dmsg2(10, "Option plugin %s will be used to backup %s\n", ff_pkt->plugin, ff_pkt->fname); jcr->opt_plugin = true; - jcr->impl_->plugin_sp = &sp; + jcr->impl->plugin_sp = &sp; PluginUpdateFfPkt(ff_pkt, &sp); do_plugin_set = true; break; @@ -744,7 +744,7 @@ int SaveFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool top_level) /* * Set up the encryption context and send the session data to the SD */ - if (has_file_data && jcr->impl_->crypto.pki_encrypt) { + if (has_file_data && jcr->impl->crypto.pki_encrypt) { if (!CryptoSessionSend(jcr, sd)) { goto bail_out; } } @@ -885,7 +885,7 @@ int SaveFile(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool top_level) SendPluginName(jcr, sd, false); /* signal end of plugin data */ } if (ff_pkt->opt_plugin) { - jcr->impl_->plugin_sp = NULL; /* sp is local to this function */ + jcr->impl->plugin_sp = NULL; /* sp is local to this function */ jcr->opt_plugin = false; } if (bsctx.digest) { CryptoDigestFree(bsctx.digest); } @@ -1220,7 +1220,7 @@ static int send_data(JobControlRecord* jcr, * For encryption, we must call finalize to push out any buffered data. */ if (!CryptoCipherFinalize(bctx.cipher_ctx, - (uint8_t*)jcr->impl_->crypto.crypto_buf, + (uint8_t*)jcr->impl->crypto.crypto_buf, &bctx.encrypted_len)) { /* * Padding failed. Shouldn't happen. @@ -1234,7 +1234,7 @@ static int send_data(JobControlRecord* jcr, */ if (bctx.encrypted_len > 0) { sd->message_length = bctx.encrypted_len; /* set encrypted length */ - sd->msg = jcr->impl_->crypto.crypto_buf; /* set correct write buffer */ + sd->msg = jcr->impl->crypto.crypto_buf; /* set correct write buffer */ if (!sd->send()) { if (!jcr->IsJobCanceled()) { Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"), @@ -1316,7 +1316,7 @@ bool EncodeAndSendAttributes(JobControlRecord* jcr, jcr->lock(); jcr->JobFiles++; /* increment number of files sent */ ff_pkt->FileIndex = jcr->JobFiles; /* return FileIndex */ - PmStrcpy(jcr->impl_->last_fname, ff_pkt->fname); + PmStrcpy(jcr->impl->last_fname, ff_pkt->fname); jcr->unlock(); /* @@ -1570,33 +1570,33 @@ static void CloseVssBackupSession(JobControlRecord* jcr) * STOP VSS ON WIN32 * Tell vss to close the backup session */ - if (jcr->impl_->pVSSClient) { + if (jcr->impl->pVSSClient) { /* * We are about to call the BackupComplete VSS method so let all plugins * know that by raising the bEventVssBackupComplete event. */ GeneratePluginEvent(jcr, bEventVssBackupComplete); - if (jcr->impl_->pVSSClient->CloseBackup()) { + if (jcr->impl->pVSSClient->CloseBackup()) { /* * Inform user about writer states */ - for (size_t i = 0; i < jcr->impl_->pVSSClient->GetWriterCount(); i++) { + for (size_t i = 0; i < jcr->impl->pVSSClient->GetWriterCount(); i++) { int msg_type = M_INFO; - if (jcr->impl_->pVSSClient->GetWriterState(i) < 1) { + if (jcr->impl->pVSSClient->GetWriterState(i) < 1) { msg_type = M_WARNING; jcr->JobErrors++; } Jmsg(jcr, msg_type, 0, _("VSS Writer (BackupComplete): %s\n"), - jcr->impl_->pVSSClient->GetWriterInfo(i)); + jcr->impl->pVSSClient->GetWriterInfo(i)); } } /* * Generate Job global writer metadata */ - wchar_t* metadata = jcr->impl_->pVSSClient->GetMetadata(); + wchar_t* metadata = jcr->impl->pVSSClient->GetMetadata(); if (metadata) { - FindFilesPacket* ff_pkt = jcr->impl_->ff; + FindFilesPacket* ff_pkt = jcr->impl->ff; ff_pkt->fname = (char*)"*all*"; /* for all plugins */ ff_pkt->type = FT_RESTORE_FIRST; ff_pkt->LinkFI = 0; diff --git a/core/src/filed/compression.cc b/core/src/filed/compression.cc index a6e20391ad6..eb866ae7934 100644 --- a/core/src/filed/compression.cc +++ b/core/src/filed/compression.cc @@ -47,7 +47,7 @@ namespace filedaemon { */ bool AdjustCompressionBuffers(JobControlRecord* jcr) { - findFILESET* fileset = jcr->impl_->ff->fileset; + findFILESET* fileset = jcr->impl->ff->fileset; uint32_t compress_buf_size = 0; if (fileset) { diff --git a/core/src/filed/crypto.cc b/core/src/filed/crypto.cc index 36f38b4d078..c9168e17f17 100644 --- a/core/src/filed/crypto.cc +++ b/core/src/filed/crypto.cc @@ -62,15 +62,15 @@ bool CryptoSessionStart(JobControlRecord* jcr, crypto_cipher_t cipher) * structure. We use a single session key for each backup, so we'll encode * the session data only once. */ - if (jcr->impl_->crypto.pki_encrypt) { + if (jcr->impl->crypto.pki_encrypt) { uint32_t size = 0; /** * Create per-job session encryption context */ - jcr->impl_->crypto.pki_session = - crypto_session_new(cipher, jcr->impl_->crypto.pki_recipients); - if (!jcr->impl_->crypto.pki_session) { + jcr->impl->crypto.pki_session = + crypto_session_new(cipher, jcr->impl->crypto.pki_recipients); + if (!jcr->impl->crypto.pki_session) { Jmsg(jcr, M_FATAL, 0, _("Cannot create a new crypto session probably unsupported cipher " "configured.\n")); @@ -80,7 +80,7 @@ bool CryptoSessionStart(JobControlRecord* jcr, crypto_cipher_t cipher) /** * Get the session data size */ - if (!CryptoSessionEncode(jcr->impl_->crypto.pki_session, (uint8_t*)0, + if (!CryptoSessionEncode(jcr->impl->crypto.pki_session, (uint8_t*)0, &size)) { Jmsg(jcr, M_FATAL, 0, _("An error occurred while encrypting the stream.\n")); @@ -90,13 +90,13 @@ bool CryptoSessionStart(JobControlRecord* jcr, crypto_cipher_t cipher) /** * Allocate buffer */ - jcr->impl_->crypto.pki_session_encoded = GetMemory(size); + jcr->impl->crypto.pki_session_encoded = GetMemory(size); /** * Encode session data */ - if (!CryptoSessionEncode(jcr->impl_->crypto.pki_session, - (uint8_t*)jcr->impl_->crypto.pki_session_encoded, + if (!CryptoSessionEncode(jcr->impl->crypto.pki_session, + (uint8_t*)jcr->impl->crypto.pki_session_encoded, &size)) { Jmsg(jcr, M_FATAL, 0, _("An error occurred while encrypting the stream.\n")); @@ -106,12 +106,12 @@ bool CryptoSessionStart(JobControlRecord* jcr, crypto_cipher_t cipher) /** * ... and store the encoded size */ - jcr->impl_->crypto.pki_session_encoded_size = size; + jcr->impl->crypto.pki_session_encoded_size = size; /** * Allocate the encryption/decryption buffer */ - jcr->impl_->crypto.crypto_buf = GetMemory(CRYPTO_CIPHER_MAX_BLOCK_SIZE); + jcr->impl->crypto.crypto_buf = GetMemory(CRYPTO_CIPHER_MAX_BLOCK_SIZE); } return true; @@ -119,16 +119,16 @@ bool CryptoSessionStart(JobControlRecord* jcr, crypto_cipher_t cipher) void CryptoSessionEnd(JobControlRecord* jcr) { - if (jcr->impl_->crypto.crypto_buf) { - FreePoolMemory(jcr->impl_->crypto.crypto_buf); - jcr->impl_->crypto.crypto_buf = NULL; + if (jcr->impl->crypto.crypto_buf) { + FreePoolMemory(jcr->impl->crypto.crypto_buf); + jcr->impl->crypto.crypto_buf = NULL; } - if (jcr->impl_->crypto.pki_session) { - CryptoSessionFree(jcr->impl_->crypto.pki_session); + if (jcr->impl->crypto.pki_session) { + CryptoSessionFree(jcr->impl->crypto.pki_session); } - if (jcr->impl_->crypto.pki_session_encoded) { - FreePoolMemory(jcr->impl_->crypto.pki_session_encoded); - jcr->impl_->crypto.pki_session_encoded = NULL; + if (jcr->impl->crypto.pki_session_encoded) { + FreePoolMemory(jcr->impl->crypto.pki_session_encoded); + jcr->impl->crypto.pki_session_encoded = NULL; } } @@ -142,8 +142,8 @@ bool CryptoSessionSend(JobControlRecord* jcr, BareosSocket* sd) sd->fsend("%ld %d 0", jcr->JobFiles, STREAM_ENCRYPTED_SESSION_DATA); msgsave = sd->msg; - sd->msg = jcr->impl_->crypto.pki_session_encoded; - sd->message_length = jcr->impl_->crypto.pki_session_encoded_size; + sd->msg = jcr->impl->crypto.pki_session_encoded; + sd->message_length = jcr->impl->crypto.pki_session_encoded_size; jcr->JobBytes += sd->message_length; Dmsg1(100, "Send data len=%d\n", sd->message_length); @@ -171,7 +171,7 @@ bool VerifySignature(JobControlRecord* jcr, r_ctx& rctx) crypto_digest_t algorithm; SIGNATURE* sig = rctx.sig; - if (!jcr->impl_->crypto.pki_sign) { + if (!jcr->impl->crypto.pki_sign) { /* * no signature OK */ @@ -180,7 +180,7 @@ bool VerifySignature(JobControlRecord* jcr, r_ctx& rctx) if (!sig) { if (rctx.type == FT_REGE || rctx.type == FT_REG || rctx.type == FT_RAW) { Jmsg1(jcr, M_ERROR, 0, _("Missing cryptographic signature for %s\n"), - jcr->impl_->last_fname); + jcr->impl->last_fname); goto bail_out; } return true; @@ -189,8 +189,8 @@ bool VerifySignature(JobControlRecord* jcr, r_ctx& rctx) /* * Iterate through the trusted signers */ - foreach_alist (keypair, jcr->impl_->crypto.pki_signers) { - err = CryptoSignGetDigest(sig, jcr->impl_->crypto.pki_keypair, algorithm, + foreach_alist (keypair, jcr->impl->crypto.pki_signers) { + err = CryptoSignGetDigest(sig, jcr->impl->crypto.pki_keypair, algorithm, &digest); switch (err) { case CRYPTO_ERROR_NONE: @@ -202,22 +202,22 @@ bool VerifySignature(JobControlRecord* jcr, r_ctx& rctx) * computing by re-reading the file. */ if (algorithm != signing_algorithm) { - if (jcr->impl_->crypto.digest) { - CryptoDigestFree(jcr->impl_->crypto.digest); - jcr->impl_->crypto.digest = NULL; + if (jcr->impl->crypto.digest) { + CryptoDigestFree(jcr->impl->crypto.digest); + jcr->impl->crypto.digest = NULL; } } - if (jcr->impl_->crypto.digest) { + if (jcr->impl->crypto.digest) { /* * Use digest computed while writing the file to verify the signature */ if ((err = - CryptoSignVerify(sig, keypair, jcr->impl_->crypto.digest)) != + CryptoSignVerify(sig, keypair, jcr->impl->crypto.digest)) != CRYPTO_ERROR_NONE) { - Dmsg1(50, "Bad signature on %s\n", jcr->impl_->last_fname); + Dmsg1(50, "Bad signature on %s\n", jcr->impl->last_fname); Jmsg2(jcr, M_ERROR, 0, _("Signature validation failed for file %s: ERR=%s\n"), - jcr->impl_->last_fname, crypto_strerror(err)); + jcr->impl->last_fname, crypto_strerror(err)); goto bail_out; } } else { @@ -225,17 +225,17 @@ bool VerifySignature(JobControlRecord* jcr, r_ctx& rctx) * Signature found, digest allocated. Old method, * re-read the file and compute the digest */ - jcr->impl_->crypto.digest = digest; + jcr->impl->crypto.digest = digest; /* * Checksum the entire file * Make sure we don't modify JobBytes by saving and restoring it */ saved_bytes = jcr->JobBytes; - if (FindOneFile(jcr, jcr->impl_->ff, DoFileDigest, - jcr->impl_->last_fname, (dev_t)-1, 1) != 0) { + if (FindOneFile(jcr, jcr->impl->ff, DoFileDigest, + jcr->impl->last_fname, (dev_t)-1, 1) != 0) { Jmsg(jcr, M_ERROR, 0, _("Digest one file failed for file: %s\n"), - jcr->impl_->last_fname); + jcr->impl->last_fname); jcr->JobBytes = saved_bytes; goto bail_out; } @@ -246,19 +246,19 @@ bool VerifySignature(JobControlRecord* jcr, r_ctx& rctx) */ if ((err = CryptoSignVerify(sig, keypair, digest)) != CRYPTO_ERROR_NONE) { - Dmsg1(50, "Bad signature on %s\n", jcr->impl_->last_fname); + Dmsg1(50, "Bad signature on %s\n", jcr->impl->last_fname); Jmsg2(jcr, M_ERROR, 0, _("Signature validation failed for file %s: ERR=%s\n"), - jcr->impl_->last_fname, crypto_strerror(err)); + jcr->impl->last_fname, crypto_strerror(err)); goto bail_out; } - jcr->impl_->crypto.digest = NULL; + jcr->impl->crypto.digest = NULL; } /* * Valid signature */ - Dmsg1(50, "Signature good on %s\n", jcr->impl_->last_fname); + Dmsg1(50, "Signature good on %s\n", jcr->impl->last_fname); CryptoDigestFree(digest); return true; @@ -276,7 +276,7 @@ bool VerifySignature(JobControlRecord* jcr, r_ctx& rctx) * Something strange happened (that shouldn't happen!)... */ Qmsg2(jcr, M_ERROR, 0, _("Signature validation failed for %s: %s\n"), - jcr->impl_->last_fname, crypto_strerror(err)); + jcr->impl->last_fname, crypto_strerror(err)); goto bail_out; } } @@ -285,7 +285,7 @@ bool VerifySignature(JobControlRecord* jcr, r_ctx& rctx) * No signer */ Dmsg1(50, "Could not find a valid public key for signature on %s\n", - jcr->impl_->last_fname); + jcr->impl->last_fname); bail_out: if (digest) { CryptoDigestFree(digest); } @@ -325,7 +325,7 @@ bool FlushCipher(JobControlRecord* jcr, */ Jmsg3(jcr, M_ERROR, 0, _("Decryption error. buf_len=%d decrypt_len=%d on file %s\n"), - cipher_ctx->buf_len, decrypted_len, jcr->impl_->last_fname); + cipher_ctx->buf_len, decrypted_len, jcr->impl->last_fname); } Dmsg2(130, "Flush decrypt len=%d buf_len=%d\n", decrypted_len, @@ -356,7 +356,7 @@ bool FlushCipher(JobControlRecord* jcr, } if (BitIsSet(FO_COMPRESS, flags)) { - if (!DecompressData(jcr, jcr->impl_->last_fname, stream, &wbuf, &wsize, + if (!DecompressData(jcr, jcr->impl->last_fname, stream, &wbuf, &wsize, false)) { return false; } @@ -444,7 +444,7 @@ bool SetupEncryptionContext(b_ctx& bctx) * Allocate the cipher context */ if ((bctx.cipher_ctx = crypto_cipher_new( - bctx.jcr->impl_->crypto.pki_session, true, &cipher_block_size)) == + bctx.jcr->impl->crypto.pki_session, true, &cipher_block_size)) == NULL) { /* * Shouldn't happen! @@ -461,15 +461,15 @@ bool SetupEncryptionContext(b_ctx& bctx) * could be returned for the given read buffer size. * (Using the larger of either rsize or max_compress_len) */ - bctx.jcr->impl_->crypto.crypto_buf = - CheckPoolMemorySize(bctx.jcr->impl_->crypto.crypto_buf, + bctx.jcr->impl->crypto.crypto_buf = + CheckPoolMemorySize(bctx.jcr->impl->crypto.crypto_buf, (MAX(bctx.jcr->buf_size + (int)sizeof(uint32_t), (int32_t)bctx.max_compress_len) + cipher_block_size - 1) / cipher_block_size * cipher_block_size); bctx.wbuf = - bctx.jcr->impl_->crypto + bctx.jcr->impl->crypto .crypto_buf; /* Encrypted, possibly compressed output here. */ } @@ -487,7 +487,7 @@ bool SetupDecryptionContext(r_ctx& rctx, RestoreCipherContext& rcctx) if (!rctx.cs) { Jmsg1(rctx.jcr, M_ERROR, 0, _("Missing encryption session data stream for %s\n"), - rctx.jcr->impl_->last_fname); + rctx.jcr->impl->last_fname); return false; } @@ -495,7 +495,7 @@ bool SetupDecryptionContext(r_ctx& rctx, RestoreCipherContext& rcctx) NULL) { Jmsg1(rctx.jcr, M_ERROR, 0, _("Failed to initialize decryption context for %s\n"), - rctx.jcr->impl_->last_fname); + rctx.jcr->impl->last_fname); FreeSession(rctx); return false; } @@ -538,7 +538,7 @@ bool EncryptData(b_ctx* bctx, bool* need_more_data) Dmsg1(20, "Encrypt len=%d\n", bctx->cipher_input_len); if (!CryptoCipherUpdate(bctx->cipher_ctx, packet_len, sizeof(packet_len), - (uint8_t*)bctx->jcr->impl_->crypto.crypto_buf, + (uint8_t*)bctx->jcr->impl->crypto.crypto_buf, &initial_len)) { /* * Encryption failed. Shouldn't happen. @@ -552,7 +552,7 @@ bool EncryptData(b_ctx* bctx, bool* need_more_data) */ if (CryptoCipherUpdate( bctx->cipher_ctx, bctx->cipher_input, bctx->cipher_input_len, - (uint8_t*)&bctx->jcr->impl_->crypto.crypto_buf[initial_len], + (uint8_t*)&bctx->jcr->impl->crypto.crypto_buf[initial_len], &bctx->encrypted_len)) { if ((initial_len + bctx->encrypted_len) == 0) { /* diff --git a/core/src/filed/dir_cmd.cc b/core/src/filed/dir_cmd.cc index 35c1baa5ced..4a08cee8497 100644 --- a/core/src/filed/dir_cmd.cc +++ b/core/src/filed/dir_cmd.cc @@ -329,7 +329,7 @@ static inline void CleanupFileset(JobControlRecord* jcr) findIncludeExcludeItem* incexe; findFOPTS* fo; - fileset = jcr->impl_->ff->fileset; + fileset = jcr->impl->ff->fileset; if (fileset) { /* * Delete FileSet Include lists @@ -394,7 +394,7 @@ static inline void CleanupFileset(JobControlRecord* jcr) fileset->exclude_list.destroy(); free(fileset); } - jcr->impl_->ff->fileset = nullptr; + jcr->impl->ff->fileset = nullptr; } static inline bool AreMaxConcurrentJobsExceeded() @@ -413,7 +413,7 @@ static inline bool AreMaxConcurrentJobsExceeded() static JobControlRecord* NewFiledJcr() { JobControlRecord* jcr = new_jcr(FiledFreeJcr); - jcr->impl_ = new JobControlRecordPrivate; + jcr->impl = new JobControlRecordPrivate; return jcr; } @@ -423,19 +423,19 @@ JobControlRecord* create_new_director_session(BareosSocket* dir) JobControlRecord* jcr{NewFiledJcr()}; jcr->dir_bsock = dir; - jcr->impl_->ff = init_find_files(); + jcr->impl->ff = init_find_files(); jcr->start_time = time(nullptr); - jcr->impl_->RunScripts = new alist(10, not_owned_by_alist); - jcr->impl_->last_fname = GetPoolMemory(PM_FNAME); - jcr->impl_->last_fname[0] = 0; + jcr->impl->RunScripts = new alist(10, not_owned_by_alist); + jcr->impl->last_fname = GetPoolMemory(PM_FNAME); + jcr->impl->last_fname[0] = 0; jcr->client_name = GetMemory(strlen(my_name) + 1); PmStrcpy(jcr->client_name, my_name); bstrncpy(jcr->Job, jobname, sizeof(jobname)); /* dummy */ - jcr->impl_->crypto.pki_sign = me->pki_sign; - jcr->impl_->crypto.pki_encrypt = me->pki_encrypt; - jcr->impl_->crypto.pki_keypair = me->pki_keypair; - jcr->impl_->crypto.pki_signers = me->pki_signers; - jcr->impl_->crypto.pki_recipients = me->pki_recipients; + jcr->impl->crypto.pki_sign = me->pki_sign; + jcr->impl->crypto.pki_encrypt = me->pki_encrypt; + jcr->impl->crypto.pki_keypair = me->pki_keypair; + jcr->impl->crypto.pki_signers = me->pki_signers; + jcr->impl->crypto.pki_recipients = me->pki_recipients; if (dir) { dir->SetJcr(jcr); } SetJcrInThreadSpecificData(jcr); @@ -469,7 +469,7 @@ void* process_director_commands(JobControlRecord* jcr, BareosSocket* dir) for (int i = 0; cmds[i].cmd; i++) { if (bstrncmp(cmds[i].cmd, dir->msg, strlen(cmds[i].cmd))) { found = true; /* indicate command found */ - if ((!cmds[i].monitoraccess) && (jcr->impl_->director->monitor)) { + if ((!cmds[i].monitoraccess) && (jcr->impl->director->monitor)) { Dmsg1(100, "Command \"%s\" is invalid.\n", cmds[i].cmd); dir->fsend(invalid_cmd); dir->signal(BNET_EOD); @@ -498,12 +498,11 @@ void* process_director_commands(JobControlRecord* jcr, BareosSocket* dir) /* * Run the after job */ - if (jcr->impl_->RunScripts) { - RunScripts( - jcr, jcr->impl_->RunScripts, "ClientAfterJob", - (jcr->impl_->director && jcr->impl_->director->allowed_script_dirs) - ? jcr->impl_->director->allowed_script_dirs - : me->allowed_script_dirs); + if (jcr->impl->RunScripts) { + RunScripts(jcr, jcr->impl->RunScripts, "ClientAfterJob", + (jcr->impl->director && jcr->impl->director->allowed_script_dirs) + ? jcr->impl->director->allowed_script_dirs + : me->allowed_script_dirs); } if (jcr->JobId) { /* send EndJob if running a job */ @@ -514,7 +513,7 @@ void* process_director_commands(JobControlRecord* jcr, BareosSocket* dir) dir->fsend(EndJob, jcr->JobStatus, jcr->JobFiles, edit_uint64(jcr->ReadBytes, ed1), edit_uint64(jcr->JobBytes, ed2), jcr->JobErrors, - jcr->impl_->enable_vss, jcr->impl_->crypto.pki_encrypt); + jcr->impl->enable_vss, jcr->impl->crypto.pki_encrypt); Dmsg1(110, "End FD msg: %s\n", dir->msg); } @@ -528,7 +527,7 @@ void* process_director_commands(JobControlRecord* jcr, BareosSocket* dir) dir->signal(BNET_TERMINATE); FreePlugins(jcr); /* release instantiated plugins */ - FreeAndNullPoolMemory(jcr->impl_->job_metadata); + FreeAndNullPoolMemory(jcr->impl->job_metadata); /* * Clean up fileset @@ -943,14 +942,14 @@ static bool EstimateCmd(JobControlRecord* jcr) */ if (!ValidateCommand( jcr, "estimate", - (jcr->impl_->director && jcr->impl_->director->allowed_job_cmds) - ? jcr->impl_->director->allowed_job_cmds + (jcr->impl->director && jcr->impl->director->allowed_job_cmds) + ? jcr->impl->director->allowed_job_cmds : me->allowed_job_cmds)) { dir->fsend(_("2992 Bad estimate command.\n")); return 0; } - if (sscanf(dir->msg, Estimatecmd, &jcr->impl_->listing) != 1) { + if (sscanf(dir->msg, Estimatecmd, &jcr->impl->listing) != 1) { PmStrcpy(jcr->errmsg, dir->msg); Jmsg(jcr, M_FATAL, 0, _("Bad estimate command: %s"), jcr->errmsg); dir->fsend(_("2992 Bad estimate command.\n")); @@ -959,8 +958,7 @@ static bool EstimateCmd(JobControlRecord* jcr) MakeEstimate(jcr); - dir->fsend(OKest, - edit_uint64_with_commas(jcr->impl_->num_files_examined, ed1), + dir->fsend(OKest, edit_uint64_with_commas(jcr->impl->num_files_examined, ed1), edit_uint64_with_commas(jcr->JobBytes, ed2)); dir->signal(BNET_EOD); @@ -1066,9 +1064,9 @@ static bool RunbeforenowCmd(JobControlRecord* jcr) { BareosSocket* dir = jcr->dir_bsock; - RunScripts(jcr, jcr->impl_->RunScripts, "ClientBeforeJob", - (jcr->impl_->director && jcr->impl_->director->allowed_script_dirs) - ? jcr->impl_->director->allowed_script_dirs + RunScripts(jcr, jcr->impl->RunScripts, "ClientBeforeJob", + (jcr->impl->director && jcr->impl->director->allowed_script_dirs) + ? jcr->impl->director->allowed_script_dirs : me->allowed_script_dirs); if (JobCanceled(jcr)) { @@ -1113,7 +1111,7 @@ static bool RunafterCmd(JobControlRecord* jcr) script->when = SCRIPT_After; FreeMemory(cmd); - jcr->impl_->RunScripts->append(script); + jcr->impl->RunScripts->append(script); return dir->fsend(OKRunAfter); } @@ -1130,8 +1128,8 @@ static bool RunscriptCmd(JobControlRecord* jcr) */ if (!ValidateCommand( jcr, "runscript", - (jcr->impl_->director && jcr->impl_->director->allowed_job_cmds) - ? jcr->impl_->director->allowed_job_cmds + (jcr->impl->director && jcr->impl->director->allowed_job_cmds) + ? jcr->impl->director->allowed_job_cmds : me->allowed_job_cmds)) { dir->fsend(FailedRunScript); return 0; @@ -1164,7 +1162,7 @@ static bool RunscriptCmd(JobControlRecord* jcr) cmd->SetCommand(msg); cmd->Debug(); - jcr->impl_->RunScripts->append(cmd); + jcr->impl->RunScripts->append(cmd); FreePoolMemory(msg); @@ -1311,7 +1309,7 @@ static bool RestoreObjectCmd(JobControlRecord* jcr) */ if (bstrcmp(rop.object_name, "job_metadata.xml")) { Dmsg0(100, "got job metadata\n"); - jcr->impl_->got_metadata = true; + jcr->impl->got_metadata = true; } GeneratePluginEvent(jcr, bEventRestoreObject, (void*)&rop); @@ -1337,7 +1335,7 @@ static inline int CountIncludeListFileEntries(JobControlRecord* jcr) findFILESET* fileset; findIncludeExcludeItem* incexe; - fileset = jcr->impl_->ff->fileset; + fileset = jcr->impl->ff->fileset; if (fileset) { for (int i = 0; i < fileset->include_list.size(); i++) { incexe = (findIncludeExcludeItem*)fileset->include_list.get(i); @@ -1373,13 +1371,13 @@ static bool FilesetCmd(JobControlRecord* jcr) if (!TermFileset(jcr)) { return false; } #if defined(WIN32_VSS) - jcr->impl_->enable_vss = + jcr->impl->enable_vss = (vss && (CountIncludeListFileEntries(jcr) > 0)) ? true : false; #endif retval = dir->fsend(OKinc); GeneratePluginEvent(jcr, bEventEndFileSet); - CheckIncludeListShadowing(jcr, jcr->impl_->ff->fileset); + CheckIncludeListShadowing(jcr, jcr->impl->ff->fileset); return retval; } @@ -1494,7 +1492,7 @@ static bool LevelCmd(JobControlRecord* jcr) } if (sscanf(dir->msg, "level = since_utime %s mtime_only=%d prev_job=%127s", - buf, &mtime_only, jcr->impl_->PrevJob) != 3) { + buf, &mtime_only, jcr->impl->PrevJob) != 3) { if (sscanf(dir->msg, "level = since_utime %s mtime_only=%d", buf, &mtime_only) != 2) { goto bail_out; @@ -1502,8 +1500,7 @@ static bool LevelCmd(JobControlRecord* jcr) } since_time = str_to_uint64(buf); /* this is the since time */ - Dmsg2(100, "since_time=%lld prev_job=%s\n", since_time, - jcr->impl_->PrevJob); + Dmsg2(100, "since_time=%lld prev_job=%s\n", since_time, jcr->impl->PrevJob); /* * Sync clocks by polling him for the time. We take 10 samples of his time * throwing out the first two. @@ -1551,9 +1548,9 @@ static bool LevelCmd(JobControlRecord* jcr) dir->signal(BNET_EOD); Dmsg2(100, "adj=%lld since_time=%lld\n", adj, since_time); - jcr->impl_->incremental = true; /* set incremental or decremental backup */ - jcr->impl_->mtime = since_time; /* set since time */ - GeneratePluginEvent(jcr, bEventSince, (void*)(time_t)jcr->impl_->mtime); + jcr->impl->incremental = true; /* set incremental or decremental backup */ + jcr->impl->mtime = since_time; /* set since time */ + GeneratePluginEvent(jcr, bEventSince, (void*)(time_t)jcr->impl->mtime); } else { Jmsg1(jcr, M_FATAL, 0, _("Unknown backup level: %s\n"), level); FreeMemory(level); @@ -1585,8 +1582,8 @@ static bool SessionCmd(JobControlRecord* jcr) Dmsg1(100, "SessionCmd: %s", dir->msg); if (sscanf(dir->msg, sessioncmd, jcr->VolumeName, &jcr->VolSessionId, - &jcr->VolSessionTime, &jcr->impl_->StartFile, &jcr->impl_->EndFile, - &jcr->impl_->StartBlock, &jcr->impl_->EndBlock) != 7) { + &jcr->VolSessionTime, &jcr->impl->StartFile, &jcr->impl->EndFile, + &jcr->impl->StartBlock, &jcr->impl->EndBlock) != 7) { PmStrcpy(jcr->errmsg, dir->msg); Jmsg(jcr, M_FATAL, 0, _("Bad session command: %s"), jcr->errmsg); return false; @@ -1621,7 +1618,7 @@ static void SetStorageAuthKeyAndTlsPolicy(JobControlRecord* jcr, * restore */ Dmsg0(5, "set multi_restore=true\n"); - jcr->impl_->multi_restore = true; + jcr->impl->multi_restore = true; free(jcr->sd_auth_key); } @@ -1668,8 +1665,8 @@ static bool StorageCmd(JobControlRecord* jcr) * TODO: see if we put limit on restore and backup... */ if (!jcr->max_bandwidth) { - if (jcr->impl_->director->max_bandwidth_per_job) { - jcr->max_bandwidth = jcr->impl_->director->max_bandwidth_per_job; + if (jcr->impl->director->max_bandwidth_per_job) { + jcr->max_bandwidth = jcr->impl->director->max_bandwidth_per_job; } else if (me->max_bandwidth_per_job) { jcr->max_bandwidth = me->max_bandwidth_per_job; } @@ -1735,7 +1732,7 @@ static void LogFlagStatus(JobControlRecord* jcr, int flag, const char* flag_text) { - findFILESET* fileset = jcr->impl_->ff->fileset; + findFILESET* fileset = jcr->impl->ff->fileset; bool found = false; if (fileset) { for (int i = 0; i < fileset->include_list.size() && !found; i++) { @@ -1769,7 +1766,7 @@ static inline void ClearFlagInFileset(JobControlRecord* jcr, findFILESET* fileset; bool cleared_flag = false; - fileset = jcr->impl_->ff->fileset; + fileset = jcr->impl->ff->fileset; if (fileset) { for (int i = 0; i < fileset->include_list.size(); i++) { findIncludeExcludeItem* incexe = @@ -1799,7 +1796,7 @@ static inline void ClearCompressionFlagInFileset(JobControlRecord* jcr) { findFILESET* fileset; - fileset = jcr->impl_->ff->fileset; + fileset = jcr->impl->ff->fileset; if (fileset) { for (int i = 0; i < fileset->include_list.size(); i++) { findIncludeExcludeItem* incexe = @@ -1859,7 +1856,7 @@ static inline bool GetWantedCryptoCipher(JobControlRecord* jcr, * Walk the fileset and check for the FO_FORCE_ENCRYPT flag and any forced * crypto cipher. */ - fileset = jcr->impl_->ff->fileset; + fileset = jcr->impl->ff->fileset; if (fileset) { for (int i = 0; i < fileset->include_list.size(); i++) { findIncludeExcludeItem* incexe = @@ -1883,7 +1880,7 @@ static inline bool GetWantedCryptoCipher(JobControlRecord* jcr, /* * See if pki_encrypt is already set for this Job. */ - if (!jcr->impl_->crypto.pki_encrypt) { + if (!jcr->impl->crypto.pki_encrypt) { if (!me->pki_keypair_file) { Jmsg(jcr, M_FATAL, 0, _("Fileset contains cipher settings but PKI Key Pair is not " @@ -1894,8 +1891,8 @@ static inline bool GetWantedCryptoCipher(JobControlRecord* jcr, /* * Enable encryption and signing for this Job. */ - jcr->impl_->crypto.pki_sign = true; - jcr->impl_->crypto.pki_encrypt = true; + jcr->impl->crypto.pki_sign = true; + jcr->impl->crypto.pki_encrypt = true; } wanted_cipher = (crypto_cipher_t)fo->Encryption_cipher; @@ -1919,7 +1916,7 @@ static inline bool GetWantedCryptoCipher(JobControlRecord* jcr, * See if FO_FORCE_ENCRYPT is set and encryption is not configured for the * filed. */ - if (force_encrypt && !jcr->impl_->crypto.pki_encrypt) { + if (force_encrypt && !jcr->impl->crypto.pki_encrypt) { Jmsg(jcr, M_FATAL, 0, _("Fileset forces encryption but encryption is not configured\n")); return false; @@ -1958,14 +1955,14 @@ static bool BackupCmd(JobControlRecord* jcr) */ if (!ValidateCommand( jcr, "backup", - (jcr->impl_->director && jcr->impl_->director->allowed_job_cmds) - ? jcr->impl_->director->allowed_job_cmds + (jcr->impl->director && jcr->impl->director->allowed_job_cmds) + ? jcr->impl->director->allowed_job_cmds : me->allowed_job_cmds)) { goto cleanup; } #if defined(WIN32_VSS) - if (jcr->impl_->enable_vss) { VSSInit(jcr); } + if (jcr->impl->enable_vss) { VSSInit(jcr); } #endif if (sscanf(dir->msg, "backup FileIndex=%ld\n", &FileIndex) == 1) { @@ -2009,7 +2006,7 @@ static bool BackupCmd(JobControlRecord* jcr) jcr->setJobStatus(JS_Blocked); jcr->setJobType(JT_BACKUP); - Dmsg1(100, "begin backup ff=%p\n", jcr->impl_->ff); + Dmsg1(100, "begin backup ff=%p\n", jcr->impl->ff); if (sd == nullptr) { Jmsg(jcr, M_FATAL, 0, _("Cannot contact Storage daemon\n")); @@ -2031,11 +2028,11 @@ static bool BackupCmd(JobControlRecord* jcr) */ if (BgetMsg(sd) >= 0) { Dmsg1(110, "msg); - if (sscanf(sd->msg, OK_open, &jcr->impl_->Ticket) != 1) { + if (sscanf(sd->msg, OK_open, &jcr->impl->Ticket) != 1) { Jmsg(jcr, M_FATAL, 0, _("Bad response to append open: %s\n"), sd->msg); goto cleanup; } - Dmsg1(110, "Got Ticket=%d\n", jcr->impl_->Ticket); + Dmsg1(110, "Got Ticket=%d\n", jcr->impl->Ticket); } else { Jmsg(jcr, M_FATAL, 0, _("Bad response from stored to open command\n")); goto cleanup; @@ -2044,7 +2041,7 @@ static bool BackupCmd(JobControlRecord* jcr) /** * Send Append data command to Storage daemon */ - sd->fsend(append_data, jcr->impl_->Ticket); + sd->fsend(append_data, jcr->impl->Ticket); Dmsg1(110, ">stored: %s", sd->msg); /** @@ -2062,8 +2059,8 @@ static bool BackupCmd(JobControlRecord* jcr) /* * START VSS ON WIN32 */ - if (jcr->impl_->pVSSClient) { - if (jcr->impl_->pVSSClient->InitializeForBackup(jcr)) { + if (jcr->impl->pVSSClient) { + if (jcr->impl->pVSSClient->InitializeForBackup(jcr)) { int drive_count; char szWinDriveLetters[27]; bool onefs_disabled; @@ -2081,18 +2078,18 @@ static bool BackupCmd(JobControlRecord* jcr) GeneratePluginEvent(jcr, bEventVssPrepareSnapshot, szWinDriveLetters); drive_count = - get_win32_driveletters(jcr->impl_->ff->fileset, szWinDriveLetters); + get_win32_driveletters(jcr->impl->ff->fileset, szWinDriveLetters); - onefs_disabled = win32_onefs_is_disabled(jcr->impl_->ff->fileset); + onefs_disabled = win32_onefs_is_disabled(jcr->impl->ff->fileset); if (drive_count > 0) { Jmsg(jcr, M_INFO, 0, _("Generate VSS snapshots. Driver=\"%s\", Drive(s)=\"%s\"\n"), - jcr->impl_->pVSSClient->GetDriverName(), + jcr->impl->pVSSClient->GetDriverName(), (drive_count) ? szWinDriveLetters : "None"); - if (!jcr->impl_->pVSSClient->CreateSnapshots(szWinDriveLetters, - onefs_disabled)) { + if (!jcr->impl->pVSSClient->CreateSnapshots(szWinDriveLetters, + onefs_disabled)) { BErrNo be; Jmsg(jcr, M_FATAL, 0, _("CreateSGenerate VSS snapshots failed. ERR=%s\n"), @@ -2103,7 +2100,7 @@ static bool BackupCmd(JobControlRecord* jcr) /* * Inform about VMPs if we have them */ - jcr->impl_->pVSSClient->ShowVolumeMountPointStats(jcr); + jcr->impl->pVSSClient->ShowVolumeMountPointStats(jcr); /* * Tell user if snapshot creation of a specific drive failed @@ -2119,11 +2116,10 @@ static bool BackupCmd(JobControlRecord* jcr) /* * Inform user about writer states */ - for (size_t i = 0; i < jcr->impl_->pVSSClient->GetWriterCount(); - i++) { - if (jcr->impl_->pVSSClient->GetWriterState(i) < 1) { + for (size_t i = 0; i < jcr->impl->pVSSClient->GetWriterCount(); i++) { + if (jcr->impl->pVSSClient->GetWriterState(i) < 1) { Jmsg(jcr, M_INFO, 0, _("VSS Writer (PrepareForBackup): %s\n"), - jcr->impl_->pVSSClient->GetWriterInfo(i)); + jcr->impl->pVSSClient->GetWriterInfo(i)); } } } @@ -2139,18 +2135,17 @@ static bool BackupCmd(JobControlRecord* jcr) be.bstrerror()); } - RunScripts( - jcr, jcr->impl_->RunScripts, "ClientAfterVSS", - (jcr->impl_->director && jcr->impl_->director->allowed_script_dirs) - ? jcr->impl_->director->allowed_script_dirs - : me->allowed_script_dirs); + RunScripts(jcr, jcr->impl->RunScripts, "ClientAfterVSS", + (jcr->impl->director && jcr->impl->director->allowed_script_dirs) + ? jcr->impl->director->allowed_script_dirs + : me->allowed_script_dirs); } #endif /** * Send Files to Storage daemon */ - Dmsg1(110, "begin blast ff=%p\n", (FindFilesPacket*)jcr->impl_->ff); + Dmsg1(110, "begin blast ff=%p\n", (FindFilesPacket*)jcr->impl->ff); if (!BlastDataToStorageDaemon(jcr, nullptr, cipher)) { jcr->setJobStatus(JS_ErrorTerminated); BnetSuppressErrorMessages(sd, 1); @@ -2173,7 +2168,7 @@ static bool BackupCmd(JobControlRecord* jcr) /** * Send Append End Data to Storage daemon */ - sd->fsend(append_end, jcr->impl_->Ticket); + sd->fsend(append_end, jcr->impl->Ticket); /* Get end OK */ if (!response(jcr, sd, OK_end, "Append End")) { jcr->setJobStatus(JS_ErrorTerminated); @@ -2183,7 +2178,7 @@ static bool BackupCmd(JobControlRecord* jcr) /** * Send Append Close to Storage daemon */ - sd->fsend(append_close, jcr->impl_->Ticket); + sd->fsend(append_close, jcr->impl->Ticket); while (BgetMsg(sd) >= 0) { /* stop on signal or error */ if (sscanf(sd->msg, OK_close, &SDJobStatus) == 1) { ok = 1; @@ -2202,7 +2197,7 @@ static bool BackupCmd(JobControlRecord* jcr) cleanup: #if defined(WIN32_VSS) - if (jcr->impl_->pVSSClient) { jcr->impl_->pVSSClient->DestroyWriterInfo(); } + if (jcr->impl->pVSSClient) { jcr->impl->pVSSClient->DestroyWriterInfo(); } #endif GeneratePluginEvent(jcr, bEventEndBackupJob); @@ -2224,8 +2219,8 @@ static bool VerifyCmd(JobControlRecord* jcr) */ if (!ValidateCommand( jcr, "verify", - (jcr->impl_->director && jcr->impl_->director->allowed_job_cmds) - ? jcr->impl_->director->allowed_job_cmds + (jcr->impl->director && jcr->impl->director->allowed_job_cmds) + ? jcr->impl->director->allowed_job_cmds : me->allowed_job_cmds)) { dir->fsend(_("2994 Bad verify command: %s\n"), dir->msg); return 0; @@ -2272,7 +2267,7 @@ static bool VerifyCmd(JobControlRecord* jcr) /* * Send Close session command to Storage daemon */ - sd->fsend(read_close, jcr->impl_->Ticket); + sd->fsend(read_close, jcr->impl->Ticket); Dmsg1(130, "filed>stored: %s", sd->msg); /* ****FIXME**** check response */ @@ -2352,7 +2347,7 @@ static BareosSocket* connect_to_director(JobControlRecord* jcr, director_socket->recv(); ParseOkVersion(director_socket->msg); - jcr->impl_->director = dir_res; + jcr->impl->director = dir_res; return director_socket.release(); } @@ -2386,8 +2381,8 @@ static bool RestoreCmd(JobControlRecord* jcr) */ if (!ValidateCommand( jcr, "restore", - (jcr->impl_->director && jcr->impl_->director->allowed_job_cmds) - ? jcr->impl_->director->allowed_job_cmds + (jcr->impl->director && jcr->impl->director->allowed_job_cmds) + ? jcr->impl->director->allowed_job_cmds : me->allowed_job_cmds)) { return 0; } @@ -2422,9 +2417,9 @@ static bool RestoreCmd(JobControlRecord* jcr) /** * No need to enable VSS for restore if we do not have plugin data to restore */ - jcr->impl_->enable_vss = jcr->impl_->got_metadata; + jcr->impl->enable_vss = jcr->impl->got_metadata; - if (jcr->impl_->enable_vss) { VSSInit(jcr); } + if (jcr->impl->enable_vss) { VSSInit(jcr); } #endif /* @@ -2452,7 +2447,7 @@ static bool RestoreCmd(JobControlRecord* jcr) } FreePoolMemory(args); - jcr->impl_->replace = replace; + jcr->impl->replace = replace; jcr->prefix_links = prefix_links; dir->fsend(OKrestore); @@ -2477,8 +2472,8 @@ static bool RestoreCmd(JobControlRecord* jcr) /* * START VSS ON WIN32 */ - if (jcr->impl_->pVSSClient) { - if (!jcr->impl_->pVSSClient->InitializeForRestore(jcr)) { + if (jcr->impl->pVSSClient) { + if (!jcr->impl->pVSSClient->InitializeForRestore(jcr)) { BErrNo be; Jmsg(jcr, M_WARNING, 0, _("VSS was not initialized properly. VSS support is disabled. " @@ -2488,11 +2483,10 @@ static bool RestoreCmd(JobControlRecord* jcr) GeneratePluginEvent(jcr, bEventVssRestoreLoadComponentMetadata); - RunScripts( - jcr, jcr->impl_->RunScripts, "ClientAfterVSS", - (jcr->impl_->director && jcr->impl_->director->allowed_script_dirs) - ? jcr->impl_->director->allowed_script_dirs - : me->allowed_script_dirs); + RunScripts(jcr, jcr->impl->RunScripts, "ClientAfterVSS", + (jcr->impl->director && jcr->impl->director->allowed_script_dirs) + ? jcr->impl->director->allowed_script_dirs + : me->allowed_script_dirs); } #endif @@ -2508,7 +2502,7 @@ static bool RestoreCmd(JobControlRecord* jcr) /** * Send Close session command to Storage daemon */ - sd->fsend(read_close, jcr->impl_->Ticket); + sd->fsend(read_close, jcr->impl->Ticket); Dmsg1(100, "filed>stored: %s", sd->msg); BgetMsg(sd); /* get OK */ @@ -2521,26 +2515,26 @@ static bool RestoreCmd(JobControlRecord* jcr) * STOP VSS ON WIN32 * Tell vss to close the restore session */ - if (jcr->impl_->pVSSClient) { + if (jcr->impl->pVSSClient) { Dmsg0(100, "About to call CloseRestore\n"); GeneratePluginEvent(jcr, bEventVssCloseRestore); Dmsg0(100, "Really about to call CloseRestore\n"); - if (jcr->impl_->pVSSClient->CloseRestore()) { + if (jcr->impl->pVSSClient->CloseRestore()) { Dmsg0(100, "CloseRestore success\n"); /* * Inform user about writer states */ - for (size_t i = 0; i < jcr->impl_->pVSSClient->GetWriterCount(); i++) { + for (size_t i = 0; i < jcr->impl->pVSSClient->GetWriterCount(); i++) { int msg_type = M_INFO; - if (jcr->impl_->pVSSClient->GetWriterState(i) < 1) { + if (jcr->impl->pVSSClient->GetWriterState(i) < 1) { msg_type = M_WARNING; jcr->JobErrors++; } Jmsg(jcr, msg_type, 0, _("VSS Writer (RestoreComplete): %s\n"), - jcr->impl_->pVSSClient->GetWriterInfo(i)); + jcr->impl->pVSSClient->GetWriterInfo(i)); } } else { Dmsg1(100, "CloseRestore fail - %08x\n", errno); @@ -2555,7 +2549,7 @@ static bool RestoreCmd(JobControlRecord* jcr) Dmsg0(100, "Done in job.c\n"); - if (jcr->impl_->multi_restore) { + if (jcr->impl->multi_restore) { Dmsg0(100, OKstoreend); dir->fsend(OKstoreend); retval = true; /* we continue the loop, waiting for next part */ @@ -2588,14 +2582,14 @@ static bool OpenSdReadSession(JobControlRecord* jcr) return false; } Dmsg4(120, "VolSessId=%ld VolsessT=%ld SF=%ld EF=%ld\n", jcr->VolSessionId, - jcr->VolSessionTime, jcr->impl_->StartFile, jcr->impl_->EndFile); + jcr->VolSessionTime, jcr->impl->StartFile, jcr->impl->EndFile); Dmsg2(120, "JobId=%d vol=%s\n", jcr->JobId, "DummyVolume"); /* * Open Read Session with Storage daemon */ sd->fsend(read_open, "DummyVolume", jcr->VolSessionId, jcr->VolSessionTime, - jcr->impl_->StartFile, jcr->impl_->EndFile, jcr->impl_->StartBlock, - jcr->impl_->EndBlock); + jcr->impl->StartFile, jcr->impl->EndFile, jcr->impl->StartBlock, + jcr->impl->EndBlock); Dmsg1(110, ">stored: %s", sd->msg); /* @@ -2603,11 +2597,11 @@ static bool OpenSdReadSession(JobControlRecord* jcr) */ if (BgetMsg(sd) >= 0) { Dmsg1(110, "filedmsg); - if (sscanf(sd->msg, OK_open, &jcr->impl_->Ticket) != 1) { + if (sscanf(sd->msg, OK_open, &jcr->impl->Ticket) != 1) { Jmsg(jcr, M_FATAL, 0, _("Bad response to SD read open: %s\n"), sd->msg); return false; } - Dmsg1(110, "filed: got Ticket=%d\n", jcr->impl_->Ticket); + Dmsg1(110, "filed: got Ticket=%d\n", jcr->impl->Ticket); } else { Jmsg(jcr, M_FATAL, 0, _("Bad response from stored to read open command\n")); return false; @@ -2616,7 +2610,7 @@ static bool OpenSdReadSession(JobControlRecord* jcr) /* * Start read of data with Storage daemon */ - sd->fsend(read_data, jcr->impl_->Ticket); + sd->fsend(read_data, jcr->impl->Ticket); Dmsg1(110, ">stored: %s", sd->msg); /* @@ -2633,9 +2627,9 @@ static bool OpenSdReadSession(JobControlRecord* jcr) static void FiledFreeJcr(JobControlRecord* jcr) { #if defined(WIN32_VSS) - if (jcr->impl_->pVSSClient) { - delete jcr->impl_->pVSSClient; - jcr->impl_->pVSSClient = nullptr; + if (jcr->impl->pVSSClient) { + delete jcr->impl->pVSSClient; + jcr->impl->pVSSClient = nullptr; } #endif @@ -2651,29 +2645,29 @@ static void FiledFreeJcr(JobControlRecord* jcr) jcr->dir_bsock = nullptr; } - if (jcr->impl_->last_fname) { FreePoolMemory(jcr->impl_->last_fname); } + if (jcr->impl->last_fname) { FreePoolMemory(jcr->impl->last_fname); } FreeBootstrap(jcr); - FreeRunscripts(jcr->impl_->RunScripts); - delete jcr->impl_->RunScripts; - jcr->impl_->RunScripts = nullptr; + FreeRunscripts(jcr->impl->RunScripts); + delete jcr->impl->RunScripts; + jcr->impl->RunScripts = nullptr; if (jcr->path_list) { FreePathList(jcr->path_list); jcr->path_list = nullptr; } - TermFindFiles(jcr->impl_->ff); - jcr->impl_->ff = nullptr; + TermFindFiles(jcr->impl->ff); + jcr->impl->ff = nullptr; if (jcr->JobId != 0) { WriteStateFile(me->working_directory, "bareos-fd", GetFirstPortHostOrder(me->FDaddrs)); } - if (jcr->impl_) { - delete jcr->impl_; - jcr->impl_ = nullptr; + if (jcr->impl) { + delete jcr->impl; + jcr->impl = nullptr; } return; diff --git a/core/src/filed/estimate.cc b/core/src/filed/estimate.cc index 1395627168a..19542642b2d 100644 --- a/core/src/filed/estimate.cc +++ b/core/src/filed/estimate.cc @@ -46,14 +46,14 @@ int MakeEstimate(JobControlRecord* jcr) jcr->setJobStatus(JS_Running); - SetFindOptions((FindFilesPacket*)jcr->impl_->ff, jcr->impl_->incremental, - jcr->impl_->mtime); + SetFindOptions((FindFilesPacket*)jcr->impl->ff, jcr->impl->incremental, + jcr->impl->mtime); /* in accurate mode, we overwrite the find_one check function */ if (jcr->accurate) { - SetFindChangedFunction((FindFilesPacket*)jcr->impl_->ff, AccurateCheckFile); + SetFindChangedFunction((FindFilesPacket*)jcr->impl->ff, AccurateCheckFile); } - status = FindFiles(jcr, (FindFilesPacket*)jcr->impl_->ff, TallyFile, + status = FindFiles(jcr, (FindFilesPacket*)jcr->impl->ff, TallyFile, PluginEstimate); AccurateFree(jcr); return status; @@ -109,9 +109,9 @@ static int TallyFile(JobControlRecord* jcr, } #endif } - jcr->impl_->num_files_examined++; + jcr->impl->num_files_examined++; jcr->JobFiles++; /* increment number of files seen */ - if (jcr->impl_->listing) { + if (jcr->impl->listing) { memcpy(&attr.statp, &ff_pkt->statp, sizeof(struct stat)); attr.type = ff_pkt->type; attr.ofname = (POOLMEM*)ff_pkt->fname; diff --git a/core/src/filed/fd_plugins.cc b/core/src/filed/fd_plugins.cc index a1cada963ae..5c38532e68c 100644 --- a/core/src/filed/fd_plugins.cc +++ b/core/src/filed/fd_plugins.cc @@ -743,8 +743,8 @@ int PluginSave(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool top_level) goto bail_out; } - jcr->impl_->plugin_sp = &sp; - ff_pkt = jcr->impl_->ff; + jcr->impl->plugin_sp = &sp; + ff_pkt = jcr->impl->ff; /* * Save original flags. @@ -1010,13 +1010,13 @@ int PluginEstimate(JobControlRecord* jcr, default: break; } - jcr->impl_->num_files_examined++; + jcr->impl->num_files_examined++; if (sp.type != FT_LNKSAVED && S_ISREG(sp.statp.st_mode)) { if (sp.statp.st_size > 0) { jcr->JobBytes += sp.statp.st_size; } } - if (jcr->impl_->listing) { + if (jcr->impl->listing) { memcpy(&attr.statp, &sp.statp, sizeof(struct stat)); attr.type = sp.type; attr.ofname = (POOLMEM*)sp.fname; @@ -1058,7 +1058,7 @@ bool SendPluginName(JobControlRecord* jcr, BareosSocket* sd, bool start) { int status; int index = jcr->JobFiles; - struct save_pkt* sp = (struct save_pkt*)jcr->impl_->plugin_sp; + struct save_pkt* sp = (struct save_pkt*)jcr->impl->plugin_sp; if (!sp) { Jmsg0(jcr, M_FATAL, 0, _("Plugin save packet not found.\n")); @@ -1258,7 +1258,7 @@ int PluginCreateFile(JobControlRecord* jcr, rp.olname = attr->olname; rp.where = jcr->where; rp.RegexWhere = jcr->RegexWhere; - rp.replace = jcr->impl_->replace; + rp.replace = jcr->impl->replace; rp.create_status = CF_ERROR; Dmsg4(debuglevel, @@ -1356,7 +1356,7 @@ bool PluginSetAttributes(JobControlRecord* jcr, rp.olname = attr->olname; rp.where = jcr->where; rp.RegexWhere = jcr->RegexWhere; - rp.replace = jcr->impl_->replace; + rp.replace = jcr->impl->replace; rp.create_status = CF_ERROR; PlugFunc(plugin)->setFileAttributes(jcr->plugin_ctx, &rp); @@ -2108,7 +2108,7 @@ static bRC bareosGetValue(bpContext* ctx, bVariable var, void* value) NPRT(*((char**)value))); break; case bVarPrevJobName: - *((char**)value) = jcr->impl_->PrevJob; + *((char**)value) = jcr->impl->PrevJob; Dmsg1(debuglevel, "fd-plugin: return bVarPrevJobName=%s\n", NPRT(*((char**)value))); break; @@ -2118,9 +2118,9 @@ static bRC bareosGetValue(bpContext* ctx, bVariable var, void* value) jcr->JobStatus); break; case bVarSinceTime: - *((int*)value) = (int)jcr->impl_->mtime; + *((int*)value) = (int)jcr->impl->mtime; Dmsg1(debuglevel, "fd-plugin: return bVarSinceTime=%d\n", - (int)jcr->impl_->mtime); + (int)jcr->impl->mtime); break; case bVarAccurate: *((int*)value) = (int)jcr->accurate; @@ -2131,8 +2131,8 @@ static bRC bareosGetValue(bpContext* ctx, bVariable var, void* value) break; /* a write only variable, ignore read request */ case bVarVssClient: #ifdef HAVE_WIN32 - if (jcr->impl_->pVSSClient) { - *(void**)value = jcr->impl_->pVSSClient; + if (jcr->impl->pVSSClient) { + *(void**)value = jcr->impl->pVSSClient; Dmsg1(debuglevel, "fd-plugin: return bVarVssClient=%p\n", *(void**)value); break; @@ -2340,7 +2340,7 @@ static bRC bareosAddExclude(bpContext* ctx, const char* fname) */ if (!old) { return bRC_Error; } - if (!bctx->exclude) { bctx->exclude = new_exclude(jcr->impl_->ff->fileset); } + if (!bctx->exclude) { bctx->exclude = new_exclude(jcr->impl->ff->fileset); } /* * Set the Exclude context @@ -2445,7 +2445,7 @@ static bRC bareosNewOptions(bpContext* ctx) b_plugin_ctx* bctx; if (!IsCtxGood(ctx, jcr, bctx)) { return bRC_Error; } - (void)NewOptions(jcr->impl_->ff, jcr->impl_->ff->fileset->incexe); + (void)NewOptions(jcr->impl->ff, jcr->impl->ff->fileset->incexe); return bRC_OK; } @@ -2456,7 +2456,7 @@ static bRC bareosNewInclude(bpContext* ctx) b_plugin_ctx* bctx; if (!IsCtxGood(ctx, jcr, bctx)) { return bRC_Error; } - (void)new_include(jcr->impl_->ff->fileset); + (void)new_include(jcr->impl->ff->fileset); return bRC_OK; } @@ -2468,8 +2468,8 @@ static bRC bareosNewPreInclude(bpContext* ctx) if (!IsCtxGood(ctx, jcr, bctx)) { return bRC_Error; } - bctx->include = new_preinclude(jcr->impl_->ff->fileset); - NewOptions(jcr->impl_->ff, bctx->include); + bctx->include = new_preinclude(jcr->impl->ff->fileset); + NewOptions(jcr->impl->ff, bctx->include); SetIncexe(jcr, bctx->include); return bRC_OK; @@ -2489,7 +2489,7 @@ static bRC bareosCheckChanges(bpContext* ctx, struct save_pkt* sp) if (!sp) { goto bail_out; } - ff_pkt = jcr->impl_->ff; + ff_pkt = jcr->impl->ff; /* * Copy fname and link because SaveFile() zaps them. * This avoids zaping the plugin's strings. @@ -2539,7 +2539,7 @@ static bRC bareosAcceptFile(bpContext* ctx, struct save_pkt* sp) if (!IsCtxGood(ctx, jcr, bctx)) { goto bail_out; } if (!sp) { goto bail_out; } - ff_pkt = jcr->impl_->ff; + ff_pkt = jcr->impl->ff; ff_pkt->fname = sp->fname; memcpy(&ff_pkt->statp, &sp->statp, sizeof(ff_pkt->statp)); diff --git a/core/src/filed/fileset.cc b/core/src/filed/fileset.cc index 962a3a0c1f0..c07bf4964b5 100644 --- a/core/src/filed/fileset.cc +++ b/core/src/filed/fileset.cc @@ -62,10 +62,10 @@ extern "C" char* job_code_callback_filed(JobControlRecord* jcr, switch (param[0]) { case 'D': - if (jcr->impl_->director) { return jcr->impl_->director->resource_name_; } + if (jcr->impl->director) { return jcr->impl->director->resource_name_; } break; case 'm': - return edit_uint64(jcr->impl_->mtime, str); + return edit_uint64(jcr->impl->mtime, str); } return NULL; @@ -76,8 +76,8 @@ bool InitFileset(JobControlRecord* jcr) FindFilesPacket* ff; findFILESET* fileset; - if (!jcr->impl_->ff) { return false; } - ff = jcr->impl_->ff; + if (!jcr->impl->ff) { return false; } + ff = jcr->impl->ff; if (ff->fileset) { return false; } fileset = (findFILESET*)malloc(sizeof(findFILESET)); *fileset = findFILESET{}; @@ -114,7 +114,7 @@ static void append_file(JobControlRecord* jcr, */ void AddFileToFileset(JobControlRecord* jcr, const char* fname, bool IsFile) { - findFILESET* fileset = jcr->impl_->ff->fileset; + findFILESET* fileset = jcr->impl->ff->fileset; char* p; Bpipe* bpipe; POOLMEM* fn; @@ -174,8 +174,8 @@ void AddFileToFileset(JobControlRecord* jcr, const char* fname, bool IsFile) findIncludeExcludeItem* get_incexe(JobControlRecord* jcr) { - if (jcr->impl_->ff && jcr->impl_->ff->fileset) { - return jcr->impl_->ff->fileset->incexe; + if (jcr->impl->ff && jcr->impl->ff->fileset) { + return jcr->impl->ff->fileset->incexe; } return NULL; @@ -183,7 +183,7 @@ findIncludeExcludeItem* get_incexe(JobControlRecord* jcr) void SetIncexe(JobControlRecord* jcr, findIncludeExcludeItem* incexe) { - findFILESET* fileset = jcr->impl_->ff->fileset; + findFILESET* fileset = jcr->impl->ff->fileset; fileset->incexe = incexe; } @@ -192,7 +192,7 @@ void SetIncexe(JobControlRecord* jcr, findIncludeExcludeItem* incexe) */ int AddRegexToFileset(JobControlRecord* jcr, const char* item, int type) { - findFOPTS* current_opts = start_options(jcr->impl_->ff); + findFOPTS* current_opts = start_options(jcr->impl->ff); regex_t* preg; int rc; char prbuf[500]; @@ -228,7 +228,7 @@ int AddRegexToFileset(JobControlRecord* jcr, const char* item, int type) */ int AddWildToFileset(JobControlRecord* jcr, const char* item, int type) { - findFOPTS* current_opts = start_options(jcr->impl_->ff); + findFOPTS* current_opts = start_options(jcr->impl->ff); if (type == ' ') { current_opts->wild.append(strdup(item)); @@ -250,7 +250,7 @@ int AddWildToFileset(JobControlRecord* jcr, const char* item, int type) */ int AddOptionsToFileset(JobControlRecord* jcr, const char* item) { - findFOPTS* current_opts = start_options(jcr->impl_->ff); + findFOPTS* current_opts = start_options(jcr->impl->ff); SetOptions(current_opts, item); @@ -259,7 +259,7 @@ int AddOptionsToFileset(JobControlRecord* jcr, const char* item) void AddFileset(JobControlRecord* jcr, const char* item) { - FindFilesPacket* ff = jcr->impl_->ff; + FindFilesPacket* ff = jcr->impl->ff; findFILESET* fileset = ff->fileset; int code, subcode; int state = fileset->state; @@ -300,10 +300,10 @@ void AddFileset(JobControlRecord* jcr, const char* item) } switch (code) { case 'I': - (void)new_include(jcr->impl_->ff->fileset); + (void)new_include(jcr->impl->ff->fileset); break; case 'E': - (void)new_exclude(jcr->impl_->ff->fileset); + (void)new_exclude(jcr->impl->ff->fileset); break; case 'N': /* Null */ state = state_none; @@ -370,18 +370,18 @@ bool TermFileset(JobControlRecord* jcr) { findFILESET* fileset; - fileset = jcr->impl_->ff->fileset; + fileset = jcr->impl->ff->fileset; #ifdef HAVE_WIN32 /* * Expand the fileset to include all drive letters when the fileset includes a * File = / entry. */ - if (!expand_win32_fileset(jcr->impl_->ff->fileset)) { return false; } + if (!expand_win32_fileset(jcr->impl->ff->fileset)) { return false; } /* * Exclude entries in NotToBackup registry key */ - if (!exclude_win32_not_to_backup_registry_entries(jcr, jcr->impl_->ff)) { + if (!exclude_win32_not_to_backup_registry_entries(jcr, jcr->impl->ff)) { return false; } #endif @@ -402,7 +402,7 @@ bool TermFileset(JobControlRecord* jcr) } } - return jcr->impl_->ff->fileset->state != state_error; + return jcr->impl->ff->fileset->state != state_error; } /** diff --git a/core/src/filed/heartbeat.cc b/core/src/filed/heartbeat.cc index 9f08a3c7fec..55db1916d25 100644 --- a/core/src/filed/heartbeat.cc +++ b/core/src/filed/heartbeat.cc @@ -67,9 +67,9 @@ extern "C" void* sd_heartbeat_thread(void* arg) sd.reset(jcr->store_bsock->clone()); dir.reset(jcr->dir_bsock->clone()); - jcr->impl_->hb_bsock = sd; - jcr->impl_->hb_started = true; - jcr->impl_->hb_dir_bsock = dir; + jcr->impl->hb_bsock = sd; + jcr->impl->hb_started = true; + jcr->impl->hb_dir_bsock = dir; dir->suppress_error_msgs_ = true; sd->suppress_error_msgs_ = true; @@ -104,9 +104,9 @@ extern "C" void* sd_heartbeat_thread(void* arg) sd->close(); dir->close(); - jcr->impl_->hb_bsock.reset(); - jcr->impl_->hb_started = false; - jcr->impl_->hb_dir_bsock = NULL; + jcr->impl->hb_bsock.reset(); + jcr->impl->hb_started = false; + jcr->impl->hb_dir_bsock = NULL; return NULL; } @@ -120,10 +120,10 @@ void StartHeartbeatMonitor(JobControlRecord* jcr) * make debugging impossible. */ if (!no_signals) { - jcr->impl_->hb_bsock = NULL; - jcr->impl_->hb_started = false; - jcr->impl_->hb_dir_bsock = NULL; - pthread_create(&jcr->impl_->heartbeat_id, NULL, sd_heartbeat_thread, + jcr->impl->hb_bsock = NULL; + jcr->impl->hb_started = false; + jcr->impl->hb_dir_bsock = NULL; + pthread_create(&jcr->impl->heartbeat_id, NULL, sd_heartbeat_thread, (void*)jcr); } } @@ -134,24 +134,24 @@ void StopHeartbeatMonitor(JobControlRecord* jcr) int cnt = 0; if (no_signals) { return; } /* Wait max 10 secs for heartbeat thread to start */ - while (!jcr->impl_->hb_started && cnt++ < 200) { + while (!jcr->impl->hb_started && cnt++ < 200) { Bmicrosleep(0, 50000); /* wait for start */ } - if (jcr->impl_->hb_started) { - jcr->impl_->hb_bsock->SetTimedOut(); /* set timed_out to Terminate read */ - jcr->impl_->hb_bsock->SetTerminated(); /* set to Terminate read */ + if (jcr->impl->hb_started) { + jcr->impl->hb_bsock->SetTimedOut(); /* set timed_out to Terminate read */ + jcr->impl->hb_bsock->SetTerminated(); /* set to Terminate read */ } - if (jcr->impl_->hb_dir_bsock) { - jcr->impl_->hb_dir_bsock + if (jcr->impl->hb_dir_bsock) { + jcr->impl->hb_dir_bsock ->SetTimedOut(); /* set timed_out to Terminate read */ - jcr->impl_->hb_dir_bsock->SetTerminated(); /* set to Terminate read */ + jcr->impl->hb_dir_bsock->SetTerminated(); /* set to Terminate read */ } - if (jcr->impl_->hb_started) { + if (jcr->impl->hb_started) { Dmsg0(100, "Send kill to heartbeat id\n"); - pthread_kill(jcr->impl_->heartbeat_id, + pthread_kill(jcr->impl->heartbeat_id, TIMEOUT_SIGNAL); /* make heartbeat thread go away */ Bmicrosleep(0, 50000); } @@ -160,20 +160,20 @@ void StopHeartbeatMonitor(JobControlRecord* jcr) /* * Wait max 100 secs for heartbeat thread to stop */ - while (jcr->impl_->hb_started && cnt++ < 200) { - pthread_kill(jcr->impl_->heartbeat_id, + while (jcr->impl->hb_started && cnt++ < 200) { + pthread_kill(jcr->impl->heartbeat_id, TIMEOUT_SIGNAL); /* make heartbeat thread go away */ Bmicrosleep(0, 500000); } - if (jcr->impl_->hb_bsock) { + if (jcr->impl->hb_bsock) { // delete jcr->impl_->hb_bsock; - jcr->impl_->hb_bsock.reset(); + jcr->impl->hb_bsock.reset(); } - if (jcr->impl_->hb_dir_bsock) { + if (jcr->impl->hb_dir_bsock) { // delete jcr->impl_->hb_dir_bsock; - jcr->impl_->hb_dir_bsock.reset(); + jcr->impl->hb_dir_bsock.reset(); } } @@ -195,8 +195,8 @@ extern "C" void* dir_heartbeat_thread(void* arg) */ dir = jcr->dir_bsock->clone(); - jcr->impl_->hb_bsock.reset(dir); - jcr->impl_->hb_started = true; + jcr->impl->hb_bsock.reset(dir); + jcr->impl->hb_started = true; dir->suppress_error_msgs_ = true; while (!dir->IsStop()) { @@ -212,8 +212,8 @@ extern "C" void* dir_heartbeat_thread(void* arg) Bmicrosleep(next, 0); } dir->close(); - jcr->impl_->hb_bsock.reset(); - jcr->impl_->hb_started = false; + jcr->impl->hb_bsock.reset(); + jcr->impl->hb_started = false; return NULL; } @@ -224,7 +224,7 @@ void StartDirHeartbeat(JobControlRecord* jcr) { if (me->heartbeat_interval) { jcr->dir_bsock->SetLocking(); - pthread_create(&jcr->impl_->heartbeat_id, NULL, dir_heartbeat_thread, + pthread_create(&jcr->impl->heartbeat_id, NULL, dir_heartbeat_thread, (void*)jcr); } } diff --git a/core/src/filed/restore.cc b/core/src/filed/restore.cc index 1bb553c586c..e8f0f14dd50 100644 --- a/core/src/filed/restore.cc +++ b/core/src/filed/restore.cc @@ -136,7 +136,7 @@ static int BcloseChksize(JobControlRecord* jcr, Qmsg3(jcr, M_WARNING, 0, _("Size of data or stream of %s not correct. Original %s, restored " "%s.\n"), - jcr->impl_->last_fname, edit_uint64(osize, ec1), + jcr->impl->last_fname, edit_uint64(osize, ec1), edit_uint64(fsize, ec2)); return -1; } @@ -155,16 +155,16 @@ static inline bool RestoreFinderinfo(JobControlRecord* jcr, attrList.commonattr = ATTR_CMN_FNDRINFO; Dmsg0(130, "Restoring Finder Info\n"); - SetBit(FO_HFSPLUS, jcr->impl_->ff->flags); + SetBit(FO_HFSPLUS, jcr->impl->ff->flags); if (buflen != 32) { Jmsg(jcr, M_WARNING, 0, _("Invalid length of Finder Info (got %d, not 32)\n"), buflen); return false; } - if (setattrlist(jcr->impl_->last_fname, &attrList, buf, buflen, 0) != 0) { + if (setattrlist(jcr->impl->last_fname, &attrList, buf, buflen, 0) != 0) { Jmsg(jcr, M_WARNING, 0, _("Could not set Finder Info on %s\n"), - jcr->impl_->last_fname); + jcr->impl->last_fname); return false; } @@ -223,14 +223,14 @@ static inline bool do_reStoreAcl(JobControlRecord* jcr, { bacl_exit_code retval; - jcr->impl_->acl_data->last_fname = jcr->impl_->last_fname; + jcr->impl->acl_data->last_fname = jcr->impl->last_fname; switch (stream) { case STREAM_ACL_PLUGIN: - retval = plugin_parse_acl_streams(jcr, jcr->impl_->acl_data, stream, + retval = plugin_parse_acl_streams(jcr, jcr->impl->acl_data, stream, content, content_length); break; default: - retval = parse_acl_streams(jcr, jcr->impl_->acl_data, stream, content, + retval = parse_acl_streams(jcr, jcr->impl->acl_data, stream, content, content_length); break; } @@ -244,11 +244,11 @@ static inline bool do_reStoreAcl(JobControlRecord* jcr, * ACL_REPORT_ERR_MAX_PER_JOB print the error message set by the lower * level routine in jcr->errmsg. */ - if (jcr->impl_->acl_data->u.parse->nr_errors < + if (jcr->impl->acl_data->u.parse->nr_errors < ACL_REPORT_ERR_MAX_PER_JOB) { Jmsg(jcr, M_WARNING, 0, "%s", jcr->errmsg); } - jcr->impl_->acl_data->u.parse->nr_errors++; + jcr->impl->acl_data->u.parse->nr_errors++; break; case bacl_exit_ok: break; @@ -268,14 +268,14 @@ static inline bool do_restore_xattr(JobControlRecord* jcr, { BxattrExitCode retval; - jcr->impl_->xattr_data->last_fname = jcr->impl_->last_fname; + jcr->impl->xattr_data->last_fname = jcr->impl->last_fname; switch (stream) { case STREAM_XATTR_PLUGIN: - retval = PluginParseXattrStreams(jcr, jcr->impl_->xattr_data, stream, + retval = PluginParseXattrStreams(jcr, jcr->impl->xattr_data, stream, content, content_length); break; default: - retval = ParseXattrStreams(jcr, jcr->impl_->xattr_data, stream, content, + retval = ParseXattrStreams(jcr, jcr->impl->xattr_data, stream, content, content_length); break; } @@ -288,7 +288,7 @@ static inline bool do_restore_xattr(JobControlRecord* jcr, break; case BxattrExitCode::kError: Jmsg(jcr, M_ERROR, 0, "%s", jcr->errmsg); - jcr->impl_->xattr_data->u.parse->nr_errors++; + jcr->impl->xattr_data->u.parse->nr_errors++; break; case BxattrExitCode::kSuccess: break; @@ -490,18 +490,18 @@ void DoRestore(JobControlRecord* jcr) binit(&rctx.forkbfd); attr = rctx.attr = new_attr(jcr); if (have_acl) { - jcr->impl_->acl_data = (acl_data_t*)malloc(sizeof(acl_data_t)); - memset(jcr->impl_->acl_data, 0, sizeof(acl_data_t)); - jcr->impl_->acl_data->u.parse = + jcr->impl->acl_data = (acl_data_t*)malloc(sizeof(acl_data_t)); + memset(jcr->impl->acl_data, 0, sizeof(acl_data_t)); + jcr->impl->acl_data->u.parse = (acl_parse_data_t*)malloc(sizeof(acl_parse_data_t)); - memset(jcr->impl_->acl_data->u.parse, 0, sizeof(acl_parse_data_t)); + memset(jcr->impl->acl_data->u.parse, 0, sizeof(acl_parse_data_t)); } if (have_xattr) { - jcr->impl_->xattr_data = (xattr_data_t*)malloc(sizeof(xattr_data_t)); - memset(jcr->impl_->xattr_data, 0, sizeof(xattr_data_t)); - jcr->impl_->xattr_data->u.parse = + jcr->impl->xattr_data = (xattr_data_t*)malloc(sizeof(xattr_data_t)); + memset(jcr->impl->xattr_data, 0, sizeof(xattr_data_t)); + jcr->impl->xattr_data->u.parse = (xattr_parse_data_t*)malloc(sizeof(xattr_parse_data_t)); - memset(jcr->impl_->xattr_data->u.parse, 0, sizeof(xattr_parse_data_t)); + memset(jcr->impl->xattr_data->u.parse, 0, sizeof(xattr_parse_data_t)); } while (BgetMsg(sd) >= 0 && !JobCanceled(jcr)) { @@ -610,20 +610,20 @@ void DoRestore(JobControlRecord* jcr) * Try to actually create the file, which returns a status telling * us if we need to extract or not. */ - jcr->impl_->num_files_examined++; + jcr->impl->num_files_examined++; rctx.extract = false; status = CF_CORE; /* By default, let Bareos's core handle it */ if (jcr->IsPlugin()) { - status = PluginCreateFile(jcr, attr, &rctx.bfd, jcr->impl_->replace); + status = PluginCreateFile(jcr, attr, &rctx.bfd, jcr->impl->replace); } if (status == CF_CORE) { - status = CreateFile(jcr, attr, &rctx.bfd, jcr->impl_->replace); + status = CreateFile(jcr, attr, &rctx.bfd, jcr->impl->replace); } jcr->lock(); - PmStrcpy(jcr->impl_->last_fname, attr->ofname); - jcr->impl_->last_type = attr->type; + PmStrcpy(jcr->impl->last_fname, attr->ofname); + jcr->impl->last_type = attr->type; jcr->unlock(); Dmsg2(130, "Outfile=%s CreateFile status=%d\n", attr->ofname, status); switch (status) { @@ -698,7 +698,7 @@ void DoRestore(JobControlRecord* jcr) /* * Do we have any keys at all? */ - if (!jcr->impl_->crypto.pki_recipients) { + if (!jcr->impl->crypto.pki_recipients) { Jmsg(jcr, M_ERROR, 0, _("No private decryption keys have been defined to decrypt " "encrypted backup data.\n")); @@ -707,11 +707,11 @@ void DoRestore(JobControlRecord* jcr) break; } - if (jcr->impl_->crypto.digest) { - CryptoDigestFree(jcr->impl_->crypto.digest); + if (jcr->impl->crypto.digest) { + CryptoDigestFree(jcr->impl->crypto.digest); } - jcr->impl_->crypto.digest = crypto_digest_new(jcr, signing_algorithm); - if (!jcr->impl_->crypto.digest) { + jcr->impl->crypto.digest = crypto_digest_new(jcr, signing_algorithm); + if (!jcr->impl->crypto.digest) { Jmsg0(jcr, M_FATAL, 0, _("Could not create digest.\n")); rctx.extract = false; bclose(&rctx.bfd); @@ -723,7 +723,7 @@ void DoRestore(JobControlRecord* jcr) */ cryptoerr = CryptoSessionDecode( (uint8_t*)sd->msg, (uint32_t)sd->message_length, - jcr->impl_->crypto.pki_recipients, &rctx.cs); + jcr->impl->crypto.pki_recipients, &rctx.cs); switch (cryptoerr) { case CRYPTO_ERROR_NONE: /* @@ -878,7 +878,7 @@ void DoRestore(JobControlRecord* jcr) case STREAM_MACOS_FORK_DATA: if (have_darwin_os) { ClearAllBits(FO_MAX, rctx.fork_flags); - SetBit(FO_HFSPLUS, jcr->impl_->ff->flags); + SetBit(FO_HFSPLUS, jcr->impl->ff->flags); if (rctx.stream == STREAM_ENCRYPTED_MACOS_FORK_DATA) { SetBit(FO_ENCRYPT, rctx.fork_flags); @@ -893,11 +893,11 @@ void DoRestore(JobControlRecord* jcr) if (rctx.extract) { if (rctx.prev_stream != rctx.stream) { - if (BopenRsrc(&rctx.forkbfd, jcr->impl_->last_fname, + if (BopenRsrc(&rctx.forkbfd, jcr->impl->last_fname, O_WRONLY | O_TRUNC | O_BINARY, 0) < 0) { Jmsg(jcr, M_WARNING, 0, _("Cannot open resource fork for %s.\n"), - jcr->impl_->last_fname); + jcr->impl->last_fname); rctx.extract = false; continue; } @@ -957,8 +957,8 @@ void DoRestore(JobControlRecord* jcr) * b) and it is not a directory (they are never "extracted") * c) or the file name is empty */ - if ((!rctx.extract && jcr->impl_->last_type != FT_DIREND) || - (*jcr->impl_->last_fname == 0)) { + if ((!rctx.extract && jcr->impl->last_type != FT_DIREND) || + (*jcr->impl->last_fname == 0)) { break; } if (have_acl) { @@ -966,7 +966,7 @@ void DoRestore(JobControlRecord* jcr) * For anything that is not a directory we delay * the restore of acls till a later stage. */ - if (jcr->impl_->last_type != FT_DIREND) { + if (jcr->impl->last_type != FT_DIREND) { PushDelayedDataStream(rctx, sd); } else { if (!do_reStoreAcl(jcr, rctx.stream, sd->msg, sd->message_length)) { @@ -995,8 +995,8 @@ void DoRestore(JobControlRecord* jcr) * b) and it is not a directory (they are never "extracted") * c) or the file name is empty */ - if ((!rctx.extract && jcr->impl_->last_type != FT_DIREND) || - (*jcr->impl_->last_fname == 0)) { + if ((!rctx.extract && jcr->impl->last_type != FT_DIREND) || + (*jcr->impl->last_fname == 0)) { break; } if (have_xattr) { @@ -1004,7 +1004,7 @@ void DoRestore(JobControlRecord* jcr) * For anything that is not a directory we delay * the restore of xattr till a later stage. */ - if (jcr->impl_->last_type != FT_DIREND) { + if (jcr->impl->last_type != FT_DIREND) { PushDelayedDataStream(rctx, sd); } else { if (!do_restore_xattr(jcr, rctx.stream, sd->msg, @@ -1024,8 +1024,8 @@ void DoRestore(JobControlRecord* jcr) * b) and it is not a directory (they are never "extracted") * c) or the file name is empty */ - if ((!rctx.extract && jcr->impl_->last_type != FT_DIREND) || - (*jcr->impl_->last_fname == 0)) { + if ((!rctx.extract && jcr->impl->last_type != FT_DIREND) || + (*jcr->impl->last_fname == 0)) { break; } if (have_xattr) { @@ -1056,7 +1056,7 @@ void DoRestore(JobControlRecord* jcr) (uint32_t)sd->message_length)) == NULL) { Jmsg1(jcr, M_ERROR, 0, _("Failed to decode message signature for %s\n"), - jcr->impl_->last_fname); + jcr->impl->last_fname); } break; @@ -1121,15 +1121,15 @@ void DoRestore(JobControlRecord* jcr) */ Dmsg2(10, "End Do Restore. Files=%d Bytes=%s\n", jcr->JobFiles, edit_uint64(jcr->JobBytes, ec1)); - if (have_acl && jcr->impl_->acl_data->u.parse->nr_errors > 0) { + if (have_acl && jcr->impl->acl_data->u.parse->nr_errors > 0) { Jmsg(jcr, M_WARNING, 0, _("Encountered %ld acl errors while doing restore\n"), - jcr->impl_->acl_data->u.parse->nr_errors); + jcr->impl->acl_data->u.parse->nr_errors); } - if (have_xattr && jcr->impl_->xattr_data->u.parse->nr_errors > 0) { + if (have_xattr && jcr->impl->xattr_data->u.parse->nr_errors > 0) { Jmsg(jcr, M_WARNING, 0, _("Encountered %ld xattr errors while doing restore\n"), - jcr->impl_->xattr_data->u.parse->nr_errors); + jcr->impl->xattr_data->u.parse->nr_errors); } if (non_support_data > 1 || non_support_attr > 1) { Jmsg(jcr, M_WARNING, 0, @@ -1163,9 +1163,9 @@ void DoRestore(JobControlRecord* jcr) */ FreeSignature(rctx); FreeSession(rctx); - if (jcr->impl_->crypto.digest) { - CryptoDigestFree(jcr->impl_->crypto.digest); - jcr->impl_->crypto.digest = NULL; + if (jcr->impl->crypto.digest) { + CryptoDigestFree(jcr->impl->crypto.digest); + jcr->impl->crypto.digest = NULL; } /* @@ -1193,16 +1193,16 @@ void DoRestore(JobControlRecord* jcr) rctx.fork_cipher_ctx.buf = NULL; } - if (have_acl && jcr->impl_->acl_data) { - free(jcr->impl_->acl_data->u.parse); - free(jcr->impl_->acl_data); - jcr->impl_->acl_data = NULL; + if (have_acl && jcr->impl->acl_data) { + free(jcr->impl->acl_data->u.parse); + free(jcr->impl->acl_data); + jcr->impl->acl_data = NULL; } - if (have_xattr && jcr->impl_->xattr_data) { - free(jcr->impl_->xattr_data->u.parse); - free(jcr->impl_->xattr_data); - jcr->impl_->xattr_data = NULL; + if (have_xattr && jcr->impl->xattr_data) { + free(jcr->impl->xattr_data->u.parse); + free(jcr->impl->xattr_data); + jcr->impl->xattr_data = NULL; } /* @@ -1223,7 +1223,7 @@ void DoRestore(JobControlRecord* jcr) int DoFileDigest(JobControlRecord* jcr, FindFilesPacket* ff_pkt, bool top_level) { Dmsg1(50, "DoFileDigest jcr=%p\n", jcr); - return (DigestFile(jcr, ff_pkt, jcr->impl_->crypto.digest)); + return (DigestFile(jcr, ff_pkt, jcr->impl->crypto.digest)); } bool SparseData(JobControlRecord* jcr, @@ -1243,7 +1243,7 @@ bool SparseData(JobControlRecord* jcr, if (blseek(bfd, (boffset_t)*addr, SEEK_SET) < 0) { BErrNo be; Jmsg3(jcr, M_ERROR, 0, _("Seek to %s error on %s: ERR=%s\n"), - edit_uint64(*addr, ec1), jcr->impl_->last_fname, + edit_uint64(*addr, ec1), jcr->impl->last_fname, be.bstrerror(bfd->BErrNo)); return false; } @@ -1259,8 +1259,8 @@ bool StoreData(JobControlRecord* jcr, const int32_t length, bool win32_decomp) { - if (jcr->impl_->crypto.digest) { - CryptoDigestUpdate(jcr->impl_->crypto.digest, (uint8_t*)data, length); + if (jcr->impl->crypto.digest) { + CryptoDigestUpdate(jcr->impl->crypto.digest, (uint8_t*)data, length); } if (win32_decomp) { @@ -1268,7 +1268,7 @@ bool StoreData(JobControlRecord* jcr, BErrNo be; Jmsg2(jcr, M_ERROR, 0, _("Write error in Win32 Block Decomposition on %s: %s\n"), - jcr->impl_->last_fname, be.bstrerror(bfd->BErrNo)); + jcr->impl->last_fname, be.bstrerror(bfd->BErrNo)); return false; } #ifdef HAVE_WIN32 @@ -1278,21 +1278,21 @@ bool StoreData(JobControlRecord* jcr, (ssize_t)length) { BErrNo be; Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: %s\n"), - jcr->impl_->last_fname, be.bstrerror(bfd->BErrNo)); + jcr->impl->last_fname, be.bstrerror(bfd->BErrNo)); return false; } } else { if (bwrite(bfd, data, length) != (ssize_t)length) { BErrNo be; Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: %s\n"), - jcr->impl_->last_fname, be.bstrerror(bfd->BErrNo)); + jcr->impl->last_fname, be.bstrerror(bfd->BErrNo)); } } } #else } else if (bwrite(bfd, data, length) != (ssize_t)length) { BErrNo be; - Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: %s\n"), jcr->impl_->last_fname, + Jmsg2(jcr, M_ERROR, 0, _("Write error on %s: %s\n"), jcr->impl->last_fname, be.bstrerror(bfd->BErrNo)); return false; } @@ -1336,7 +1336,7 @@ int32_t ExtractData(JobControlRecord* jcr, } if (BitIsSet(FO_COMPRESS, flags)) { - if (!DecompressData(jcr, jcr->impl_->last_fname, stream, &wbuf, &wsize, + if (!DecompressData(jcr, jcr->impl->last_fname, stream, &wbuf, &wsize, false)) { goto bail_out; } @@ -1425,7 +1425,7 @@ static bool ClosePreviousStream(JobControlRecord* jcr, r_ctx& rctx) */ FreeSignature(rctx); FreeSession(rctx); - ClearAllBits(FO_MAX, rctx.jcr->impl_->ff->flags); + ClearAllBits(FO_MAX, rctx.jcr->impl->ff->flags); Dmsg0(130, "Stop extracting.\n"); } else if (IsBopen(&rctx.bfd)) { Jmsg0(rctx.jcr, M_ERROR, 0, diff --git a/core/src/filed/sd_cmds.cc b/core/src/filed/sd_cmds.cc index af780068c13..cd8f569105d 100644 --- a/core/src/filed/sd_cmds.cc +++ b/core/src/filed/sd_cmds.cc @@ -97,8 +97,8 @@ void* handle_stored_connection(BareosSocket* sd) } if (!jcr->max_bandwidth) { - if (jcr->impl_->director->max_bandwidth_per_job) { - jcr->max_bandwidth = jcr->impl_->director->max_bandwidth_per_job; + if (jcr->impl->director->max_bandwidth_per_job) { + jcr->max_bandwidth = jcr->impl->director->max_bandwidth_per_job; } else if (me->max_bandwidth_per_job) { jcr->max_bandwidth = me->max_bandwidth_per_job; } diff --git a/core/src/filed/status.cc b/core/src/filed/status.cc index 9d611aeff35..7dd3d6f3ae5 100644 --- a/core/src/filed/status.cc +++ b/core/src/filed/status.cc @@ -182,7 +182,7 @@ static void ListRunningJobsPlain(StatusPacket* sp) #ifdef WIN32_VSS len = Mmsg( msg, _(" %s%s %s Job started: %s\n"), - (njcr->impl_->pVSSClient && njcr->impl_->pVSSClient->IsInitialized()) + (njcr->impl->pVSSClient && njcr->impl->pVSSClient->IsInitialized()) ? "VSS " : "", JobLevelToString(njcr->getJobLevel()), @@ -192,9 +192,9 @@ static void ListRunningJobsPlain(StatusPacket* sp) JobLevelToString(njcr->getJobLevel()), job_type_to_str(njcr->getJobType()), dt); #endif - } else if ((njcr->JobId == 0) && (njcr->impl_->director)) { + } else if ((njcr->JobId == 0) && (njcr->impl->director)) { len = Mmsg(msg, _("%s (director) connected at: %s\n"), - njcr->impl_->director->resource_name_, dt); + njcr->impl->director->resource_name_, dt); } else { /* * This should only occur shortly, until the JobControlRecord values are @@ -216,11 +216,11 @@ static void ListRunningJobsPlain(StatusPacket* sp) edit_uint64_with_commas(njcr->max_bandwidth, b4)); sendit(msg, len, sp); len = Mmsg(msg, _(" Files Examined=%s\n"), - edit_uint64_with_commas(njcr->impl_->num_files_examined, b1)); + edit_uint64_with_commas(njcr->impl->num_files_examined, b1)); sendit(msg, len, sp); if (njcr->JobFiles > 0) { njcr->lock(); - len = Mmsg(msg, _(" Processing file: %s\n"), njcr->impl_->last_fname); + len = Mmsg(msg, _(" Processing file: %s\n"), njcr->impl->last_fname); njcr->unlock(); sendit(msg, len, sp); } @@ -266,7 +266,7 @@ static void ListRunningJobsApi(StatusPacket* sp) #ifdef WIN32_VSS len = Mmsg( msg, " VSS=%d\n Level=%c\n JobType=%c\n JobStarted=%s\n", - (njcr->impl_->pVSSClient && njcr->impl_->pVSSClient->IsInitialized()) + (njcr->impl->pVSSClient && njcr->impl->pVSSClient->IsInitialized()) ? 1 : 0, njcr->getJobLevel(), njcr->getJobType(), dt); @@ -288,11 +288,11 @@ static void ListRunningJobsApi(StatusPacket* sp) edit_int64(njcr->max_bandwidth, b4)); sendit(msg, len, sp); len = Mmsg(msg, " Files Examined=%s\n", - edit_uint64(njcr->impl_->num_files_examined, b1)); + edit_uint64(njcr->impl->num_files_examined, b1)); sendit(msg, len, sp); if (njcr->JobFiles > 0) { njcr->lock(); - len = Mmsg(msg, " Processing file=%s\n", njcr->impl_->last_fname); + len = Mmsg(msg, " Processing file=%s\n", njcr->impl->last_fname); njcr->unlock(); sendit(msg, len, sp); } diff --git a/core/src/filed/verify.cc b/core/src/filed/verify.cc index 5379754dba3..394aa937903 100644 --- a/core/src/filed/verify.cc +++ b/core/src/filed/verify.cc @@ -66,20 +66,20 @@ void DoVerify(JobControlRecord* jcr) { jcr->setJobStatus(JS_Running); jcr->buf_size = DEFAULT_NETWORK_BUFFER_SIZE; - if ((jcr->impl_->big_buf = (char*)malloc(jcr->buf_size)) == NULL) { + if ((jcr->impl->big_buf = (char*)malloc(jcr->buf_size)) == NULL) { Jmsg1(jcr, M_ABORT, 0, _("Cannot malloc %d network read buffer\n"), DEFAULT_NETWORK_BUFFER_SIZE); } - SetFindOptions((FindFilesPacket*)jcr->impl_->ff, jcr->impl_->incremental, - jcr->impl_->mtime); + SetFindOptions((FindFilesPacket*)jcr->impl->ff, jcr->impl->incremental, + jcr->impl->mtime); Dmsg0(10, "Start find files\n"); /* Subroutine VerifyFile() is called for each file */ - FindFiles(jcr, (FindFilesPacket*)jcr->impl_->ff, VerifyFile, NULL); + FindFiles(jcr, (FindFilesPacket*)jcr->impl->ff, VerifyFile, NULL); Dmsg0(10, "End find files\n"); - if (jcr->impl_->big_buf) { - free(jcr->impl_->big_buf); - jcr->impl_->big_buf = NULL; + if (jcr->impl->big_buf) { + free(jcr->impl->big_buf); + jcr->impl->big_buf = NULL; } jcr->setJobStatus(JS_Terminated); } @@ -100,7 +100,7 @@ static int VerifyFile(JobControlRecord* jcr, if (JobCanceled(jcr)) { return 0; } dir = jcr->dir_bsock; - jcr->impl_->num_files_examined++; /* bump total file count */ + jcr->impl->num_files_examined++; /* bump total file count */ switch (ff_pkt->type) { case FT_LNKSAVED: /* Hard linked, file already saved */ @@ -116,7 +116,7 @@ static int VerifyFile(JobControlRecord* jcr, Dmsg2(30, "FT_LNK saving: %s -> %s\n", ff_pkt->fname, ff_pkt->link); break; case FT_DIRBEGIN: - jcr->impl_->num_files_examined--; /* correct file count */ + jcr->impl->num_files_examined--; /* correct file count */ return 1; /* ignored */ case FT_REPARSE: case FT_JUNCTION: @@ -201,7 +201,7 @@ static int VerifyFile(JobControlRecord* jcr, jcr->lock(); jcr->JobFiles++; /* increment number of files sent */ - PmStrcpy(jcr->impl_->last_fname, ff_pkt->fname); + PmStrcpy(jcr->impl->last_fname, ff_pkt->fname); jcr->unlock(); /* @@ -343,7 +343,7 @@ static int ReadDigest(BareosWinFilePacket* bfd, char buf[DEFAULT_NETWORK_BUFFER_SIZE]; int64_t n; int64_t bufsiz = (int64_t)sizeof(buf); - FindFilesPacket* ff_pkt = (FindFilesPacket*)jcr->impl_->ff; + FindFilesPacket* ff_pkt = (FindFilesPacket*)jcr->impl->ff; uint64_t fileAddr = 0; /* file address */ @@ -373,10 +373,10 @@ static int ReadDigest(BareosWinFilePacket* bfd, if (n < 0) { BErrNo be; be.SetErrno(bfd->BErrNo); - Dmsg2(100, "Error reading file %s: ERR=%s\n", jcr->impl_->last_fname, + Dmsg2(100, "Error reading file %s: ERR=%s\n", jcr->impl->last_fname, be.bstrerror()); Jmsg(jcr, M_ERROR, 1, _("Error reading file %s: ERR=%s\n"), - jcr->impl_->last_fname, be.bstrerror()); + jcr->impl->last_fname, be.bstrerror()); jcr->JobErrors++; return -1; } diff --git a/core/src/filed/verify_vol.cc b/core/src/filed/verify_vol.cc index aa1249e9490..de571e2b056 100644 --- a/core/src/filed/verify_vol.cc +++ b/core/src/filed/verify_vol.cc @@ -173,8 +173,8 @@ void DoVerifyVolume(JobControlRecord* jcr) } jcr->lock(); jcr->JobFiles++; - jcr->impl_->num_files_examined++; - PmStrcpy(jcr->impl_->last_fname, fname); /* last file examined */ + jcr->impl->num_files_examined++; + PmStrcpy(jcr->impl->last_fname, fname); /* last file examined */ jcr->unlock(); /* @@ -256,7 +256,7 @@ void DoVerifyVolume(JobControlRecord* jcr) case STREAM_RESTORE_OBJECT: jcr->lock(); jcr->JobFiles++; - jcr->impl_->num_files_examined++; + jcr->impl->num_files_examined++; jcr->unlock(); Dmsg2(400, "send inx=%d STREAM_RESTORE_OBJECT-%d\n", jcr->JobFiles, diff --git a/core/src/include/jcr.h b/core/src/include/jcr.h index 67d177e7c07..ab655c39fa4 100644 --- a/core/src/include/jcr.h +++ b/core/src/include/jcr.h @@ -367,7 +367,7 @@ class JobControlRecord { htable* path_list{}; /**< Directory list (used by findlib) */ bool is_passive_client_connection_probing{}; /**< Set if director probes a passive client connection */ - JobControlRecordPrivate* impl_{nullptr}; /* Pointer to implementation of each daemon */ + JobControlRecordPrivate* impl{nullptr}; /* Pointer to implementation of each daemon */ }; /* clang-format on */ diff --git a/core/src/plugins/stored/scsicrypto-sd.cc b/core/src/plugins/stored/scsicrypto-sd.cc index 07b3784055d..42f2796a6be 100644 --- a/core/src/plugins/stored/scsicrypto-sd.cc +++ b/core/src/plugins/stored/scsicrypto-sd.cc @@ -366,8 +366,8 @@ static bRC do_set_scsi_encryption_key(void* value) * has been wrapped using RFC3394 key wrapping. We first copy the current * wrapped key into a temporary variable for unwrapping. */ - if (dcr->jcr && dcr->jcr->impl_->director) { - director = dcr->jcr->impl_->director; + if (dcr->jcr && dcr->jcr->impl->director) { + director = dcr->jcr->impl->director; if (director->keyencrkey.value) { char WrappedVolEncrKey[MAX_NAME_LENGTH]; diff --git a/core/src/stored/acquire.cc b/core/src/stored/acquire.cc index 2fa5e2a110b..21034efb902 100644 --- a/core/src/stored/acquire.cc +++ b/core/src/stored/acquire.cc @@ -113,7 +113,7 @@ bool AcquireDeviceForRead(DeviceControlRecord* dcr) } /* Find next Volume, if any */ - vol = jcr->impl_->VolList; + vol = jcr->impl->VolList; if (!vol) { char ed1[50]; Jmsg(jcr, M_FATAL, 0, @@ -121,12 +121,12 @@ bool AcquireDeviceForRead(DeviceControlRecord* dcr) edit_int64(jcr->JobId, ed1)); goto get_out; } - jcr->impl_->CurReadVolume++; - for (i = 1; i < jcr->impl_->CurReadVolume; i++) { vol = vol->next; } + jcr->impl->CurReadVolume++; + for (i = 1; i < jcr->impl->CurReadVolume; i++) { vol = vol->next; } if (!vol) { Jmsg(jcr, M_FATAL, 0, _("Logic error: no next volume to read. Numvol=%d Curvol=%d\n"), - jcr->impl_->NumReadVolumes, jcr->impl_->CurReadVolume); + jcr->impl->NumReadVolumes, jcr->impl->CurReadVolume); goto get_out; /* should not happen */ } SetDcrFromVol(dcr, vol); @@ -167,8 +167,8 @@ bool AcquireDeviceForRead(DeviceControlRecord* dcr) LockReservations(); memset(&rctx, 0, sizeof(ReserveContext)); rctx.jcr = jcr; - jcr->impl_->read_dcr = dcr; - jcr->impl_->reserve_msgs = new alist(10, not_owned_by_alist); + jcr->impl->read_dcr = dcr; + jcr->impl->reserve_msgs = new alist(10, not_owned_by_alist); rctx.any_drive = true; rctx.device_name = vol->device; store = new DirectorStorage; @@ -509,7 +509,7 @@ DeviceControlRecord* AcquireDeviceForAppend(DeviceControlRecord* dcr) } dev->num_writers++; /* we are now a writer */ - if (jcr->impl_->NumWriteVolumes == 0) { jcr->impl_->NumWriteVolumes = 1; } + if (jcr->impl->NumWriteVolumes == 0) { jcr->impl->NumWriteVolumes = 1; } dev->VolCatInfo.VolCatJobs++; /* increment number of jobs on vol */ Dmsg4(100, "=== nwriters=%d nres=%d vcatjob=%d dev=%s\n", dev->num_writers, dev->NumReserved(), dev->VolCatInfo.VolCatJobs, dev->print_name()); @@ -783,8 +783,8 @@ void SetupNewDcrDevice(JobControlRecord* jcr, /* * Use job spoolsize prior to device spoolsize */ - if (jcr && jcr->impl_->spool_size) { - dcr->max_job_spool_size = jcr->impl_->spool_size; + if (jcr && jcr->impl->spool_size) { + dcr->max_job_spool_size = jcr->impl->spool_size; } else { dcr->max_job_spool_size = dev->device->max_job_spool_size; } @@ -877,9 +877,9 @@ void FreeDeviceControlRecord(DeviceControlRecord* dcr) if (dcr->rec) { FreeRecord(dcr->rec); } - if (jcr && jcr->impl_->dcr == dcr) { jcr->impl_->dcr = NULL; } + if (jcr && jcr->impl->dcr == dcr) { jcr->impl->dcr = NULL; } - if (jcr && jcr->impl_->read_dcr == dcr) { jcr->impl_->read_dcr = NULL; } + if (jcr && jcr->impl->read_dcr == dcr) { jcr->impl->read_dcr = NULL; } V(dcr->mutex_); diff --git a/core/src/stored/append.cc b/core/src/stored/append.cc index 0e9d18fe842..1b42dcb2ae5 100644 --- a/core/src/stored/append.cc +++ b/core/src/stored/append.cc @@ -61,7 +61,7 @@ bool DoAppendData(JobControlRecord* jcr, BareosSocket* bs, const char* what) int32_t n, file_index, stream, last_file_index, job_elapsed; bool ok = true; char buf1[100]; - DeviceControlRecord* dcr = jcr->impl_->dcr; + DeviceControlRecord* dcr = jcr->impl->dcr; Device* dev; POOLMEM* rec_data; char ec[50]; @@ -363,11 +363,11 @@ bool SendAttrsToDir(JobControlRecord* jcr, DeviceRecord* rec) rec->maskedStream == STREAM_UNIX_ATTRIBUTES_EX || rec->maskedStream == STREAM_RESTORE_OBJECT || CryptoDigestStreamType(rec->maskedStream) != CRYPTO_DIGEST_NONE) { - if (!jcr->impl_->no_attributes) { + if (!jcr->impl->no_attributes) { BareosSocket* dir = jcr->dir_bsock; if (AreAttributesSpooled(jcr)) { dir->SetSpooling(); } Dmsg0(850, "Send attributes to dir.\n"); - if (!jcr->impl_->dcr->DirUpdateFileAttributes(rec)) { + if (!jcr->impl->dcr->DirUpdateFileAttributes(rec)) { Jmsg(jcr, M_FATAL, 0, _("Error updating file attributes. ERR=%s\n"), dir->bstrerror()); dir->ClearSpooling(); diff --git a/core/src/stored/authenticate.cc b/core/src/stored/authenticate.cc index 9d0b50831e3..394d178e472 100644 --- a/core/src/stored/authenticate.cc +++ b/core/src/stored/authenticate.cc @@ -89,7 +89,7 @@ bool AuthenticateDirector(JobControlRecord* jcr) UnbashSpaces(dirname); director = (DirectorResource*)my_config->GetResWithName(R_DIRECTOR, dirname); - jcr->impl_->director = director; + jcr->impl->director = director; if (!director) { Dmsg2(debuglevel, "Connection from unknown Director %s at %s rejected.\n", diff --git a/core/src/stored/bcopy.cc b/core/src/stored/bcopy.cc index 7d81fb24996..5c468b8d93b 100644 --- a/core/src/stored/bcopy.cc +++ b/core/src/stored/bcopy.cc @@ -208,9 +208,9 @@ int main(int argc, char* argv[]) true); /* read device */ if (!in_jcr) { exit(1); } - in_jcr->impl_->ignore_label_errors = ignore_label_errors; + in_jcr->impl->ignore_label_errors = ignore_label_errors; - in_dev = in_jcr->impl_->dcr->dev; + in_dev = in_jcr->impl->dcr->dev; if (!in_dev) { exit(1); } /* @@ -223,7 +223,7 @@ int main(int argc, char* argv[]) false); /* write device */ if (!out_jcr) { exit(1); } - out_dev = out_jcr->impl_->dcr->dev; + out_dev = out_jcr->impl->dcr->dev; if (!out_dev) { exit(1); } Dmsg0(100, "About to acquire device for writing\n"); @@ -232,22 +232,22 @@ int main(int argc, char* argv[]) * For we must now acquire the device for writing */ out_dev->rLock(false); - if (!out_dev->open(out_jcr->impl_->dcr, OPEN_READ_WRITE)) { + if (!out_dev->open(out_jcr->impl->dcr, OPEN_READ_WRITE)) { Emsg1(M_FATAL, 0, _("dev open failed: %s\n"), out_dev->errmsg); out_dev->Unlock(); exit(1); } out_dev->Unlock(); - if (!AcquireDeviceForAppend(out_jcr->impl_->dcr)) { + if (!AcquireDeviceForAppend(out_jcr->impl->dcr)) { FreeJcr(in_jcr); exit(1); } - out_block = out_jcr->impl_->dcr->block; + out_block = out_jcr->impl->dcr->block; - ok = ReadRecords(in_jcr->impl_->dcr, RecordCb, MountNextReadVolume); + ok = ReadRecords(in_jcr->impl->dcr, RecordCb, MountNextReadVolume); if (ok || out_dev->CanWrite()) { - if (!out_jcr->impl_->dcr->WriteBlockToDevice()) { + if (!out_jcr->impl->dcr->WriteBlockToDevice()) { Pmsg0(000, _("Write of last block failed.\n")); } } @@ -306,10 +306,10 @@ static bool RecordCb(DeviceControlRecord* in_dcr, DeviceRecord* rec) /* Skipping record, because does not match BootStrapRecord filter */ return true; } - while (!WriteRecordToBlock(out_jcr->impl_->dcr, rec)) { + while (!WriteRecordToBlock(out_jcr->impl->dcr, rec)) { Dmsg2(150, "!WriteRecordToBlock data_len=%d rem=%d\n", rec->data_len, rec->remainder); - if (!out_jcr->impl_->dcr->WriteBlockToDevice()) { + if (!out_jcr->impl->dcr->WriteBlockToDevice()) { Dmsg2(90, "Got WriteBlockToDev error on device %s: ERR=%s\n", out_dev->print_name(), out_dev->bstrerror()); Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"), @@ -317,7 +317,7 @@ static bool RecordCb(DeviceControlRecord* in_dcr, DeviceRecord* rec) return false; } } - if (!out_jcr->impl_->dcr->WriteBlockToDevice()) { + if (!out_jcr->impl->dcr->WriteBlockToDevice()) { Dmsg2(90, "Got WriteBlockToDev error on device %s: ERR=%s\n", out_dev->print_name(), out_dev->bstrerror()); Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"), @@ -342,10 +342,10 @@ static bool RecordCb(DeviceControlRecord* in_dcr, DeviceRecord* rec) return true; } records++; - while (!WriteRecordToBlock(out_jcr->impl_->dcr, rec)) { + while (!WriteRecordToBlock(out_jcr->impl->dcr, rec)) { Dmsg2(150, "!WriteRecordToBlock data_len=%d rem=%d\n", rec->data_len, rec->remainder); - if (!out_jcr->impl_->dcr->WriteBlockToDevice()) { + if (!out_jcr->impl->dcr->WriteBlockToDevice()) { Dmsg2(90, "Got WriteBlockToDev error on device %s: ERR=%s\n", out_dev->print_name(), out_dev->bstrerror()); Jmsg(out_jcr, M_FATAL, 0, _("Cannot fixup device error. %s\n"), diff --git a/core/src/stored/bextract.cc b/core/src/stored/bextract.cc index 6b69b232a14..f9f60f8c0f1 100644 --- a/core/src/stored/bextract.cc +++ b/core/src/stored/bextract.cc @@ -403,9 +403,9 @@ static void DoExtract(char* devname) jcr = SetupJcr("bextract", devname, bsr, director, dcr, VolumeName, true); /* read device */ if (!jcr) { exit(1); } - dev = jcr->impl_->read_dcr->dev; + dev = jcr->impl->read_dcr->dev; if (!dev) { exit(1); } - dcr = jcr->impl_->read_dcr; + dcr = jcr->impl->read_dcr; /* * Make sure where directory exists and that it is a directory @@ -454,7 +454,7 @@ static void DoExtract(char* devname) CleanupCompression(jcr); - CleanDevice(jcr->impl_->dcr); + CleanDevice(jcr->impl->dcr); dev->term(); FreeDeviceControlRecord(dcr); FreeJcr(jcr); diff --git a/core/src/stored/bls.cc b/core/src/stored/bls.cc index 10a07135c96..37d4d6ea601 100644 --- a/core/src/stored/bls.cc +++ b/core/src/stored/bls.cc @@ -254,10 +254,10 @@ int main(int argc, char* argv[]) jcr = SetupJcr("bls", argv[i], bsr, director, dcr, VolumeName, true); /* read device */ if (!jcr) { exit(1); } - jcr->impl_->ignore_label_errors = ignore_label_errors; - dev = jcr->impl_->dcr->dev; + jcr->impl->ignore_label_errors = ignore_label_errors; + dev = jcr->impl->dcr->dev; if (!dev) { exit(1); } - dcr = jcr->impl_->dcr; + dcr = jcr->impl->dcr; rec = new_record(); attr = new_attr(jcr); /* @@ -290,9 +290,9 @@ static void do_close(JobControlRecord* jcr) { FreeAttr(attr); FreeRecord(rec); - CleanDevice(jcr->impl_->dcr); + CleanDevice(jcr->impl->dcr); dev->term(); - FreeDeviceControlRecord(jcr->impl_->dcr); + FreeDeviceControlRecord(jcr->impl->dcr); FreeJcr(jcr); } diff --git a/core/src/stored/bscan.cc b/core/src/stored/bscan.cc index 42c117bab87..2c9de8d65a7 100644 --- a/core/src/stored/bscan.cc +++ b/core/src/stored/bscan.cc @@ -343,7 +343,7 @@ int main(int argc, char* argv[]) dcr = new DeviceControlRecord; bjcr = SetupJcr("bscan", argv[0], bsr, director, dcr, VolumeName, true); if (!bjcr) { exit(1); } - dev = bjcr->impl_->read_dcr->dev; + dev = bjcr->impl->read_dcr->dev; if (showProgress) { char ed1[50]; @@ -386,9 +386,9 @@ int main(int argc, char* argv[]) } DbFlushBackends(); - CleanDevice(bjcr->impl_->dcr); + CleanDevice(bjcr->impl->dcr); dev->term(); - FreeDeviceControlRecord(bjcr->impl_->dcr); + FreeDeviceControlRecord(bjcr->impl->dcr); FreeJcr(bjcr); return 0; @@ -416,8 +416,8 @@ static bool BscanMountNextReadVolume(DeviceControlRecord* dcr) mdcr->EndBlock = dcr->EndBlock; mdcr->EndFile = dcr->EndFile; mdcr->VolMediaId = dcr->VolMediaId; - mjcr->impl_->read_dcr->VolLastIndex = dcr->VolLastIndex; - if (mjcr->impl_->insert_jobmedia_records) { + mjcr->impl->read_dcr->VolLastIndex = dcr->VolLastIndex; + if (mjcr->impl->insert_jobmedia_records) { if (!CreateJobmediaRecord(db, mjcr)) { Pmsg2(000, _("Could not create JobMedia record for Volume=%s Job=%s\n"), dev->getVolCatName(), mjcr->Job); @@ -464,7 +464,7 @@ static void do_scan() /* * Detach bscan's jcr as we are not a real Job on the tape */ - ReadRecords(bjcr->impl_->read_dcr, RecordCb, BscanMountNextReadVolume); + ReadRecords(bjcr->impl->read_dcr, RecordCb, BscanMountNextReadVolume); if (update_db) { db->WriteBatchFileRecords(bjcr); /* used by bulk batch file insert */ @@ -682,7 +682,7 @@ static bool RecordCb(DeviceControlRecord* dcr, DeviceRecord* rec) * Process label, if Job record exists don't update db */ mjcr = CreateJobRecord(db, &jr, &label, rec); - dcr = mjcr->impl_->read_dcr; + dcr = mjcr->impl->read_dcr; update_db = save_update_db; jr.PoolId = pr.PoolId; @@ -691,8 +691,8 @@ static bool RecordCb(DeviceControlRecord* dcr, DeviceRecord* rec) mjcr->client_name = GetPoolMemory(PM_FNAME); PmStrcpy(mjcr->client_name, label.ClientName); - mjcr->impl_->fileset_name = GetPoolMemory(PM_FNAME); - PmStrcpy(mjcr->impl_->fileset_name, label.FileSetName); + mjcr->impl->fileset_name = GetPoolMemory(PM_FNAME); + PmStrcpy(mjcr->impl->fileset_name, label.FileSetName); bstrncpy(dcr->pool_type, label.PoolType, sizeof(dcr->pool_type)); bstrncpy(dcr->pool_name, label.PoolName, sizeof(dcr->pool_name)); @@ -706,9 +706,9 @@ static bool RecordCb(DeviceControlRecord* dcr, DeviceRecord* rec) jr.JobId); db->SqlQuery(sql_buffer.c_str(), db_int64_handler, &jmr_count); if (jmr_count.value > 0) { - mjcr->impl_->insert_jobmedia_records = false; + mjcr->impl->insert_jobmedia_records = false; } else { - mjcr->impl_->insert_jobmedia_records = true; + mjcr->impl->insert_jobmedia_records = true; } if (rec->VolSessionId != jr.VolSessionId) { @@ -771,11 +771,11 @@ static bool RecordCb(DeviceControlRecord* dcr, DeviceRecord* rec) /* * Create JobMedia record */ - mjcr->impl_->read_dcr->VolLastIndex = dcr->VolLastIndex; - if (mjcr->impl_->insert_jobmedia_records) { + mjcr->impl->read_dcr->VolLastIndex = dcr->VolLastIndex; + if (mjcr->impl->insert_jobmedia_records) { CreateJobmediaRecord(db, mjcr); } - FreeDeviceControlRecord(mjcr->impl_->read_dcr); + FreeDeviceControlRecord(mjcr->impl->read_dcr); FreeJcr(mjcr); } break; @@ -832,7 +832,7 @@ static bool RecordCb(DeviceControlRecord* dcr, DeviceRecord* rec) } return true; } - dcr = mjcr->impl_->read_dcr; + dcr = mjcr->impl->read_dcr; if (dcr->VolFirstIndex == 0) { dcr->VolFirstIndex = block->FirstIndex; } /* @@ -1071,19 +1071,19 @@ static void BscanFreeJcr(JobControlRecord* jcr) if (jcr->RestoreBootstrap) { free(jcr->RestoreBootstrap); } - if (jcr->impl_->dcr) { - FreeDeviceControlRecord(jcr->impl_->dcr); - jcr->impl_->dcr = NULL; + if (jcr->impl->dcr) { + FreeDeviceControlRecord(jcr->impl->dcr); + jcr->impl->dcr = NULL; } - if (jcr->impl_->read_dcr) { - FreeDeviceControlRecord(jcr->impl_->read_dcr); - jcr->impl_->read_dcr = NULL; + if (jcr->impl->read_dcr) { + FreeDeviceControlRecord(jcr->impl->read_dcr); + jcr->impl->read_dcr = NULL; } - if (jcr->impl_) { - delete jcr->impl_; - jcr->impl_ = nullptr; + if (jcr->impl) { + delete jcr->impl; + jcr->impl = nullptr; } Dmsg0(200, "End bscan FreeJcr\n"); @@ -1101,7 +1101,7 @@ static bool CreateFileAttributesRecord(BareosDb* db, char* ap, DeviceRecord* rec) { - DeviceControlRecord* dcr = mjcr->impl_->read_dcr; + DeviceControlRecord* dcr = mjcr->impl->read_dcr; ar.fname = fname; ar.link = lname; ar.ClientId = mjcr->ClientId; @@ -1453,7 +1453,7 @@ static bool UpdateJobRecord(BareosDb* db, "Last Volume Bytes: %s\n" "Bareos binary info: %s\n" "Termination: %s\n\n"), - edt, mjcr->JobId, mjcr->Job, mjcr->impl_->fileset_name, + edt, mjcr->JobId, mjcr->Job, mjcr->impl->fileset_name, job_level_to_str(mjcr->getJobLevel()), mjcr->client_name, sdt, edt, edit_uint64_with_commas(mjcr->JobFiles, ec1), edit_uint64_with_commas(mjcr->JobBytes, ec2), mjcr->VolSessionId, @@ -1468,7 +1468,7 @@ static bool UpdateJobRecord(BareosDb* db, static bool CreateJobmediaRecord(BareosDb* db, JobControlRecord* mjcr) { JobMediaDbRecord jmr; - DeviceControlRecord* dcr = mjcr->impl_->read_dcr; + DeviceControlRecord* dcr = mjcr->impl->read_dcr; dcr->EndBlock = dev->EndBlock; dcr->EndFile = dev->EndFile; @@ -1550,7 +1550,7 @@ static JobControlRecord* create_jcr(JobDbRecord* jr, * the JobId and the ClientId. */ jobjcr = new_jcr(BscanFreeJcr); - jobjcr->impl_ = new JobControlRecordPrivate; + jobjcr->impl = new JobControlRecordPrivate; jobjcr->setJobType(jr->JobType); jobjcr->setJobLevel(jr->JobLevel); jobjcr->JobStatus = jr->JobStatus; @@ -1561,8 +1561,8 @@ static JobControlRecord* create_jcr(JobDbRecord* jr, jobjcr->VolSessionId = rec->VolSessionId; jobjcr->VolSessionTime = rec->VolSessionTime; jobjcr->ClientId = jr->ClientId; - jobjcr->impl_->dcr = jobjcr->impl_->read_dcr = new DeviceControlRecord; - SetupNewDcrDevice(jobjcr, jobjcr->impl_->dcr, dev, NULL); + jobjcr->impl->dcr = jobjcr->impl->read_dcr = new DeviceControlRecord; + SetupNewDcrDevice(jobjcr, jobjcr->impl->dcr, dev, NULL); return jobjcr; } diff --git a/core/src/stored/bsr.cc b/core/src/stored/bsr.cc index 7b5459c56c6..e4eaaf1c483 100644 --- a/core/src/stored/bsr.cc +++ b/core/src/stored/bsr.cc @@ -796,13 +796,13 @@ static VolumeList* new_restore_volume() */ static bool AddRestoreVolume(JobControlRecord* jcr, VolumeList* vol) { - VolumeList* next = jcr->impl_->VolList; + VolumeList* next = jcr->impl->VolList; /* Add volume to volume manager's read list */ AddReadVolume(jcr, vol->VolumeName); if (!next) { /* list empty ? */ - jcr->impl_->VolList = vol; /* yes, add volume */ + jcr->impl->VolList = vol; /* yes, add volume */ } else { /* Loop through all but last */ for (; next->next; next = next->next) { @@ -838,10 +838,10 @@ void CreateRestoreVolumeList(JobControlRecord* jcr) /* * Build a list of volumes to be processed */ - jcr->impl_->NumReadVolumes = 0; - jcr->impl_->CurReadVolume = 0; - if (jcr->impl_->bsr) { - BootStrapRecord* bsr = jcr->impl_->bsr; + jcr->impl->NumReadVolumes = 0; + jcr->impl->CurReadVolume = 0; + if (jcr->impl->bsr) { + BootStrapRecord* bsr = jcr->impl->bsr; if (!bsr->volume || !bsr->volume->VolumeName[0]) { return; } for (; bsr; bsr = bsr->next) { BsrVolume* bsrvol; @@ -861,7 +861,7 @@ void CreateRestoreVolumeList(JobControlRecord* jcr) vol->Slot = bsrvol->Slot; vol->start_file = sfile; if (AddRestoreVolume(jcr, vol)) { - jcr->impl_->NumReadVolumes++; + jcr->impl->NumReadVolumes++; Dmsg2(400, "Added volume=%s mediatype=%s\n", vol->VolumeName, vol->MediaType); } else { @@ -873,15 +873,15 @@ void CreateRestoreVolumeList(JobControlRecord* jcr) } } else { /* This is the old way -- deprecated */ - for (p = jcr->impl_->dcr->VolumeName; p && *p;) { + for (p = jcr->impl->dcr->VolumeName; p && *p;) { n = strchr(p, '|'); /* volume name separator */ if (n) { *n++ = 0; /* Terminate name */ } vol = new_restore_volume(); bstrncpy(vol->VolumeName, p, sizeof(vol->VolumeName)); - bstrncpy(vol->MediaType, jcr->impl_->dcr->media_type, + bstrncpy(vol->MediaType, jcr->impl->dcr->media_type, sizeof(vol->MediaType)); if (AddRestoreVolume(jcr, vol)) { - jcr->impl_->NumReadVolumes++; + jcr->impl->NumReadVolumes++; } else { free((char*)vol); } @@ -892,7 +892,7 @@ void CreateRestoreVolumeList(JobControlRecord* jcr) void FreeRestoreVolumeList(JobControlRecord* jcr) { - VolumeList* vol = jcr->impl_->VolList; + VolumeList* vol = jcr->impl->VolList; VolumeList* tmp; for (; vol;) { @@ -901,7 +901,7 @@ void FreeRestoreVolumeList(JobControlRecord* jcr) free(vol); vol = tmp; } - jcr->impl_->VolList = NULL; + jcr->impl->VolList = NULL; } } /* namespace storagedaemon */ diff --git a/core/src/stored/btape.cc b/core/src/stored/btape.cc index 48b931a6e47..0ffbbb4276c 100644 --- a/core/src/stored/btape.cc +++ b/core/src/stored/btape.cc @@ -311,7 +311,7 @@ int main(int margc, char* margv[]) false); /* write device */ if (!jcr) { exit(1); } - dev = jcr->impl_->dcr->dev; + dev = jcr->impl->dcr->dev; if (!dev) { exit(1); } if (!dev->IsTape()) { @@ -2173,7 +2173,7 @@ static void fillcmd() exit_code = 1; return; } - block = jcr->impl_->dcr->block; + block = jcr->impl->dcr->block; Dmsg0(100, "Just after AcquireDeviceForAppend\n"); /* @@ -2199,7 +2199,7 @@ static void fillcmd() /* * Generate data as if from File daemon, write to device */ - jcr->impl_->dcr->VolFirstIndex = 0; + jcr->impl->dcr->VolFirstIndex = 0; time(&jcr->run_time); /* start counting time for rates */ bstrftime(buf1, sizeof(buf1), jcr->run_time, "%H:%M:%S"); @@ -2345,15 +2345,15 @@ static void fillcmd() Pmsg3(0, _("\n\n%s Done filling tape at %d:%d. Now beginning re-read of " "tape ...\n"), - buf1, jcr->impl_->dcr->dev->file, jcr->impl_->dcr->dev->block_num); + buf1, jcr->impl->dcr->dev->file, jcr->impl->dcr->dev->block_num); } else { Pmsg3(0, _("\n\n%s Done filling tapes at %d:%d. Now beginning re-read of " "first tape ...\n"), - buf1, jcr->impl_->dcr->dev->file, jcr->impl_->dcr->dev->block_num); + buf1, jcr->impl->dcr->dev->file, jcr->impl->dcr->dev->block_num); } - jcr->impl_->dcr->block = block; + jcr->impl->dcr->block = block; if (!do_unfill()) { Pmsg0(000, _("do_unfill failed.\n")); exit_code = 1; @@ -2446,13 +2446,13 @@ static bool do_unfill() last_block = last_block1; FreeRestoreVolumeList(jcr); - jcr->impl_->bsr = NULL; + jcr->impl->bsr = NULL; bstrncpy(dcr->VolumeName, "TestVolume1|TestVolume2", sizeof(dcr->VolumeName)); CreateRestoreVolumeList(jcr); - if (jcr->impl_->VolList != NULL) { - jcr->impl_->VolList->Slot = 1; - if (jcr->impl_->VolList->next != NULL) { - jcr->impl_->VolList->next->Slot = 2; + if (jcr->impl->VolList != NULL) { + jcr->impl->VolList->Slot = 1; + if (jcr->impl->VolList->next != NULL) { + jcr->impl->VolList->next->Slot = 2; } } @@ -2473,7 +2473,7 @@ static bool do_unfill() dev->close(dcr); dev->num_writers = 0; - jcr->impl_->dcr->clear_will_write(); + jcr->impl->dcr->clear_will_write(); if (!AcquireDeviceForRead(dcr)) { Pmsg1(-1, "%s", dev->errmsg); @@ -2700,7 +2700,7 @@ static int FlushBlock(DeviceBlock* block, int dump) stop = -1; /* stop, but do simplified test */ } else { /* Full test in progress */ - if (!FixupDeviceBlockWriteError(jcr->impl_->dcr)) { + if (!FixupDeviceBlockWriteError(jcr->impl->dcr)) { Pmsg1(000, _("Cannot fixup device error. %s\n"), dev->bstrerror()); ok = false; dev->Unlock(); @@ -3066,7 +3066,7 @@ static bool MyMountNextReadVolume(DeviceControlRecord* dcr) static void SetVolumeName(const char* VolName, int volnum) { - DeviceControlRecord* dcr = jcr->impl_->dcr; + DeviceControlRecord* dcr = jcr->impl->dcr; volumename = VolName; vol_num = volnum; dev->setVolCatName(VolName); diff --git a/core/src/stored/butil.cc b/core/src/stored/butil.cc index 48aa4568890..60dc78f9cf7 100644 --- a/core/src/stored/butil.cc +++ b/core/src/stored/butil.cc @@ -69,28 +69,28 @@ JobControlRecord* SetupJcr(const char* name, bool readonly) { JobControlRecord* jcr = new_jcr(MyFreeJcr); - jcr->impl_ = new JobControlRecordPrivate; + jcr->impl = new JobControlRecordPrivate; - jcr->impl_->bsr = bsr; - jcr->impl_->director = director; + jcr->impl->bsr = bsr; + jcr->impl->director = director; jcr->VolSessionId = 1; jcr->VolSessionTime = (uint32_t)time(NULL); - jcr->impl_->NumReadVolumes = 0; - jcr->impl_->NumWriteVolumes = 0; + jcr->impl->NumReadVolumes = 0; + jcr->impl->NumWriteVolumes = 0; jcr->JobId = 0; jcr->setJobType(JT_CONSOLE); jcr->setJobLevel(L_FULL); jcr->JobStatus = JS_Terminated; jcr->where = strdup(""); - jcr->impl_->job_name = GetPoolMemory(PM_FNAME); - PmStrcpy(jcr->impl_->job_name, "Dummy.Job.Name"); + jcr->impl->job_name = GetPoolMemory(PM_FNAME); + PmStrcpy(jcr->impl->job_name, "Dummy.Job.Name"); jcr->client_name = GetPoolMemory(PM_FNAME); PmStrcpy(jcr->client_name, "Dummy.Client.Name"); bstrncpy(jcr->Job, name, sizeof(jcr->Job)); - jcr->impl_->fileset_name = GetPoolMemory(PM_FNAME); - PmStrcpy(jcr->impl_->fileset_name, "Dummy.fileset.name"); - jcr->impl_->fileset_md5 = GetPoolMemory(PM_FNAME); - PmStrcpy(jcr->impl_->fileset_md5, "Dummy.fileset.md5"); + jcr->impl->fileset_name = GetPoolMemory(PM_FNAME); + PmStrcpy(jcr->impl->fileset_name, "Dummy.fileset.name"); + jcr->impl->fileset_md5 = GetPoolMemory(PM_FNAME); + PmStrcpy(jcr->impl->fileset_md5, "Dummy.fileset.md5"); NewPlugins(jcr); /* instantiate plugins */ @@ -142,7 +142,7 @@ static bool setup_to_access_device(DeviceControlRecord* dcr, } else { VolName[0] = 0; } - if (!jcr->impl_->bsr && VolName[0] == 0) { + if (!jcr->impl->bsr && VolName[0] == 0) { if (!bstrncmp(dev_name, "/dev/", 5)) { /* Try stripping file part */ p = dev_name + strlen(dev_name); @@ -167,7 +167,7 @@ static bool setup_to_access_device(DeviceControlRecord* dcr, return false; } device->dev = dev; - jcr->impl_->dcr = dcr; + jcr->impl->dcr = dcr; SetupNewDcrDevice(jcr, dcr, dev, NULL); if (!readonly) { dcr->SetWillWrite(); } @@ -181,7 +181,7 @@ static bool setup_to_access_device(DeviceControlRecord* dcr, if (readonly) { /* read only access? */ Dmsg0(100, "Acquire device for read\n"); if (!AcquireDeviceForRead(dcr)) { return false; } - jcr->impl_->read_dcr = dcr; + jcr->impl->read_dcr = dcr; } else { if (!FirstOpenDevice(dcr)) { Jmsg1(jcr, M_FATAL, 0, _("Cannot open %s\n"), dev->print_name()); @@ -198,9 +198,9 @@ static bool setup_to_access_device(DeviceControlRecord* dcr, */ static void MyFreeJcr(JobControlRecord* jcr) { - if (jcr->impl_->job_name) { - FreePoolMemory(jcr->impl_->job_name); - jcr->impl_->job_name = NULL; + if (jcr->impl->job_name) { + FreePoolMemory(jcr->impl->job_name); + jcr->impl->job_name = NULL; } if (jcr->client_name) { @@ -208,14 +208,14 @@ static void MyFreeJcr(JobControlRecord* jcr) jcr->client_name = NULL; } - if (jcr->impl_->fileset_name) { - FreePoolMemory(jcr->impl_->fileset_name); - jcr->impl_->fileset_name = NULL; + if (jcr->impl->fileset_name) { + FreePoolMemory(jcr->impl->fileset_name); + jcr->impl->fileset_name = NULL; } - if (jcr->impl_->fileset_md5) { - FreePoolMemory(jcr->impl_->fileset_md5); - jcr->impl_->fileset_md5 = NULL; + if (jcr->impl->fileset_md5) { + FreePoolMemory(jcr->impl->fileset_md5); + jcr->impl->fileset_md5 = NULL; } if (jcr->comment) { @@ -223,16 +223,16 @@ static void MyFreeJcr(JobControlRecord* jcr) jcr->comment = NULL; } - if (jcr->impl_->VolList) { FreeRestoreVolumeList(jcr); } + if (jcr->impl->VolList) { FreeRestoreVolumeList(jcr); } - if (jcr->impl_->dcr) { - FreeDeviceControlRecord(jcr->impl_->dcr); - jcr->impl_->dcr = NULL; + if (jcr->impl->dcr) { + FreeDeviceControlRecord(jcr->impl->dcr); + jcr->impl->dcr = NULL; } - if (jcr->impl_) { - delete jcr->impl_; - jcr->impl_ = nullptr; + if (jcr->impl) { + delete jcr->impl; + jcr->impl = nullptr; } return; diff --git a/core/src/stored/dev.cc b/core/src/stored/dev.cc index 790cfc4096f..51aaf2e0882 100644 --- a/core/src/stored/dev.cc +++ b/core/src/stored/dev.cc @@ -447,23 +447,23 @@ void InitDeviceWaitTimers(DeviceControlRecord* dcr) dev->num_wait = 0; dev->poll = false; - jcr->impl_->min_wait = 60 * 60; - jcr->impl_->max_wait = 24 * 60 * 60; - jcr->impl_->max_num_wait = 9; /* 5 waits =~ 1 day, then 1 day at a time */ - jcr->impl_->wait_sec = jcr->impl_->min_wait; - jcr->impl_->rem_wait_sec = jcr->impl_->wait_sec; - jcr->impl_->num_wait = 0; + jcr->impl->min_wait = 60 * 60; + jcr->impl->max_wait = 24 * 60 * 60; + jcr->impl->max_num_wait = 9; /* 5 waits =~ 1 day, then 1 day at a time */ + jcr->impl->wait_sec = jcr->impl->min_wait; + jcr->impl->rem_wait_sec = jcr->impl->wait_sec; + jcr->impl->num_wait = 0; } void InitJcrDeviceWaitTimers(JobControlRecord* jcr) { /* ******FIXME******* put these on config variables */ - jcr->impl_->min_wait = 60 * 60; - jcr->impl_->max_wait = 24 * 60 * 60; - jcr->impl_->max_num_wait = 9; /* 5 waits =~ 1 day, then 1 day at a time */ - jcr->impl_->wait_sec = jcr->impl_->min_wait; - jcr->impl_->rem_wait_sec = jcr->impl_->wait_sec; - jcr->impl_->num_wait = 0; + jcr->impl->min_wait = 60 * 60; + jcr->impl->max_wait = 24 * 60 * 60; + jcr->impl->max_num_wait = 9; /* 5 waits =~ 1 day, then 1 day at a time */ + jcr->impl->wait_sec = jcr->impl->min_wait; + jcr->impl->rem_wait_sec = jcr->impl->wait_sec; + jcr->impl->num_wait = 0; } /** diff --git a/core/src/stored/device.cc b/core/src/stored/device.cc index 6b5a21e1e93..449fbede64b 100644 --- a/core/src/stored/device.cc +++ b/core/src/stored/device.cc @@ -173,7 +173,7 @@ bool FixupDeviceBlockWriteError(DeviceControlRecord* dcr, int retries) } /* Clear NewVol now because DirGetVolumeInfo() already done */ - jcr->impl_->dcr->NewVol = false; + jcr->impl->dcr->NewVol = false; SetNewVolumeParameters(dcr); jcr->run_time += time(NULL) - wait_time; /* correct run time for mount wait */ @@ -231,7 +231,7 @@ void SetNewVolumeParameters(DeviceControlRecord* dcr) Jmsg1(jcr, M_ERROR, 0, "%s", jcr->errmsg); } SetNewFileParameters(dcr); - jcr->impl_->NumWriteVolumes++; + jcr->impl->NumWriteVolumes++; dcr->NewVol = false; } @@ -313,9 +313,9 @@ BootStrapRecord* PositionDeviceToFirstFile(JobControlRecord* jcr, * Now find and position to first file and block * on this tape. */ - if (jcr->impl_->bsr) { - jcr->impl_->bsr->Reposition = true; /* force repositioning */ - bsr = find_next_bsr(jcr->impl_->bsr, dev); + if (jcr->impl->bsr) { + jcr->impl->bsr->Reposition = true; /* force repositioning */ + bsr = find_next_bsr(jcr->impl->bsr, dev); if (GetBsrStartAddr(bsr, &file, &block) > 0) { Jmsg(jcr, M_INFO, 0, _("Forward spacing Volume \"%s\" to file:block %u:%u.\n"), @@ -339,15 +339,15 @@ bool TryDeviceRepositioning(JobControlRecord* jcr, BootStrapRecord* bsr; Device* dev = dcr->dev; - bsr = find_next_bsr(jcr->impl_->bsr, dev); - if (bsr == NULL && jcr->impl_->bsr->mount_next_volume) { + bsr = find_next_bsr(jcr->impl->bsr, dev); + if (bsr == NULL && jcr->impl->bsr->mount_next_volume) { Dmsg0(500, "Would mount next volume here\n"); Dmsg2(500, "Current position (file:block) %u:%u\n", dev->file, dev->block_num); - jcr->impl_->bsr->mount_next_volume = false; + jcr->impl->bsr->mount_next_volume = false; if (!dev->AtEot()) { /* Set EOT flag to force mount of next Volume */ - jcr->impl_->mount_next_volume = true; + jcr->impl->mount_next_volume = true; dev->SetEot(); } rec->Block = 0; diff --git a/core/src/stored/dir_cmd.cc b/core/src/stored/dir_cmd.cc index d1eb69bd67d..3fb1edcf5c9 100644 --- a/core/src/stored/dir_cmd.cc +++ b/core/src/stored/dir_cmd.cc @@ -253,7 +253,7 @@ void* HandleDirectorConnection(BareosSocket* dir) /* * Initialize Start Job condition variable */ - errstat = pthread_cond_init(&jcr->impl_->job_start_wait, NULL); + errstat = pthread_cond_init(&jcr->impl->job_start_wait, NULL); if (errstat != 0) { BErrNo be; Jmsg1(jcr, M_FATAL, 0, @@ -265,7 +265,7 @@ void* HandleDirectorConnection(BareosSocket* dir) /* * Initialize End Job condition variable */ - errstat = pthread_cond_init(&jcr->impl_->job_end_wait, NULL); + errstat = pthread_cond_init(&jcr->impl->job_end_wait, NULL); if (errstat != 0) { BErrNo be; Jmsg1(jcr, M_FATAL, 0, _("Unable to init job end cond variable: ERR=%s\n"), @@ -304,7 +304,7 @@ void* HandleDirectorConnection(BareosSocket* dir) found = false; for (i = 0; cmds[i].cmd; i++) { if (bstrncmp(cmds[i].cmd, dir->msg, strlen(cmds[i].cmd))) { - if ((!cmds[i].monitoraccess) && (jcr->impl_->director->monitor)) { + if ((!cmds[i].monitoraccess) && (jcr->impl->director->monitor)) { Dmsg1(100, "Command \"%s\" is invalid.\n", cmds[i].cmd); dir->fsend(invalid_cmd); dir->signal(BNET_EOD); @@ -496,7 +496,7 @@ static bool CancelCmd(JobControlRecord* cjcr) Dmsg2(800, "Cancel JobId=%d %p\n", jcr->JobId, jcr); if (!jcr->authenticated && (oldStatus == JS_WaitFD || oldStatus == JS_WaitSD)) { - pthread_cond_signal(&jcr->impl_->job_start_wait); /* wake waiting thread */ + pthread_cond_signal(&jcr->impl->job_start_wait); /* wake waiting thread */ } if (jcr->file_bsock) { @@ -508,7 +508,7 @@ static bool CancelCmd(JobControlRecord* cjcr) /* * Still waiting for FD to connect, release it */ - pthread_cond_signal(&jcr->impl_->job_start_wait); /* wake waiting job */ + pthread_cond_signal(&jcr->impl->job_start_wait); /* wake waiting job */ Dmsg2(800, "Signal FD connect jid=%d %p\n", jcr->JobId, jcr); } } @@ -516,17 +516,17 @@ static bool CancelCmd(JobControlRecord* cjcr) /* * If thread waiting on mount, wake him */ - if (jcr->impl_->dcr && jcr->impl_->dcr->dev && - jcr->impl_->dcr->dev->waiting_for_mount()) { - pthread_cond_broadcast(&jcr->impl_->dcr->dev->wait_next_vol); + if (jcr->impl->dcr && jcr->impl->dcr->dev && + jcr->impl->dcr->dev->waiting_for_mount()) { + pthread_cond_broadcast(&jcr->impl->dcr->dev->wait_next_vol); Dmsg1(100, "JobId=%u broadcast wait_device_release\n", (uint32_t)jcr->JobId); ReleaseDeviceCond(); } - if (jcr->impl_->read_dcr && jcr->impl_->read_dcr->dev && - jcr->impl_->read_dcr->dev->waiting_for_mount()) { - pthread_cond_broadcast(&jcr->impl_->read_dcr->dev->wait_next_vol); + if (jcr->impl->read_dcr && jcr->impl->read_dcr->dev && + jcr->impl->read_dcr->dev->waiting_for_mount()) { + pthread_cond_broadcast(&jcr->impl->read_dcr->dev->wait_next_vol); Dmsg1(100, "JobId=%u broadcast wait_device_release\n", (uint32_t)jcr->JobId); ReleaseDeviceCond(); @@ -550,7 +550,7 @@ static bool CancelCmd(JobControlRecord* cjcr) } } - pthread_cond_signal(&jcr->impl_->job_end_wait); /* wake waiting job */ + pthread_cond_signal(&jcr->impl->job_end_wait); /* wake waiting job */ jcr->MyThreadSendSignal(TIMEOUT_SIGNAL); dir->fsend(_("3000 JobId=%ld Job=\"%s\" marked to be %s.\n"), jcr->JobId, @@ -1314,12 +1314,12 @@ static inline bool GetBootstrapFile(JobControlRecord* jcr, BareosSocket* sock) } fclose(bs); Dmsg0(10, "=== end bootstrap file ===\n"); - jcr->impl_->bsr = libbareos::parse_bsr(jcr, jcr->RestoreBootstrap); - if (!jcr->impl_->bsr) { + jcr->impl->bsr = libbareos::parse_bsr(jcr, jcr->RestoreBootstrap); + if (!jcr->impl->bsr) { Jmsg(jcr, M_FATAL, 0, _("Error parsing bootstrap file.\n")); goto bail_out; } - if (debug_level >= 10) { libbareos::DumpBsr(jcr->impl_->bsr, true); } + if (debug_level >= 10) { libbareos::DumpBsr(jcr->impl->bsr, true); } /* If we got a bootstrap, we are reading, so create read volume list */ CreateRestoreVolumeList(jcr); ok = true; @@ -1651,8 +1651,8 @@ static bool ReplicateCmd(JobControlRecord* jcr) storage_daemon_socket->SetSourceAddress(me->SDsrc_addr); if (!jcr->max_bandwidth) { - if (jcr->impl_->director->max_bandwidth_per_job) { - jcr->max_bandwidth = jcr->impl_->director->max_bandwidth_per_job; + if (jcr->impl->director->max_bandwidth_per_job) { + jcr->max_bandwidth = jcr->impl->director->max_bandwidth_per_job; } else if (me->max_bandwidth_per_job) { jcr->max_bandwidth = me->max_bandwidth_per_job; } @@ -1707,7 +1707,7 @@ static bool ReplicateCmd(JobControlRecord* jcr) connect_state(ReplicateCmdState::kAuthenticated); Dmsg0(110, "Authenticated with SD.\n"); - jcr->impl_->remote_replicate = true; + jcr->impl->remote_replicate = true; storage_daemon_socket.release(); /* jcr->store_bsock */ return dir->fsend(OK_replicate); @@ -1828,10 +1828,10 @@ static bool PluginoptionsCmd(JobControlRecord* jcr) } UnbashSpaces(plugin_options); - if (!jcr->impl_->plugin_options) { - jcr->impl_->plugin_options = new alist(10, owned_by_alist); + if (!jcr->impl->plugin_options) { + jcr->impl->plugin_options = new alist(10, owned_by_alist); } - jcr->impl_->plugin_options->append(strdup(plugin_options)); + jcr->impl->plugin_options->append(strdup(plugin_options)); /* * Send OK to Director diff --git a/core/src/stored/fd_cmds.cc b/core/src/stored/fd_cmds.cc index 82176b42d75..dd8d1ab1251 100644 --- a/core/src/stored/fd_cmds.cc +++ b/core/src/stored/fd_cmds.cc @@ -154,7 +154,7 @@ void* HandleFiledConnection(BareosSocket* fd, char* job_name) UpdateJobStatistics(jcr, now); } - pthread_cond_signal(&jcr->impl_->job_start_wait); /* wake waiting job */ + pthread_cond_signal(&jcr->impl->job_start_wait); /* wake waiting job */ FreeJcr(jcr); return NULL; @@ -263,7 +263,7 @@ static bool AppendDataCmd(JobControlRecord* jcr) BareosSocket* fd = jcr->file_bsock; Dmsg1(120, "Append data: %s", fd->msg); - if (jcr->impl_->session_opened) { + if (jcr->impl->session_opened) { Dmsg1(110, "msg); jcr->setJobType(JT_BACKUP); if (DoAppendData(jcr, fd, "FD")) { @@ -285,7 +285,7 @@ static bool AppendEndSession(JobControlRecord* jcr) BareosSocket* fd = jcr->file_bsock; Dmsg1(120, "storedmsg); - if (!jcr->impl_->session_opened) { + if (!jcr->impl->session_opened) { PmStrcpy(jcr->errmsg, _("Attempt to close non-open session.\n")); fd->fsend(NOT_opened); return false; @@ -301,13 +301,13 @@ static bool AppendOpenSession(JobControlRecord* jcr) BareosSocket* fd = jcr->file_bsock; Dmsg1(120, "Append open session: %s", fd->msg); - if (jcr->impl_->session_opened) { + if (jcr->impl->session_opened) { PmStrcpy(jcr->errmsg, _("Attempt to open already open session.\n")); fd->fsend(NO_open); return false; } - jcr->impl_->session_opened = true; + jcr->impl->session_opened = true; /* Send "Ticket" to File Daemon */ fd->fsend(OK_open, jcr->VolSessionId); @@ -326,7 +326,7 @@ static bool AppendCloseSession(JobControlRecord* jcr) BareosSocket* fd = jcr->file_bsock; Dmsg1(120, "msg); - if (!jcr->impl_->session_opened) { + if (!jcr->impl->session_opened) { PmStrcpy(jcr->errmsg, _("Attempt to close non-open session.\n")); fd->fsend(NOT_opened); return false; @@ -340,7 +340,7 @@ static bool AppendCloseSession(JobControlRecord* jcr) fd->signal(BNET_EOD); /* send EOD to File daemon */ - jcr->impl_->session_opened = false; + jcr->impl->session_opened = false; return true; } @@ -355,7 +355,7 @@ static bool ReadDataCmd(JobControlRecord* jcr) BareosSocket* fd = jcr->file_bsock; Dmsg1(120, "Read data: %s", fd->msg); - if (jcr->impl_->session_opened) { + if (jcr->impl->session_opened) { Dmsg1(120, "msg); return DoReadData(jcr); } else { @@ -375,31 +375,31 @@ static bool ReadOpenSession(JobControlRecord* jcr) BareosSocket* fd = jcr->file_bsock; Dmsg1(120, "%s\n", fd->msg); - if (jcr->impl_->session_opened) { + if (jcr->impl->session_opened) { PmStrcpy(jcr->errmsg, _("Attempt to open read on non-open session.\n")); fd->fsend(NO_open); return false; } - if (sscanf(fd->msg, read_open, jcr->impl_->read_dcr->VolumeName, - &jcr->impl_->read_VolSessionId, &jcr->impl_->read_VolSessionTime, - &jcr->impl_->read_StartFile, &jcr->impl_->read_EndFile, - &jcr->impl_->read_StartBlock, &jcr->impl_->read_EndBlock) == 7) { - if (jcr->impl_->session_opened) { + if (sscanf(fd->msg, read_open, jcr->impl->read_dcr->VolumeName, + &jcr->impl->read_VolSessionId, &jcr->impl->read_VolSessionTime, + &jcr->impl->read_StartFile, &jcr->impl->read_EndFile, + &jcr->impl->read_StartBlock, &jcr->impl->read_EndBlock) == 7) { + if (jcr->impl->session_opened) { PmStrcpy(jcr->errmsg, _("Attempt to open read on non-open session.\n")); fd->fsend(NOT_opened); return false; } Dmsg4(100, "ReadOpenSession got: JobId=%d Vol=%s VolSessId=%ld VolSessT=%ld\n", - jcr->JobId, jcr->impl_->read_dcr->VolumeName, - jcr->impl_->read_VolSessionId, jcr->impl_->read_VolSessionTime); + jcr->JobId, jcr->impl->read_dcr->VolumeName, + jcr->impl->read_VolSessionId, jcr->impl->read_VolSessionTime); Dmsg4(100, " StartF=%ld EndF=%ld StartB=%ld EndB=%ld\n", - jcr->impl_->read_StartFile, jcr->impl_->read_EndFile, - jcr->impl_->read_StartBlock, jcr->impl_->read_EndBlock); + jcr->impl->read_StartFile, jcr->impl->read_EndFile, + jcr->impl->read_StartBlock, jcr->impl->read_EndBlock); } - jcr->impl_->session_opened = true; + jcr->impl->session_opened = true; jcr->setJobType(JT_RESTORE); /* @@ -420,7 +420,7 @@ static bool ReadCloseSession(JobControlRecord* jcr) BareosSocket* fd = jcr->file_bsock; Dmsg1(120, "Read close session: %s\n", fd->msg); - if (!jcr->impl_->session_opened) { + if (!jcr->impl->session_opened) { fd->fsend(NOT_opened); return false; } @@ -433,7 +433,7 @@ static bool ReadCloseSession(JobControlRecord* jcr) fd->signal(BNET_EOD); /* send EOD to File daemon */ - jcr->impl_->session_opened = false; + jcr->impl->session_opened = false; return true; } diff --git a/core/src/stored/job.cc b/core/src/stored/job.cc index 2112d5ca1b0..c8f212cf8b9 100644 --- a/core/src/stored/job.cc +++ b/core/src/stored/job.cc @@ -135,27 +135,27 @@ bool job_cmd(JobControlRecord* jcr) } bstrncpy(jcr->Job, job, sizeof(jcr->Job)); UnbashSpaces(job_name); - jcr->impl_->job_name = GetPoolMemory(PM_NAME); - PmStrcpy(jcr->impl_->job_name, job_name); + jcr->impl->job_name = GetPoolMemory(PM_NAME); + PmStrcpy(jcr->impl->job_name, job_name); UnbashSpaces(client_name); jcr->client_name = GetPoolMemory(PM_NAME); PmStrcpy(jcr->client_name, client_name); UnbashSpaces(fileset_name); - jcr->impl_->fileset_name = GetPoolMemory(PM_NAME); - PmStrcpy(jcr->impl_->fileset_name, fileset_name); + jcr->impl->fileset_name = GetPoolMemory(PM_NAME); + PmStrcpy(jcr->impl->fileset_name, fileset_name); jcr->setJobType(JobType); jcr->setJobLevel(level); - jcr->impl_->no_attributes = no_attributes; - jcr->impl_->spool_attributes = spool_attributes; - jcr->impl_->spool_data = spool_data; - jcr->impl_->spool_size = str_to_int64(spool_size); - jcr->impl_->fileset_md5 = GetPoolMemory(PM_NAME); - PmStrcpy(jcr->impl_->fileset_md5, fileset_md5); - jcr->impl_->PreferMountedVols = PreferMountedVols; - jcr->impl_->RemainingQuota = quota; + jcr->impl->no_attributes = no_attributes; + jcr->impl->spool_attributes = spool_attributes; + jcr->impl->spool_data = spool_data; + jcr->impl->spool_size = str_to_int64(spool_size); + jcr->impl->fileset_md5 = GetPoolMemory(PM_NAME); + PmStrcpy(jcr->impl->fileset_md5, fileset_md5); + jcr->impl->PreferMountedVols = PreferMountedVols; + jcr->impl->RemainingQuota = quota; UnbashSpaces(backup_format); - jcr->impl_->backup_format = GetPoolMemory(PM_NAME); - PmStrcpy(jcr->impl_->backup_format, backup_format); + jcr->impl->backup_format = GetPoolMemory(PM_NAME); + PmStrcpy(jcr->impl->backup_format, backup_format); jcr->authenticated = false; Dmsg1(50, "Quota set as %llu\n", quota); @@ -201,7 +201,7 @@ bool DoJobRun(JobControlRecord* jcr) P(mutex); while (!jcr->authenticated && !JobCanceled(jcr)) { errstat = - pthread_cond_timedwait(&jcr->impl_->job_start_wait, &mutex, &timeout); + pthread_cond_timedwait(&jcr->impl->job_start_wait, &mutex, &timeout); if (errstat == ETIMEDOUT || errstat == EINVAL || errstat == EPERM) { break; } @@ -227,7 +227,7 @@ bool DoJobRun(JobControlRecord* jcr) */ Dmsg2(800, "Wait for end job jid=%d %p\n", jcr->JobId, jcr); P(mutex); - pthread_cond_wait(&jcr->impl_->job_end_wait, &mutex); + pthread_cond_wait(&jcr->impl->job_end_wait, &mutex); V(mutex); } Dmsg2(800, "Done jid=%d %p\n", jcr->JobId, jcr); @@ -296,7 +296,7 @@ bool nextRunCmd(JobControlRecord* jcr) P(mutex); while (!jcr->authenticated && !JobCanceled(jcr)) { - errstat = pthread_cond_timedwait(&jcr->impl_->job_start_wait, &mutex, + errstat = pthread_cond_timedwait(&jcr->impl->job_start_wait, &mutex, &timeout); if (errstat == ETIMEDOUT || errstat == EINVAL || errstat == EPERM) { break; @@ -320,7 +320,7 @@ bool nextRunCmd(JobControlRecord* jcr) */ Dmsg2(800, "Wait for end job jid=%d %p\n", jcr->JobId, jcr); P(mutex); - pthread_cond_wait(&jcr->impl_->job_end_wait, &mutex); + pthread_cond_wait(&jcr->impl->job_end_wait, &mutex); V(mutex); } Dmsg2(800, "Done jid=%d %p\n", jcr->JobId, jcr); @@ -416,27 +416,27 @@ void StoredFreeJcr(JobControlRecord* jcr) jcr->file_bsock = NULL; } - if (jcr->impl_->job_name) { FreePoolMemory(jcr->impl_->job_name); } + if (jcr->impl->job_name) { FreePoolMemory(jcr->impl->job_name); } if (jcr->client_name) { FreeMemory(jcr->client_name); jcr->client_name = NULL; } - if (jcr->impl_->fileset_name) { FreeMemory(jcr->impl_->fileset_name); } + if (jcr->impl->fileset_name) { FreeMemory(jcr->impl->fileset_name); } - if (jcr->impl_->fileset_md5) { FreeMemory(jcr->impl_->fileset_md5); } + if (jcr->impl->fileset_md5) { FreeMemory(jcr->impl->fileset_md5); } - if (jcr->impl_->backup_format) { FreeMemory(jcr->impl_->backup_format); } + if (jcr->impl->backup_format) { FreeMemory(jcr->impl->backup_format); } - if (jcr->impl_->bsr) { - libbareos::FreeBsr(jcr->impl_->bsr); - jcr->impl_->bsr = NULL; + if (jcr->impl->bsr) { + libbareos::FreeBsr(jcr->impl->bsr); + jcr->impl->bsr = NULL; } - if (jcr->impl_->rctx) { - FreeReadContext(jcr->impl_->rctx); - jcr->impl_->rctx = NULL; + if (jcr->impl->rctx) { + FreeReadContext(jcr->impl->rctx); + jcr->impl->rctx = NULL; } if (jcr->compress.deflate_buffer || jcr->compress.inflate_buffer) { @@ -453,48 +453,48 @@ void StoredFreeJcr(JobControlRecord* jcr) jcr->RestoreBootstrap = NULL; } - if (jcr->impl_->next_dev || jcr->impl_->prev_dev) { + if (jcr->impl->next_dev || jcr->impl->prev_dev) { Emsg0(M_FATAL, 0, _("In FreeJcr(), but still attached to device!!!!\n")); } - pthread_cond_destroy(&jcr->impl_->job_start_wait); - pthread_cond_destroy(&jcr->impl_->job_end_wait); + pthread_cond_destroy(&jcr->impl->job_start_wait); + pthread_cond_destroy(&jcr->impl->job_end_wait); /* * Avoid a double free */ - if (jcr->impl_->dcr == jcr->impl_->read_dcr) { jcr->impl_->read_dcr = NULL; } + if (jcr->impl->dcr == jcr->impl->read_dcr) { jcr->impl->read_dcr = NULL; } - if (jcr->impl_->dcr) { - FreeDeviceControlRecord(jcr->impl_->dcr); - jcr->impl_->dcr = NULL; + if (jcr->impl->dcr) { + FreeDeviceControlRecord(jcr->impl->dcr); + jcr->impl->dcr = NULL; } - if (jcr->impl_->read_dcr) { - FreeDeviceControlRecord(jcr->impl_->read_dcr); - jcr->impl_->read_dcr = NULL; + if (jcr->impl->read_dcr) { + FreeDeviceControlRecord(jcr->impl->read_dcr); + jcr->impl->read_dcr = NULL; } - if (jcr->impl_->plugin_options) { delete jcr->impl_->plugin_options; } + if (jcr->impl->plugin_options) { delete jcr->impl->plugin_options; } - if (jcr->impl_->read_store) { + if (jcr->impl->read_store) { DirectorStorage* store = nullptr; - foreach_alist (store, jcr->impl_->read_store) { + foreach_alist (store, jcr->impl->read_store) { delete store->device; delete store; } - delete jcr->impl_->read_store; - jcr->impl_->read_store = NULL; + delete jcr->impl->read_store; + jcr->impl->read_store = NULL; } - if (jcr->impl_->write_store) { + if (jcr->impl->write_store) { DirectorStorage* store = nullptr; - foreach_alist (store, jcr->impl_->write_store) { + foreach_alist (store, jcr->impl->write_store) { delete store->device; delete store; } - delete jcr->impl_->write_store; - jcr->impl_->write_store = NULL; + delete jcr->impl->write_store; + jcr->impl->write_store = NULL; } FreePlugins(jcr); /* release instantiated plugins */ @@ -505,9 +505,9 @@ void StoredFreeJcr(JobControlRecord* jcr) GetFirstPortHostOrder(me->SDaddrs)); } - if (jcr->impl_) { - delete jcr->impl_; - jcr->impl_ = nullptr; + if (jcr->impl) { + delete jcr->impl; + jcr->impl = nullptr; } Dmsg0(200, "End stored FreeJcr\n"); @@ -518,7 +518,7 @@ void StoredFreeJcr(JobControlRecord* jcr) JobControlRecord* NewStoredJcr() { JobControlRecord* jcr = new_jcr(StoredFreeJcr); - jcr->impl_ = new JobControlRecordPrivate; + jcr->impl = new JobControlRecordPrivate; return jcr; } diff --git a/core/src/stored/label.cc b/core/src/stored/label.cc index b3633d32d07..8750173c85c 100644 --- a/core/src/stored/label.cc +++ b/core/src/stored/label.cc @@ -132,7 +132,7 @@ int ReadDevVolumeLabel(DeviceControlRecord* dcr) Mmsg(jcr->errmsg, _("Wrong Volume mounted on device %s: Wanted %s have %s\n"), dev->print_name(), VolName, dev->VolHdr.VolumeName); - if (!dev->poll && jcr->impl_->label_errors++ > 100) { + if (!dev->poll && jcr->impl->label_errors++ > 100) { Jmsg(jcr, M_FATAL, 0, _("Too many tries: %s"), jcr->errmsg); } goto bail_out; @@ -178,7 +178,7 @@ int ReadDevVolumeLabel(DeviceControlRecord* dcr) if (!dev->IsVolumeToUnload()) { dev->ClearUnload(); } if (!ok) { - if (forge_on || jcr->impl_->ignore_label_errors) { + if (forge_on || jcr->impl->ignore_label_errors) { dev->SetLabeled(); /* set has Bareos label */ Jmsg(jcr, M_ERROR, 0, "%s", jcr->errmsg); goto ok_out; @@ -214,7 +214,7 @@ int ReadDevVolumeLabel(DeviceControlRecord* dcr) Mmsg(jcr->errmsg, _("Volume on %s has bad Bareos label type: %x\n"), dev->print_name(), dev->VolHdr.LabelType); Dmsg1(130, "%s", jcr->errmsg); - if (!dev->poll && jcr->impl_->label_errors++ > 100) { + if (!dev->poll && jcr->impl->label_errors++ > 100) { Jmsg(jcr, M_FATAL, 0, _("Too many tries: %s"), jcr->errmsg); } Dmsg0(150, "return VOL_LABEL_ERROR\n"); @@ -237,7 +237,7 @@ int ReadDevVolumeLabel(DeviceControlRecord* dcr) * Cancel Job if too many label errors * => we are in a loop */ - if (!dev->poll && jcr->impl_->label_errors++ > 100) { + if (!dev->poll && jcr->impl->label_errors++ > 100) { Jmsg(jcr, M_FATAL, 0, "Too many tries: %s", jcr->errmsg); } Dmsg0(150, "return VOL_NAME_ERROR\n"); @@ -544,8 +544,8 @@ static void CreateVolumeLabelRecord(DeviceControlRecord* dcr, rec->FileIndex = dev->VolHdr.LabelType; rec->VolSessionId = jcr->VolSessionId; rec->VolSessionTime = jcr->VolSessionTime; - rec->Stream = jcr->impl_->NumWriteVolumes; - rec->maskedStream = jcr->impl_->NumWriteVolumes; + rec->Stream = jcr->impl->NumWriteVolumes; + rec->maskedStream = jcr->impl->NumWriteVolumes; Dmsg2(150, "Created Vol label rec: FI=%s len=%d\n", FI_to_ascii(buf, rec->FileIndex), rec->data_len); } @@ -628,16 +628,16 @@ static void CreateSessionLabel(DeviceControlRecord* dcr, SerString(dcr->pool_name); SerString(dcr->pool_type); - SerString(jcr->impl_->job_name); /* base Job name */ + SerString(jcr->impl->job_name); /* base Job name */ SerString(jcr->client_name); /* Added in VerNum 10 */ SerString(jcr->Job); /* Unique name of this Job */ - SerString(jcr->impl_->fileset_name); + SerString(jcr->impl->fileset_name); ser_uint32(jcr->getJobType()); ser_uint32(jcr->getJobLevel()); /* Added in VerNum 11 */ - SerString(jcr->impl_->fileset_md5); + SerString(jcr->impl->fileset_md5); if (label == EOS_LABEL) { ser_uint32(jcr->JobFiles); diff --git a/core/src/stored/mac.cc b/core/src/stored/mac.cc index 4668430073b..c7c34efb6ef 100644 --- a/core/src/stored/mac.cc +++ b/core/src/stored/mac.cc @@ -120,7 +120,7 @@ static bool CloneRecordInternally(DeviceControlRecord* dcr, DeviceRecord* rec) bool retval = false; bool translated_record = false; JobControlRecord* jcr = dcr->jcr; - Device* dev = jcr->impl_->dcr->dev; + Device* dev = jcr->impl->dcr->dev; char buf1[100], buf2[100]; /* @@ -149,10 +149,10 @@ static bool CloneRecordInternally(DeviceControlRecord* dcr, DeviceRecord* rec) if (jcr->is_JobType(JT_MIGRATE) || jcr->is_JobType(JT_COPY)) { bstrncpy(jcr->Job, label->Job, sizeof(jcr->Job)); - PmStrcpy(jcr->impl_->job_name, label->JobName); + PmStrcpy(jcr->impl->job_name, label->JobName); PmStrcpy(jcr->client_name, label->ClientName); - PmStrcpy(jcr->impl_->fileset_name, label->FileSetName); - PmStrcpy(jcr->impl_->fileset_md5, label->FileSetMD5); + PmStrcpy(jcr->impl->fileset_name, label->FileSetName); + PmStrcpy(jcr->impl->fileset_md5, label->FileSetMD5); } jcr->setJobType(label->JobType); jcr->setJobLevel(label->JobLevel); @@ -171,7 +171,7 @@ static bool CloneRecordInternally(DeviceControlRecord* dcr, DeviceRecord* rec) jcr->start_time = jcr->sched_time; /* write the SOS Label with the existing timestamp infos */ - if (!WriteSessionLabel(jcr->impl_->dcr, SOS_LABEL)) { + if (!WriteSessionLabel(jcr->impl->dcr, SOS_LABEL)) { Jmsg1(jcr, M_FATAL, 0, _("Write session label failed. ERR=%s\n"), dev->bstrerror()); jcr->setJobStatus(JS_ErrorTerminated); @@ -223,10 +223,10 @@ static bool CloneRecordInternally(DeviceControlRecord* dcr, DeviceRecord* rec) /* * Perform record translations. */ - jcr->impl_->dcr->before_rec = rec; - jcr->impl_->dcr->after_rec = NULL; + jcr->impl->dcr->before_rec = rec; + jcr->impl->dcr->after_rec = NULL; if (GeneratePluginEvent(jcr, bsdEventWriteRecordTranslation, - jcr->impl_->dcr) != bRC_OK) { + jcr->impl->dcr) != bRC_OK) { goto bail_out; } @@ -236,17 +236,17 @@ static bool CloneRecordInternally(DeviceControlRecord* dcr, DeviceRecord* rec) * taken place we just point the after_rec pointer to same DeviceRecord as in * the before_rec pointer. */ - if (!jcr->impl_->dcr->after_rec) { - jcr->impl_->dcr->after_rec = jcr->impl_->dcr->before_rec; + if (!jcr->impl->dcr->after_rec) { + jcr->impl->dcr->after_rec = jcr->impl->dcr->before_rec; } else { translated_record = true; } - while (!WriteRecordToBlock(jcr->impl_->dcr, jcr->impl_->dcr->after_rec)) { + while (!WriteRecordToBlock(jcr->impl->dcr, jcr->impl->dcr->after_rec)) { Dmsg4(200, "!WriteRecordToBlock blkpos=%u:%u len=%d rem=%d\n", dev->file, - dev->block_num, jcr->impl_->dcr->after_rec->data_len, - jcr->impl_->dcr->after_rec->remainder); - if (!jcr->impl_->dcr->WriteBlockToDevice()) { + dev->block_num, jcr->impl->dcr->after_rec->data_len, + jcr->impl->dcr->after_rec->remainder); + if (!jcr->impl->dcr->WriteBlockToDevice()) { Dmsg2(90, "Got WriteBlockToDev error on device %s. %s\n", dev->print_name(), dev->bstrerror()); Jmsg2(jcr, M_FATAL, 0, _("Fatal append error on device %s: ERR=%s\n"), @@ -259,34 +259,34 @@ static bool CloneRecordInternally(DeviceControlRecord* dcr, DeviceRecord* rec) /* * Restore packet */ - jcr->impl_->dcr->after_rec->VolSessionId = - jcr->impl_->dcr->after_rec->last_VolSessionId; - jcr->impl_->dcr->after_rec->VolSessionTime = - jcr->impl_->dcr->after_rec->last_VolSessionTime; + jcr->impl->dcr->after_rec->VolSessionId = + jcr->impl->dcr->after_rec->last_VolSessionId; + jcr->impl->dcr->after_rec->VolSessionTime = + jcr->impl->dcr->after_rec->last_VolSessionTime; - if (jcr->impl_->dcr->after_rec->FileIndex < 0) { + if (jcr->impl->dcr->after_rec->FileIndex < 0) { retval = true; /* don't send LABELs to Dir */ goto bail_out; } jcr->JobBytes += - jcr->impl_->dcr->after_rec->data_len; /* increment bytes of this job */ + jcr->impl->dcr->after_rec->data_len; /* increment bytes of this job */ Dmsg5(500, "wrote_record JobId=%d FI=%s SessId=%d Strm=%s len=%d\n", - jcr->JobId, FI_to_ascii(buf1, jcr->impl_->dcr->after_rec->FileIndex), - jcr->impl_->dcr->after_rec->VolSessionId, - stream_to_ascii(buf2, jcr->impl_->dcr->after_rec->Stream, - jcr->impl_->dcr->after_rec->FileIndex), - jcr->impl_->dcr->after_rec->data_len); + jcr->JobId, FI_to_ascii(buf1, jcr->impl->dcr->after_rec->FileIndex), + jcr->impl->dcr->after_rec->VolSessionId, + stream_to_ascii(buf2, jcr->impl->dcr->after_rec->Stream, + jcr->impl->dcr->after_rec->FileIndex), + jcr->impl->dcr->after_rec->data_len); - SendAttrsToDir(jcr, jcr->impl_->dcr->after_rec); + SendAttrsToDir(jcr, jcr->impl->dcr->after_rec); retval = true; bail_out: if (translated_record) { - FreeRecord(jcr->impl_->dcr->after_rec); - jcr->impl_->dcr->after_rec = NULL; + FreeRecord(jcr->impl->dcr->after_rec); + jcr->impl->dcr->after_rec = NULL; } return retval; @@ -435,22 +435,22 @@ static inline void CheckAutoXflation(JobControlRecord* jcr) /* * Check autodeflation. */ - switch (jcr->impl_->read_dcr->autodeflate) { + switch (jcr->impl->read_dcr->autodeflate) { case IO_DIRECTION_IN: case IO_DIRECTION_INOUT: Dmsg0(200, "Clearing autodeflate on read_dcr\n"); - jcr->impl_->read_dcr->autodeflate = IO_DIRECTION_NONE; + jcr->impl->read_dcr->autodeflate = IO_DIRECTION_NONE; break; default: break; } - if (jcr->impl_->dcr) { - switch (jcr->impl_->dcr->autodeflate) { + if (jcr->impl->dcr) { + switch (jcr->impl->dcr->autodeflate) { case IO_DIRECTION_OUT: case IO_DIRECTION_INOUT: Dmsg0(200, "Clearing autodeflate on write dcr\n"); - jcr->impl_->dcr->autodeflate = IO_DIRECTION_NONE; + jcr->impl->dcr->autodeflate = IO_DIRECTION_NONE; break; default: break; @@ -460,22 +460,22 @@ static inline void CheckAutoXflation(JobControlRecord* jcr) /* * Check autoinflation. */ - switch (jcr->impl_->read_dcr->autoinflate) { + switch (jcr->impl->read_dcr->autoinflate) { case IO_DIRECTION_IN: case IO_DIRECTION_INOUT: Dmsg0(200, "Clearing autoinflate on read_dcr\n"); - jcr->impl_->read_dcr->autoinflate = IO_DIRECTION_NONE; + jcr->impl->read_dcr->autoinflate = IO_DIRECTION_NONE; break; default: break; } - if (jcr->impl_->dcr) { - switch (jcr->impl_->dcr->autoinflate) { + if (jcr->impl->dcr) { + switch (jcr->impl->dcr->autoinflate) { case IO_DIRECTION_OUT: case IO_DIRECTION_INOUT: Dmsg0(200, "Clearing autoinflate on write dcr\n"); - jcr->impl_->dcr->autoinflate = IO_DIRECTION_NONE; + jcr->impl->dcr->autoinflate = IO_DIRECTION_NONE; break; default: break; @@ -494,7 +494,7 @@ bool DoMacRun(JobControlRecord* jcr) bool ok = true; bool acquire_fail = false; BareosSocket* dir = jcr->dir_bsock; - Device* dev = jcr->impl_->dcr->dev; + Device* dev = jcr->impl->dcr->dev; switch (jcr->getJobType()) { case JT_MIGRATE: @@ -516,7 +516,7 @@ bool DoMacRun(JobControlRecord* jcr) Dmsg0(20, "Start read data.\n"); - if (jcr->impl_->NumReadVolumes == 0) { + if (jcr->impl->NumReadVolumes == 0) { Jmsg(jcr, M_FATAL, 0, _("No Volume names found for %s.\n"), Type); goto bail_out; } @@ -529,30 +529,30 @@ bool DoMacRun(JobControlRecord* jcr) /* * See if we perform both read and write or read only. */ - if (jcr->impl_->remote_replicate) { + if (jcr->impl->remote_replicate) { BareosSocket* sd; - if (!jcr->impl_->read_dcr) { + if (!jcr->impl->read_dcr) { Jmsg(jcr, M_FATAL, 0, _("Read device not properly initialized.\n")); goto bail_out; } - Dmsg1(100, "read_dcr=%p\n", jcr->impl_->read_dcr); + Dmsg1(100, "read_dcr=%p\n", jcr->impl->read_dcr); Dmsg3(200, "Found %d volumes names for %s. First=%s\n", - jcr->impl_->NumReadVolumes, Type, jcr->impl_->VolList->VolumeName); + jcr->impl->NumReadVolumes, Type, jcr->impl->VolList->VolumeName); /* * Ready devices for reading. */ - if (!AcquireDeviceForRead(jcr->impl_->read_dcr)) { + if (!AcquireDeviceForRead(jcr->impl->read_dcr)) { ok = false; acquire_fail = true; goto bail_out; } Dmsg2(200, "===== After acquire pos %u:%u\n", - jcr->impl_->read_dcr->dev->file, - jcr->impl_->read_dcr->dev->block_num); + jcr->impl->read_dcr->dev->file, + jcr->impl->read_dcr->dev->block_num); jcr->sendJobStatus(JS_Running); @@ -577,12 +577,12 @@ bool DoMacRun(JobControlRecord* jcr) */ if (BgetMsg(sd) >= 0) { Dmsg1(110, "msg); - if (sscanf(sd->msg, OK_start_replicate, &jcr->impl_->Ticket) != 1) { + if (sscanf(sd->msg, OK_start_replicate, &jcr->impl->Ticket) != 1) { Jmsg(jcr, M_FATAL, 0, _("Bad response to start replicate: %s\n"), sd->msg); goto bail_out; } - Dmsg1(110, "Got Ticket=%d\n", jcr->impl_->Ticket); + Dmsg1(110, "Got Ticket=%d\n", jcr->impl->Ticket); } else { Jmsg(jcr, M_FATAL, 0, _("Bad response from stored to start replicate command\n")); @@ -592,7 +592,7 @@ bool DoMacRun(JobControlRecord* jcr) /* * Let the remote SD know we are now really going to send the data. */ - sd->fsend(ReplicateData, jcr->impl_->Ticket); + sd->fsend(ReplicateData, jcr->impl->Ticket); Dmsg1(110, ">stored: %s", sd->msg); /* @@ -612,7 +612,7 @@ bool DoMacRun(JobControlRecord* jcr) /* * Read all data and send it to remote SD. */ - ok = ReadRecords(jcr->impl_->read_dcr, CloneRecordToRemoteSd, + ok = ReadRecords(jcr->impl->read_dcr, CloneRecordToRemoteSd, MountNextReadVolume); /* @@ -652,28 +652,28 @@ bool DoMacRun(JobControlRecord* jcr) /* Inform Storage daemon that we are done */ sd->signal(BNET_TERMINATE); } else { - if (!jcr->impl_->read_dcr) { + if (!jcr->impl->read_dcr) { Jmsg(jcr, M_FATAL, 0, _("Read device not properly initialized.\n")); goto bail_out; } - Dmsg2(100, "read_dcr=%p write_dcr=%p\n", jcr->impl_->read_dcr, - jcr->impl_->dcr); + Dmsg2(100, "read_dcr=%p write_dcr=%p\n", jcr->impl->read_dcr, + jcr->impl->dcr); Dmsg3(200, "Found %d volumes names for %s. First=%s\n", - jcr->impl_->NumReadVolumes, Type, jcr->impl_->VolList->VolumeName); + jcr->impl->NumReadVolumes, Type, jcr->impl->VolList->VolumeName); /* * Ready devices for reading and writing. */ - if (!AcquireDeviceForRead(jcr->impl_->read_dcr) || - !AcquireDeviceForAppend(jcr->impl_->dcr)) { + if (!AcquireDeviceForRead(jcr->impl->read_dcr) || + !AcquireDeviceForAppend(jcr->impl->dcr)) { ok = false; acquire_fail = true; goto bail_out; } - Dmsg2(200, "===== After acquire pos %u:%u\n", jcr->impl_->dcr->dev->file, - jcr->impl_->dcr->dev->block_num); + Dmsg2(200, "===== After acquire pos %u:%u\n", jcr->impl->dcr->dev->file, + jcr->impl->dcr->dev->block_num); jcr->sendJobStatus(JS_Running); @@ -683,7 +683,7 @@ bool DoMacRun(JobControlRecord* jcr) now = (utime_t)time(NULL); UpdateJobStatistics(jcr, now); - if (!BeginDataSpool(jcr->impl_->dcr)) { + if (!BeginDataSpool(jcr->impl->dcr)) { ok = false; goto bail_out; } @@ -693,22 +693,22 @@ bool DoMacRun(JobControlRecord* jcr) goto bail_out; } - jcr->impl_->dcr->VolFirstIndex = jcr->impl_->dcr->VolLastIndex = 0; + jcr->impl->dcr->VolFirstIndex = jcr->impl->dcr->VolLastIndex = 0; jcr->run_time = time(NULL); - SetStartVolPosition(jcr->impl_->dcr); + SetStartVolPosition(jcr->impl->dcr); jcr->JobFiles = 0; /* * Read all data and make a local clone of it. */ - ok = ReadRecords(jcr->impl_->read_dcr, CloneRecordInternally, + ok = ReadRecords(jcr->impl->read_dcr, CloneRecordInternally, MountNextReadVolume); } bail_out: if (!ok) { jcr->setJobStatus(JS_ErrorTerminated); } - if (!acquire_fail && !jcr->impl_->remote_replicate && jcr->impl_->dcr) { + if (!acquire_fail && !jcr->impl->remote_replicate && jcr->impl->dcr) { /* * Don't use time_t for job_elapsed as time_t can be 32 or 64 bits, * and the subsequent Jmsg() editing will break @@ -728,7 +728,7 @@ bool DoMacRun(JobControlRecord* jcr) /* * Write End Of Session Label */ - DeviceControlRecord* dcr = jcr->impl_->dcr; + DeviceControlRecord* dcr = jcr->impl->dcr; if (!WriteSessionLabel(dcr, EOS_LABEL)) { /* * Print only if ok and not cancelled to avoid spurious messages @@ -747,7 +747,7 @@ bool DoMacRun(JobControlRecord* jcr) /* * Flush out final partial block of this session */ - if (!jcr->impl_->dcr->WriteBlockToDevice()) { + if (!jcr->impl->dcr->WriteBlockToDevice()) { Jmsg2(jcr, M_FATAL, 0, _("Fatal append error on device %s: ERR=%s\n"), dev->print_name(), dev->bstrerror()); Dmsg0(100, _("Set ok=FALSE after WriteBlockToDevice.\n")); @@ -759,12 +759,12 @@ bool DoMacRun(JobControlRecord* jcr) if (!ok) { - DiscardDataSpool(jcr->impl_->dcr); + DiscardDataSpool(jcr->impl->dcr); } else { /* * Note: if commit is OK, the device will remain blocked */ - CommitDataSpool(jcr->impl_->dcr); + CommitDataSpool(jcr->impl->dcr); } job_elapsed = time(NULL) - jcr->run_time; @@ -778,7 +778,7 @@ bool DoMacRun(JobControlRecord* jcr) /* * Release the device -- and send final Vol info to DIR */ - ReleaseDevice(jcr->impl_->dcr); + ReleaseDevice(jcr->impl->dcr); if (!ok || JobCanceled(jcr)) { DiscardAttributeSpool(jcr); @@ -787,8 +787,8 @@ bool DoMacRun(JobControlRecord* jcr) } } - if (jcr->impl_->read_dcr) { - if (!ReleaseDevice(jcr->impl_->read_dcr)) { ok = false; } + if (jcr->impl->read_dcr) { + if (!ReleaseDevice(jcr->impl->read_dcr)) { ok = false; } } jcr->sendJobStatus(); /* update director */ diff --git a/core/src/stored/mount.cc b/core/src/stored/mount.cc index ffe0a98678c..aaa17cd9325 100644 --- a/core/src/stored/mount.cc +++ b/core/src/stored/mount.cc @@ -953,15 +953,15 @@ bool MountNextReadVolume(DeviceControlRecord* dcr) { Device* dev = dcr->dev; JobControlRecord* jcr = dcr->jcr; - Dmsg2(90, "NumReadVolumes=%d CurReadVolume=%d\n", jcr->impl_->NumReadVolumes, - jcr->impl_->CurReadVolume); + Dmsg2(90, "NumReadVolumes=%d CurReadVolume=%d\n", jcr->impl->NumReadVolumes, + jcr->impl->CurReadVolume); VolumeUnused(dcr); /* release current volume */ /* * End Of Tape -- mount next Volume (if another specified) */ - if (jcr->impl_->NumReadVolumes > 1 && - jcr->impl_->CurReadVolume < jcr->impl_->NumReadVolumes) { + if (jcr->impl->NumReadVolumes > 1 && + jcr->impl->CurReadVolume < jcr->impl->NumReadVolumes) { dev->Lock(); dev->close(dcr); dev->SetRead(); diff --git a/core/src/stored/ndmp_tape.cc b/core/src/stored/ndmp_tape.cc index f7264b614f0..100bf116fa0 100644 --- a/core/src/stored/ndmp_tape.cc +++ b/core/src/stored/ndmp_tape.cc @@ -327,7 +327,7 @@ static inline bool bndmp_write_data_to_block(JobControlRecord* jcr, uint32_t data_length) { bool retval = false; - DeviceControlRecord* dcr = jcr->impl_->dcr; + DeviceControlRecord* dcr = jcr->impl->dcr; POOLMEM* rec_data; if (!dcr) { @@ -376,8 +376,8 @@ static inline bool bndmp_read_data_from_block(JobControlRecord* jcr, uint32_t wanted_data_length, uint32_t* data_length) { - DeviceControlRecord* dcr = jcr->impl_->read_dcr; - READ_CTX* rctx = jcr->impl_->rctx; + DeviceControlRecord* dcr = jcr->impl->read_dcr; + READ_CTX* rctx = jcr->impl->rctx; bool done = false; bool ok = true; @@ -480,7 +480,7 @@ static inline bool bndmp_read_data_from_block(JobControlRecord* jcr, */ static inline bool BndmpCreateVirtualFile(JobControlRecord* jcr, char* filename) { - DeviceControlRecord* dcr = jcr->impl_->dcr; + DeviceControlRecord* dcr = jcr->impl->dcr; struct stat statp; time_t now = time(NULL); PoolMem attribs(PM_NAME), data(PM_NAME); @@ -592,7 +592,7 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess, * In NDMP terms this is the same as a FD connecting so wake any waiting * threads. */ - pthread_cond_signal(&jcr->impl_->job_start_wait); + pthread_cond_signal(&jcr->impl->job_start_wait); /* * Save the JobControlRecord to ndm_session binding so everything furher @@ -624,9 +624,9 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess, * Depending on the open mode select the right DeviceControlRecord. */ if (will_write) { - dcr = jcr->impl_->dcr; + dcr = jcr->impl->dcr; } else { - dcr = jcr->impl_->read_dcr; + dcr = jcr->impl->read_dcr; } if (!dcr) { @@ -654,7 +654,7 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess, * One NDMP backup Job can be one or more save sessions so we keep * track if we already acquired the storage. */ - if (!jcr->impl_->acquired_storage) { + if (!jcr->impl->acquired_storage) { /* * Actually acquire the device which we reserved. */ @@ -672,7 +672,7 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess, /* * Keep track that we acquired the storage. */ - jcr->impl_->acquired_storage = true; + jcr->impl->acquired_storage = true; Dmsg1(50, "Begin append device=%s\n", dcr->dev->print_name()); @@ -730,16 +730,16 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess, /* * Setup internal system for reading data (if not done before). */ - if (!jcr->impl_->acquired_storage) { + if (!jcr->impl->acquired_storage) { Dmsg0(20, "Start read data.\n"); - if (jcr->impl_->NumReadVolumes == 0) { + if (jcr->impl->NumReadVolumes == 0) { Jmsg(jcr, M_FATAL, 0, _("No Volume names found for restore.\n")); goto bail_out; } Dmsg2(200, "Found %d volumes names to restore. First=%s\n", - jcr->impl_->NumReadVolumes, jcr->impl_->VolList->VolumeName); + jcr->impl->NumReadVolumes, jcr->impl->VolList->VolumeName); /* * Ready device for reading @@ -758,7 +758,7 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess, /* * Keep track that we acquired the storage. */ - jcr->impl_->acquired_storage = true; + jcr->impl->acquired_storage = true; /* * Change the Job to running state. @@ -768,13 +768,13 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess, Dmsg1(50, "Begin reading device=%s\n", dcr->dev->print_name()); PositionDeviceToFirstFile(jcr, dcr); - jcr->impl_->mount_next_volume = false; + jcr->impl->mount_next_volume = false; /* * Allocate a new read context for this Job. */ rctx = new_read_context(); - jcr->impl_->rctx = rctx; + jcr->impl->rctx = rctx; /* * Read the first block and setup record processing. @@ -852,7 +852,7 @@ extern "C" ndmp9_error BndmpTapeClose(struct ndm_session* sess) } } - pthread_cond_signal(&jcr->impl_->job_end_wait); /* wake any waiting thread */ + pthread_cond_signal(&jcr->impl->job_end_wait); /* wake any waiting thread */ ndmos_tape_initialize(sess); @@ -1034,7 +1034,7 @@ static inline void UnregisterCallbackHooks(struct ndm_session* sess) void EndOfNdmpBackup(JobControlRecord* jcr) { - DeviceControlRecord* dcr = jcr->impl_->dcr; + DeviceControlRecord* dcr = jcr->impl->dcr; char ec[50]; /* @@ -1100,9 +1100,9 @@ void EndOfNdmpBackup(JobControlRecord* jcr) /* * Release the device -- and send final Vol info to DIR and unlock it. */ - if (jcr->impl_->acquired_storage) { + if (jcr->impl->acquired_storage) { ReleaseDevice(dcr); - jcr->impl_->acquired_storage = false; + jcr->impl->acquired_storage = false; } else { dcr->UnreserveDevice(); } @@ -1113,16 +1113,16 @@ void EndOfNdmpBackup(JobControlRecord* jcr) void EndOfNdmpRestore(JobControlRecord* jcr) { - if (jcr->impl_->rctx) { - FreeReadContext(jcr->impl_->rctx); - jcr->impl_->rctx = NULL; + if (jcr->impl->rctx) { + FreeReadContext(jcr->impl->rctx); + jcr->impl->rctx = NULL; } - if (jcr->impl_->acquired_storage) { - ReleaseDevice(jcr->impl_->read_dcr); - jcr->impl_->acquired_storage = false; + if (jcr->impl->acquired_storage) { + ReleaseDevice(jcr->impl->read_dcr); + jcr->impl->acquired_storage = false; } else { - jcr->impl_->read_dcr->UnreserveDevice(); + jcr->impl->read_dcr->UnreserveDevice(); } } diff --git a/core/src/stored/read.cc b/core/src/stored/read.cc index 0e9bc57153b..1838ea6dc9b 100644 --- a/core/src/stored/read.cc +++ b/core/src/stored/read.cc @@ -58,7 +58,7 @@ static char rec_header[] = "rechdr %ld %ld %ld %ld %ld"; bool DoReadData(JobControlRecord* jcr) { BareosSocket* fd = jcr->file_bsock; - DeviceControlRecord* dcr = jcr->impl_->read_dcr; + DeviceControlRecord* dcr = jcr->impl->read_dcr; bool ok = true; Dmsg0(20, "Start read data.\n"); @@ -68,14 +68,14 @@ bool DoReadData(JobControlRecord* jcr) return false; } - if (jcr->impl_->NumReadVolumes == 0) { + if (jcr->impl->NumReadVolumes == 0) { Jmsg(jcr, M_FATAL, 0, _("No Volume names found for restore.\n")); fd->fsend(FD_error); return false; } Dmsg2(200, "Found %d volumes names to restore. First=%s\n", - jcr->impl_->NumReadVolumes, jcr->impl_->VolList->VolumeName); + jcr->impl->NumReadVolumes, jcr->impl->VolList->VolumeName); /* * Ready device for reading @@ -105,7 +105,7 @@ bool DoReadData(JobControlRecord* jcr) */ fd->signal(BNET_EOD); - if (!ReleaseDevice(jcr->impl_->read_dcr)) { ok = false; } + if (!ReleaseDevice(jcr->impl->read_dcr)) { ok = false; } Dmsg0(30, "Done reading.\n"); return ok; diff --git a/core/src/stored/read_record.cc b/core/src/stored/read_record.cc index cb6de0be79f..e2a4dc4b3f3 100644 --- a/core/src/stored/read_record.cc +++ b/core/src/stored/read_record.cc @@ -222,15 +222,15 @@ bool ReadNextBlockFromDevice(DeviceControlRecord* dcr, trec->FileIndex = EOT_LABEL; trec->File = dcr->dev->file; *status = RecordCb(dcr, trec); - if (jcr->impl_->mount_next_volume) { - jcr->impl_->mount_next_volume = false; + if (jcr->impl->mount_next_volume) { + jcr->impl->mount_next_volume = false; dcr->dev->ClearEot(); } FreeRecord(trec); } return false; } - jcr->impl_->mount_next_volume = false; + jcr->impl->mount_next_volume = false; /* * We just have a new tape up, now read the label (first record) @@ -263,7 +263,7 @@ bool ReadNextBlockFromDevice(DeviceControlRecord* dcr, * I/O error or strange end of tape */ DisplayTapeErrorStatus(jcr, dcr->dev); - if (forge_on || jcr->impl_->ignore_label_errors) { + if (forge_on || jcr->impl->ignore_label_errors) { dcr->dev->fsr(1); /* try skipping bad record */ Pmsg0(000, _("Did fsr in attemp to skip bad record.\n")); continue; @@ -329,11 +329,11 @@ bool ReadNextRecordFromBlock(DeviceControlRecord* dcr, */ if (rec->FileIndex < 0) { HandleSessionRecord(dcr->dev, rec, &rctx->sessrec); - if (jcr->impl_->bsr) { + if (jcr->impl->bsr) { /* * We just check block FI and FT not FileIndex */ - rec->match_stat = MatchBsrBlock(jcr->impl_->bsr, dcr->block); + rec->match_stat = MatchBsrBlock(jcr->impl->bsr, dcr->block); } else { rec->match_stat = 0; } @@ -344,9 +344,9 @@ bool ReadNextRecordFromBlock(DeviceControlRecord* dcr, /* * Apply BootStrapRecord filter */ - if (jcr->impl_->bsr) { + if (jcr->impl->bsr) { rec->match_stat = - MatchBsr(jcr->impl_->bsr, rec, &dev->VolHdr, &rctx->sessrec, jcr); + MatchBsr(jcr->impl->bsr, rec, &dev->VolHdr, &rctx->sessrec, jcr); if (rec->match_stat == -1) { /* no more possible matches */ *done = true; /* all items found, stop */ Dmsg2(debuglevel, "All done=(file:block) %u:%u\n", dev->file, @@ -377,7 +377,7 @@ bool ReadNextRecordFromBlock(DeviceControlRecord* dcr, if (rctx->lastFileIndex != READ_NO_FILEINDEX && rctx->lastFileIndex != rec->FileIndex) { - if (IsThisBsrDone(jcr->impl_->bsr, rec) && + if (IsThisBsrDone(jcr->impl->bsr, rec) && TryDeviceRepositioning(jcr, rec, dcr)) { Dmsg2(debuglevel, "This bsr done, break pos %u:%u\n", dev->file, dev->block_num); @@ -412,7 +412,7 @@ bool ReadRecords(DeviceControlRecord* dcr, rctx = new_read_context(); PositionDeviceToFirstFile(jcr, dcr); - jcr->impl_->mount_next_volume = false; + jcr->impl->mount_next_volume = false; while (ok && !done) { if (JobCanceled(jcr)) { diff --git a/core/src/stored/record.cc b/core/src/stored/record.cc index 8b4660bceb8..7b41263c60a 100644 --- a/core/src/stored/record.cc +++ b/core/src/stored/record.cc @@ -685,8 +685,8 @@ bool DeviceControlRecord::WriteRecord() } jcr->JobBytes += after_rec->data_len; /* increment bytes this job */ - if (jcr->impl_->RemainingQuota && - jcr->JobBytes > jcr->impl_->RemainingQuota) { + if (jcr->impl->RemainingQuota && + jcr->JobBytes > jcr->impl->RemainingQuota) { Jmsg0(jcr, M_FATAL, 0, _("Quota Exceeded. Job Terminated.\n")); goto bail_out; } diff --git a/core/src/stored/reserve.cc b/core/src/stored/reserve.cc index 9038413a8ab..18a11aa262e 100644 --- a/core/src/stored/reserve.cc +++ b/core/src/stored/reserve.cc @@ -210,7 +210,7 @@ static bool UseDeviceCmd(JobControlRecord* jcr) * If there are multiple devices, the director sends us * use_device for each device that it wants to use. */ - jcr->impl_->reserve_msgs = new alist(10, not_owned_by_alist); + jcr->impl->reserve_msgs = new alist(10, not_owned_by_alist); do { Dmsg1(debuglevel, "msg); ok = sscanf(dir->msg, use_storage, StoreName.c_str(), media_type.c_str(), @@ -219,9 +219,9 @@ static bool UseDeviceCmd(JobControlRecord* jcr) if (!ok) { break; } dirstore = new alist(10, not_owned_by_alist); if (append) { - jcr->impl_->write_store = dirstore; + jcr->impl->write_store = dirstore; } else { - jcr->impl_->read_store = dirstore; + jcr->impl->read_store = dirstore; } rctx.append = append; UnbashSpaces(StoreName); @@ -251,11 +251,11 @@ static bool UseDeviceCmd(JobControlRecord* jcr) } while (ok && dir->recv() >= 0); InitJcrDeviceWaitTimers(jcr); - jcr->impl_->dcr = new StorageDaemonDeviceControlRecord; - SetupNewDcrDevice(jcr, jcr->impl_->dcr, NULL, NULL); - if (rctx.append) { jcr->impl_->dcr->SetWillWrite(); } + jcr->impl->dcr = new StorageDaemonDeviceControlRecord; + SetupNewDcrDevice(jcr, jcr->impl->dcr, NULL, NULL); + if (rctx.append) { jcr->impl->dcr->SetWillWrite(); } - if (!jcr->impl_->dcr) { + if (!jcr->impl->dcr) { BareosSocket* dir = jcr->dir_bsock; dir->fsend(_("3939 Could not get dcr\n")); Dmsg1(debuglevel, ">dird: %s", dir->msg); @@ -282,9 +282,9 @@ static bool UseDeviceCmd(JobControlRecord* jcr) * Put new dcr in proper location */ if (rctx.append) { - rctx.jcr->impl_->dcr = jcr->impl_->dcr; + rctx.jcr->impl->dcr = jcr->impl->dcr; } else { - rctx.jcr->impl_->read_dcr = jcr->impl_->dcr; + rctx.jcr->impl->read_dcr = jcr->impl->dcr; } LockReservations(); @@ -294,7 +294,7 @@ static bool UseDeviceCmd(JobControlRecord* jcr) rctx.have_volume = false; rctx.VolumeName[0] = 0; rctx.any_drive = false; - if (!jcr->impl_->PreferMountedVols) { + if (!jcr->impl->PreferMountedVols) { /* * Here we try to find a drive that is not used. * This will maximize the use of available drives. @@ -429,12 +429,12 @@ bool FindSuitableDeviceForJob(JobControlRecord* jcr, ReserveContext& rctx) DirectorStorage* store; char* device_name = nullptr; alist* dirstore; - DeviceControlRecord* dcr = jcr->impl_->dcr; + DeviceControlRecord* dcr = jcr->impl->dcr; if (rctx.append) { - dirstore = jcr->impl_->write_store; + dirstore = jcr->impl->write_store; } else { - dirstore = jcr->impl_->read_store; + dirstore = jcr->impl->read_store; } Dmsg5(debuglevel, "Start find_suit_dev PrefMnt=%d exact=%d suitable=%d chgronly=%d " @@ -602,11 +602,11 @@ int SearchResForDevice(ReserveContext& rctx) if (rctx.store->append == SD_APPEND) { Dmsg2(debuglevel, "Device %s reserved=%d for append.\n", rctx.device->resource_name_, - rctx.jcr->impl_->dcr->dev->NumReserved()); + rctx.jcr->impl->dcr->dev->NumReserved()); } else { Dmsg2(debuglevel, "Device %s reserved=%d for read.\n", rctx.device->resource_name_, - rctx.jcr->impl_->read_dcr->dev->NumReserved()); + rctx.jcr->impl->read_dcr->dev->NumReserved()); } return status; } @@ -635,11 +635,11 @@ int SearchResForDevice(ReserveContext& rctx) if (rctx.store->append == SD_APPEND) { Dmsg2(debuglevel, "Device %s reserved=%d for append.\n", rctx.device->resource_name_, - rctx.jcr->impl_->dcr->dev->NumReserved()); + rctx.jcr->impl->dcr->dev->NumReserved()); } else { Dmsg2(debuglevel, "Device %s reserved=%d for read.\n", rctx.device->resource_name_, - rctx.jcr->impl_->read_dcr->dev->NumReserved()); + rctx.jcr->impl->read_dcr->dev->NumReserved()); } return status; } @@ -669,11 +669,11 @@ int SearchResForDevice(ReserveContext& rctx) if (rctx.store->append == SD_APPEND) { Dmsg2(debuglevel, "Device %s reserved=%d for append.\n", rctx.device->resource_name_, - rctx.jcr->impl_->dcr->dev->NumReserved()); + rctx.jcr->impl->dcr->dev->NumReserved()); } else { Dmsg2(debuglevel, "Device %s reserved=%d for read.\n", rctx.device->resource_name_, - rctx.jcr->impl_->read_dcr->dev->NumReserved()); + rctx.jcr->impl->read_dcr->dev->NumReserved()); } return status; } @@ -729,12 +729,12 @@ static int ReserveDevice(ReserveContext& rctx) Dmsg1(debuglevel, "try reserve %s\n", rctx.device->resource_name_); if (rctx.store->append) { - SetupNewDcrDevice(rctx.jcr, rctx.jcr->impl_->dcr, rctx.device->dev, NULL); - dcr = rctx.jcr->impl_->dcr; + SetupNewDcrDevice(rctx.jcr, rctx.jcr->impl->dcr, rctx.device->dev, NULL); + dcr = rctx.jcr->impl->dcr; } else { - SetupNewDcrDevice(rctx.jcr, rctx.jcr->impl_->read_dcr, rctx.device->dev, + SetupNewDcrDevice(rctx.jcr, rctx.jcr->impl->read_dcr, rctx.device->dev, NULL); - dcr = rctx.jcr->impl_->read_dcr; + dcr = rctx.jcr->impl->read_dcr; } if (!dcr) { @@ -757,7 +757,7 @@ static int ReserveDevice(ReserveContext& rctx) ok = ReserveDeviceForAppend(dcr, rctx); if (!ok) { goto bail_out; } - rctx.jcr->impl_->dcr = dcr; + rctx.jcr->impl->dcr = dcr; Dmsg5(debuglevel, "Reserved=%d dev_name=%s mediatype=%s pool=%s ok=%d\n", dcr->dev->NumReserved(), dcr->dev_name, dcr->media_type, dcr->pool_name, ok); @@ -816,7 +816,7 @@ static int ReserveDevice(ReserveContext& rctx) } else { ok = ReserveDeviceForRead(dcr); if (ok) { - rctx.jcr->impl_->read_dcr = dcr; + rctx.jcr->impl->read_dcr = dcr; Dmsg5(debuglevel, "Read reserved=%d dev_name=%s mediatype=%s pool=%s ok=%d\n", dcr->dev->NumReserved(), dcr->dev_name, dcr->media_type, @@ -1229,7 +1229,7 @@ static void QueueReserveMessage(JobControlRecord* jcr) jcr->lock(); - msgs = jcr->impl_->reserve_msgs; + msgs = jcr->impl->reserve_msgs; if (!msgs) { goto bail_out; } /* * Look for duplicate message. If found, do not insert @@ -1247,7 +1247,7 @@ static void QueueReserveMessage(JobControlRecord* jcr) /* * Message unique, so insert it. */ - jcr->impl_->reserve_msgs->push(strdup(jcr->errmsg)); + jcr->impl->reserve_msgs->push(strdup(jcr->errmsg)); bail_out: jcr->unlock(); @@ -1262,7 +1262,7 @@ static void PopReserveMessages(JobControlRecord* jcr) char* msg; jcr->lock(); - msgs = jcr->impl_->reserve_msgs; + msgs = jcr->impl->reserve_msgs; if (!msgs) { goto bail_out; } while ((msg = (char*)msgs->pop())) { free(msg); } bail_out: @@ -1276,9 +1276,9 @@ void ReleaseReserveMessages(JobControlRecord* jcr) { PopReserveMessages(jcr); jcr->lock(); - if (!jcr->impl_->reserve_msgs) { goto bail_out; } - delete jcr->impl_->reserve_msgs; - jcr->impl_->reserve_msgs = NULL; + if (!jcr->impl->reserve_msgs) { goto bail_out; } + delete jcr->impl->reserve_msgs; + jcr->impl->reserve_msgs = NULL; bail_out: jcr->unlock(); diff --git a/core/src/stored/sd_cmds.cc b/core/src/stored/sd_cmds.cc index 15c9e97be65..db1c490e687 100644 --- a/core/src/stored/sd_cmds.cc +++ b/core/src/stored/sd_cmds.cc @@ -146,7 +146,7 @@ void* handle_stored_connection(BareosSocket* sd, char* job_name) if (!jcr->authenticated) { jcr->setJobStatus(JS_ErrorTerminated); } - pthread_cond_signal(&jcr->impl_->job_start_wait); /* wake waiting job */ + pthread_cond_signal(&jcr->impl->job_start_wait); /* wake waiting job */ FreeJcr(jcr); return NULL; @@ -239,7 +239,7 @@ bool DoListenRun(JobControlRecord* jcr) */ P(mutex); while (!jcr->authenticated && !JobCanceled(jcr)) { - errstat = pthread_cond_wait(&jcr->impl_->job_start_wait, &mutex); + errstat = pthread_cond_wait(&jcr->impl->job_start_wait, &mutex); if (errstat == EINVAL || errstat == EPERM) { break; } Dmsg1(800, "=== Auth cond errstat=%d\n", errstat); } @@ -300,13 +300,13 @@ static bool StartReplicationSession(JobControlRecord* jcr) BareosSocket* sd = jcr->store_bsock; Dmsg1(120, "Start replication session: %s", sd->msg); - if (jcr->impl_->session_opened) { + if (jcr->impl->session_opened) { PmStrcpy(jcr->errmsg, _("Attempt to open already open session.\n")); sd->fsend(NO_open); return false; } - jcr->impl_->session_opened = true; + jcr->impl->session_opened = true; /* * Send "Ticket" to Storage Daemon @@ -327,7 +327,7 @@ static bool ReplicateData(JobControlRecord* jcr) BareosSocket* sd = jcr->store_bsock; Dmsg1(120, "Replicate data: %s", sd->msg); - if (jcr->impl_->session_opened) { + if (jcr->impl->session_opened) { utime_t now; /* @@ -360,7 +360,7 @@ static bool EndReplicationSession(JobControlRecord* jcr) BareosSocket* sd = jcr->store_bsock; Dmsg1(120, "storedmsg); - if (!jcr->impl_->session_opened) { + if (!jcr->impl->session_opened) { PmStrcpy(jcr->errmsg, _("Attempt to close non-open session.\n")); sd->fsend(NOT_opened); return false; diff --git a/core/src/stored/sd_plugins.cc b/core/src/stored/sd_plugins.cc index d346cbe45a9..366a20831eb 100644 --- a/core/src/stored/sd_plugins.cc +++ b/core/src/stored/sd_plugins.cc @@ -533,11 +533,11 @@ void DispatchNewPluginOptions(JobControlRecord* jcr) if (!sd_plugin_list || sd_plugin_list->empty()) { return; } - if (jcr->impl_->plugin_options && jcr->impl_->plugin_options->size()) { + if (jcr->impl->plugin_options && jcr->impl->plugin_options->size()) { eventType = bsdEventNewPluginOptions; event.eventType = eventType; - foreach_alist_index (i, plugin_options, jcr->impl_->plugin_options) { + foreach_alist_index (i, plugin_options, jcr->impl->plugin_options) { /* * Make a private copy of plugin options. */ @@ -704,7 +704,7 @@ static bRC bareosGetValue(bpContext* ctx, bsdrVariable var, void* value) if (jcr) { switch (var) { case bsdVarJob: - *((char**)value) = jcr->impl_->job_name; + *((char**)value) = jcr->impl->job_name; Dmsg1(debuglevel, "sd-plugin: return bsdVarJobName=%s\n", NPRT(*((char**)value))); break; @@ -728,8 +728,8 @@ static bRC bareosGetValue(bpContext* ctx, bsdrVariable var, void* value) NPRT(*((char**)value))); break; case bsdVarPool: - if (jcr->impl_->dcr) { - *((char**)value) = jcr->impl_->dcr->pool_name; + if (jcr->impl->dcr) { + *((char**)value) = jcr->impl->dcr->pool_name; Dmsg1(debuglevel, "sd-plugin: return bsdVarPool=%s\n", NPRT(*((char**)value))); } else { @@ -737,8 +737,8 @@ static bRC bareosGetValue(bpContext* ctx, bsdrVariable var, void* value) } break; case bsdVarPoolType: - if (jcr->impl_->dcr) { - *((char**)value) = jcr->impl_->dcr->pool_type; + if (jcr->impl->dcr) { + *((char**)value) = jcr->impl->dcr->pool_type; Dmsg1(debuglevel, "sd-plugin: return bsdVarPoolType=%s\n", NPRT(*((char**)value))); } else { @@ -746,8 +746,8 @@ static bRC bareosGetValue(bpContext* ctx, bsdrVariable var, void* value) } break; case bsdVarStorage: - if (jcr->impl_->dcr && jcr->impl_->dcr->device) { - *((char**)value) = jcr->impl_->dcr->device->resource_name_; + if (jcr->impl->dcr && jcr->impl->dcr->device) { + *((char**)value) = jcr->impl->dcr->device->resource_name_; Dmsg1(debuglevel, "sd-plugin: return bsdVarStorage=%s\n", NPRT(*((char**)value))); } else { @@ -755,8 +755,8 @@ static bRC bareosGetValue(bpContext* ctx, bsdrVariable var, void* value) } break; case bsdVarMediaType: - if (jcr->impl_->dcr) { - *((char**)value) = jcr->impl_->dcr->media_type; + if (jcr->impl->dcr) { + *((char**)value) = jcr->impl->dcr->media_type; Dmsg1(debuglevel, "sd-plugin: return bsdVarMediaType=%s\n", NPRT(*((char**)value))); } else { @@ -774,8 +774,8 @@ static bRC bareosGetValue(bpContext* ctx, bsdrVariable var, void* value) jcr->JobStatus); break; case bsdVarVolumeName: - if (jcr->impl_->dcr) { - *((char**)value) = jcr->impl_->dcr->VolumeName; + if (jcr->impl->dcr) { + *((char**)value) = jcr->impl->dcr->VolumeName; Dmsg1(debuglevel, "sd-plugin: return bsdVarVolumeName=%s\n", NPRT(*((char**)value))); } else { diff --git a/core/src/stored/sd_stats.cc b/core/src/stored/sd_stats.cc index dc48c788300..851a84ee5d8 100644 --- a/core/src/stored/sd_stats.cc +++ b/core/src/stored/sd_stats.cc @@ -306,8 +306,8 @@ void UpdateJobStatistics(JobControlRecord* jcr, utime_t now) job_stat->timestamp = now; job_stat->JobFiles = jcr->JobFiles; job_stat->JobBytes = jcr->JobBytes; - if (jcr->impl_->dcr && jcr->impl_->dcr->device) { - job_stat->DevName = strdup(jcr->impl_->dcr->device->resource_name_); + if (jcr->impl->dcr && jcr->impl->dcr->device) { + job_stat->DevName = strdup(jcr->impl->dcr->device->resource_name_); } else { job_stat->DevName = strdup("unknown"); } diff --git a/core/src/stored/spool.cc b/core/src/stored/spool.cc index a5c8624913d..b3ea43ccb9e 100644 --- a/core/src/stored/spool.cc +++ b/core/src/stored/spool.cc @@ -119,7 +119,7 @@ bool BeginDataSpool(DeviceControlRecord* dcr) { bool status = true; - if (dcr->jcr->impl_->spool_data) { + if (dcr->jcr->impl->spool_data) { Dmsg0(100, "Turning on data spooling\n"); dcr->spool_data = true; status = OpenDataSpoolFile(dcr); @@ -187,7 +187,7 @@ static bool OpenDataSpoolFile(DeviceControlRecord* dcr) if ((spool_fd = open(name, O_CREAT | O_TRUNC | O_RDWR | O_BINARY, 0640)) >= 0) { dcr->spool_fd = spool_fd; - dcr->jcr->impl_->spool_attributes = true; + dcr->jcr->impl->spool_attributes = true; } else { BErrNo be; @@ -251,7 +251,7 @@ static bool DespoolData(DeviceControlRecord* dcr, bool commit) BareosSocket* dir = jcr->dir_bsock; Dmsg0(100, "Despooling data\n"); - if (jcr->impl_->dcr->job_spool_size == 0) { + if (jcr->impl->dcr->job_spool_size == 0) { Jmsg(jcr, M_WARNING, 0, _("Despooling zero bytes. Your disk is probably FULL!\n")); } @@ -265,13 +265,13 @@ static bool DespoolData(DeviceControlRecord* dcr, bool commit) Jmsg(jcr, M_INFO, 0, _("Committing spooled data to Volume \"%s\". Despooling %s bytes " "...\n"), - jcr->impl_->dcr->VolumeName, - edit_uint64_with_commas(jcr->impl_->dcr->job_spool_size, ec1)); + jcr->impl->dcr->VolumeName, + edit_uint64_with_commas(jcr->impl->dcr->job_spool_size, ec1)); jcr->setJobStatus(JS_DataCommitting); } else { Jmsg(jcr, M_INFO, 0, _("Writing spooled data to Volume. Despooling %s bytes ...\n"), - edit_uint64_with_commas(jcr->impl_->dcr->job_spool_size, ec1)); + edit_uint64_with_commas(jcr->impl->dcr->job_spool_size, ec1)); jcr->setJobStatus(JS_DataDespooling); } jcr->sendJobStatus(JS_DataDespooling); @@ -376,7 +376,7 @@ static bool DespoolData(DeviceControlRecord* dcr, bool commit) despool_elapsed / 3600, despool_elapsed % 3600 / 60, despool_elapsed % 60, edit_uint64_with_suffix( - jcr->impl_->dcr->job_spool_size / despool_elapsed, ec1)); + jcr->impl->dcr->job_spool_size / despool_elapsed, ec1)); dcr->block = block; /* reset block */ @@ -687,7 +687,7 @@ static bool WriteSpoolData(DeviceControlRecord* dcr) bool AreAttributesSpooled(JobControlRecord* jcr) { - return jcr->impl_->spool_attributes && jcr->dir_bsock->spool_fd_ != -1; + return jcr->impl->spool_attributes && jcr->dir_bsock->spool_fd_ != -1; } /** @@ -699,7 +699,7 @@ bool AreAttributesSpooled(JobControlRecord* jcr) */ bool BeginAttributeSpool(JobControlRecord* jcr) { - if (!jcr->impl_->no_attributes && jcr->impl_->spool_attributes) { + if (!jcr->impl->no_attributes && jcr->impl->spool_attributes) { return OpenAttrSpoolFile(jcr, jcr->dir_bsock); } return true; diff --git a/core/src/stored/status.cc b/core/src/stored/status.cc index 0cf35d31c9f..c90778dde3e 100644 --- a/core/src/stored/status.cc +++ b/core/src/stored/status.cc @@ -688,8 +688,8 @@ static void ListRunningJobs(StatusPacket* sp) job_type_to_str(jcr->getJobType()), jcr->Job); sendit(msg, len, sp); } - dcr = jcr->impl_->dcr; - rdcr = jcr->impl_->read_dcr; + dcr = jcr->impl->dcr; + rdcr = jcr->impl->read_dcr; if ((dcr && dcr->device) || (rdcr && rdcr->device)) { bstrncpy(JobName, jcr->Job, sizeof(JobName)); /* There are three periods after the Job name */ @@ -777,7 +777,7 @@ static inline void SendDriveReserveMessages(JobControlRecord* jcr, char* msg; jcr->lock(); - msgs = jcr->impl_->reserve_msgs; + msgs = jcr->impl->reserve_msgs; if (!msgs || msgs->size() == 0) { goto bail_out; } for (i = msgs->size() - 1; i >= 0; i--) { msg = (char*)msgs->get(i); @@ -805,7 +805,7 @@ static void ListJobsWaitingOnReservation(StatusPacket* sp) } foreach_jcr (jcr) { - if (!jcr->impl_->reserve_msgs) { continue; } + if (!jcr->impl->reserve_msgs) { continue; } SendDriveReserveMessages(jcr, sp); } endeach_jcr(jcr); diff --git a/core/src/stored/stored.cc b/core/src/stored/stored.cc index c312c946593..cdb655cf330 100644 --- a/core/src/stored/stored.cc +++ b/core/src/stored/stored.cc @@ -541,7 +541,7 @@ extern "C" void* device_initialization(void* arg) /* * Initialize job start condition variable */ - errstat = pthread_cond_init(&jcr->impl_->job_start_wait, NULL); + errstat = pthread_cond_init(&jcr->impl->job_start_wait, NULL); if (errstat != 0) { BErrNo be; Jmsg1(jcr, M_ABORT, 0, @@ -552,7 +552,7 @@ extern "C" void* device_initialization(void* arg) /* * Initialize job end condition variable */ - errstat = pthread_cond_init(&jcr->impl_->job_end_wait, NULL); + errstat = pthread_cond_init(&jcr->impl->job_end_wait, NULL); if (errstat != 0) { BErrNo be; Jmsg1(jcr, M_ABORT, 0, @@ -571,9 +571,9 @@ extern "C" void* device_initialization(void* arg) } dcr = new StorageDaemonDeviceControlRecord; - jcr->impl_->dcr = dcr; + jcr->impl->dcr = dcr; SetupNewDcrDevice(jcr, dcr, dev, NULL); - jcr->impl_->dcr->SetWillWrite(); + jcr->impl->dcr->SetWillWrite(); GeneratePluginEvent(jcr, bsdEventDeviceInit, dcr); if (dev->IsAutochanger()) { /* @@ -589,7 +589,7 @@ extern "C" void* device_initialization(void* arg) dev->print_name()); Dmsg1(20, "Could not open device %s\n", dev->print_name()); FreeDeviceControlRecord(dcr); - jcr->impl_->dcr = NULL; + jcr->impl->dcr = NULL; continue; } } @@ -607,7 +607,7 @@ extern "C" void* device_initialization(void* arg) } } FreeDeviceControlRecord(dcr); - jcr->impl_->dcr = NULL; + jcr->impl->dcr = NULL; } FreeJcr(jcr); init_done = true; @@ -661,16 +661,16 @@ static jcr->MyThreadSendSignal(TIMEOUT_SIGNAL); Dmsg1(100, "term_stored killing JobId=%d\n", jcr->JobId); /* ***FIXME*** wiffle through all dcrs */ - if (jcr->impl_->dcr && jcr->impl_->dcr->dev && - jcr->impl_->dcr->dev->blocked()) { - pthread_cond_broadcast(&jcr->impl_->dcr->dev->wait_next_vol); + if (jcr->impl->dcr && jcr->impl->dcr->dev && + jcr->impl->dcr->dev->blocked()) { + pthread_cond_broadcast(&jcr->impl->dcr->dev->wait_next_vol); Dmsg1(100, "JobId=%u broadcast wait_device_release\n", (uint32_t)jcr->JobId); ReleaseDeviceCond(); } - if (jcr->impl_->read_dcr && jcr->impl_->read_dcr->dev && - jcr->impl_->read_dcr->dev->blocked()) { - pthread_cond_broadcast(&jcr->impl_->read_dcr->dev->wait_next_vol); + if (jcr->impl->read_dcr && jcr->impl->read_dcr->dev && + jcr->impl->read_dcr->dev->blocked()) { + pthread_cond_broadcast(&jcr->impl->read_dcr->dev->wait_next_vol); Dmsg1(100, "JobId=%u broadcast wait_device_release\n", (uint32_t)jcr->JobId); ReleaseDeviceCond(); diff --git a/core/src/tests/sd_reservation.cc b/core/src/tests/sd_reservation.cc index 4cccc8a33d9..df170dcc042 100644 --- a/core/src/tests/sd_reservation.cc +++ b/core/src/tests/sd_reservation.cc @@ -138,7 +138,7 @@ void WaitThenUnreserve(std::unique_ptr&); void WaitThenUnreserve(std::unique_ptr& job) { std::this_thread::sleep_for(std::chrono::milliseconds(10)); - job->jcr->impl_->dcr->UnreserveDevice(); + job->jcr->impl->dcr->UnreserveDevice(); ReleaseDeviceCond(); } diff --git a/core/src/win32/filed/vss.cc b/core/src/win32/filed/vss.cc index 041d62ba69c..aef9f39cbd2 100644 --- a/core/src/win32/filed/vss.cc +++ b/core/src/win32/filed/vss.cc @@ -56,8 +56,8 @@ static bool VSSPathConvert(const char* szFilePath, { JobControlRecord* jcr = GetJcrFromThreadSpecificData(); - if (jcr && jcr->impl_->pVSSClient) { - return jcr->impl_->pVSSClient->GetShadowPath(szFilePath, szShadowPath, + if (jcr && jcr->impl->pVSSClient) { + return jcr->impl->pVSSClient->GetShadowPath(szFilePath, szShadowPath, nBuflen); } @@ -70,8 +70,8 @@ static bool VSSPathConvertW(const wchar_t* szFilePath, { JobControlRecord* jcr = GetJcrFromThreadSpecificData(); - if (jcr && jcr->impl_->pVSSClient) { - return jcr->impl_->pVSSClient->GetShadowPathW(szFilePath, szShadowPath, + if (jcr && jcr->impl->pVSSClient) { + return jcr->impl->pVSSClient->GetShadowPathW(szFilePath, szShadowPath, nBuflen); } @@ -86,17 +86,17 @@ void VSSInit(JobControlRecord* jcr) if (g_MajorVersion == 5) { switch (g_MinorVersion) { case 1: - jcr->impl_->pVSSClient = new VSSClientXP(); + jcr->impl->pVSSClient = new VSSClientXP(); break; case 2: - jcr->impl_->pVSSClient = new VSSClient2003(); + jcr->impl->pVSSClient = new VSSClient2003(); break; } /* * Vista or Longhorn or later */ } else if (g_MajorVersion >= 6) { - jcr->impl_->pVSSClient = new VSSClientVista(); + jcr->impl->pVSSClient = new VSSClientVista(); } /* From e6a7135c78e4ab7759475e66700f1cfcc6b410ab Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Wed, 6 Nov 2019 10:39:44 +0100 Subject: [PATCH 09/23] stored: refactore member initializers --- core/src/stored/jcr_private.h | 92 +++++++++++++++++------------------ 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/core/src/stored/jcr_private.h b/core/src/stored/jcr_private.h index 6b8c74bd53f..7df89552b0c 100644 --- a/core/src/stored/jcr_private.h +++ b/core/src/stored/jcr_private.h @@ -38,61 +38,61 @@ struct BootStrapRecord; /* clang-format off */ struct JobControlRecordPrivate { - JobControlRecord* next_dev = nullptr; /**< Next JobControlRecord attached to device */ - JobControlRecord* prev_dev = nullptr; /**< Previous JobControlRecord attached to device */ + JobControlRecord* next_dev{}; /**< Next JobControlRecord attached to device */ + JobControlRecord* prev_dev{}; /**< Previous JobControlRecord attached to device */ pthread_cond_t job_start_wait = PTHREAD_COND_INITIALIZER; /**< Wait for FD to start Job */ - pthread_cond_t job_end_wait = PTHREAD_COND_INITIALIZER; /**< Wait for Job to end */ - storagedaemon::DeviceControlRecord* read_dcr = nullptr; /**< Device context for reading */ - storagedaemon::DeviceControlRecord* dcr = nullptr; /**< Device context record */ - POOLMEM* job_name = nullptr; /**< Base Job name (not unique) */ - POOLMEM* fileset_name = nullptr; /**< FileSet */ - POOLMEM* fileset_md5 = nullptr; /**< MD5 for FileSet */ - POOLMEM* backup_format = nullptr; /**< Backup format used when doing a NDMP backup */ - storagedaemon::VolumeList* VolList = nullptr; /**< List to read */ - int32_t NumWriteVolumes = 0; /**< Number of volumes written */ - int32_t NumReadVolumes = 0; /**< Total number of volumes to read */ - int32_t CurReadVolume = 0; /**< Current read volume number */ - int32_t label_errors = 0; /**< Count of label errors */ - bool session_opened = false; - bool remote_replicate = false; /**< Replicate data to remote SD */ - int32_t Ticket = 0; /**< Ticket for this job */ - bool ignore_label_errors = false; /**< Ignore Volume label errors */ - bool spool_attributes = false; /**< Set if spooling attributes */ - bool no_attributes = false; /**< Set if no attributes wanted */ - int64_t spool_size = 0; /**< Spool size for this job */ - bool spool_data = false; /**< Set to spool data */ - storagedaemon::DirectorResource* director = nullptr; /**< Director resource */ - alist* plugin_options = nullptr; /**< Specific Plugin Options sent by DIR */ - alist* write_store = nullptr; /**< List of write storage devices sent by DIR */ - alist* read_store = nullptr; /**< List of read devices sent by DIR */ - alist* reserve_msgs = nullptr; /**< Reserve fail messages */ - bool acquired_storage = false; /**< Did we acquire our reserved storage already or not */ - bool PreferMountedVols = false; /**< Prefer mounted vols rather than new */ - bool insert_jobmedia_records = false; /**< Need to insert job media records */ - uint64_t RemainingQuota = 0; /**< Available bytes to use as quota */ + pthread_cond_t job_end_wait = PTHREAD_COND_INITIALIZER; /**< Wait for Job to end */ + storagedaemon::DeviceControlRecord* read_dcr{}; /**< Device context for reading */ + storagedaemon::DeviceControlRecord* dcr{}; /**< Device context record */ + POOLMEM* job_name{}; /**< Base Job name (not unique) */ + POOLMEM* fileset_name{}; /**< FileSet */ + POOLMEM* fileset_md5{}; /**< MD5 for FileSet */ + POOLMEM* backup_format{}; /**< Backup format used when doing a NDMP backup */ + storagedaemon::VolumeList* VolList{}; /**< List to read */ + int32_t NumWriteVolumes{}; /**< Number of volumes written */ + int32_t NumReadVolumes{}; /**< Total number of volumes to read */ + int32_t CurReadVolume{}; /**< Current read volume number */ + int32_t label_errors{}; /**< Count of label errors */ + bool session_opened{}; + bool remote_replicate{}; /**< Replicate data to remote SD */ + int32_t Ticket{}; /**< Ticket for this job */ + bool ignore_label_errors{}; /**< Ignore Volume label errors */ + bool spool_attributes{}; /**< Set if spooling attributes */ + bool no_attributes{}; /**< Set if no attributes wanted */ + int64_t spool_size{}; /**< Spool size for this job */ + bool spool_data{}; /**< Set to spool data */ + storagedaemon::DirectorResource* director{}; /**< Director resource */ + alist* plugin_options{}; /**< Specific Plugin Options sent by DIR */ + alist* write_store{}; /**< List of write storage devices sent by DIR */ + alist* read_store{}; /**< List of read devices sent by DIR */ + alist* reserve_msgs{}; /**< Reserve fail messages */ + bool acquired_storage{}; /**< Did we acquire our reserved storage already or not */ + bool PreferMountedVols{}; /**< Prefer mounted vols rather than new */ + bool insert_jobmedia_records{}; /**< Need to insert job media records */ + uint64_t RemainingQuota{}; /**< Available bytes to use as quota */ /* * Parameters for Open Read Session */ - storagedaemon::READ_CTX* rctx = nullptr; /**< Read context used to keep track of what is processed or not */ - storagedaemon::BootStrapRecord* bsr = nullptr; /**< Bootstrap record -- has everything */ - bool mount_next_volume = false; /**< Set to cause next volume mount */ - uint32_t read_VolSessionId = 0; - uint32_t read_VolSessionTime = 0; - uint32_t read_StartFile = 0; - uint32_t read_EndFile = 0; - uint32_t read_StartBlock = 0; - uint32_t read_EndBlock = 0; + storagedaemon::READ_CTX* rctx{}; /**< Read context used to keep track of what is processed or not */ + storagedaemon::BootStrapRecord* bsr{}; /**< Bootstrap record -- has everything */ + bool mount_next_volume{}; /**< Set to cause next volume mount */ + uint32_t read_VolSessionId{}; + uint32_t read_VolSessionTime{}; + uint32_t read_StartFile{}; + uint32_t read_EndFile{}; + uint32_t read_StartBlock{}; + uint32_t read_EndBlock{}; /* * Device wait times */ - int32_t min_wait = 0; - int32_t max_wait = 0; - int32_t max_num_wait = 0; - int32_t wait_sec = 0; - int32_t rem_wait_sec = 0; - int32_t num_wait = 0; + int32_t min_wait{}; + int32_t max_wait{}; + int32_t max_num_wait{}; + int32_t wait_sec{}; + int32_t rem_wait_sec{}; + int32_t num_wait{}; }; /* clang-format on */ From e07b91ab1970ecdd2920b3a9939cd9880bc7547d Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Wed, 6 Nov 2019 10:37:05 +0100 Subject: [PATCH 10/23] filed: refactore member initializers --- core/src/filed/jcr_private.h | 84 ++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/core/src/filed/jcr_private.h b/core/src/filed/jcr_private.h index 30fe47dbe37..bf5048837ad 100644 --- a/core/src/filed/jcr_private.h +++ b/core/src/filed/jcr_private.h @@ -35,55 +35,53 @@ class BareosAccurateFilelist; /* clang-format off */ struct CryptoContext { - bool pki_sign = false; /**< Enable PKI Signatures? */ - bool pki_encrypt = false; /**< Enable PKI Encryption? */ - DIGEST* digest = nullptr; /**< Last file's digest context */ - X509_KEYPAIR* pki_keypair = nullptr; /**< Encryption key pair */ - alist* pki_signers = nullptr; /**< Trusted Signers */ - alist* pki_recipients = nullptr; /**< Trusted Recipients */ - CRYPTO_SESSION* pki_session = nullptr; /**< PKE Public Keys + Symmetric Session Keys */ - POOLMEM* crypto_buf = nullptr; /**< Encryption/Decryption buffer */ - POOLMEM* pki_session_encoded = nullptr; /**< Cached DER-encoded copy of pki_session */ - int32_t pki_session_encoded_size = 0; /**< Size of DER-encoded pki_session */ + bool pki_sign{}; /**< Enable PKI Signatures? */ + bool pki_encrypt{}; /**< Enable PKI Encryption? */ + DIGEST* digest{}; /**< Last file's digest context */ + X509_KEYPAIR* pki_keypair{}; /**< Encryption key pair */ + alist* pki_signers{}; /**< Trusted Signers */ + alist* pki_recipients{}; /**< Trusted Recipients */ + CRYPTO_SESSION* pki_session{}; /**< PKE Public Keys + Symmetric Session Keys */ + POOLMEM* crypto_buf{}; /**< Encryption/Decryption buffer */ + POOLMEM* pki_session_encoded{}; /**< Cached DER-encoded copy of pki_session */ + int32_t pki_session_encoded_size{}; /**< Size of DER-encoded pki_session */ }; struct JobControlRecordPrivate { - uint32_t num_files_examined = 0; /**< Files examined this job */ - POOLMEM* last_fname = nullptr; /**< Last file saved/verified */ - POOLMEM* job_metadata = nullptr; /**< VSS job metadata */ - acl_data_t* acl_data = nullptr; /**< ACLs for backup/restore */ - xattr_data_t* xattr_data = - nullptr; /**< Extended Attributes for backup/restore */ - int32_t last_type = 0; /**< Type of last file saved/verified */ - bool incremental = false; /**< Set if incremental for SINCE */ - utime_t mtime = 0; /**< Begin time for SINCE */ - int listing = 0; /**< Job listing in estimate */ - int32_t Ticket = 0; /**< Ticket */ - char* big_buf = nullptr; /**< I/O buffer */ - int32_t replace = 0; /**< Replace options */ - FindFilesPacket* ff = nullptr; /**< Find Files packet */ - char PrevJob[MAX_NAME_LENGTH]{ - 0}; /**< Previous job name assiciated with since time */ - uint32_t ExpectedFiles = 0; /**< Expected restore files */ - uint32_t StartFile = 0; - uint32_t EndFile = 0; - uint32_t StartBlock = 0; - uint32_t EndBlock = 0; - pthread_t heartbeat_id = 0; /**< Id of heartbeat thread */ - volatile bool hb_started = false; /**< Heartbeat running */ + uint32_t num_files_examined{}; /**< Files examined this job */ + POOLMEM* last_fname{}; /**< Last file saved/verified */ + POOLMEM* job_metadata{}; /**< VSS job metadata */ + acl_data_t* acl_data{}; /**< ACLs for backup/restore */ + xattr_data_t* xattr_data{}; /**< Extended Attributes for backup/restore */ + int32_t last_type{}; /**< Type of last file saved/verified */ + bool incremental{}; /**< Set if incremental for SINCE */ + utime_t mtime{}; /**< Begin time for SINCE */ + int listing{}; /**< Job listing in estimate */ + int32_t Ticket{}; /**< Ticket */ + char* big_buf{}; /**< I/O buffer */ + int32_t replace{}; /**< Replace options */ + FindFilesPacket* ff{}; /**< Find Files packet */ + char PrevJob[MAX_NAME_LENGTH]{};/**< Previous job name assiciated with since time */ + uint32_t ExpectedFiles{}; /**< Expected restore files */ + uint32_t StartFile{}; + uint32_t EndFile{}; + uint32_t StartBlock{}; + uint32_t EndBlock{}; + pthread_t heartbeat_id{}; /**< Id of heartbeat thread */ + volatile bool hb_started{}; /**< Heartbeat running */ std::shared_ptr hb_bsock; /**< Duped SD socket */ std::shared_ptr hb_dir_bsock; /**< Duped DIR socket */ - alist* RunScripts = nullptr; /**< Commands to run before and after job */ - CryptoContext crypto; /**< Crypto ctx */ - filedaemon::DirectorResource* director = nullptr; /**< Director resource */ - bool enable_vss = false; /**< VSS used by FD */ - bool got_metadata = false; /**< Set when found job_metadata */ - bool multi_restore = false; /**< Dir can do multiple storage restore */ - filedaemon::BareosAccurateFilelist* file_list = nullptr; /**< Previous file list (accurate mode) */ - uint64_t base_size = 0; /**< Compute space saved with base job */ - filedaemon::save_pkt* plugin_sp = nullptr; /**< Plugin save packet */ + alist* RunScripts{}; /**< Commands to run before and after job */ + CryptoContext crypto; /**< Crypto ctx */ + filedaemon::DirectorResource* director{}; /**< Director resource */ + bool enable_vss{}; /**< VSS used by FD */ + bool got_metadata{}; /**< Set when found job_metadata */ + bool multi_restore{}; /**< Dir can do multiple storage restore */ + filedaemon::BareosAccurateFilelist* file_list{}; /**< Previous file list (accurate mode) */ + uint64_t base_size{}; /**< Compute space saved with base job */ + filedaemon::save_pkt* plugin_sp{}; /**< Plugin save packet */ #ifdef HAVE_WIN32 - VSSClient* pVSSClient = nullptr; /**< VSS Client Instance */ + VSSClient* pVSSClient{}; /**< VSS Client Instance */ #endif }; /* clang-format on */ From b7ac25df0b57fdb2436f38576cae233c362496ca Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Wed, 6 Nov 2019 10:37:05 +0100 Subject: [PATCH 11/23] dird: refactore member initializers --- core/src/dird/jcr_private.h | 189 ++++++++++++++++++------------------ 1 file changed, 94 insertions(+), 95 deletions(-) diff --git a/core/src/dird/jcr_private.h b/core/src/dird/jcr_private.h index d63587a5138..97c989e5483 100644 --- a/core/src/dird/jcr_private.h +++ b/core/src/dird/jcr_private.h @@ -47,109 +47,108 @@ class CatalogResource; /* clang-format off */ struct Resources { - directordaemon::JobResource* job = nullptr; /**< Job resource */ - directordaemon::JobResource* verify_job = nullptr; /**< Job resource of verify previous job */ - directordaemon::JobResource* previous_job = nullptr; /**< Job resource of migration previous job */ - directordaemon::StorageResource* read_storage = nullptr; /**< Selected read storage */ - directordaemon::StorageResource* write_storage = nullptr; /**< Selected write storage */ - directordaemon::StorageResource* paired_read_write_storage = nullptr; /*< Selected paired storage (savedwrite_storage or read_storage)*/ - directordaemon::ClientResource* client = nullptr; /**< Client resource */ - directordaemon::PoolResource* pool = nullptr; /**< Pool resource = write for migration */ - directordaemon::PoolResource* rpool = nullptr; /**< Read pool. Used only in migration */ - directordaemon::PoolResource* full_pool = nullptr; /**< Full backup pool resource */ - directordaemon::PoolResource* vfull_pool = nullptr; /**< Virtual Full backup pool resource */ - directordaemon::PoolResource* inc_pool = nullptr; /**< Incremental backup pool resource */ - directordaemon::PoolResource* diff_pool = nullptr; /**< Differential backup pool resource */ - directordaemon::PoolResource* next_pool = nullptr; /**< Next Pool used for migration/copy and virtual backup */ - directordaemon::FilesetResource* fileset = nullptr; /**< FileSet resource */ - directordaemon::CatalogResource* catalog = nullptr; /**< Catalog resource */ - MessagesResource* messages = nullptr; /**< Default message handler */ - POOLMEM* pool_source = nullptr; /**< Where pool came from */ - POOLMEM* npool_source = nullptr; /**< Where next pool came from */ - POOLMEM* rpool_source = nullptr; /**< Where migrate read pool came from */ - POOLMEM* rstore_source = nullptr; /**< Where read storage came from */ - POOLMEM* wstore_source = nullptr; /**< Where write storage came from */ - POOLMEM* catalog_source = nullptr; /**< Where catalog came from */ - alist* read_storage_list = nullptr; /**< Read storage possibilities */ - alist* write_storage_list = nullptr; /**< Write storage possibilities */ - alist* paired_read_write_storage_list = nullptr; /**< Paired storage possibilities - * (saved write_storage_list or read_storage_list) */ - bool run_pool_override = false; /**< Pool override was given on run cmdline */ - bool run_full_pool_override = false; /**< Full pool override was given on run cmdline */ - bool run_vfull_pool_override = false; /**< Virtual Full pool override was given on run cmdline */ - bool run_inc_pool_override = false; /**< Incremental pool override was given on run cmdline */ - bool run_diff_pool_override = false; /**< Differential pool override was given on run cmdline */ - bool run_next_pool_override = false; /**< Next pool override was given on run cmdline */ + directordaemon::JobResource* job{}; /**< Job resource */ + directordaemon::JobResource* verify_job{}; /**< Job resource of verify previous job */ + directordaemon::JobResource* previous_job{}; /**< Job resource of migration previous job */ + directordaemon::StorageResource* read_storage{}; /**< Selected read storage */ + directordaemon::StorageResource* write_storage{}; /**< Selected write storage */ + directordaemon::StorageResource* paired_read_write_storage{}; /*< Selected paired storage (savedwrite_storage or read_storage)*/ + directordaemon::ClientResource* client{}; /**< Client resource */ + directordaemon::PoolResource* pool{}; /**< Pool resource = write for migration */ + directordaemon::PoolResource* rpool{}; /**< Read pool. Used only in migration */ + directordaemon::PoolResource* full_pool{}; /**< Full backup pool resource */ + directordaemon::PoolResource* vfull_pool{}; /**< Virtual Full backup pool resource */ + directordaemon::PoolResource* inc_pool{}; /**< Incremental backup pool resource */ + directordaemon::PoolResource* diff_pool{}; /**< Differential backup pool resource */ + directordaemon::PoolResource* next_pool{}; /**< Next Pool used for migration/copy and virtual backup */ + directordaemon::FilesetResource* fileset{}; /**< FileSet resource */ + directordaemon::CatalogResource* catalog{}; /**< Catalog resource */ + MessagesResource* messages{}; /**< Default message handler */ + POOLMEM* pool_source{}; /**< Where pool came from */ + POOLMEM* npool_source{}; /**< Where next pool came from */ + POOLMEM* rpool_source{}; /**< Where migrate read pool came from */ + POOLMEM* rstore_source{}; /**< Where read storage came from */ + POOLMEM* wstore_source{}; /**< Where write storage came from */ + POOLMEM* catalog_source{}; /**< Where catalog came from */ + alist* read_storage_list{}; /**< Read storage possibilities */ + alist* write_storage_list{}; /**< Write storage possibilities */ + alist* paired_read_write_storage_list{}; /**< Paired storage possibilities (saved write_storage_list or read_storage_list) */ + bool run_pool_override{}; /**< Pool override was given on run cmdline */ + bool run_full_pool_override{}; /**< Full pool override was given on run cmdline */ + bool run_vfull_pool_override{}; /**< Virtual Full pool override was given on run cmdline */ + bool run_inc_pool_override{}; /**< Incremental pool override was given on run cmdline */ + bool run_diff_pool_override{}; /**< Differential pool override was given on run cmdline */ + bool run_next_pool_override{}; /**< Next pool override was given on run cmdline */ }; struct JobControlRecordPrivate { JobControlRecordPrivate() { RestoreJobId = 0; MigrateJobId = 0; VerifyJobId = 0; } - pthread_t SD_msg_chan = 0; /**< Message channel thread id */ - bool SD_msg_chan_started = false; /**< Message channel thread started */ - pthread_cond_t term_wait = PTHREAD_COND_INITIALIZER; /**< Wait for job termination */ - pthread_cond_t nextrun_ready = PTHREAD_COND_INITIALIZER; /**< Wait for job next run to become ready */ - Resources res; /**< Resources assigned */ - TREE_ROOT* restore_tree_root = nullptr; /**< Selected files to restore (some protocols need this info) */ - storagedaemon::BootStrapRecord* bsr = nullptr; /**< Bootstrap record -- has everything */ - char* backup_format = nullptr; /**< Backup format used when doing a NDMP backup */ - char* plugin_options = nullptr; /**< User set options for plugin */ - uint32_t SDJobFiles = 0; /**< Number of files written, this job */ - uint64_t SDJobBytes = 0; /**< Number of bytes processed this job */ - uint32_t SDErrors = 0; /**< Number of non-fatal errors */ - volatile int32_t SDJobStatus = 0; /**< Storage Job Status */ - volatile int32_t FDJobStatus = 0; /**< File daemon Job Status */ - uint32_t DumpLevel = 0; /**< Dump level when doing a NDMP backup */ - uint32_t ExpectedFiles = 0; /**< Expected restore files */ - uint32_t MediaId = 0; /**< DB record IDs associated with this job */ - uint32_t FileIndex = 0; /**< Last FileIndex processed */ - utime_t MaxRunSchedTime = 0; /**< Max run time in seconds from Initial Scheduled time */ - JobDbRecord jr; /**< Job DB record for current job */ - JobDbRecord previous_jr; /**< Previous job database record */ - JobControlRecord* mig_jcr = nullptr; /**< JobControlRecord for migration/copy job */ - char FSCreateTime[MAX_TIME_LENGTH]{0}; /**< FileSet CreateTime as returned from DB */ - char since[MAX_TIME_LENGTH]{0}; /**< Since time */ - char PrevJob[MAX_NAME_LENGTH]{0}; /**< Previous job name assiciated with since time */ + pthread_t SD_msg_chan{}; /**< Message channel thread id */ + bool SD_msg_chan_started{}; /**< Message channel thread started */ + pthread_cond_t term_wait = PTHREAD_COND_INITIALIZER; /**< Wait for job termination */ + pthread_cond_t nextrun_ready = PTHREAD_COND_INITIALIZER; /**< Wait for job next run to become ready */ + Resources res; /**< Resources assigned */ + TREE_ROOT* restore_tree_root{}; /**< Selected files to restore (some protocols need this info) */ + storagedaemon::BootStrapRecord* bsr{}; /**< Bootstrap record -- has everything */ + char* backup_format{}; /**< Backup format used when doing a NDMP backup */ + char* plugin_options{}; /**< User set options for plugin */ + uint32_t SDJobFiles{}; /**< Number of files written, this job */ + uint64_t SDJobBytes{}; /**< Number of bytes processed this job */ + uint32_t SDErrors{}; /**< Number of non-fatal errors */ + volatile int32_t SDJobStatus{}; /**< Storage Job Status */ + volatile int32_t FDJobStatus{}; /**< File daemon Job Status */ + uint32_t DumpLevel{}; /**< Dump level when doing a NDMP backup */ + uint32_t ExpectedFiles{}; /**< Expected restore files */ + uint32_t MediaId{}; /**< DB record IDs associated with this job */ + uint32_t FileIndex{}; /**< Last FileIndex processed */ + utime_t MaxRunSchedTime{}; /**< Max run time in seconds from Initial Scheduled time */ + JobDbRecord jr; /**< Job DB record for current job */ + JobDbRecord previous_jr; /**< Previous job database record */ + JobControlRecord* mig_jcr{}; /**< JobControlRecord for migration/copy job */ + char FSCreateTime[MAX_TIME_LENGTH]{}; /**< FileSet CreateTime as returned from DB */ + char since[MAX_TIME_LENGTH]{}; /**< Since time */ + char PrevJob[MAX_NAME_LENGTH]{}; /**< Previous job name assiciated with since time */ union { - JobId_t RestoreJobId; /**< Restore JobId specified by UA */ - JobId_t MigrateJobId; /**< Migration JobId specified by UA */ - JobId_t VerifyJobId; /**< Verify JobId specified by UA */ + JobId_t RestoreJobId; /**< Restore JobId specified by UA */ + JobId_t MigrateJobId; /**< Migration JobId specified by UA */ + JobId_t VerifyJobId; /**< Verify JobId specified by UA */ }; - POOLMEM* fname = nullptr; /**< Name to put into catalog */ - POOLMEM* client_uname = nullptr; /**< Client uname */ - POOLMEM* FDSecureEraseCmd = nullptr; /**< Report: Secure Erase Command */ - POOLMEM* SDSecureEraseCmd = nullptr; /**< Report: Secure Erase Command */ - POOLMEM* vf_jobids = nullptr; /**< JobIds to use for Virtual Full */ - uint32_t replace = 0; /**< Replace option */ - int32_t NumVols = 0; /**< Number of Volume used in pool */ - int32_t reschedule_count = 0; /**< Number of times rescheduled */ - int32_t FDVersion = 0; /**< File daemon version number */ - int64_t spool_size = 0; /**< Spool size for this job */ - volatile bool sd_msg_thread_done = false; /**< Set when Storage message thread done */ - bool IgnoreDuplicateJobChecking = false; /**< Set in migration jobs */ - bool IgnoreLevelPoolOverides = false; /**< Set if a cmdline pool was specified */ - bool IgnoreClientConcurrency = false; /**< Set in migration jobs */ - bool IgnoreStorageConcurrency = false; /**< Set in migration jobs */ - bool spool_data = false; /**< Spool data in SD */ - bool acquired_resource_locks = false; /**< Set if resource locks acquired */ - bool term_wait_inited = false; /**< Set when cond var inited */ - bool nextrun_ready_inited = false; /**< Set when cond var inited */ - bool fn_printed = false; /**< Printed filename */ - bool needs_sd = false; /**< Set if SD needed by Job */ - bool cloned = false; /**< Set if cloned */ - bool unlink_bsr = false; /**< Unlink bsr file created */ - bool VSS = false; /**< VSS used by FD */ - bool Encrypt = false; /**< Encryption used by FD */ - bool no_maxtime = false; /**< Don't check Max*Time for this JobControlRecord */ - bool keep_sd_auth_key = false; /**< Clear or not the SD auth key after connection*/ - bool use_accurate_chksum = false; /**< Use or not checksum option in accurate code */ - bool sd_canceled = false; /**< Set if SD canceled */ - bool remote_replicate = false; /**< Replicate data to remote SD */ - bool HasQuota = false; /**< Client has quota limits */ - bool HasSelectedJobs = false; /**< Migration/Copy Job did actually select some JobIds */ - directordaemon::ClientConnectionHandshakeMode connection_handshake_try_ = - directordaemon::ClientConnectionHandshakeMode::kUndefined; + POOLMEM* fname{}; /**< Name to put into catalog */ + POOLMEM* client_uname{}; /**< Client uname */ + POOLMEM* FDSecureEraseCmd{}; /**< Report: Secure Erase Command */ + POOLMEM* SDSecureEraseCmd{}; /**< Report: Secure Erase Command */ + POOLMEM* vf_jobids{}; /**< JobIds to use for Virtual Full */ + uint32_t replace{}; /**< Replace option */ + int32_t NumVols{}; /**< Number of Volume used in pool */ + int32_t reschedule_count{}; /**< Number of times rescheduled */ + int32_t FDVersion{}; /**< File daemon version number */ + int64_t spool_size{}; /**< Spool size for this job */ + volatile bool sd_msg_thread_done{}; /**< Set when Storage message thread done */ + bool IgnoreDuplicateJobChecking{}; /**< Set in migration jobs */ + bool IgnoreLevelPoolOverides{}; /**< Set if a cmdline pool was specified */ + bool IgnoreClientConcurrency{}; /**< Set in migration jobs */ + bool IgnoreStorageConcurrency{}; /**< Set in migration jobs */ + bool spool_data{}; /**< Spool data in SD */ + bool acquired_resource_locks{}; /**< Set if resource locks acquired */ + bool term_wait_inited{}; /**< Set when cond var inited */ + bool nextrun_ready_inited{}; /**< Set when cond var inited */ + bool fn_printed{}; /**< Printed filename */ + 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 */ + bool no_maxtime{}; /**< Don't check Max*Time for this JobControlRecord */ + 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 */ + bool sd_canceled{}; /**< Set if SD canceled */ + bool remote_replicate{}; /**< Replicate data to remote SD */ + bool HasQuota{}; /**< Client has quota limits */ + bool HasSelectedJobs{}; /**< Migration/Copy Job did actually select some JobIds */ + directordaemon::ClientConnectionHandshakeMode connection_handshake_try_{ + directordaemon::ClientConnectionHandshakeMode::kUndefined}; }; /* clang-format on */ From 2f40f563f663f1ff1812eb7d812f8abd3e64d31f Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Wed, 6 Nov 2019 11:47:33 +0100 Subject: [PATCH 12/23] stored: place members into separate struct DeviceWaitTimes --- core/src/stored/dev.cc | 28 ++++++++++++++++------------ core/src/stored/jcr_private.h | 22 +++++++++++++--------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/core/src/stored/dev.cc b/core/src/stored/dev.cc index 51aaf2e0882..f84810cb55e 100644 --- a/core/src/stored/dev.cc +++ b/core/src/stored/dev.cc @@ -447,23 +447,27 @@ void InitDeviceWaitTimers(DeviceControlRecord* dcr) dev->num_wait = 0; dev->poll = false; - jcr->impl->min_wait = 60 * 60; - jcr->impl->max_wait = 24 * 60 * 60; - jcr->impl->max_num_wait = 9; /* 5 waits =~ 1 day, then 1 day at a time */ - jcr->impl->wait_sec = jcr->impl->min_wait; - jcr->impl->rem_wait_sec = jcr->impl->wait_sec; - jcr->impl->num_wait = 0; + jcr->impl->device_wait_times.min_wait = 60 * 60; + jcr->impl->device_wait_times.max_wait = 24 * 60 * 60; + jcr->impl->device_wait_times.max_num_wait = + 9; /* 5 waits =~ 1 day, then 1 day at a time */ + jcr->impl->device_wait_times.wait_sec = jcr->impl->device_wait_times.min_wait; + jcr->impl->device_wait_times.rem_wait_sec = + jcr->impl->device_wait_times.wait_sec; + jcr->impl->device_wait_times.num_wait = 0; } void InitJcrDeviceWaitTimers(JobControlRecord* jcr) { /* ******FIXME******* put these on config variables */ - jcr->impl->min_wait = 60 * 60; - jcr->impl->max_wait = 24 * 60 * 60; - jcr->impl->max_num_wait = 9; /* 5 waits =~ 1 day, then 1 day at a time */ - jcr->impl->wait_sec = jcr->impl->min_wait; - jcr->impl->rem_wait_sec = jcr->impl->wait_sec; - jcr->impl->num_wait = 0; + jcr->impl->device_wait_times.min_wait = 60 * 60; + jcr->impl->device_wait_times.max_wait = 24 * 60 * 60; + jcr->impl->device_wait_times.max_num_wait = + 9; /* 5 waits =~ 1 day, then 1 day at a time */ + jcr->impl->device_wait_times.wait_sec = jcr->impl->device_wait_times.min_wait; + jcr->impl->device_wait_times.rem_wait_sec = + jcr->impl->device_wait_times.wait_sec; + jcr->impl->device_wait_times.num_wait = 0; } /** diff --git a/core/src/stored/jcr_private.h b/core/src/stored/jcr_private.h index 7df89552b0c..540aecb513b 100644 --- a/core/src/stored/jcr_private.h +++ b/core/src/stored/jcr_private.h @@ -30,12 +30,24 @@ #define SD_READ 0 namespace storagedaemon { + struct VolumeList; class DeviceControlRecord; class DirectorResource; struct BootStrapRecord; + +struct DeviceWaitTimes { + int32_t min_wait{}; + int32_t max_wait{}; + int32_t max_num_wait{}; + int32_t wait_sec{}; + int32_t rem_wait_sec{}; + int32_t num_wait{}; +}; + } // namespace storagedaemon + /* clang-format off */ struct JobControlRecordPrivate { JobControlRecord* next_dev{}; /**< Next JobControlRecord attached to device */ @@ -84,15 +96,7 @@ struct JobControlRecordPrivate { uint32_t read_StartBlock{}; uint32_t read_EndBlock{}; - /* - * Device wait times - */ - int32_t min_wait{}; - int32_t max_wait{}; - int32_t max_num_wait{}; - int32_t wait_sec{}; - int32_t rem_wait_sec{}; - int32_t num_wait{}; + storagedaemon::DeviceWaitTimes device_wait_times; }; /* clang-format on */ From 4947216b49603ec81f94319710a79478aa4216f5 Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Wed, 6 Nov 2019 11:55:56 +0100 Subject: [PATCH 13/23] stored: place members into separate struct ReadSession --- core/src/stored/bsr.cc | 6 +++--- core/src/stored/btape.cc | 2 +- core/src/stored/butil.cc | 4 ++-- core/src/stored/device.cc | 14 +++++++------- core/src/stored/dir_cmd.cc | 9 ++++++--- core/src/stored/fd_cmds.cc | 18 ++++++++++++------ core/src/stored/jcr_private.h | 26 +++++++++++++------------- core/src/stored/job.cc | 12 ++++++------ core/src/stored/ndmp_tape.cc | 12 ++++++------ core/src/stored/read_record.cc | 21 +++++++++++---------- 10 files changed, 67 insertions(+), 57 deletions(-) diff --git a/core/src/stored/bsr.cc b/core/src/stored/bsr.cc index e4eaaf1c483..2c174d83c16 100644 --- a/core/src/stored/bsr.cc +++ b/core/src/stored/bsr.cc @@ -801,7 +801,7 @@ static bool AddRestoreVolume(JobControlRecord* jcr, VolumeList* vol) /* Add volume to volume manager's read list */ AddReadVolume(jcr, vol->VolumeName); - if (!next) { /* list empty ? */ + if (!next) { /* list empty ? */ jcr->impl->VolList = vol; /* yes, add volume */ } else { /* Loop through all but last */ @@ -840,8 +840,8 @@ void CreateRestoreVolumeList(JobControlRecord* jcr) */ jcr->impl->NumReadVolumes = 0; jcr->impl->CurReadVolume = 0; - if (jcr->impl->bsr) { - BootStrapRecord* bsr = jcr->impl->bsr; + if (jcr->impl->read_session.bsr) { + BootStrapRecord* bsr = jcr->impl->read_session.bsr; if (!bsr->volume || !bsr->volume->VolumeName[0]) { return; } for (; bsr; bsr = bsr->next) { BsrVolume* bsrvol; diff --git a/core/src/stored/btape.cc b/core/src/stored/btape.cc index 0ffbbb4276c..924bdb4cd79 100644 --- a/core/src/stored/btape.cc +++ b/core/src/stored/btape.cc @@ -2446,7 +2446,7 @@ static bool do_unfill() last_block = last_block1; FreeRestoreVolumeList(jcr); - jcr->impl->bsr = NULL; + jcr->impl->read_session.bsr = NULL; bstrncpy(dcr->VolumeName, "TestVolume1|TestVolume2", sizeof(dcr->VolumeName)); CreateRestoreVolumeList(jcr); if (jcr->impl->VolList != NULL) { diff --git a/core/src/stored/butil.cc b/core/src/stored/butil.cc index 60dc78f9cf7..93ccb348f4b 100644 --- a/core/src/stored/butil.cc +++ b/core/src/stored/butil.cc @@ -71,7 +71,7 @@ JobControlRecord* SetupJcr(const char* name, JobControlRecord* jcr = new_jcr(MyFreeJcr); jcr->impl = new JobControlRecordPrivate; - jcr->impl->bsr = bsr; + jcr->impl->read_session.bsr = bsr; jcr->impl->director = director; jcr->VolSessionId = 1; jcr->VolSessionTime = (uint32_t)time(NULL); @@ -142,7 +142,7 @@ static bool setup_to_access_device(DeviceControlRecord* dcr, } else { VolName[0] = 0; } - if (!jcr->impl->bsr && VolName[0] == 0) { + if (!jcr->impl->read_session.bsr && VolName[0] == 0) { if (!bstrncmp(dev_name, "/dev/", 5)) { /* Try stripping file part */ p = dev_name + strlen(dev_name); diff --git a/core/src/stored/device.cc b/core/src/stored/device.cc index 449fbede64b..ee809b28a9c 100644 --- a/core/src/stored/device.cc +++ b/core/src/stored/device.cc @@ -313,9 +313,9 @@ BootStrapRecord* PositionDeviceToFirstFile(JobControlRecord* jcr, * Now find and position to first file and block * on this tape. */ - if (jcr->impl->bsr) { - jcr->impl->bsr->Reposition = true; /* force repositioning */ - bsr = find_next_bsr(jcr->impl->bsr, dev); + if (jcr->impl->read_session.bsr) { + jcr->impl->read_session.bsr->Reposition = true; + bsr = find_next_bsr(jcr->impl->read_session.bsr, dev); if (GetBsrStartAddr(bsr, &file, &block) > 0) { Jmsg(jcr, M_INFO, 0, _("Forward spacing Volume \"%s\" to file:block %u:%u.\n"), @@ -339,15 +339,15 @@ bool TryDeviceRepositioning(JobControlRecord* jcr, BootStrapRecord* bsr; Device* dev = dcr->dev; - bsr = find_next_bsr(jcr->impl->bsr, dev); - if (bsr == NULL && jcr->impl->bsr->mount_next_volume) { + bsr = find_next_bsr(jcr->impl->read_session.bsr, dev); + if (bsr == NULL && jcr->impl->read_session.bsr->mount_next_volume) { Dmsg0(500, "Would mount next volume here\n"); Dmsg2(500, "Current position (file:block) %u:%u\n", dev->file, dev->block_num); - jcr->impl->bsr->mount_next_volume = false; + jcr->impl->read_session.bsr->mount_next_volume = false; if (!dev->AtEot()) { /* Set EOT flag to force mount of next Volume */ - jcr->impl->mount_next_volume = true; + jcr->impl->read_session.mount_next_volume = true; dev->SetEot(); } rec->Block = 0; diff --git a/core/src/stored/dir_cmd.cc b/core/src/stored/dir_cmd.cc index 3fb1edcf5c9..80a49537f3b 100644 --- a/core/src/stored/dir_cmd.cc +++ b/core/src/stored/dir_cmd.cc @@ -1314,12 +1314,15 @@ static inline bool GetBootstrapFile(JobControlRecord* jcr, BareosSocket* sock) } fclose(bs); Dmsg0(10, "=== end bootstrap file ===\n"); - jcr->impl->bsr = libbareos::parse_bsr(jcr, jcr->RestoreBootstrap); - if (!jcr->impl->bsr) { + jcr->impl->read_session.bsr = + libbareos::parse_bsr(jcr, jcr->RestoreBootstrap); + if (!jcr->impl->read_session.bsr) { Jmsg(jcr, M_FATAL, 0, _("Error parsing bootstrap file.\n")); goto bail_out; } - if (debug_level >= 10) { libbareos::DumpBsr(jcr->impl->bsr, true); } + if (debug_level >= 10) { + libbareos::DumpBsr(jcr->impl->read_session.bsr, true); + } /* If we got a bootstrap, we are reading, so create read volume list */ CreateRestoreVolumeList(jcr); ok = true; diff --git a/core/src/stored/fd_cmds.cc b/core/src/stored/fd_cmds.cc index dd8d1ab1251..11b52872410 100644 --- a/core/src/stored/fd_cmds.cc +++ b/core/src/stored/fd_cmds.cc @@ -382,9 +382,12 @@ static bool ReadOpenSession(JobControlRecord* jcr) } if (sscanf(fd->msg, read_open, jcr->impl->read_dcr->VolumeName, - &jcr->impl->read_VolSessionId, &jcr->impl->read_VolSessionTime, - &jcr->impl->read_StartFile, &jcr->impl->read_EndFile, - &jcr->impl->read_StartBlock, &jcr->impl->read_EndBlock) == 7) { + &jcr->impl->read_session.read_VolSessionId, + &jcr->impl->read_session.read_VolSessionTime, + &jcr->impl->read_session.read_StartFile, + &jcr->impl->read_session.read_EndFile, + &jcr->impl->read_session.read_StartBlock, + &jcr->impl->read_session.read_EndBlock) == 7) { if (jcr->impl->session_opened) { PmStrcpy(jcr->errmsg, _("Attempt to open read on non-open session.\n")); fd->fsend(NOT_opened); @@ -393,10 +396,13 @@ static bool ReadOpenSession(JobControlRecord* jcr) Dmsg4(100, "ReadOpenSession got: JobId=%d Vol=%s VolSessId=%ld VolSessT=%ld\n", jcr->JobId, jcr->impl->read_dcr->VolumeName, - jcr->impl->read_VolSessionId, jcr->impl->read_VolSessionTime); + jcr->impl->read_session.read_VolSessionId, + jcr->impl->read_session.read_VolSessionTime); Dmsg4(100, " StartF=%ld EndF=%ld StartB=%ld EndB=%ld\n", - jcr->impl->read_StartFile, jcr->impl->read_EndFile, - jcr->impl->read_StartBlock, jcr->impl->read_EndBlock); + jcr->impl->read_session.read_StartFile, + jcr->impl->read_session.read_EndFile, + jcr->impl->read_session.read_StartBlock, + jcr->impl->read_session.read_EndBlock); } jcr->impl->session_opened = true; diff --git a/core/src/stored/jcr_private.h b/core/src/stored/jcr_private.h index 540aecb513b..4d9c581c517 100644 --- a/core/src/stored/jcr_private.h +++ b/core/src/stored/jcr_private.h @@ -36,6 +36,18 @@ class DeviceControlRecord; class DirectorResource; struct BootStrapRecord; +struct ReadSession { + READ_CTX* rctx{}; + BootStrapRecord* bsr{}; + bool mount_next_volume{}; + uint32_t read_VolSessionId{}; + uint32_t read_VolSessionTime{}; + uint32_t read_StartFile{}; + uint32_t read_EndFile{}; + uint32_t read_StartBlock{}; + uint32_t read_EndBlock{}; +}; + struct DeviceWaitTimes { int32_t min_wait{}; int32_t max_wait{}; @@ -83,19 +95,7 @@ struct JobControlRecordPrivate { bool insert_jobmedia_records{}; /**< Need to insert job media records */ uint64_t RemainingQuota{}; /**< Available bytes to use as quota */ - /* - * Parameters for Open Read Session - */ - storagedaemon::READ_CTX* rctx{}; /**< Read context used to keep track of what is processed or not */ - storagedaemon::BootStrapRecord* bsr{}; /**< Bootstrap record -- has everything */ - bool mount_next_volume{}; /**< Set to cause next volume mount */ - uint32_t read_VolSessionId{}; - uint32_t read_VolSessionTime{}; - uint32_t read_StartFile{}; - uint32_t read_EndFile{}; - uint32_t read_StartBlock{}; - uint32_t read_EndBlock{}; - + storagedaemon::ReadSession read_session; storagedaemon::DeviceWaitTimes device_wait_times; }; /* clang-format on */ diff --git a/core/src/stored/job.cc b/core/src/stored/job.cc index c8f212cf8b9..dcd3384c806 100644 --- a/core/src/stored/job.cc +++ b/core/src/stored/job.cc @@ -429,14 +429,14 @@ void StoredFreeJcr(JobControlRecord* jcr) if (jcr->impl->backup_format) { FreeMemory(jcr->impl->backup_format); } - if (jcr->impl->bsr) { - libbareos::FreeBsr(jcr->impl->bsr); - jcr->impl->bsr = NULL; + if (jcr->impl->read_session.bsr) { + libbareos::FreeBsr(jcr->impl->read_session.bsr); + jcr->impl->read_session.bsr = NULL; } - if (jcr->impl->rctx) { - FreeReadContext(jcr->impl->rctx); - jcr->impl->rctx = NULL; + if (jcr->impl->read_session.rctx) { + FreeReadContext(jcr->impl->read_session.rctx); + jcr->impl->read_session.rctx = NULL; } if (jcr->compress.deflate_buffer || jcr->compress.inflate_buffer) { diff --git a/core/src/stored/ndmp_tape.cc b/core/src/stored/ndmp_tape.cc index 100bf116fa0..10555cf9614 100644 --- a/core/src/stored/ndmp_tape.cc +++ b/core/src/stored/ndmp_tape.cc @@ -377,7 +377,7 @@ static inline bool bndmp_read_data_from_block(JobControlRecord* jcr, uint32_t* data_length) { DeviceControlRecord* dcr = jcr->impl->read_dcr; - READ_CTX* rctx = jcr->impl->rctx; + READ_CTX* rctx = jcr->impl->read_session.rctx; bool done = false; bool ok = true; @@ -768,13 +768,13 @@ extern "C" ndmp9_error bndmp_tape_open(struct ndm_session* sess, Dmsg1(50, "Begin reading device=%s\n", dcr->dev->print_name()); PositionDeviceToFirstFile(jcr, dcr); - jcr->impl->mount_next_volume = false; + jcr->impl->read_session.mount_next_volume = false; /* * Allocate a new read context for this Job. */ rctx = new_read_context(); - jcr->impl->rctx = rctx; + jcr->impl->read_session.rctx = rctx; /* * Read the first block and setup record processing. @@ -1113,9 +1113,9 @@ void EndOfNdmpBackup(JobControlRecord* jcr) void EndOfNdmpRestore(JobControlRecord* jcr) { - if (jcr->impl->rctx) { - FreeReadContext(jcr->impl->rctx); - jcr->impl->rctx = NULL; + if (jcr->impl->read_session.rctx) { + FreeReadContext(jcr->impl->read_session.rctx); + jcr->impl->read_session.rctx = NULL; } if (jcr->impl->acquired_storage) { diff --git a/core/src/stored/read_record.cc b/core/src/stored/read_record.cc index e2a4dc4b3f3..326e6d75a0c 100644 --- a/core/src/stored/read_record.cc +++ b/core/src/stored/read_record.cc @@ -222,15 +222,15 @@ bool ReadNextBlockFromDevice(DeviceControlRecord* dcr, trec->FileIndex = EOT_LABEL; trec->File = dcr->dev->file; *status = RecordCb(dcr, trec); - if (jcr->impl->mount_next_volume) { - jcr->impl->mount_next_volume = false; + if (jcr->impl->read_session.mount_next_volume) { + jcr->impl->read_session.mount_next_volume = false; dcr->dev->ClearEot(); } FreeRecord(trec); } return false; } - jcr->impl->mount_next_volume = false; + jcr->impl->read_session.mount_next_volume = false; /* * We just have a new tape up, now read the label (first record) @@ -329,11 +329,12 @@ bool ReadNextRecordFromBlock(DeviceControlRecord* dcr, */ if (rec->FileIndex < 0) { HandleSessionRecord(dcr->dev, rec, &rctx->sessrec); - if (jcr->impl->bsr) { + if (jcr->impl->read_session.bsr) { /* * We just check block FI and FT not FileIndex */ - rec->match_stat = MatchBsrBlock(jcr->impl->bsr, dcr->block); + rec->match_stat = + MatchBsrBlock(jcr->impl->read_session.bsr, dcr->block); } else { rec->match_stat = 0; } @@ -344,9 +345,9 @@ bool ReadNextRecordFromBlock(DeviceControlRecord* dcr, /* * Apply BootStrapRecord filter */ - if (jcr->impl->bsr) { - rec->match_stat = - MatchBsr(jcr->impl->bsr, rec, &dev->VolHdr, &rctx->sessrec, jcr); + if (jcr->impl->read_session.bsr) { + rec->match_stat = MatchBsr(jcr->impl->read_session.bsr, rec, + &dev->VolHdr, &rctx->sessrec, jcr); if (rec->match_stat == -1) { /* no more possible matches */ *done = true; /* all items found, stop */ Dmsg2(debuglevel, "All done=(file:block) %u:%u\n", dev->file, @@ -377,7 +378,7 @@ bool ReadNextRecordFromBlock(DeviceControlRecord* dcr, if (rctx->lastFileIndex != READ_NO_FILEINDEX && rctx->lastFileIndex != rec->FileIndex) { - if (IsThisBsrDone(jcr->impl->bsr, rec) && + if (IsThisBsrDone(jcr->impl->read_session.bsr, rec) && TryDeviceRepositioning(jcr, rec, dcr)) { Dmsg2(debuglevel, "This bsr done, break pos %u:%u\n", dev->file, dev->block_num); @@ -412,7 +413,7 @@ bool ReadRecords(DeviceControlRecord* dcr, rctx = new_read_context(); PositionDeviceToFirstFile(jcr, dcr); - jcr->impl->mount_next_volume = false; + jcr->impl->read_session.mount_next_volume = false; while (ok && !done) { if (JobCanceled(jcr)) { From d6f0e84b50278b2f8f995dae7ac8e6e9120e53ae Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Wed, 6 Nov 2019 12:16:27 +0100 Subject: [PATCH 14/23] jcr: separate file for JobLevelCode --- core/src/include/jcr.h | 19 +--------------- core/src/include/job_level.h | 44 ++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 18 deletions(-) create mode 100644 core/src/include/job_level.h diff --git a/core/src/include/jcr.h b/core/src/include/jcr.h index ab655c39fa4..7617d08b8a0 100644 --- a/core/src/include/jcr.h +++ b/core/src/include/jcr.h @@ -35,6 +35,7 @@ #define BAREOS_INCLUDE_JCR_H_ 1 #include +#include #include "lib/tls_conf.h" #ifdef DIRECTOR_DAEMON @@ -48,24 +49,6 @@ typedef struct s_tree_root TREE_ROOT; class dlist; -/** - * Backup/Verify level code. These are stored in the DB - */ -#define L_FULL 'F' /**< Full backup */ -#define L_INCREMENTAL 'I' /**< Since last backup */ -#define L_DIFFERENTIAL 'D' /**< Since last full backup */ -#define L_SINCE 'S' -#define L_VERIFY_CATALOG 'C' /**< Verify from catalog */ -#define L_VERIFY_INIT 'V' /**< Verify save (init DB) */ -#define L_VERIFY_VOLUME_TO_CATALOG \ - 'O' /**< Verify Volume to catalog entries \ - */ -#define L_VERIFY_DISK_TO_CATALOG 'd' /**< Verify Disk attributes to catalog */ -#define L_VERIFY_DATA 'A' /**< Verify data on volume */ -#define L_BASE 'B' /**< Base level job */ -#define L_NONE ' ' /**< None, for Restore and Admin */ -#define L_VIRTUAL_FULL 'f' /**< Virtual full backup */ - /** * Job Types. These are stored in the DB */ diff --git a/core/src/include/job_level.h b/core/src/include/job_level.h new file mode 100644 index 00000000000..e90ad7144e6 --- /dev/null +++ b/core/src/include/job_level.h @@ -0,0 +1,44 @@ +/* + BAREOS® - Backup Archiving REcovery Open Sourced + + Copyright (C) 2000-2012 Free Software Foundation Europe e.V. + Copyright (C) 2011-2012 Planets Communications B.V. + Copyright (C) 2013-2019 Bareos GmbH & Co. KG + + This program is Free Software; you can redistribute it and/or + modify it under the terms of version three of the GNU Affero General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#ifndef BAREOS_SRC_INCLUDE_JOB_LEVEL_H_ +#define BAREOS_SRC_INCLUDE_JOB_LEVEL_H_ + +enum JobLevelCode : char +{ + L_FULL = 'F', /**< Full backup */ + L_INCREMENTAL = 'I', /**< Since last backup */ + L_DIFFERENTIAL = 'D', /**< Since last full backup */ + L_SINCE = 'S', + L_VERIFY_CATALOG = 'C', /**< Verify from catalog */ + L_VERIFY_INIT = 'V', /**< Verify save (init DB) */ + L_VERIFY_VOLUME_TO_CATALOG = 'O', /**< Verify Volume to catalog entries \ + */ + L_VERIFY_DISK_TO_CATALOG = 'd', /**< Verify Disk attributes to catalog */ + L_VERIFY_DATA = 'A', /**< Verify data on volume */ + L_BASE = 'B', /**< Base level job */ + L_NONE = ' ', /**< None, for Restore and Admin */ + L_VIRTUAL_FULL = 'f' /**< Virtual full backup */ +}; + +#endif // BAREOS_SRC_INCLUDE_JOB_LEVEL_H_ From 70a2d5dcc9a9a5848ce9195d1cdf8a4f8d587ffb Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Wed, 6 Nov 2019 12:24:35 +0100 Subject: [PATCH 15/23] jcr: separate file for JobStatus and JobTypes --- core/src/include/jcr.h | 50 ++---------------------------- core/src/include/job_status.h | 58 +++++++++++++++++++++++++++++++++++ core/src/include/job_types.h | 44 ++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 48 deletions(-) create mode 100644 core/src/include/job_status.h create mode 100644 core/src/include/job_types.h diff --git a/core/src/include/jcr.h b/core/src/include/jcr.h index 7617d08b8a0..442e42c6319 100644 --- a/core/src/include/jcr.h +++ b/core/src/include/jcr.h @@ -36,6 +36,8 @@ #include #include +#include +#include #include "lib/tls_conf.h" #ifdef DIRECTOR_DAEMON @@ -49,54 +51,6 @@ typedef struct s_tree_root TREE_ROOT; class dlist; -/** - * Job Types. These are stored in the DB - */ -#define JT_BACKUP 'B' /**< Backup Job */ -#define JT_MIGRATED_JOB 'M' /**< A previous backup job that was migrated */ -#define JT_VERIFY 'V' /**< Verify Job */ -#define JT_RESTORE 'R' /**< Restore Job */ -#define JT_CONSOLE 'U' /**< console program */ -#define JT_SYSTEM 'I' /**< internal system "job" */ -#define JT_ADMIN 'D' /**< admin job */ -#define JT_ARCHIVE 'A' /**< Archive Job */ -#define JT_JOB_COPY 'C' /**< Copy of a Job */ -#define JT_COPY 'c' /**< Copy Job */ -#define JT_MIGRATE 'g' /**< Migration Job */ -#define JT_SCAN 'S' /**< Scan Job */ -#define JT_CONSOLIDATE 'O' /**< Always Incremental Consolidate Job */ - -/** - * Job Status. Some of these are stored in the DB - */ -#define JS_Canceled 'A' /**< Canceled by user */ -#define JS_Blocked 'B' /**< Blocked */ -#define JS_Created 'C' /**< Created but not yet running */ -#define JS_Differences 'D' /**< Verify differences */ -#define JS_ErrorTerminated 'E' /**< Job terminated in error */ -#define JS_WaitFD 'F' /**< Waiting on File daemon */ -#define JS_Incomplete 'I' /**< Incomplete Job */ -#define JS_DataCommitting 'L' /**< Committing data (last despool) */ -#define JS_WaitMount 'M' /**< Waiting for Mount */ -#define JS_Running 'R' /**< Running */ -#define JS_WaitSD 'S' /**< Waiting on the Storage daemon */ -#define JS_Terminated 'T' /**< Terminated normally */ -#define JS_Warnings 'W' /**< Terminated normally with warnings */ - -#define JS_AttrDespooling 'a' /**< SD despooling attributes */ -#define JS_WaitClientRes 'c' /**< Waiting for Client resource */ -#define JS_WaitMaxJobs 'd' /**< Waiting for maximum jobs */ -#define JS_Error 'e' /**< Non-fatal error */ -#define JS_FatalError 'f' /**< Fatal error */ -#define JS_AttrInserting 'i' /**< Doing batch insert file records */ -#define JS_WaitJobRes 'j' /**< Waiting for job resource */ -#define JS_DataDespooling 'l' /**< Doing data despooling */ -#define JS_WaitMedia 'm' /**< Waiting for new media */ -#define JS_WaitPriority 'p' /**< Waiting for higher priority jobs to finish */ -#define JS_WaitDevice 'q' /**< Queued waiting for device */ -#define JS_WaitStoreRes 's' /**< Waiting for storage resource */ -#define JS_WaitStartTime 't' /**< Waiting for start time */ - /** * Protocol types */ diff --git a/core/src/include/job_status.h b/core/src/include/job_status.h new file mode 100644 index 00000000000..8f03afa80bb --- /dev/null +++ b/core/src/include/job_status.h @@ -0,0 +1,58 @@ +/* + BAREOS® - Backup Archiving REcovery Open Sourced + + Copyright (C) 2000-2012 Free Software Foundation Europe e.V. + Copyright (C) 2011-2012 Planets Communications B.V. + Copyright (C) 2013-2019 Bareos GmbH & Co. KG + + This program is Free Software; you can redistribute it and/or + modify it under the terms of version three of the GNU Affero General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#ifndef BAREOS_SRC_INCLUDE_JOB_STATUS_H_ +#define BAREOS_SRC_INCLUDE_JOB_STATUS_H_ + +enum JobStatus : char +{ + JS_Canceled = 'A', /**< Canceled by user */ + JS_Blocked = 'B', /**< Blocked */ + JS_Created = 'C', /**< Created but not yet running */ + JS_Differences = 'D', /**< Verify differences */ + JS_ErrorTerminated = 'E', /**< Job terminated in error */ + JS_WaitFD = 'F', /**< Waiting on File daemon */ + JS_Incomplete = 'I', /**< Incomplete Job */ + JS_DataCommitting = 'L', /**< Committing data (last despool) */ + JS_WaitMount = 'M', /**< Waiting for Mount */ + JS_Running = 'R', /**< Running */ + JS_WaitSD = 'S', /**< Waiting on the Storage daemon */ + JS_Terminated = 'T', /**< Terminated normally */ + JS_Warnings = 'W', /**< Terminated normally with warnings */ + + JS_AttrDespooling = 'a', /**< SD despooling attributes */ + JS_WaitClientRes = 'c', /**< Waiting for Client resource */ + JS_WaitMaxJobs = 'd', /**< Waiting for maximum jobs */ + JS_Error = 'e', /**< Non-fatal error */ + JS_FatalError = 'f', /**< Fatal error */ + JS_AttrInserting = 'i', /**< Doing batch insert file records */ + JS_WaitJobRes = 'j', /**< Waiting for job resource */ + JS_DataDespooling = 'l', /**< Doing data despooling */ + JS_WaitMedia = 'm', /**< Waiting for new media */ + JS_WaitPriority = 'p', /**< Waiting for higher priority jobs to finish */ + JS_WaitDevice = 'q', /**< Queued waiting for device */ + JS_WaitStoreRes = 's', /**< Waiting for storage resource */ + JS_WaitStartTime = 't' /**< Waiting for start time */ +}; + +#endif // BAREOS_SRC_INCLUDE_JOB_STATUS_H_ diff --git a/core/src/include/job_types.h b/core/src/include/job_types.h new file mode 100644 index 00000000000..1c0d2b54049 --- /dev/null +++ b/core/src/include/job_types.h @@ -0,0 +1,44 @@ +/* + BAREOS® - Backup Archiving REcovery Open Sourced + + Copyright (C) 2000-2012 Free Software Foundation Europe e.V. + Copyright (C) 2011-2012 Planets Communications B.V. + Copyright (C) 2013-2019 Bareos GmbH & Co. KG + + This program is Free Software; you can redistribute it and/or + modify it under the terms of version three of the GNU Affero General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#ifndef BAREOS_SRC_INCLUDE_JOB_TYPES_H_ +#define BAREOS_SRC_INCLUDE_JOB_TYPES_H_ + +enum JobTypes : char +{ + JT_BACKUP = 'B', /**< Backup Job */ + JT_MIGRATED_JOB = 'M', /**< A previous backup job that was migrated */ + JT_VERIFY = 'V', /**< Verify Job */ + JT_RESTORE = 'R', /**< Restore Job */ + JT_CONSOLE = 'U', /**< console program */ + JT_SYSTEM = 'I', /**< internal system "job" */ + JT_ADMIN = 'D', /**< admin job */ + JT_ARCHIVE = 'A', /**< Archive Job */ + JT_JOB_COPY = 'C', /**< Copy of a Job */ + JT_COPY = 'c', /**< Copy Job */ + JT_MIGRATE = 'g', /**< Migration Job */ + JT_SCAN = 'S', /**< Scan Job */ + JT_CONSOLIDATE = 'O' /**< Always Incremental Consolidate Job */ +}; + +#endif // BAREOS_SRC_INCLUDE_JOB_TYPES_H_ From 5ff077397870a8b3f50ba7fe496abde2e2143e5c Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Wed, 6 Nov 2019 12:32:21 +0100 Subject: [PATCH 16/23] jcr: separate file for ProtocolTypes --- core/src/dird/backup.cc | 1 + core/src/dird/dird_conf.cc | 1 + core/src/dird/job.cc | 1 + core/src/dird/ndmp_fhdb_helpers.cc | 1 + core/src/dird/restore.cc | 1 + core/src/dird/ua_restore.cc | 1 + core/src/include/jcr.h | 10 --------- core/src/include/protocol_types.h | 34 ++++++++++++++++++++++++++++++ core/src/stored/dir_cmd.cc | 1 + core/src/stored/job.cc | 1 + 10 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 core/src/include/protocol_types.h diff --git a/core/src/dird/backup.cc b/core/src/dird/backup.cc index d1c23c3bf76..8f6d881e820 100644 --- a/core/src/dird/backup.cc +++ b/core/src/dird/backup.cc @@ -48,6 +48,7 @@ #include "dird/sd_cmds.h" #include "ndmp/smc.h" #include "dird/storage.h" +#include "include/protocol_types.h" #include "cats/sql.h" #include "lib/bnet.h" diff --git a/core/src/dird/dird_conf.cc b/core/src/dird/dird_conf.cc index c0bfc41d38e..7284b49c7f0 100644 --- a/core/src/dird/dird_conf.cc +++ b/core/src/dird/dird_conf.cc @@ -52,6 +52,7 @@ #include "dird/inc_conf.h" #include "dird/dird_globals.h" #include "dird/jcr_private.h" +#include "include/protocol_types.h" #include "lib/berrno.h" #include "lib/breg.h" #include "lib/tls_conf.h" diff --git a/core/src/dird/job.cc b/core/src/dird/job.cc index 335d7f91bbe..6c47922b60e 100644 --- a/core/src/dird/job.cc +++ b/core/src/dird/job.cc @@ -70,6 +70,7 @@ #include "lib/util.h" #include "lib/watchdog.h" #include "include/make_unique.h" +#include "include/protocol_types.h" namespace directordaemon { diff --git a/core/src/dird/ndmp_fhdb_helpers.cc b/core/src/dird/ndmp_fhdb_helpers.cc index 8c5963e21c0..6c98fb2fd3d 100644 --- a/core/src/dird/ndmp_fhdb_helpers.cc +++ b/core/src/dird/ndmp_fhdb_helpers.cc @@ -29,6 +29,7 @@ #include "include/bareos.h" #include "dird.h" +#include "include/protocol_types.h" #if HAVE_NDMP diff --git a/core/src/dird/restore.cc b/core/src/dird/restore.cc index 715e6445188..12dfc63ca60 100644 --- a/core/src/dird/restore.cc +++ b/core/src/dird/restore.cc @@ -52,6 +52,7 @@ #include "dird/restore.h" #include "dird/sd_cmds.h" #include "dird/storage.h" +#include "include/protocol_types.h" #include "lib/edit.h" #include "lib/util.h" diff --git a/core/src/dird/ua_restore.cc b/core/src/dird/ua_restore.cc index 3f99672d3d9..5550aea800a 100644 --- a/core/src/dird/ua_restore.cc +++ b/core/src/dird/ua_restore.cc @@ -49,6 +49,7 @@ #include "lib/parse_conf.h" #include "lib/tree.h" #include "include/make_unique.h" +#include "include/protocol_types.h" namespace directordaemon { diff --git a/core/src/include/jcr.h b/core/src/include/jcr.h index 442e42c6319..c0764dabec3 100644 --- a/core/src/include/jcr.h +++ b/core/src/include/jcr.h @@ -51,16 +51,6 @@ typedef struct s_tree_root TREE_ROOT; class dlist; -/** - * Protocol types - */ -enum -{ - PT_NATIVE = 0, - PT_NDMP_BAREOS, /* alias for PT_NDMP */ - PT_NDMP_NATIVE -}; - /** * Authentication Protocol types */ diff --git a/core/src/include/protocol_types.h b/core/src/include/protocol_types.h new file mode 100644 index 00000000000..64e18cc87da --- /dev/null +++ b/core/src/include/protocol_types.h @@ -0,0 +1,34 @@ +/* + BAREOS® - Backup Archiving REcovery Open Sourced + + Copyright (C) 2000-2012 Free Software Foundation Europe e.V. + Copyright (C) 2011-2012 Planets Communications B.V. + Copyright (C) 2013-2019 Bareos GmbH & Co. KG + + This program is Free Software; you can redistribute it and/or + modify it under the terms of version three of the GNU Affero General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#ifndef BAREOS_SRC_INCLUDE_PROTOCOL_TYPES_H_ +#define BAREOS_SRC_INCLUDE_PROTOCOL_TYPES_H_ + +enum ProtocolTypes +{ + PT_NATIVE = 0, + PT_NDMP_BAREOS, /* alias for PT_NDMP */ + PT_NDMP_NATIVE +}; + +#endif // BAREOS_SRC_INCLUDE_PROTOCOL_TYPES_H_ diff --git a/core/src/stored/dir_cmd.cc b/core/src/stored/dir_cmd.cc index 80a49537f3b..23b92b93ef7 100644 --- a/core/src/stored/dir_cmd.cc +++ b/core/src/stored/dir_cmd.cc @@ -61,6 +61,7 @@ #include "stored/job.h" #include "stored/mac.h" #include "include/make_unique.h" +#include "include/protocol_types.h" #include "lib/berrno.h" #include "lib/bnet.h" #include "lib/bsock.h" diff --git a/core/src/stored/job.cc b/core/src/stored/job.cc index dcd3384c806..b43ef9e5864 100644 --- a/core/src/stored/job.cc +++ b/core/src/stored/job.cc @@ -42,6 +42,7 @@ #include "lib/parse_bsr.h" #include "lib/util.h" #include "include/jcr.h" +#include "include/protocol_types.h" namespace storagedaemon { From 861a55f4a5c8076b373a0e16ab33682b97baf8e2 Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Wed, 6 Nov 2019 12:37:29 +0100 Subject: [PATCH 17/23] jcr: separate file for AuthenticationProtocolType --- core/src/dird/backup.cc | 1 + core/src/dird/dird_conf.cc | 1 + core/src/dird/migrate.cc | 1 + core/src/dird/ndmp_dma_generic.cc | 1 + core/src/dird/stats.cc | 1 + core/src/dird/storage.cc | 1 + core/src/dird/ua_cmds.cc | 1 + core/src/dird/ua_label.cc | 1 + core/src/dird/ua_purge.cc | 1 + core/src/dird/ua_status.cc | 1 + core/src/include/auth_protocol_types.h | 35 ++++++++++++++++++++++++++ core/src/include/jcr.h | 11 -------- 12 files changed, 45 insertions(+), 11 deletions(-) create mode 100644 core/src/include/auth_protocol_types.h diff --git a/core/src/dird/backup.cc b/core/src/dird/backup.cc index 8f6d881e820..0b0657be887 100644 --- a/core/src/dird/backup.cc +++ b/core/src/dird/backup.cc @@ -48,6 +48,7 @@ #include "dird/sd_cmds.h" #include "ndmp/smc.h" #include "dird/storage.h" +#include "include/auth_protocol_types.h" #include "include/protocol_types.h" #include "cats/sql.h" diff --git a/core/src/dird/dird_conf.cc b/core/src/dird/dird_conf.cc index 7284b49c7f0..c5c61ce6afa 100644 --- a/core/src/dird/dird_conf.cc +++ b/core/src/dird/dird_conf.cc @@ -52,6 +52,7 @@ #include "dird/inc_conf.h" #include "dird/dird_globals.h" #include "dird/jcr_private.h" +#include "include/auth_protocol_types.h" #include "include/protocol_types.h" #include "lib/berrno.h" #include "lib/breg.h" diff --git a/core/src/dird/migrate.cc b/core/src/dird/migrate.cc index 50f632420d0..b62cc1c729c 100644 --- a/core/src/dird/migrate.cc +++ b/core/src/dird/migrate.cc @@ -52,6 +52,7 @@ #include "dird/ua_server.h" #include "dird/ua_purge.h" #include "dird/ua_run.h" +#include "include/auth_protocol_types.h" #include "lib/edit.h" #include "lib/parse_conf.h" #include "lib/util.h" diff --git a/core/src/dird/ndmp_dma_generic.cc b/core/src/dird/ndmp_dma_generic.cc index b91b9a0be8a..6a4d22db69c 100644 --- a/core/src/dird/ndmp_dma_generic.cc +++ b/core/src/dird/ndmp_dma_generic.cc @@ -31,6 +31,7 @@ #include "dird.h" #include "dird/jcr_private.h" #include "dird/dird_globals.h" +#include "include/auth_protocol_types.h" #if HAVE_NDMP #define SMTAPE_MIN_BLOCKSIZE 4096 /**< 4 Kb */ diff --git a/core/src/dird/stats.cc b/core/src/dird/stats.cc index 56884b8c074..1e042dc180b 100644 --- a/core/src/dird/stats.cc +++ b/core/src/dird/stats.cc @@ -34,6 +34,7 @@ #include "cats/sql_pooling.h" #include "dird/sd_cmds.h" #include "dird/ua_server.h" +#include "include/auth_protocol_types.h" #include "lib/bnet.h" #include "lib/parse_conf.h" #include "lib/util.h" diff --git a/core/src/dird/storage.cc b/core/src/dird/storage.cc index 0207f1d4420..618331deab2 100644 --- a/core/src/dird/storage.cc +++ b/core/src/dird/storage.cc @@ -34,6 +34,7 @@ #include "dird/dird_globals.h" #include "dird/jcr_private.h" #include "dird/sd_cmds.h" +#include "include/auth_protocol_types.h" #include "lib/parse_conf.h" #include "lib/util.h" diff --git a/core/src/dird/ua_cmds.cc b/core/src/dird/ua_cmds.cc index 3085cbbe2f9..9ec5c9821f0 100644 --- a/core/src/dird/ua_cmds.cc +++ b/core/src/dird/ua_cmds.cc @@ -48,6 +48,7 @@ #include "dird/ua_status.h" #include "dird/ua_purge.h" #include "dird/ua_run.h" +#include "include/auth_protocol_types.h" #include "lib/bnet.h" #include "lib/edit.h" #include "lib/parse_conf.h" diff --git a/core/src/dird/ua_label.cc b/core/src/dird/ua_label.cc index 6bf84cc7ca4..b87673c524b 100644 --- a/core/src/dird/ua_label.cc +++ b/core/src/dird/ua_label.cc @@ -46,6 +46,7 @@ #include "dird/ua_input.h" #include "dird/ua_label.h" #include "dird/ua_select.h" +#include "include/auth_protocol_types.h" #include "lib/crypto_wrap.h" #include "lib/passphrase.h" #include "lib/util.h" diff --git a/core/src/dird/ua_purge.cc b/core/src/dird/ua_purge.cc index 666ed6a11aa..5f6f2b070f4 100644 --- a/core/src/dird/ua_purge.cc +++ b/core/src/dird/ua_purge.cc @@ -43,6 +43,7 @@ #include "dird/ua_select.h" #include "dird/ua_prune.h" #include "dird/ua_purge.h" +#include "include/auth_protocol_types.h" #include "lib/edit.h" #include "lib/util.h" diff --git a/core/src/dird/ua_status.cc b/core/src/dird/ua_status.cc index ca24c2824ff..02d7614b61f 100644 --- a/core/src/dird/ua_status.cc +++ b/core/src/dird/ua_status.cc @@ -45,6 +45,7 @@ #include "dird/ua_output.h" #include "dird/ua_select.h" #include "dird/ua_status.h" +#include "include/auth_protocol_types.h" #include "lib/edit.h" #include "lib/recent_job_results_list.h" #include "lib/parse_conf.h" diff --git a/core/src/include/auth_protocol_types.h b/core/src/include/auth_protocol_types.h new file mode 100644 index 00000000000..568d9d976fe --- /dev/null +++ b/core/src/include/auth_protocol_types.h @@ -0,0 +1,35 @@ +/* + BAREOS® - Backup Archiving REcovery Open Sourced + + Copyright (C) 2000-2012 Free Software Foundation Europe e.V. + Copyright (C) 2011-2012 Planets Communications B.V. + Copyright (C) 2013-2019 Bareos GmbH & Co. KG + + This program is Free Software; you can redistribute it and/or + modify it under the terms of version three of the GNU Affero General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#ifndef BAREOS_SRC_INCLUDE_AUTH_PROTOCOL_TYPES_H_ +#define BAREOS_SRC_INCLUDE_AUTH_PROTOCOL_TYPES_H_ + +enum AuthenticationProtocolType +{ + APT_NATIVE = 0, + APT_NDMPV2, + APT_NDMPV3, + APT_NDMPV4 +}; + +#endif // BAREOS_SRC_INCLUDE_AUTH_PROTOCOL_TYPES_H_ diff --git a/core/src/include/jcr.h b/core/src/include/jcr.h index c0764dabec3..f828b4edc3c 100644 --- a/core/src/include/jcr.h +++ b/core/src/include/jcr.h @@ -51,17 +51,6 @@ typedef struct s_tree_root TREE_ROOT; class dlist; -/** - * Authentication Protocol types - */ -enum -{ - APT_NATIVE = 0, - APT_NDMPV2, - APT_NDMPV3, - APT_NDMPV4 -}; - /** * Authentication types */ From ebfedc576e61596c33efb24b2f4f103120e66bde Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Wed, 6 Nov 2019 12:44:52 +0100 Subject: [PATCH 18/23] jcr: separate file for AuthenticationTypes --- core/src/dird/dird_conf.cc | 1 + core/src/dird/ndmp_dma_generic.cc | 1 + core/src/include/auth_types.h | 35 +++++++++++++++++++++++++++++++ core/src/include/jcr.h | 11 ---------- core/src/stored/ndmp_tape.cc | 1 + core/src/stored/stored_conf.cc | 1 + 6 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 core/src/include/auth_types.h diff --git a/core/src/dird/dird_conf.cc b/core/src/dird/dird_conf.cc index c5c61ce6afa..b86cefcc4f5 100644 --- a/core/src/dird/dird_conf.cc +++ b/core/src/dird/dird_conf.cc @@ -53,6 +53,7 @@ #include "dird/dird_globals.h" #include "dird/jcr_private.h" #include "include/auth_protocol_types.h" +#include "include/auth_types.h" #include "include/protocol_types.h" #include "lib/berrno.h" #include "lib/breg.h" diff --git a/core/src/dird/ndmp_dma_generic.cc b/core/src/dird/ndmp_dma_generic.cc index 6a4d22db69c..39f5db26d58 100644 --- a/core/src/dird/ndmp_dma_generic.cc +++ b/core/src/dird/ndmp_dma_generic.cc @@ -32,6 +32,7 @@ #include "dird/jcr_private.h" #include "dird/dird_globals.h" #include "include/auth_protocol_types.h" +#include "include/auth_types.h" #if HAVE_NDMP #define SMTAPE_MIN_BLOCKSIZE 4096 /**< 4 Kb */ diff --git a/core/src/include/auth_types.h b/core/src/include/auth_types.h new file mode 100644 index 00000000000..6ab25cbccdd --- /dev/null +++ b/core/src/include/auth_types.h @@ -0,0 +1,35 @@ +/* + BAREOS® - Backup Archiving REcovery Open Sourced + + Copyright (C) 2000-2012 Free Software Foundation Europe e.V. + Copyright (C) 2011-2012 Planets Communications B.V. + Copyright (C) 2013-2019 Bareos GmbH & Co. KG + + This program is Free Software; you can redistribute it and/or + modify it under the terms of version three of the GNU Affero General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#ifndef BAREOS_SRC_INCLUDE_AUTH_TYPES_H_ +#define BAREOS_SRC_INCLUDE_AUTH_TYPES_H_ + +enum AuthenticationTypes +{ + AT_NONE = 0, + AT_CLEAR, + AT_MD5, + AT_VOID +}; + +#endif // BAREOS_SRC_INCLUDE_AUTH_TYPES_H_ diff --git a/core/src/include/jcr.h b/core/src/include/jcr.h index f828b4edc3c..3be99c56ff8 100644 --- a/core/src/include/jcr.h +++ b/core/src/include/jcr.h @@ -51,17 +51,6 @@ typedef struct s_tree_root TREE_ROOT; class dlist; -/** - * Authentication types - */ -enum -{ - AT_NONE = 0, - AT_CLEAR, - AT_MD5, - AT_VOID -}; - /** * Migration selection types */ diff --git a/core/src/stored/ndmp_tape.cc b/core/src/stored/ndmp_tape.cc index 10555cf9614..0277459b0b0 100644 --- a/core/src/stored/ndmp_tape.cc +++ b/core/src/stored/ndmp_tape.cc @@ -58,6 +58,7 @@ #include "lib/bpoll.h" #include "lib/parse_conf.h" #include "lib/thread_list.h" +#include "include/auth_types.h" #include "include/jcr.h" #include diff --git a/core/src/stored/stored_conf.cc b/core/src/stored/stored_conf.cc index bd853a42370..5962fbbaed0 100644 --- a/core/src/stored/stored_conf.cc +++ b/core/src/stored/stored_conf.cc @@ -45,6 +45,7 @@ #define NEED_JANSSON_NAMESPACE 1 #include "lib/output_formatter.h" #include "lib/json.h" +#include "include/auth_types.h" #include "include/jcr.h" namespace storagedaemon { From 03e38b54dfd7f4ec945f3a6179f5bf423bd4ffed Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Wed, 6 Nov 2019 12:50:31 +0100 Subject: [PATCH 19/23] jcr: separate file for MigrationSelectionTypes --- core/src/dird/dird_conf.cc | 1 + core/src/dird/migrate.cc | 1 + core/src/include/jcr.h | 18 +-------- core/src/include/migration_selection_types.h | 40 ++++++++++++++++++++ 4 files changed, 43 insertions(+), 17 deletions(-) create mode 100644 core/src/include/migration_selection_types.h diff --git a/core/src/dird/dird_conf.cc b/core/src/dird/dird_conf.cc index b86cefcc4f5..c002c469979 100644 --- a/core/src/dird/dird_conf.cc +++ b/core/src/dird/dird_conf.cc @@ -54,6 +54,7 @@ #include "dird/jcr_private.h" #include "include/auth_protocol_types.h" #include "include/auth_types.h" +#include "include/migration_selection_types.h" #include "include/protocol_types.h" #include "lib/berrno.h" #include "lib/breg.h" diff --git a/core/src/dird/migrate.cc b/core/src/dird/migrate.cc index b62cc1c729c..530d7b578fa 100644 --- a/core/src/dird/migrate.cc +++ b/core/src/dird/migrate.cc @@ -53,6 +53,7 @@ #include "dird/ua_purge.h" #include "dird/ua_run.h" #include "include/auth_protocol_types.h" +#include "include/migration_selection_types.h" #include "lib/edit.h" #include "lib/parse_conf.h" #include "lib/util.h" diff --git a/core/src/include/jcr.h b/core/src/include/jcr.h index 3be99c56ff8..060e66027dd 100644 --- a/core/src/include/jcr.h +++ b/core/src/include/jcr.h @@ -49,23 +49,6 @@ typedef struct s_tree_root TREE_ROOT; #include "lib/alist.h" #include "lib/volume_session_info.h" -class dlist; - -/** - * Migration selection types - */ -enum -{ - MT_SMALLEST_VOL = 1, - MT_OLDEST_VOL, - MT_POOL_OCCUPANCY, - MT_POOL_TIME, - MT_POOL_UNCOPIED_JOBS, - MT_CLIENT, - MT_VOLUME, - MT_JOB, - MT_SQLQUERY -}; #define JobTerminatedSuccessfully(jcr) \ (jcr->JobStatus == JS_Terminated || jcr->JobStatus == JS_Warnings) @@ -79,6 +62,7 @@ enum #define endeach_jcr(jcr) JcrWalkEnd(jcr) +class dlist; class JobControlRecord; class BareosSocket; class BareosDb; diff --git a/core/src/include/migration_selection_types.h b/core/src/include/migration_selection_types.h new file mode 100644 index 00000000000..4076db4b6a9 --- /dev/null +++ b/core/src/include/migration_selection_types.h @@ -0,0 +1,40 @@ +/* + BAREOS® - Backup Archiving REcovery Open Sourced + + Copyright (C) 2000-2012 Free Software Foundation Europe e.V. + Copyright (C) 2011-2012 Planets Communications B.V. + Copyright (C) 2013-2019 Bareos GmbH & Co. KG + + This program is Free Software; you can redistribute it and/or + modify it under the terms of version three of the GNU Affero General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#ifndef BAREOS_SRC_INCLUDE_MIGRATION_SELECTION_TYPES_H_ +#define BAREOS_SRC_INCLUDE_MIGRATION_SELECTION_TYPES_H_ + +enum MigrationSelectionTypes +{ + MT_SMALLEST_VOL = 1, + MT_OLDEST_VOL, + MT_POOL_OCCUPANCY, + MT_POOL_TIME, + MT_POOL_UNCOPIED_JOBS, + MT_CLIENT, + MT_VOLUME, + MT_JOB, + MT_SQLQUERY +}; + +#endif // BAREOS_SRC_INCLUDE_MIGRATION_SELECTION_TYPES_H_ From e42a50805052c4fffe1689a2761168335e000a2c Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Wed, 6 Nov 2019 12:59:00 +0100 Subject: [PATCH 20/23] jcr: cleanup header file --- core/src/include/jcr.h | 50 +++++++++++----------------- core/src/lib/jcr.cc | 6 ++++ core/src/tests/job_control_record.cc | 1 + 3 files changed, 26 insertions(+), 31 deletions(-) diff --git a/core/src/include/jcr.h b/core/src/include/jcr.h index 060e66027dd..bd73b2963b5 100644 --- a/core/src/include/jcr.h +++ b/core/src/include/jcr.h @@ -39,43 +39,24 @@ #include #include #include "lib/tls_conf.h" - -#ifdef DIRECTOR_DAEMON -#include "cats/cats.h" -#include "dird/client_connection_handshake_mode.h" -typedef struct s_tree_root TREE_ROOT; -#endif - #include "lib/alist.h" -#include "lib/volume_session_info.h" - - -#define JobTerminatedSuccessfully(jcr) \ - (jcr->JobStatus == JS_Terminated || jcr->JobStatus == JS_Warnings) - -#define JobCanceled(jcr) \ - (jcr->JobStatus == JS_Canceled || jcr->JobStatus == JS_ErrorTerminated || \ - jcr->JobStatus == JS_FatalError) - -#define foreach_jcr(jcr) \ - for (jcr = jcr_walk_start(); jcr; (jcr = jcr_walk_next(jcr))) - -#define endeach_jcr(jcr) JcrWalkEnd(jcr) +#include "lib/tls_conf.h" -class dlist; -class JobControlRecord; -class BareosSocket; class BareosDb; +class BareosSocket; +class dlist; class htable; +class JobControlRecord; struct AttributesDbRecord; struct bpContext; +struct JobControlRecordPrivate; +struct VolumeSessionInfo; + #ifdef HAVE_WIN32 struct CopyThreadContext; #endif -struct JobControlRecordPrivate; - /* clang-format off */ struct CompressionContext { POOLMEM* deflate_buffer{nullptr}; /**< Buffer used for deflation (compression) */ @@ -94,13 +75,20 @@ struct CompressionContext { }; /* clang-format on */ -struct job_callback_item { - void (*JobEndCb)(JobControlRecord* jcr, void*); - void* ctx{}; -}; - typedef void(JCR_free_HANDLER)(JobControlRecord* jcr); +#define JobTerminatedSuccessfully(jcr) \ + (jcr->JobStatus == JS_Terminated || jcr->JobStatus == JS_Warnings) + +#define JobCanceled(jcr) \ + (jcr->JobStatus == JS_Canceled || jcr->JobStatus == JS_ErrorTerminated || \ + jcr->JobStatus == JS_FatalError) + +#define foreach_jcr(jcr) \ + for (jcr = jcr_walk_start(); jcr; (jcr = jcr_walk_next(jcr))) + +#define endeach_jcr(jcr) JcrWalkEnd(jcr) + /* clang-format off */ class JobControlRecord { private: diff --git a/core/src/lib/jcr.cc b/core/src/lib/jcr.cc index e70e8970f9d..730f0b6914c 100644 --- a/core/src/lib/jcr.cc +++ b/core/src/lib/jcr.cc @@ -54,6 +54,7 @@ #include "lib/bsock.h" #include "lib/recent_job_results_list.h" #include "lib/message_queue_item.h" +#include "lib/volume_session_info.h" #include "lib/watchdog.h" #include @@ -150,6 +151,11 @@ bool JobControlRecord::JobReads() return false; } +struct job_callback_item { + void (*JobEndCb)(JobControlRecord* jcr, void*); + void* ctx{}; +}; + /* * Push a job_callback_item onto the job end callback stack. */ diff --git a/core/src/tests/job_control_record.cc b/core/src/tests/job_control_record.cc index dde10e0f5cb..cbae4fa0b1d 100644 --- a/core/src/tests/job_control_record.cc +++ b/core/src/tests/job_control_record.cc @@ -22,6 +22,7 @@ #include "gtest/gtest.h" #include "include/bareos.h" #include "include/jcr.h" +#include "lib/volume_session_info.h" static bool callback_called_from_destructor = false; static void callback(JobControlRecord* jcr) From f7df319e18954a223618b047c7fefedd3c47d930 Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Wed, 6 Nov 2019 13:17:58 +0100 Subject: [PATCH 21/23] jcr: separate file for CompressionContext --- core/src/include/compression_context.h | 45 ++++++++++++++++++++++++++ core/src/include/jcr.h | 28 +++------------- 2 files changed, 50 insertions(+), 23 deletions(-) create mode 100644 core/src/include/compression_context.h diff --git a/core/src/include/compression_context.h b/core/src/include/compression_context.h new file mode 100644 index 00000000000..c0705d9b5fe --- /dev/null +++ b/core/src/include/compression_context.h @@ -0,0 +1,45 @@ +/* + BAREOS® - Backup Archiving REcovery Open Sourced + + Copyright (C) 2000-2012 Free Software Foundation Europe e.V. + Copyright (C) 2011-2012 Planets Communications B.V. + Copyright (C) 2013-2019 Bareos GmbH & Co. KG + + This program is Free Software; you can redistribute it and/or + modify it under the terms of version three of the GNU Affero General Public + License as published by the Free Software Foundation and included + in the file LICENSE. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + 02110-1301, USA. +*/ + +#ifndef BAREOS_SRC_INCLUDE_COMPRESSION_CONTEXT_H_ +#define BAREOS_SRC_INCLUDE_COMPRESSION_CONTEXT_H_ + +/* clang-format off */ +struct CompressionContext { + POOLMEM* deflate_buffer{nullptr}; /**< Buffer used for deflation (compression) */ + POOLMEM* inflate_buffer{nullptr}; /**< Buffer used for inflation (decompression) */ + uint32_t deflate_buffer_size{}; /**< Length of deflation buffer */ + uint32_t inflate_buffer_size{}; /**< Length of inflation buffer */ + struct { +#ifdef HAVE_LIBZ + void* pZLIB{nullptr}; /**< ZLIB compression session data */ +#endif +#ifdef HAVE_LZO + void* pLZO{nullptr}; /**< LZO compression session data */ +#endif + void* pZFAST{nullptr}; /**< FASTLZ compression session data */ + } workset; +}; +/* clang-format on */ + +#endif // BAREOS_SRC_INCLUDE_COMPRESSION_CONTEXT_H_ diff --git a/core/src/include/jcr.h b/core/src/include/jcr.h index bd73b2963b5..01bc0b88058 100644 --- a/core/src/include/jcr.h +++ b/core/src/include/jcr.h @@ -34,11 +34,11 @@ #ifndef BAREOS_INCLUDE_JCR_H_ #define BAREOS_INCLUDE_JCR_H_ 1 -#include -#include -#include -#include -#include "lib/tls_conf.h" +#include "include/bareos.h" +#include "include/compression_context.h" +#include "include/job_level.h" +#include "include/job_status.h" +#include "include/job_types.h" #include "lib/alist.h" #include "lib/tls_conf.h" @@ -57,24 +57,6 @@ struct VolumeSessionInfo; struct CopyThreadContext; #endif -/* clang-format off */ -struct CompressionContext { - POOLMEM* deflate_buffer{nullptr}; /**< Buffer used for deflation (compression) */ - POOLMEM* inflate_buffer{nullptr}; /**< Buffer used for inflation (decompression) */ - uint32_t deflate_buffer_size{}; /**< Length of deflation buffer */ - uint32_t inflate_buffer_size{}; /**< Length of inflation buffer */ - struct { -#ifdef HAVE_LIBZ - void* pZLIB{nullptr}; /**< ZLIB compression session data */ -#endif -#ifdef HAVE_LZO - void* pLZO{nullptr}; /**< LZO compression session data */ -#endif - void* pZFAST{nullptr}; /**< FASTLZ compression session data */ - } workset; -}; -/* clang-format on */ - typedef void(JCR_free_HANDLER)(JobControlRecord* jcr); #define JobTerminatedSuccessfully(jcr) \ From f5d3c327991f13fe4d6519a5f0febf1562f35b12 Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Wed, 6 Nov 2019 13:35:37 +0100 Subject: [PATCH 22/23] dird: fixup header includes --- core/src/dird/ua_dotcmds.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/src/dird/ua_dotcmds.cc b/core/src/dird/ua_dotcmds.cc index 36b2bf51942..bdc07dd740a 100644 --- a/core/src/dird/ua_dotcmds.cc +++ b/core/src/dird/ua_dotcmds.cc @@ -35,6 +35,7 @@ #include "include/bareos.h" #include "dird.h" +#include "dird/jcr_private.h" #include "dird/job.h" #include "dird/dird_globals.h" #include "dird/sd_cmds.h" @@ -44,6 +45,7 @@ #include "dird/ua_db.h" #include "dird/ua_select.h" #include "dird/storage.h" +#include "include/auth_protocol_types.h" #include "lib/edit.h" #include "lib/parse_conf.h" #include "lib/util.h" From aa927140c4b226cd6ec42a622c2c9c51c210aec8 Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Wed, 6 Nov 2019 15:04:12 +0100 Subject: [PATCH 23/23] lib: remove obvious comments --- core/src/lib/jcr.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/core/src/lib/jcr.cc b/core/src/lib/jcr.cc index 730f0b6914c..fa4e61b649a 100644 --- a/core/src/lib/jcr.cc +++ b/core/src/lib/jcr.cc @@ -361,7 +361,7 @@ static void FreeCommonJcr(JobControlRecord* jcr, static void JcrCleanup(JobControlRecord* jcr, bool is_destructor_call = false) { DequeueMessages(jcr); - CallJobEndCallbacks(jcr); /* call registered callbacks */ + CallJobEndCallbacks(jcr); Dmsg1(debuglevel, "End job=%d\n", jcr->JobId); @@ -381,14 +381,12 @@ static void JcrCleanup(JobControlRecord* jcr, bool is_destructor_call = false) break; } - CloseMsg(jcr); /* close messages for this job */ + CloseMsg(jcr); - if (jcr->daemon_free_jcr) { - jcr->daemon_free_jcr(jcr); /* call daemon free routine */ - } + if (jcr->daemon_free_jcr) { jcr->daemon_free_jcr(jcr); } FreeCommonJcr(jcr, is_destructor_call); - CloseMsg(nullptr); /* flush any daemon messages */ + CloseMsg(nullptr); // flush any daemon messages } JobControlRecord::~JobControlRecord()