From af5e0fd37b7d66091b0ffcc7538c51233e932bef Mon Sep 17 00:00:00 2001 From: Frank Ueberschar Date: Mon, 14 Jan 2019 14:53:04 +0100 Subject: [PATCH] jcr: renamed rstore, wstore and related resource variables --- core/src/dird/backup.cc | 18 +- core/src/dird/backup.h | 2 +- core/src/dird/bsr.cc | 8 +- core/src/dird/catreq.cc | 10 +- core/src/dird/dir_plugins.cc | 24 +-- core/src/dird/dird_conf.cc | 4 +- core/src/dird/expand.cc | 12 +- core/src/dird/fd_cmds.cc | 2 +- core/src/dird/job.cc | 2 +- core/src/dird/jobq.cc | 60 +++--- core/src/dird/migrate.cc | 86 ++++---- core/src/dird/msgchan.cc | 14 +- core/src/dird/msgchan.h | 2 +- core/src/dird/ndmp_dma_backup_NDMP_BAREOS.cc | 8 +- core/src/dird/ndmp_dma_backup_NDMP_NATIVE.cc | 10 +- core/src/dird/ndmp_dma_generic.cc | 6 +- core/src/dird/ndmp_dma_restore_NDMP_BAREOS.cc | 8 +- core/src/dird/ndmp_dma_restore_NDMP_NATIVE.cc | 12 +- core/src/dird/newvol.cc | 2 +- core/src/dird/next_vol.cc | 4 +- core/src/dird/restore.cc | 4 +- core/src/dird/sd_cmds.cc | 40 ++-- core/src/dird/stats.cc | 2 +- core/src/dird/storage.cc | 200 +++++++++--------- core/src/dird/ua_cmds.cc | 20 +- core/src/dird/ua_label.cc | 10 +- core/src/dird/ua_purge.cc | 4 +- core/src/dird/ua_run.cc | 38 ++-- core/src/dird/ua_select.cc | 6 +- core/src/dird/ua_status.cc | 18 +- core/src/dird/ua_update.cc | 2 +- core/src/dird/vbackup.cc | 12 +- core/src/dird/verify.cc | 4 +- core/src/filed/evaluate_job_command.cc | 86 ++++++++ core/src/include/jcr.h | 12 +- 35 files changed, 419 insertions(+), 333 deletions(-) create mode 100644 core/src/filed/evaluate_job_command.cc diff --git a/core/src/dird/backup.cc b/core/src/dird/backup.cc index dfa140716b9..5b0450ff284 100644 --- a/core/src/dird/backup.cc +++ b/core/src/dird/backup.cc @@ -115,12 +115,12 @@ char* ClientAddressToContact(ClientResource *client, StorageResource *store) * use wstores' LanAddress to connect to. * */ -char* StorageAddressToContact(StorageResource *rstore, StorageResource *wstore) +char* StorageAddressToContact(StorageResource *read_storage, StorageResource *write_storage) { - if (rstore->lanaddress && wstore->lanaddress) { - return wstore->lanaddress; + if (read_storage->lanaddress && write_storage->lanaddress) { + return write_storage->lanaddress; } else { - return wstore->address; + return write_storage->address; } } @@ -128,7 +128,7 @@ static inline bool ValidateStorage(JobControlRecord *jcr) { StorageResource *store = nullptr; - foreach_alist(store, jcr->res.wstorage) { + foreach_alist(store, jcr->res.write_storage_list) { switch (store->Protocol) { case APT_NATIVE: continue; @@ -162,7 +162,7 @@ bool DoNativeBackupInit(JobControlRecord *jcr) * If pool storage specified, use it instead of job storage */ CopyWstorage(jcr, jcr->res.pool->storage, _("Pool resource")); - if (!jcr->res.wstorage) { + if (!jcr->res.write_storage_list) { Jmsg(jcr, M_FATAL, 0, _("No Storage specification found in Job or Pool.\n")); return false; } @@ -454,7 +454,7 @@ bool DoNativeBackup(JobControlRecord *jcr) /* * Now start a job with the Storage daemon */ - if (!StartStorageDaemonJob(jcr, NULL, jcr->res.wstorage)) { + if (!StartStorageDaemonJob(jcr, NULL, jcr->res.write_storage_list)) { return false; } @@ -538,7 +538,7 @@ bool DoNativeBackup(JobControlRecord *jcr) } client = jcr->res.client; - store = jcr->res.wstore; + store = jcr->res.write_storage; char *connection_target_address; /* @@ -1225,7 +1225,7 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty jcr->res.fileset->name(), jcr->FSCreateTime, jcr->res.pool->name(), jcr->res.pool_source, jcr->res.catalog->name(), jcr->res.catalog_source, - jcr->res.wstore->name(), jcr->res.wstore_source, + jcr->res.write_storage->name(), jcr->res.wstore_source, schedt, sdt, edt, diff --git a/core/src/dird/backup.h b/core/src/dird/backup.h index 67aa6ccfbd4..0a7a9f1ae5f 100644 --- a/core/src/dird/backup.h +++ b/core/src/dird/backup.h @@ -35,7 +35,7 @@ void GenerateBackupSummary(JobControlRecord *jcr, ClientDbRecord *cr, int msg_ty char* StorageAddressToContact(ClientResource *client, StorageResource *store); char* ClientAddressToContact(ClientResource *client, StorageResource *store); -char* StorageAddressToContact(StorageResource *rstore, StorageResource *wstore); +char* StorageAddressToContact(StorageResource *read_storage, StorageResource *write_storage); } /* namespace directordaemon */ #endif // BAREOS_DIRD_BACKUP_H_ diff --git a/core/src/dird/bsr.cc b/core/src/dird/bsr.cc index 6c23c93c03e..101ebcae8b7 100644 --- a/core/src/dird/bsr.cc +++ b/core/src/dird/bsr.cc @@ -733,7 +733,7 @@ bool OpenBootstrapFile(JobControlRecord *jcr, bootstrap_info &info) if (!jcr->RestoreBootstrap) { return false; } - bstrncpy(info.storage, jcr->res.rstore->name(), MAX_NAME_LENGTH); + bstrncpy(info.storage, jcr->res.read_storage->name(), MAX_NAME_LENGTH); bs = fopen(jcr->RestoreBootstrap, "rb"); if (!bs) { @@ -788,7 +788,7 @@ static inline bool IsOnSameStorage(JobControlRecord *jcr, char *new_one) /* * Same name */ - if (bstrcmp(new_one, jcr->res.rstore->name())) { + if (bstrcmp(new_one, jcr->res.read_storage->name())) { return true; } @@ -803,8 +803,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.rstore->SDport != new_store->SDport || - !bstrcmp(jcr->res.rstore->address, new_store->address)) { + if (jcr->res.read_storage->SDport != new_store->SDport || + !bstrcmp(jcr->res.read_storage->address, new_store->address)) { return false; } diff --git a/core/src/dird/catreq.cc b/core/src/dird/catreq.cc index 5e510bf9f10..8285f194845 100644 --- a/core/src/dird/catreq.cc +++ b/core/src/dird/catreq.cc @@ -150,7 +150,7 @@ void CatalogRequest(JobControlRecord *jcr, BareosSocket *bs) ok = jcr->db->GetPoolRecord(jcr, &pr); if (ok) { mr.PoolId = pr.PoolId; - SetStorageidInMr(jcr->res.wstore, &mr); + SetStorageidInMr(jcr->res.write_storage, &mr); mr.ScratchPoolId = pr.ScratchPoolId; ok = FindNextVolumeForAppend(jcr, &mr, index, unwanted_volumes.c_str(), fnv_create_vol, fnv_prune); Dmsg3(050, "find_media ok=%d idx=%d vol=%s\n", ok, index, mr.VolumeName); @@ -191,7 +191,7 @@ void CatalogRequest(JobControlRecord *jcr, BareosSocket *bs) */ if (mr.PoolId != jcr->jr.PoolId) { reason = _("not in Pool"); - } else if (!bstrcmp(mr.MediaType, jcr->res.wstore->media_type)) { + } else if (!bstrcmp(mr.MediaType, jcr->res.write_storage->media_type)) { reason = _("not correct MediaType"); } else { /* @@ -292,12 +292,12 @@ 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.wstore && sdmr.VolWrites > mr.VolWrites) { - Dmsg2(050, "Update StorageId old=%d new=%d\n", mr.StorageId, jcr->res.wstore->StorageId); + if (jcr->res.write_storage && sdmr.VolWrites > mr.VolWrites) { + Dmsg2(050, "Update StorageId old=%d new=%d\n", mr.StorageId, jcr->res.write_storage->StorageId); /* * Update StorageId after write */ - SetStorageidInMr(jcr->res.wstore, &mr); + SetStorageidInMr(jcr->res.write_storage, &mr); } else { /* * Nothing written, reset same StorageId diff --git a/core/src/dird/dir_plugins.cc b/core/src/dird/dir_plugins.cc index 6d08f44581c..892e4c2b209 100644 --- a/core/src/dird/dir_plugins.cc +++ b/core/src/dird/dir_plugins.cc @@ -642,10 +642,10 @@ static bRC bareosGetValue(bpContext *ctx, brDirVariable var, void *value) Dmsg1(debuglevel, "dir-plugin: return bDirVarPool=%s\n", NPRT(*((char **)value))); break; case bDirVarStorage: - if (jcr->res.wstore) { - *((char **)value) = jcr->res.wstore->hdr.name; - } else if (jcr->res.rstore) { - *((char **)value) = jcr->res.rstore->hdr.name; + if (jcr->res.write_storage) { + *((char **)value) = jcr->res.write_storage->hdr.name; + } else if (jcr->res.read_storage) { + *((char **)value) = jcr->res.read_storage->hdr.name; } else { *((char **)value) = NULL; retval = bRC_Error; @@ -653,8 +653,8 @@ static bRC bareosGetValue(bpContext *ctx, brDirVariable var, void *value) Dmsg1(debuglevel, "dir-plugin: return bDirVarStorage=%s\n", NPRT(*((char **)value))); break; case bDirVarWriteStorage: - if (jcr->res.wstore) { - *((char **)value) = jcr->res.wstore->hdr.name; + if (jcr->res.write_storage) { + *((char **)value) = jcr->res.write_storage->hdr.name; } else { *((char **)value) = NULL; retval = bRC_Error; @@ -662,8 +662,8 @@ static bRC bareosGetValue(bpContext *ctx, brDirVariable var, void *value) Dmsg1(debuglevel, "dir-plugin: return bDirVarWriteStorage=%s\n", NPRT(*((char **)value))); break; case bDirVarReadStorage: - if (jcr->res.rstore) { - *((char **)value) = jcr->res.rstore->hdr.name; + if (jcr->res.read_storage) { + *((char **)value) = jcr->res.read_storage->hdr.name; } else { *((char **)value) = NULL; retval = bRC_Error; @@ -675,10 +675,10 @@ static bRC bareosGetValue(bpContext *ctx, brDirVariable var, void *value) Dmsg1(debuglevel, "dir-plugin: return bDirVarCatalog=%s\n", NPRT(*((char **)value))); break; case bDirVarMediaType: - if (jcr->res.wstore) { - *((char **)value) = jcr->res.wstore->media_type; - } else if (jcr->res.rstore) { - *((char **)value) = jcr->res.rstore->media_type; + 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; } else { *((char **)value) = NULL; retval = bRC_Error; diff --git a/core/src/dird/dird_conf.cc b/core/src/dird/dird_conf.cc index f5fa3685ee8..9e2f22aacbb 100644 --- a/core/src/dird/dird_conf.cc +++ b/core/src/dird/dird_conf.cc @@ -3408,8 +3408,8 @@ extern "C" char *job_code_callback_director(JobControlRecord *jcr, const char *p } break; case 'w': - if (jcr->res.wstore) { - return jcr->res.wstore->name(); + if (jcr->res.write_storage) { + return jcr->res.write_storage->name(); } break; case 'x': diff --git a/core/src/dird/expand.cc b/core/src/dird/expand.cc index 9946741f6f8..6b15560e14e 100644 --- a/core/src/dird/expand.cc +++ b/core/src/dird/expand.cc @@ -119,20 +119,20 @@ static int job_item(JobControlRecord *jcr, str = jcr->res.pool->name(); break; case 9: /* Storage */ - if (jcr->res.wstore) { - str = jcr->res.wstore->name(); + if (jcr->res.write_storage) { + str = jcr->res.write_storage->name(); } else { - str = jcr->res.rstore->name(); + str = jcr->res.read_storage->name(); } break; case 10: /* Catalog */ str = jcr->res.catalog->name(); break; case 11: /* MediaType */ - if (jcr->res.wstore) { - str = jcr->res.wstore->media_type; + if (jcr->res.write_storage) { + str = jcr->res.write_storage->media_type; } else { - str = jcr->res.rstore->media_type; + str = jcr->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 1813cc702b4..bf3a41655dd 100644 --- a/core/src/dird/fd_cmds.cc +++ b/core/src/dird/fd_cmds.cc @@ -493,7 +493,7 @@ static bool SendFileset(JobControlRecord *jcr) { FilesetResource *fileset = jcr->res.fileset; BareosSocket *fd = jcr->file_bsock; - StorageResource *store = jcr->res.wstore; + StorageResource *store = jcr->res.write_storage; int num; bool include = true; diff --git a/core/src/dird/job.cc b/core/src/dird/job.cc index 1eac588feda..baa687a7274 100644 --- a/core/src/dird/job.cc +++ b/core/src/dird/job.cc @@ -242,7 +242,7 @@ bool SetupJob(JobControlRecord *jcr, bool suppress_output) goto bail_out; } - if (jcr->JobReads() && !jcr->res.rstorage) { + if (jcr->JobReads() && !jcr->res.read_storage_list) { if (jcr->res.job->storage) { CopyRwstorage(jcr, jcr->res.job->storage, _("Job resource")); } else { diff --git a/core/src/dird/jobq.cc b/core/src/dird/jobq.cc index 9757a262342..671947bcf4e 100644 --- a/core/src/dird/jobq.cc +++ b/core/src/dird/jobq.cc @@ -743,13 +743,13 @@ static bool RescheduleJob(JobControlRecord *jcr, jobq_t *jq, jobq_item_t *je) njcr->res.run_next_pool_override = jcr->res.run_next_pool_override; njcr->JobStatus = -1; njcr->setJobStatus(jcr->JobStatus); - if (jcr->res.rstore) { - CopyRstorage(njcr, jcr->res.rstorage, _("previous Job")); + if (jcr->res.read_storage) { + CopyRstorage(njcr, jcr->res.read_storage_list, _("previous Job")); } else { FreeRstorage(njcr); } - if (jcr->res.wstore) { - CopyWstorage(njcr, jcr->res.wstorage, _("previous Job")); + if (jcr->res.write_storage) { + CopyWstorage(njcr, jcr->res.write_storage_list, _("previous Job")); } else { FreeWstorage(njcr); } @@ -816,17 +816,17 @@ static bool AcquireResources(JobControlRecord *jcr) * autochanger), and in principle, the SD reservation system * should detect these deadlocks, so push the work off on it. */ - if (jcr->res.rstore && jcr->res.rstore == jcr->res.wstore) { /* possible deadlock */ + if (jcr->res.read_storage && jcr->res.read_storage == jcr->res.write_storage) { /* possible deadlock */ Jmsg(jcr, M_FATAL, 0, _("Job canceled. Attempt to read and write same device.\n" " Read storage \"%s\" (From %s) -- Write storage \"%s\" (From %s)\n"), - jcr->res.rstore->name(), jcr->res.rstore_source, jcr->res.wstore->name(), jcr->res.wstore_source); + jcr->res.read_storage->name(), jcr->res.rstore_source, jcr->res.write_storage->name(), jcr->res.wstore_source); jcr->setJobStatus(JS_Canceled); return false; } #endif - if (jcr->res.rstore) { + if (jcr->res.read_storage) { if (!IncReadStore(jcr)) { jcr->setJobStatus(JS_WaitStoreRes); @@ -834,7 +834,7 @@ static bool AcquireResources(JobControlRecord *jcr) } } - if (jcr->res.wstore) { + if (jcr->res.write_storage) { if (!IncWriteStore(jcr)) { DecReadStore(jcr); jcr->setJobStatus(JS_WaitStoreRes); @@ -944,11 +944,11 @@ bool IncReadStore(JobControlRecord *jcr) } P(mutex); - if (jcr->res.rstore->rss->NumConcurrentJobs < jcr->res.rstore->MaxConcurrentJobs) { - jcr->res.rstore->rss->NumConcurrentReadJobs++; - jcr->res.rstore->rss->NumConcurrentJobs++; + if (jcr->res.read_storage->rss->NumConcurrentJobs < jcr->res.read_storage->MaxConcurrentJobs) { + jcr->res.read_storage->rss->NumConcurrentReadJobs++; + jcr->res.read_storage->rss->NumConcurrentJobs++; Dmsg2(50, "Inc Rstore=%s rncj=%d\n", - jcr->res.rstore->name(), jcr->res.rstore->rss->NumConcurrentJobs); + jcr->res.read_storage->name(), jcr->res.read_storage->rss->NumConcurrentJobs); V(mutex); return true; @@ -956,28 +956,28 @@ bool IncReadStore(JobControlRecord *jcr) V(mutex); Dmsg2(50, "Fail to acquire Rstore=%s rncj=%d\n", - jcr->res.rstore->name(), jcr->res.rstore->rss->NumConcurrentJobs); + jcr->res.read_storage->name(), jcr->res.read_storage->rss->NumConcurrentJobs); return false; } void DecReadStore(JobControlRecord *jcr) { - if (jcr->res.rstore && !jcr->IgnoreStorageConcurrency) { + if (jcr->res.read_storage && !jcr->IgnoreStorageConcurrency) { P(mutex); - jcr->res.rstore->rss->NumConcurrentReadJobs--; - jcr->res.rstore->rss->NumConcurrentJobs--; + jcr->res.read_storage->rss->NumConcurrentReadJobs--; + jcr->res.read_storage->rss->NumConcurrentJobs--; Dmsg2(50, "Dec Rstore=%s rncj=%d\n", - jcr->res.rstore->name(), jcr->res.rstore->rss->NumConcurrentJobs); + jcr->res.read_storage->name(), jcr->res.read_storage->rss->NumConcurrentJobs); - if (jcr->res.rstore->rss->NumConcurrentReadJobs < 0) { + if (jcr->res.read_storage->rss->NumConcurrentReadJobs < 0) { Jmsg(jcr, M_FATAL, 0, _("NumConcurrentReadJobs Dec Rstore=%s rncj=%d\n"), - jcr->res.rstore->name(), jcr->res.rstore->rss->NumConcurrentReadJobs); + jcr->res.read_storage->name(), jcr->res.read_storage->rss->NumConcurrentReadJobs); } - if (jcr->res.rstore->rss->NumConcurrentJobs < 0) { + if (jcr->res.read_storage->rss->NumConcurrentJobs < 0) { Jmsg(jcr, M_FATAL, 0, _("NumConcurrentJobs Dec Rstore=%s rncj=%d\n"), - jcr->res.rstore->name(), jcr->res.rstore->rss->NumConcurrentJobs); + jcr->res.read_storage->name(), jcr->res.read_storage->rss->NumConcurrentJobs); } V(mutex); } @@ -990,10 +990,10 @@ static bool IncWriteStore(JobControlRecord *jcr) } P(mutex); - if (jcr->res.wstore->rss->NumConcurrentJobs < jcr->res.wstore->MaxConcurrentJobs) { - jcr->res.wstore->rss->NumConcurrentJobs++; + if (jcr->res.write_storage->rss->NumConcurrentJobs < jcr->res.write_storage->MaxConcurrentJobs) { + jcr->res.write_storage->rss->NumConcurrentJobs++; Dmsg2(50, "Inc Wstore=%s wncj=%d\n", - jcr->res.wstore->name(), jcr->res.wstore->rss->NumConcurrentJobs); + jcr->res.write_storage->name(), jcr->res.write_storage->rss->NumConcurrentJobs); V(mutex); return true; @@ -1001,22 +1001,22 @@ static bool IncWriteStore(JobControlRecord *jcr) V(mutex); Dmsg2(50, "Fail to acquire Wstore=%s wncj=%d\n", - jcr->res.wstore->name(), jcr->res.wstore->rss->NumConcurrentJobs); + jcr->res.write_storage->name(), jcr->res.write_storage->rss->NumConcurrentJobs); return false; } static void DecWriteStore(JobControlRecord *jcr) { - if (jcr->res.wstore && !jcr->IgnoreStorageConcurrency) { + if (jcr->res.write_storage && !jcr->IgnoreStorageConcurrency) { P(mutex); - jcr->res.wstore->rss->NumConcurrentJobs--; + jcr->res.write_storage->rss->NumConcurrentJobs--; Dmsg2(50, "Dec Wstore=%s wncj=%d\n", - jcr->res.wstore->name(), jcr->res.wstore->rss->NumConcurrentJobs); + jcr->res.write_storage->name(), jcr->res.write_storage->rss->NumConcurrentJobs); - if (jcr->res.wstore->rss->NumConcurrentJobs < 0) { + if (jcr->res.write_storage->rss->NumConcurrentJobs < 0) { Jmsg(jcr, M_FATAL, 0, _("NumConcurrentJobs Dec Wstore=%s wncj=%d\n"), - jcr->res.wstore->name(), jcr->res.wstore->rss->NumConcurrentJobs); + jcr->res.write_storage->name(), jcr->res.write_storage->rss->NumConcurrentJobs); } V(mutex); } diff --git a/core/src/dird/migrate.cc b/core/src/dird/migrate.cc index 6f2b391b9c7..006cd59711a 100644 --- a/core/src/dird/migrate.cc +++ b/core/src/dird/migrate.cc @@ -237,11 +237,11 @@ struct idpkt { * - SDport * - password */ -static inline bool IsSameStorageDaemon(StorageResource *rstore, StorageResource *wstore) +static inline bool IsSameStorageDaemon(StorageResource *read_storage, StorageResource *write_storage) { - return rstore->SDport == wstore->SDport && - Bstrcasecmp(rstore->address, wstore->address) && - Bstrcasecmp(rstore->password_.value, wstore->password_.value); + return read_storage->SDport == write_storage->SDport && + Bstrcasecmp(read_storage->address, write_storage->address) && + Bstrcasecmp(read_storage->password_.value, write_storage->password_.value); } bool SetMigrationWstorage(JobControlRecord *jcr, PoolResource *pool, PoolResource *next_pool, const char *where) @@ -356,8 +356,8 @@ static inline bool SameStorage(JobControlRecord *jcr) { StorageResource *read_store, *write_store; - read_store = (StorageResource *)jcr->res.rstorage->first(); - write_store = (StorageResource *)jcr->res.wstorage->first(); + read_store = (StorageResource *)jcr->res.read_storage_list->first(); + write_store = (StorageResource *)jcr->res.write_storage_list->first(); if (!read_store->autochanger && !write_store->autochanger && bstrcmp(read_store->name(), write_store->name())) { @@ -1251,7 +1251,7 @@ bool DoMigrationInit(JobControlRecord *jcr) * Get the storage that was used for the original Job. * This only happens when the original pool used doesn't have an explicit storage. */ - if (!jcr->res.rstorage) { + if (!jcr->res.read_storage_list) { CopyRstorage(jcr, prev_job->storage, _("previous Job")); } @@ -1261,7 +1261,7 @@ 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.rstore, jcr->res.wstore); + jcr->remote_replicate = !IsSameStorageDaemon(jcr->res.read_storage, jcr->res.write_storage); /* * set the JobLevel to what the original job was @@ -1352,12 +1352,12 @@ static inline bool DoActualMigration(JobControlRecord *jcr) } Dmsg2(dbglevel, "Read store=%s, write store=%s\n", - ((StorageResource *)jcr->res.rstorage->first())->name(), - ((StorageResource *)jcr->res.wstorage->first())->name()); + ((StorageResource *)jcr->res.read_storage_list->first())->name(), + ((StorageResource *)jcr->res.write_storage_list->first())->name()); if (jcr->remote_replicate) { - alist *wstorage; + alist *write_storage_list; /* * See if we need to apply any bandwidth limiting. @@ -1368,10 +1368,10 @@ static inline bool DoActualMigration(JobControlRecord *jcr) */ if (jcr->res.job->max_bandwidth > 0) { jcr->max_bandwidth = jcr->res.job->max_bandwidth; - } else if (jcr->res.wstore->max_bandwidth > 0) { - jcr->max_bandwidth = jcr->res.wstore->max_bandwidth; - } else if (jcr->res.rstore->max_bandwidth > 0) { - jcr->max_bandwidth = jcr->res.rstore->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; } /* @@ -1380,19 +1380,19 @@ static inline bool DoActualMigration(JobControlRecord *jcr) Dmsg0(110, "Open connection with reading storage daemon\n"); /* - * Clear the wstore of the jcr and assign it to the mig_jcr so + * Clear the write_storage of the jcr and assign it to the mig_jcr so * the jcr is connected to the reading storage daemon and the * mig_jcr to the writing storage daemon. */ - mig_jcr->res.wstore = jcr->res.wstore; - jcr->res.wstore = NULL; + mig_jcr->res.write_storage = jcr->res.write_storage; + jcr->res.write_storage = NULL; /* - * Swap the wstorage between the jcr and the mig_jcr. + * Swap the write_storage_list between the jcr and the mig_jcr. */ - wstorage = mig_jcr->res.wstorage; - mig_jcr->res.wstorage = jcr->res.wstorage; - jcr->res.wstorage = wstorage; + 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; /* * Start conversation with Reading Storage daemon @@ -1418,7 +1418,7 @@ static inline bool DoActualMigration(JobControlRecord *jcr) /* * Now start a job with the Reading Storage daemon */ - if (!StartStorageDaemonJob(jcr, jcr->res.rstorage, NULL, /* send_bsr */ true)) { + if (!StartStorageDaemonJob(jcr, jcr->res.read_storage_list, NULL, /* send_bsr */ true)) { goto bail_out; } @@ -1428,7 +1428,7 @@ static inline bool DoActualMigration(JobControlRecord *jcr) * Now start a job with the Writing Storage daemon */ - if (!StartStorageDaemonJob(mig_jcr, NULL, mig_jcr->res.wstorage, /* send_bsr */ false)) { + if (!StartStorageDaemonJob(mig_jcr, NULL, mig_jcr->res.write_storage_list, /* send_bsr */ false)) { goto bail_out; } @@ -1454,7 +1454,7 @@ static inline bool DoActualMigration(JobControlRecord *jcr) /* * Now start a job with the Storage daemon */ - if (!StartStorageDaemonJob(jcr, jcr->res.rstorage, jcr->res.wstorage, /* send_bsr */ true)) { + if (!StartStorageDaemonJob(jcr, jcr->res.read_storage_list, jcr->res.write_storage_list, /* send_bsr */ true)) { FreePairedStorage(jcr); return false; } @@ -1513,8 +1513,8 @@ static inline bool DoActualMigration(JobControlRecord *jcr) * to replicate to the other. */ if (jcr->remote_replicate) { - StorageResource *wstore = mig_jcr->res.wstore; - StorageResource *rstore = jcr->res.rstore; + StorageResource *write_storage = mig_jcr->res.write_storage; + StorageResource *read_storage = jcr->res.read_storage; PoolMem command(PM_MESSAGE); uint32_t tls_need = 0; @@ -1538,19 +1538,19 @@ static inline bool DoActualMigration(JobControlRecord *jcr) /* * Send Storage daemon address to the other Storage daemon */ - if (wstore->SDDport == 0) { - wstore->SDDport = wstore->SDport; + if (write_storage->SDDport == 0) { + write_storage->SDDport = write_storage->SDport; } /* * TLS Requirement */ - tls_need = wstore->IsTlsConfigured() ? TlsPolicy::kBnetTlsAuto : TlsPolicy::kBnetTlsNone; + tls_need = write_storage->IsTlsConfigured() ? TlsPolicy::kBnetTlsAuto : TlsPolicy::kBnetTlsNone; - char *connection_target_address = StorageAddressToContact(rstore, wstore); + char *connection_target_address = StorageAddressToContact(read_storage, write_storage); Mmsg(command, replicatecmd, mig_jcr->JobId, mig_jcr->Job, connection_target_address, - wstore->SDDport, tls_need, mig_jcr->sd_auth_key); + write_storage->SDDport, tls_need, mig_jcr->sd_auth_key); if (!jcr->store_bsock->fsend(command.c_str())) { FreePairedStorage(jcr); @@ -1596,25 +1596,25 @@ static inline bool DoActualMigration(JobControlRecord *jcr) bail_out: if (jcr->remote_replicate && mig_jcr) { - alist *wstorage; + alist *write_storage_list; /* - * Swap the wstorage between the jcr and the mig_jcr. + * Swap the write_storage_list between the jcr and the mig_jcr. */ - wstorage = mig_jcr->res.wstorage; - mig_jcr->res.wstorage = jcr->res.wstorage; - jcr->res.wstorage = wstorage; + 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; /* - * Undo the clear of the wstore in the jcr and assign the mig_jcr wstore + * Undo the clear of the write_storage in the jcr and assign the mig_jcr write_storage * back to the jcr. This is an undo of the clearing we did earlier * as we want the jcr connected to the reading storage daemon and the - * mig_jcr to the writing jcr. By clearing the wstore of the jcr the + * mig_jcr to the writing jcr. By clearing the write_storage of the jcr the * ConnectToStorageDaemon function will do the right thing e.g. connect * the jcrs in the way we want them to. */ - jcr->res.wstore = mig_jcr->res.wstore; - mig_jcr->res.wstore = NULL; + jcr->res.write_storage = mig_jcr->res.write_storage; + mig_jcr->res.write_storage = NULL; } FreePairedStorage(jcr); @@ -1726,10 +1726,10 @@ static inline void GenerateMigrateSummary(JobControlRecord *jcr, MediaDbRecord * jcr->res.client ? jcr->res.client->name() : _("*None*"), jcr->res.fileset ? jcr->res.fileset->name() : _("*None*"), jcr->res.rpool->name(), jcr->res.rpool_source, - jcr->res.rstore ? jcr->res.rstore->name() : _("*None*"), + jcr->res.read_storage ? jcr->res.read_storage->name() : _("*None*"), NPRT(jcr->res.rstore_source), jcr->res.pool->name(), jcr->res.pool_source, - jcr->res.wstore ? jcr->res.wstore->name() : _("*None*"), + jcr->res.write_storage ? jcr->res.write_storage->name() : _("*None*"), NPRT(jcr->res.wstore_source), jcr->res.next_pool ? jcr->res.next_pool->name() : _("*None*"), NPRT(jcr->res.npool_source), diff --git a/core/src/dird/msgchan.cc b/core/src/dird/msgchan.cc index 8ba2600dae4..1c900aa682f 100644 --- a/core/src/dird/msgchan.cc +++ b/core/src/dird/msgchan.cc @@ -149,7 +149,7 @@ static inline bool SendBootstrapFileToSd(JobControlRecord *jcr, BareosSocket *sd /** Start a job with the Storage daemon */ -bool StartStorageDaemonJob(JobControlRecord *jcr, alist *rstore, alist *wstore, bool send_bsr) +bool StartStorageDaemonJob(JobControlRecord *jcr, alist *read_storage, alist *write_storage, bool send_bsr) { bool ok = true; StorageResource *storage = nullptr; @@ -273,7 +273,7 @@ bool StartStorageDaemonJob(JobControlRecord *jcr, alist *rstore, alist *wstore, * */ /* Do read side of storage daemon */ - if (ok && rstore) { + if (ok && read_storage) { /* 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))) { @@ -285,7 +285,7 @@ bool StartStorageDaemonJob(JobControlRecord *jcr, alist *rstore, alist *wstore, } BashSpaces(pool_type); BashSpaces(pool_name); - foreach_alist(storage, rstore) { + foreach_alist(storage, read_storage) { Dmsg1(100, "Rstore=%s\n", storage->name()); PmStrcpy(StoreName, storage->name()); BashSpaces(StoreName); @@ -293,7 +293,7 @@ bool StartStorageDaemonJob(JobControlRecord *jcr, alist *rstore, alist *wstore, BashSpaces(media_type); sd->fsend(use_storage, StoreName.c_str(), media_type.c_str(), pool_name.c_str(), pool_type.c_str(), 0, copy, stripe); - Dmsg1(100, "rstore >stored: %s", sd->msg); + Dmsg1(100, "read_storage >stored: %s", sd->msg); DeviceResource *dev = nullptr; /* Loop over alternative storage Devices until one is OK */ foreach_alist(dev, storage->device) { @@ -318,12 +318,12 @@ bool StartStorageDaemonJob(JobControlRecord *jcr, alist *rstore, alist *wstore, } /* Do write side of storage daemon */ - if (ok && wstore) { + if (ok && write_storage) { PmStrcpy(pool_type, jcr->res.pool->pool_type); PmStrcpy(pool_name, jcr->res.pool->name()); BashSpaces(pool_type); BashSpaces(pool_name); - foreach_alist(storage, wstore) { + foreach_alist(storage, write_storage) { PmStrcpy(StoreName, storage->name()); BashSpaces(StoreName); PmStrcpy(media_type, storage->media_type); @@ -331,7 +331,7 @@ bool StartStorageDaemonJob(JobControlRecord *jcr, alist *rstore, alist *wstore, sd->fsend(use_storage, StoreName.c_str(), media_type.c_str(), pool_name.c_str(), pool_type.c_str(), 1, copy, stripe); - Dmsg1(100, "wstore >stored: %s", sd->msg); + Dmsg1(100, "write_storage >stored: %s", sd->msg); DeviceResource *dev = nullptr; /* Loop over alternative storage Devices until one is OK */ foreach_alist(dev, storage->device) { diff --git a/core/src/dird/msgchan.h b/core/src/dird/msgchan.h index 4c1098cc34e..5a614c4550d 100644 --- a/core/src/dird/msgchan.h +++ b/core/src/dird/msgchan.h @@ -24,7 +24,7 @@ namespace directordaemon { -bool StartStorageDaemonJob(JobControlRecord *jcr, alist *rstore, alist *wstore, +bool StartStorageDaemonJob(JobControlRecord *jcr, alist *read_storage, alist *write_storage, bool send_bsr = false); bool StartStorageDaemonMessageThread(JobControlRecord *jcr); int BgetDirmsg(BareosSocket *bs, bool allow_any_msg = false); diff --git a/core/src/dird/ndmp_dma_backup_NDMP_BAREOS.cc b/core/src/dird/ndmp_dma_backup_NDMP_BAREOS.cc index b24b55c618e..47eab65bd84 100644 --- a/core/src/dird/ndmp_dma_backup_NDMP_BAREOS.cc +++ b/core/src/dird/ndmp_dma_backup_NDMP_BAREOS.cc @@ -155,7 +155,7 @@ bool DoNdmpBackupInit(JobControlRecord *jcr) */ CopyWstorage(jcr, jcr->res.pool->storage, _("Pool resource")); - if (!jcr->res.wstorage) { + if (!jcr->res.write_storage_list) { Jmsg(jcr, M_FATAL, 0, _("No Storage specification found in Job or Pool.\n")); return false; } @@ -239,7 +239,7 @@ bool DoNdmpBackup(JobControlRecord *jcr) * data mover which moves the data from the NDMP DATA AGENT to the NDMP * TAPE AGENT. */ - if (jcr->res.wstore->paired_storage) { + if (jcr->res.write_storage->paired_storage) { SetPairedStorage(jcr); jcr->setJobStatus(JS_WaitSD); @@ -250,7 +250,7 @@ bool DoNdmpBackup(JobControlRecord *jcr) /* * Now start a job with the Storage daemon */ - if (!StartStorageDaemonJob(jcr, NULL, jcr->res.wstorage)) { + if (!StartStorageDaemonJob(jcr, NULL, jcr->res.write_storage_list)) { return false; } @@ -281,7 +281,7 @@ 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.pstore, NDM_JOB_OP_BACKUP, &ndmp_job)) { + if (!NdmpBuildClientJob(jcr, jcr->res.client, jcr->res.paired_read_write_storage, NDM_JOB_OP_BACKUP, &ndmp_job)) { goto bail_out; } diff --git a/core/src/dird/ndmp_dma_backup_NDMP_NATIVE.cc b/core/src/dird/ndmp_dma_backup_NDMP_NATIVE.cc index 662350aac0f..9d82959ac15 100644 --- a/core/src/dird/ndmp_dma_backup_NDMP_NATIVE.cc +++ b/core/src/dird/ndmp_dma_backup_NDMP_NATIVE.cc @@ -78,7 +78,7 @@ int NdmpLoadNext(struct ndm_session *sess) { bool prune = false; struct ndmmedia *media; int index = 1; - StorageResource *store = jcr->res.wstore; + StorageResource *store = jcr->res.write_storage; /* * get the poolid for pool name @@ -217,7 +217,7 @@ bool DoNdmpBackupNdmpNative(JobControlRecord *jcr) */ status = 0; - StorageResource *store = jcr->res.wstore; + StorageResource *store = jcr->res.write_storage; int drive = 0; /* @@ -225,7 +225,7 @@ bool DoNdmpBackupNdmpNative(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 (!NdmpBuildClientAndStorageJob(jcr, jcr->res.wstore, jcr->res.client, + if (!NdmpBuildClientAndStorageJob(jcr, jcr->res.write_storage, jcr->res.client, true, /* init_tape */ true, /* init_robot */ NDM_JOB_OP_BACKUP, &ndmp_job)) { @@ -521,7 +521,7 @@ bool DoNdmpBackupInitNdmpNative(JobControlRecord *jcr) */ CopyWstorage(jcr, jcr->res.pool->storage, _("Pool resource")); - if (!jcr->res.wstorage) { + if (!jcr->res.write_storage_list) { Jmsg(jcr, M_FATAL, 0, _("No Storage specification found in Job or Pool.\n")); return false; } @@ -573,7 +573,7 @@ static inline bool extract_post_backup_stats_ndmp_native(JobControlRecord *jcr, * translate Physical to Logical Slot before storing into database */ - media->slot_addr = LookupStorageMapping(jcr->res.wstore, slot_type_normal, + media->slot_addr = LookupStorageMapping(jcr->res.write_storage, slot_type_normal, PHYSICAL_TO_LOGICAL, media->slot_addr); #if 0 Jmsg(jcr, M_INFO, 0, _("Physical Slot is %d\n"), media->slot_addr); diff --git a/core/src/dird/ndmp_dma_generic.cc b/core/src/dird/ndmp_dma_generic.cc index c24d147c5d0..a9edb185e2a 100644 --- a/core/src/dird/ndmp_dma_generic.cc +++ b/core/src/dird/ndmp_dma_generic.cc @@ -136,14 +136,14 @@ bool NdmpValidateStorage(JobControlRecord *jcr) { StorageResource *store = nullptr; - if (jcr->res.wstorage) { - foreach_alist(store, jcr->res.wstorage) { + if (jcr->res.write_storage_list) { + foreach_alist(store, jcr->res.write_storage_list) { if (!NdmpValidateStorage(jcr, store)) { return false; } } } else { - foreach_alist(store, jcr->res.rstorage) { + foreach_alist(store, jcr->res.read_storage_list) { if (!NdmpValidateStorage(jcr, store)) { return false; } diff --git a/core/src/dird/ndmp_dma_restore_NDMP_BAREOS.cc b/core/src/dird/ndmp_dma_restore_NDMP_BAREOS.cc index 9c4925c97d1..225d819de97 100644 --- a/core/src/dird/ndmp_dma_restore_NDMP_BAREOS.cc +++ b/core/src/dird/ndmp_dma_restore_NDMP_BAREOS.cc @@ -451,10 +451,10 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord *jcr) * Setup all paired read storage. */ SetPairedStorage(jcr); - if (!jcr->res.pstore) { + if (!jcr->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.rstore->name()); + jcr->res.read_storage->name()); goto bail_out; } @@ -482,7 +482,7 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord *jcr) * and reuse the job definition for each separate sub-restore 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.pstore, NDM_JOB_OP_EXTRACT, &ndmp_job)) { + if (!NdmpBuildClientJob(jcr, jcr->res.client, jcr->res.paired_read_write_storage, NDM_JOB_OP_EXTRACT, &ndmp_job)) { goto cleanup; } @@ -506,7 +506,7 @@ static inline bool DoNdmpRestoreBootstrap(JobControlRecord *jcr) /* * Now start a job with the Storage daemon */ - if (!StartStorageDaemonJob(jcr, jcr->res.rstorage, NULL)) { + if (!StartStorageDaemonJob(jcr, jcr->res.read_storage_list, NULL)) { goto cleanup; } diff --git a/core/src/dird/ndmp_dma_restore_NDMP_NATIVE.cc b/core/src/dird/ndmp_dma_restore_NDMP_NATIVE.cc index e36d333fbc4..0646866d8e4 100644 --- a/core/src/dird/ndmp_dma_restore_NDMP_NATIVE.cc +++ b/core/src/dird/ndmp_dma_restore_NDMP_NATIVE.cc @@ -296,8 +296,8 @@ static bool DoNdmpNativeRestore(JobControlRecord *jcr) int drive=0; - ndmp_job.tape_device = lookup_ndmp_drive(jcr->res.rstore, drive); - if (!NdmpBuildClientAndStorageJob(jcr, jcr->res.rstore, jcr->res.client, + ndmp_job.tape_device = lookup_ndmp_drive(jcr->res.read_storage, drive); + if (!NdmpBuildClientAndStorageJob(jcr, jcr->res.read_storage, jcr->res.client, true, /* init_tape */ true, /* init_robot */ NDM_JOB_OP_EXTRACT, &ndmp_job)) { @@ -325,7 +325,7 @@ static bool DoNdmpNativeRestore(JobControlRecord *jcr) goto cleanup_ndmp; } - ndmp_job.tape_device = lookup_ndmp_drive(jcr->res.rstore, drive); + ndmp_job.tape_device = lookup_ndmp_drive(jcr->res.read_storage, drive); ndmp_job.record_size = jcr->res.client->ndmp_blocksize; Jmsg(jcr, M_INFO, 0, _("Record size is %d\n"), ndmp_job.record_size); @@ -342,7 +342,7 @@ static bool DoNdmpNativeRestore(JobControlRecord *jcr) for (ndmmedia *media = ndmp_sess.control_acb->job.media_tab.head; media; media = media->next) { - if (!NdmpUpdateStorageMappings(jcr, jcr->res.rstore )){ + if (!NdmpUpdateStorageMappings(jcr, jcr->res.read_storage )){ Jmsg(jcr, M_ERROR, 0, _("ERROR in NdmpUpdateStorageMappings\n")); } /* @@ -350,7 +350,7 @@ static bool DoNdmpNativeRestore(JobControlRecord *jcr) */ Jmsg(jcr, M_INFO, 0, _("Logical slot for volume %s is %d\n"), media->label, media->slot_addr); - ndmp_slot = LookupStorageMapping(jcr->res.rstore, slot_type_normal, LOGICAL_TO_PHYSICAL, media->slot_addr); + ndmp_slot = LookupStorageMapping(jcr->res.read_storage, slot_type_normal, LOGICAL_TO_PHYSICAL, media->slot_addr); media->slot_addr = ndmp_slot; Jmsg(jcr, M_INFO, 0, _("Physical(NDMP) slot for volume %s is %d\n"), media->label, media->slot_addr); @@ -364,7 +364,7 @@ static bool DoNdmpNativeRestore(JobControlRecord *jcr) * Set the robot to use */ ndmp_sess.control_acb->job.robot_target = (struct ndmscsi_target *)actuallymalloc(sizeof(struct ndmscsi_target)); - if (ndmscsi_target_from_str(ndmp_sess.control_acb->job.robot_target, jcr->res.rstore->ndmp_changer_device) != 0) { + if (ndmscsi_target_from_str(ndmp_sess.control_acb->job.robot_target, jcr->res.read_storage->ndmp_changer_device) != 0) { Actuallyfree(ndmp_sess.control_acb->job.robot_target); Dmsg0(100,"no robot to use\n"); goto bail_out; diff --git a/core/src/dird/newvol.cc b/core/src/dird/newvol.cc index aa8fc33913e..5c9c254d0fc 100644 --- a/core/src/dird/newvol.cc +++ b/core/src/dird/newvol.cc @@ -77,7 +77,7 @@ bool newVolume(JobControlRecord *jcr, MediaDbRecord *mr, StorageResource *store) memset(mr, 0, sizeof(MediaDbRecord)); SetPoolDbrDefaultsInMediaDbr(mr, &pr); jcr->VolumeName[0] = 0; - bstrncpy(mr->MediaType, jcr->res.wstore->media_type, sizeof(mr->MediaType)); + bstrncpy(mr->MediaType, jcr->res.write_storage->media_type, sizeof(mr->MediaType)); GeneratePluginEvent(jcr, bDirEventNewVolume); /* return void... */ if (jcr->VolumeName[0] && IsVolumeNameLegal(NULL, jcr->VolumeName)) { bstrncpy(mr->VolumeName, jcr->VolumeName, sizeof(mr->VolumeName)); diff --git a/core/src/dird/next_vol.cc b/core/src/dird/next_vol.cc index d27457b0b56..4cc016aedb0 100644 --- a/core/src/dird/next_vol.cc +++ b/core/src/dird/next_vol.cc @@ -61,7 +61,7 @@ void SetStorageidInMr(StorageResource *store, MediaDbRecord *mr) * * mr.PoolId must be set * mr.ScratchPoolId could be set (used if create==true) - * jcr->wstore + * jcr->write_storage * jcr->db * jcr->pool * MediaDbRecord mr with PoolId set @@ -75,7 +75,7 @@ int FindNextVolumeForAppend(JobControlRecord *jcr, MediaDbRecord *mr, int index, int retry = 0; bool ok; bool InChanger; - StorageResource *store = jcr->res.wstore; + StorageResource *store = jcr->res.write_storage; bstrncpy(mr->MediaType, store->media_type, sizeof(mr->MediaType)); Dmsg3(debuglevel, "find_next_vol_for_append: JobId=%u PoolId=%d, MediaType=%s\n", diff --git a/core/src/dird/restore.cc b/core/src/dird/restore.cc index 3eea068b640..ed1c1a53793 100644 --- a/core/src/dird/restore.cc +++ b/core/src/dird/restore.cc @@ -163,7 +163,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord *jcr) if (!SelectNextRstore(jcr, info)) { goto bail_out; } - store = jcr->res.rstore; + store = jcr->res.read_storage; /** * Open a message channel connection with the Storage @@ -185,7 +185,7 @@ static inline bool DoNativeRestoreBootstrap(JobControlRecord *jcr) /* * Now start a job with the Storage daemon */ - if (!StartStorageDaemonJob(jcr, jcr->res.rstorage, NULL)) { + if (!StartStorageDaemonJob(jcr, jcr->res.read_storage_list, NULL)) { goto bail_out; } diff --git a/core/src/dird/sd_cmds.cc b/core/src/dird/sd_cmds.cc index 5a12ee7b96e..ce03cd17ca6 100644 --- a/core/src/dird/sd_cmds.cc +++ b/core/src/dird/sd_cmds.cc @@ -109,10 +109,10 @@ bool ConnectToStorageDaemon(JobControlRecord *jcr, int retry_interval, } StorageResource *store; - if (jcr->res.wstore) { - store = jcr->res.wstore; + if (jcr->res.write_storage) { + store = jcr->res.write_storage; } else { - store = jcr->res.rstore; + store = jcr->res.read_storage; } if (!store) { @@ -166,7 +166,7 @@ bool ConnectToStorageDaemon(JobControlRecord *jcr, int retry_interval, BareosSocket *open_sd_bsock(UaContext *ua) { - StorageResource *store = ua->jcr->res.wstore; + StorageResource *store = ua->jcr->res.write_storage; if (!store) { Dmsg0(200, "open_sd_bsock: No storage resource pointer set\n"); @@ -195,12 +195,12 @@ void CloseSdBsock(UaContext *ua) char *get_volume_name_from_SD(UaContext *ua, slot_number_t Slot, drive_number_t drive) { BareosSocket *sd; - StorageResource *store = ua->jcr->res.wstore; + StorageResource *store = ua->jcr->res.write_storage; char dev_name[MAX_NAME_LENGTH]; char *VolName = nullptr; int rtn_slot; - ua->jcr->res.wstore = store; + ua->jcr->res.write_storage = store; if (!(sd = open_sd_bsock(ua))) { ua->ErrorMsg(_("Could not open SD socket.\n")); return nullptr; @@ -276,7 +276,7 @@ dlist *native_get_vol_list(UaContext *ua, StorageResource *store, bool listall, dlist *vol_list; BareosSocket *sd = nullptr; - ua->jcr->res.wstore = store; + ua->jcr->res.write_storage = store; if (!(sd = open_sd_bsock(ua))) { return nullptr; } @@ -553,7 +553,7 @@ slot_number_t NativeGetNumSlots(UaContext *ua, StorageResource *store) BareosSocket *sd; slot_number_t slots = 0; - ua->jcr->res.wstore = store; + ua->jcr->res.write_storage = store; if (!(sd = open_sd_bsock(ua))) { return 0; } @@ -587,7 +587,7 @@ drive_number_t NativeGetNumDrives(UaContext *ua, StorageResource *store) BareosSocket *sd; drive_number_t drives = 0; - ua->jcr->res.wstore = store; + ua->jcr->res.write_storage = store; if (!(sd = open_sd_bsock(ua))) { return 0; } @@ -623,7 +623,7 @@ bool CancelStorageDaemonJob(UaContext *ua, StorageResource *store, char *JobId) control_jcr = new_control_jcr("*JobCancel*", JT_SYSTEM); - control_jcr->res.wstore = store; + control_jcr->res.write_storage = store; /* the next call will set control_jcr->store_bsock */ if (!ConnectToStorageDaemon(control_jcr, 10, me->SDConnectTimeout, true)) { @@ -649,18 +649,18 @@ bool CancelStorageDaemonJob(UaContext *ua, StorageResource *store, char *JobId) */ bool CancelStorageDaemonJob(UaContext *ua, JobControlRecord *jcr, bool interactive) { - if (!ua->jcr->res.wstorage) { - if (jcr->res.rstorage) { - CopyWstorage(ua->jcr, jcr->res.rstorage, _("Job resource")); + if (!ua->jcr->res.write_storage_list) { + if (jcr->res.read_storage_list) { + CopyWstorage(ua->jcr, jcr->res.read_storage_list, _("Job resource")); } else { - CopyWstorage(ua->jcr, jcr->res.wstorage, _("Job resource")); + CopyWstorage(ua->jcr, jcr->res.write_storage_list, _("Job resource")); } } else { UnifiedStorageResource store; - if (jcr->res.rstorage) { - store.store = jcr->res.rstore; + if (jcr->res.read_storage_list) { + store.store = jcr->res.read_storage; } else { - store.store = jcr->res.wstore; + store.store = jcr->res.write_storage; } if (!store.store) { Dmsg0(200, "CancelStorageDaemonJob: No storage resource pointer set\n"); @@ -792,7 +792,7 @@ bool NativeTransferVolume(UaContext *ua, StorageResource *store, bool retval = true; char dev_name[MAX_NAME_LENGTH]; - ua->jcr->res.wstore = store; + ua->jcr->res.write_storage = store; if (!(sd = open_sd_bsock(ua))) { return false; } @@ -840,7 +840,7 @@ bool NativeAutochangerVolumeOperation(UaContext *ua, StorageResource *store, bool retval = true; char dev_name[MAX_NAME_LENGTH]; - ua->jcr->res.wstore = store; + ua->jcr->res.write_storage = store; if (!(sd = open_sd_bsock(ua))) { return false; } @@ -922,7 +922,7 @@ bool DoStorageResolve(UaContext *ua, StorageResource *store) PmStrcpy(lstore.store_source, _("unknown source")); SetWstorage(ua->jcr, &lstore); - ua->jcr->res.wstore = store; + ua->jcr->res.write_storage = store; if (!(sd = open_sd_bsock(ua))) { return false; } diff --git a/core/src/dird/stats.cc b/core/src/dird/stats.cc index ce34a267b32..913d7b8aebe 100644 --- a/core/src/dird/stats.cc +++ b/core/src/dird/stats.cc @@ -194,7 +194,7 @@ void *statistics_thread(void *arg) continue; } - jcr->res.rstore = store; + jcr->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 035efa38f41..5bcf09993a6 100644 --- a/core/src/dird/storage.cc +++ b/core/src/dird/storage.cc @@ -80,19 +80,19 @@ void CopyRstorage(JobControlRecord *jcr, alist *storage, const char *where) { if (storage) { StorageResource *store = nullptr; - if (jcr->res.rstorage) { - delete jcr->res.rstorage; + if (jcr->res.read_storage_list) { + delete jcr->res.read_storage_list; } - jcr->res.rstorage = New(alist(10, not_owned_by_alist)); + jcr->res.read_storage_list = New(alist(10, not_owned_by_alist)); foreach_alist(store, storage) { - jcr->res.rstorage->append(store); + jcr->res.read_storage_list->append(store); } if (!jcr->res.rstore_source) { jcr->res.rstore_source = GetPoolMemory(PM_MESSAGE); } PmStrcpy(jcr->res.rstore_source, where); - if (jcr->res.rstorage) { - jcr->res.rstore = (StorageResource *)jcr->res.rstorage->first(); + if (jcr->res.read_storage_list) { + jcr->res.read_storage = (StorageResource *)jcr->res.read_storage_list->first(); } } } @@ -108,33 +108,33 @@ void SetRstorage(JobControlRecord *jcr, UnifiedStorageResource *store) if (!store->store) { return; } - if (jcr->res.rstorage) { + if (jcr->res.read_storage_list) { FreeRstorage(jcr); } - if (!jcr->res.rstorage) { - jcr->res.rstorage = New(alist(10, not_owned_by_alist)); + if (!jcr->res.read_storage_list) { + jcr->res.read_storage_list = New(alist(10, not_owned_by_alist)); } - jcr->res.rstore = store->store; + jcr->res.read_storage = store->store; if (!jcr->res.rstore_source) { jcr->res.rstore_source = GetPoolMemory(PM_MESSAGE); } PmStrcpy(jcr->res.rstore_source, store->store_source); - foreach_alist(storage, jcr->res.rstorage) { + foreach_alist(storage, jcr->res.read_storage_list) { if (store->store == storage) { return; } } /* Store not in list, so add it */ - jcr->res.rstorage->prepend(store->store); + jcr->res.read_storage_list->prepend(store->store); } void FreeRstorage(JobControlRecord *jcr) { - if (jcr->res.rstorage) { - delete jcr->res.rstorage; - jcr->res.rstorage = NULL; + if (jcr->res.read_storage_list) { + delete jcr->res.read_storage_list; + jcr->res.read_storage_list = NULL; } - jcr->res.rstore = NULL; + jcr->res.read_storage = NULL; } /** @@ -144,21 +144,21 @@ void CopyWstorage(JobControlRecord *jcr, alist *storage, const char *where) { if (storage) { StorageResource *st = nullptr; - if (jcr->res.wstorage) { - delete jcr->res.wstorage; + if (jcr->res.write_storage_list) { + delete jcr->res.write_storage_list; } - jcr->res.wstorage = New(alist(10, not_owned_by_alist)); + jcr->res.write_storage_list = New(alist(10, not_owned_by_alist)); foreach_alist(st, storage) { - Dmsg1(100, "wstorage=%s\n", st->name()); - jcr->res.wstorage->append(st); + Dmsg1(100, "write_storage_list=%s\n", st->name()); + jcr->res.write_storage_list->append(st); } if (!jcr->res.wstore_source) { jcr->res.wstore_source = GetPoolMemory(PM_MESSAGE); } PmStrcpy(jcr->res.wstore_source, where); - if (jcr->res.wstorage) { - jcr->res.wstore = (StorageResource *)jcr->res.wstorage->first(); - Dmsg2(100, "wstore=%s where=%s\n", jcr->res.wstore->name(), jcr->res.wstore_source); + if (jcr->res.write_storage_list) { + jcr->res.write_storage = (StorageResource *)jcr->res.write_storage_list->first(); + Dmsg2(100, "write_storage=%s where=%s\n", jcr->res.write_storage->name(), jcr->res.wstore_source); } } } @@ -174,19 +174,19 @@ void SetWstorage(JobControlRecord *jcr, UnifiedStorageResource *store) if (!store->store) { return; } - if (jcr->res.wstorage) { + if (jcr->res.write_storage_list) { FreeWstorage(jcr); } - if (!jcr->res.wstorage) { - jcr->res.wstorage = New(alist(10, not_owned_by_alist)); + if (!jcr->res.write_storage_list) { + jcr->res.write_storage_list = New(alist(10, not_owned_by_alist)); } - jcr->res.wstore = store->store; + jcr->res.write_storage = store->store; if (!jcr->res.wstore_source) { jcr->res.wstore_source = GetPoolMemory(PM_MESSAGE); } PmStrcpy(jcr->res.wstore_source, store->store_source); - Dmsg2(50, "wstore=%s where=%s\n", jcr->res.wstore->name(), jcr->res.wstore_source); - foreach_alist(storage, jcr->res.wstorage) { + Dmsg2(50, "write_storage=%s where=%s\n", jcr->res.write_storage->name(), jcr->res.wstore_source); + foreach_alist(storage, jcr->res.write_storage_list) { if (store->store == storage) { return; } @@ -195,16 +195,16 @@ void SetWstorage(JobControlRecord *jcr, UnifiedStorageResource *store) /* * Store not in list, so add it */ - jcr->res.wstorage->prepend(store->store); + jcr->res.write_storage_list->prepend(store->store); } void FreeWstorage(JobControlRecord *jcr) { - if (jcr->res.wstorage) { - delete jcr->res.wstorage; - jcr->res.wstorage = NULL; + if (jcr->res.write_storage_list) { + delete jcr->res.write_storage_list; + jcr->res.write_storage_list = NULL; } - jcr->res.wstore = NULL; + jcr->res.write_storage = NULL; } /** @@ -215,37 +215,37 @@ void FreeWstorage(JobControlRecord *jcr) */ void SetPairedStorage(JobControlRecord *jcr) { - StorageResource *store = nullptr, *pstore = nullptr; + StorageResource *store = nullptr, *paired_read_write_storage = nullptr; switch (jcr->getJobType()) { case JT_BACKUP: /* * For a backup we look at the write storage. */ - if (jcr->res.wstorage) { + if (jcr->res.write_storage_list) { /* - * Setup the jcr->res.wstorage to point to all paired_storage - * entries of all the storage currently in the jcrres.->wstorage. - * Save the original list under jcr->res.pstorage. + * Setup the jcr->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->res.pstorage = jcr->res.wstorage; - jcr->res.wstorage = New(alist(10, not_owned_by_alist)); - foreach_alist(store, jcr->res.pstorage) { + 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) { if (store->paired_storage) { - Dmsg1(100, "wstorage=%s\n", store->paired_storage->name()); - jcr->res.wstorage->append(store->paired_storage); + Dmsg1(100, "write_storage_list=%s\n", store->paired_storage->name()); + jcr->res.write_storage_list->append(store->paired_storage); } } /* - * Swap the actual jcr->res.wstore to point to the paired storage entry. - * We save the actual storage entry in pstore which is for restore + * 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. */ - store = jcr->res.wstore; + store = jcr->res.write_storage; if (store->paired_storage) { - jcr->res.wstore = store->paired_storage; - jcr->res.pstore = store; + jcr->res.write_storage = store->paired_storage; + jcr->res.paired_read_write_storage = store; } } else { Jmsg(jcr, M_FATAL, 0, @@ -256,16 +256,16 @@ void SetPairedStorage(JobControlRecord *jcr) /* * For a restores we look at the read storage. */ - if (jcr->res.rstorage) { + if (jcr->res.read_storage_list) { /* - * Setup the jcr->res.pstorage to point to all paired_storage - * entries of all the storage currently in the jcr->res.rstorage. + * 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. */ - jcr->res.pstorage = New(alist(10, not_owned_by_alist)); - foreach_alist(pstore, jcr->res.rstorage) { + jcr->res.paired_read_write_storage_list = New(alist(10, not_owned_by_alist)); + foreach_alist(paired_read_write_storage, jcr->res.read_storage_list) { store = (StorageResource *)my_config->GetNextRes(R_STORAGE, NULL); while (store) { - if (store->paired_storage == pstore) { + if (store->paired_storage == paired_read_write_storage) { break; } @@ -273,19 +273,19 @@ void SetPairedStorage(JobControlRecord *jcr) } /* - * See if we found a store that has the current pstore as + * See if we found a store that has the current paired_read_write_storage as * its paired storage. */ if (store) { - jcr->res.pstorage->append(store); + jcr->res.paired_read_write_storage_list->append(store); /* - * If the current processed pstore is also the current - * entry in jcr->res.rstore update the jcr->pstore to point + * If the current processed paired_read_write_storage is also the current + * entry in jcr->res.read_storage update the jcr->paired_read_write_storage to point * to this storage entry. */ - if (pstore == jcr->res.rstore) { - jcr->res.pstore = store; + if (paired_read_write_storage == jcr->res.read_storage) { + jcr->res.paired_read_write_storage = store; } } } @@ -299,30 +299,30 @@ void SetPairedStorage(JobControlRecord *jcr) /* * For a migrate or copy we look at the read storage. */ - if (jcr->res.rstorage) { + if (jcr->res.read_storage_list) { /* - * Setup the jcr->res.rstorage to point to all paired_storage - * entries of all the storage currently in the jcr->res.rstorage. - * Save the original list under jcr->res.pstorage. + * 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. */ - jcr->res.pstorage = jcr->res.rstorage; - jcr->res.rstorage = New(alist(10, not_owned_by_alist)); - foreach_alist(store, jcr->res.pstorage) { + 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) { if (store->paired_storage) { - Dmsg1(100, "rstorage=%s\n", store->paired_storage->name()); - jcr->res.rstorage->append(store->paired_storage); + Dmsg1(100, "read_storage_list=%s\n", store->paired_storage->name()); + jcr->res.read_storage_list->append(store->paired_storage); } } /* - * Swap the actual jcr->res.rstore to point to the paired storage entry. - * We save the actual storage entry in pstore which is for restore + * 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. */ - store = jcr->res.rstore; + store = jcr->res.read_storage; if (store->paired_storage) { - jcr->res.rstore = store->paired_storage; - jcr->res.pstore = store; + jcr->res.read_storage = store->paired_storage; + jcr->res.paired_read_write_storage = store; } } else { Jmsg(jcr, M_FATAL, 0, @@ -344,49 +344,49 @@ void SetPairedStorage(JobControlRecord *jcr) */ void FreePairedStorage(JobControlRecord *jcr) { - if (jcr->res.pstorage) { + if (jcr->res.paired_read_write_storage_list) { switch (jcr->getJobType()) { case JT_BACKUP: /* * For a backup we look at the write storage. */ - if (jcr->res.wstorage) { + if (jcr->res.write_storage_list) { /* - * The jcr->res.wstorage contain a set of paired storages. + * 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. */ - delete jcr->res.wstorage; - jcr->res.wstorage = jcr->res.pstorage; - jcr->res.pstorage = NULL; - jcr->res.wstore = jcr->res.pstore; - jcr->res.pstore = NULL; + 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; } break; case JT_RESTORE: /* - * The jcr->res.rstorage contain a set of paired storages. + * 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. */ - delete jcr->res.pstorage; - jcr->res.pstorage = NULL; - jcr->res.pstore = NULL; + delete jcr->res.paired_read_write_storage_list; + jcr->res.paired_read_write_storage_list = NULL; + jcr->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.rstorage) { + if (jcr->res.read_storage_list) { /* - * The jcr->res.rstorage contains a set of paired storages. + * 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. */ - delete jcr->res.rstorage; - jcr->res.rstorage = jcr->res.pstorage; - jcr->res.pstorage = NULL; - jcr->res.rstore = jcr->res.pstore; - jcr->res.pstore = NULL; + 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; } break; default: @@ -410,8 +410,8 @@ bool HasPairedStorage(JobControlRecord *jcr) /* * For a backup we look at the write storage. */ - if (jcr->res.wstorage) { - foreach_alist(store, jcr->res.wstorage) { + if (jcr->res.write_storage_list) { + foreach_alist(store, jcr->res.write_storage_list) { if (!store->paired_storage) { return false; } @@ -425,8 +425,8 @@ bool HasPairedStorage(JobControlRecord *jcr) case JT_RESTORE: case JT_MIGRATE: case JT_COPY: - if (jcr->res.rstorage) { - foreach_alist(store, jcr->res.rstorage) { + if (jcr->res.read_storage_list) { + foreach_alist(store, jcr->res.read_storage_list) { if (!store->paired_storage) { return false; } @@ -456,7 +456,7 @@ bool SelectNextRstore(JobControlRecord *jcr, bootstrap_info &info) { UnifiedStorageResource ustore; - if (bstrcmp(jcr->res.rstore->name(), info.storage)) { + if (bstrcmp(jcr->res.read_storage->name(), info.storage)) { return true; /* Same SD nothing to change */ } diff --git a/core/src/dird/ua_cmds.cc b/core/src/dird/ua_cmds.cc index 31c57792df0..5cc07c766e7 100644 --- a/core/src/dird/ua_cmds.cc +++ b/core/src/dird/ua_cmds.cc @@ -474,8 +474,8 @@ bool Do_a_command(UaContext *ua) return false; } - while (ua->jcr->res.wstorage && ua->jcr->res.wstorage->size()) { - ua->jcr->res.wstorage->remove(0); + while (ua->jcr->res.write_storage_list && ua->jcr->res.write_storage_list->size()) { + ua->jcr->res.write_storage_list->remove(0); } len = strlen(ua->argk[0]); @@ -879,7 +879,7 @@ static inline bool setbwlimit_stored(UaContext *ua, StorageResource *store, /* * Connect to Storage daemon */ - ua->jcr->res.wstore = store; + ua->jcr->res.write_storage = store; ua->jcr->max_bandwidth = limit; /* @@ -904,7 +904,7 @@ static inline bool setbwlimit_stored(UaContext *ua, StorageResource *store, ua->jcr->store_bsock->close(); delete ua->jcr->store_bsock; ua->jcr->store_bsock = NULL; - ua->jcr->res.wstore = NULL; + ua->jcr->res.write_storage = NULL; ua->jcr->max_bandwidth = 0; return true; @@ -962,7 +962,7 @@ static bool SetbwlimitCmd(UaContext *ua, const char *cmd) switch (jcr->getJobType()) { case JT_COPY: case JT_MIGRATE: - store = jcr->res.rstore; + store = jcr->res.read_storage; break; default: client = jcr->res.client; @@ -2066,13 +2066,13 @@ static bool DoTruncate(UaContext *ua, MediaDbRecord &mr) /* * Choose storage */ - ua->jcr->res.wstore = ua->GetStoreResWithName(storage_dbr.Name); - if (!ua->jcr->res.wstore) { + ua->jcr->res.write_storage = ua->GetStoreResWithName(storage_dbr.Name); + if (!ua->jcr->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.wstore, + if (SendLabelRequest(ua, ua->jcr->res.write_storage, &mr, &mr, &pool_dbr, /* bool media_record_exists */ @@ -2088,7 +2088,7 @@ static bool DoTruncate(UaContext *ua, MediaDbRecord &mr) } bail_out: - ua->jcr->res.wstore = NULL; + ua->jcr->res.write_storage = NULL; return retval; } @@ -2416,7 +2416,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.wstore); + nr_drives = GetNumDrives(ua, ua->jcr->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_label.cc b/core/src/dird/ua_label.cc index c44043c09c7..3d88e4e846f 100644 --- a/core/src/dird/ua_label.cc +++ b/core/src/dird/ua_label.cc @@ -61,7 +61,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.wstore, mr); + SetStorageidInMr(ua->jcr->res.write_storage, mr); if (!ua->db->UpdateMediaRecord(ua->jcr, mr)) { ua->ErrorMsg("%s", ua->db->strerror()); retval = false; @@ -73,7 +73,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.wstore, mr); + SetStorageidInMr(ua->jcr->res.write_storage, mr); if (ua->db->CreateMediaRecord(ua->jcr, mr)) { ua->InfoMsg(_("Catalog record for Volume \"%s\", Slot %hd successfully created.\n"), @@ -114,7 +114,7 @@ static inline bool native_send_label_request(UaContext *ua, return false; } - bstrncpy(dev_name, ua->jcr->res.wstore->dev_name(), sizeof(dev_name)); + bstrncpy(dev_name, ua->jcr->res.write_storage->dev_name(), sizeof(dev_name)); BashSpaces(dev_name); BashSpaces(mr->VolumeName); BashSpaces(mr->MediaType); @@ -299,7 +299,7 @@ static inline bool IsCleaningTape(UaContext *ua, MediaDbRecord *mr, PoolDbRecord static void label_from_barcodes(UaContext *ua, drive_number_t drive, bool label_encrypt, bool yes) { - StorageResource *store = ua->jcr->res.wstore; + StorageResource *store = ua->jcr->res.write_storage; PoolDbRecord pr; MediaDbRecord mr; vol_list_t *vl; @@ -310,7 +310,7 @@ static void label_from_barcodes(UaContext *ua, drive_number_t drive, memset(&mr, 0, sizeof(mr)); - max_slots = GetNumSlots(ua, ua->jcr->res.wstore); + max_slots = GetNumSlots(ua, ua->jcr->res.write_storage); if (max_slots <= 0) { ua->WarningMsg(_("No slots in changer to scan.\n")); return; diff --git a/core/src/dird/ua_purge.cc b/core/src/dird/ua_purge.cc index bb4ee1d5750..f5101de5a24 100644 --- a/core/src/dird/ua_purge.cc +++ b/core/src/dird/ua_purge.cc @@ -814,7 +814,7 @@ static bool ActionOnPurgeCmd(UaContext *ua, const char *cmd) /* * Choose storage */ - ua->jcr->res.wstore = store = get_storage_resource(ua); + ua->jcr->res.write_storage = store = get_storage_resource(ua); if (!store) { goto bail_out; } @@ -895,7 +895,7 @@ static bool ActionOnPurgeCmd(UaContext *ua, const char *cmd) if (sd) { CloseSdBsock(ua); } - ua->jcr->res.wstore = NULL; + ua->jcr->res.write_storage = NULL; if (results) { free(results); } diff --git a/core/src/dird/ua_run.cc b/core/src/dird/ua_run.cc index 5ed99ebeeba..67af1b76b28 100644 --- a/core/src/dird/ua_run.cc +++ b/core/src/dird/ua_run.cc @@ -1256,7 +1256,7 @@ static bool DisplayJobParameters(UaContext *ua, JobControlRecord *jcr, RunContex job->name(), jcr->res.fileset->name(), NPRT(jcr->res.client->name()), - jcr->res.wstore ? jcr->res.wstore->name() : _("*None*"), + jcr->res.write_storage ? jcr->res.write_storage->name() : _("*None*"), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } else { @@ -1270,7 +1270,7 @@ static bool DisplayJobParameters(UaContext *ua, JobControlRecord *jcr, RunContex job->name(), jcr->res.fileset->name(), NPRT(jcr->res.client->name()), - jcr->res.wstore ? jcr->res.wstore->name() : _("*None*"), + jcr->res.write_storage ? jcr->res.write_storage->name() : _("*None*"), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } @@ -1290,7 +1290,7 @@ static bool DisplayJobParameters(UaContext *ua, JobControlRecord *jcr, RunContex job->name(), jcr->res.fileset->name(), NPRT(jcr->res.client->name()), - jcr->res.wstore ? jcr->res.wstore->name() : _("*None*"), + jcr->res.write_storage ? jcr->res.write_storage->name() : _("*None*"), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } else { @@ -1304,7 +1304,7 @@ static bool DisplayJobParameters(UaContext *ua, JobControlRecord *jcr, RunContex job->name(), jcr->res.fileset->name(), NPRT(jcr->res.client->name()), - jcr->res.wstore ? jcr->res.wstore->name() : _("*None*"), + jcr->res.write_storage ? jcr->res.write_storage->name() : _("*None*"), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } @@ -1324,7 +1324,7 @@ static bool DisplayJobParameters(UaContext *ua, JobControlRecord *jcr, RunContex job->name(), jcr->res.fileset->name(), NPRT(jcr->res.client->name()), - jcr->res.wstore ? jcr->res.wstore->name() : _("*None*"), + jcr->res.write_storage ? jcr->res.write_storage->name() : _("*None*"), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } else { @@ -1338,7 +1338,7 @@ static bool DisplayJobParameters(UaContext *ua, JobControlRecord *jcr, RunContex job->name(), jcr->res.fileset->name(), NPRT(jcr->res.client->name()), - jcr->res.wstore ? jcr->res.wstore->name() : _("*None*"), + jcr->res.write_storage ? jcr->res.write_storage->name() : _("*None*"), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); } @@ -1373,7 +1373,7 @@ static bool DisplayJobParameters(UaContext *ua, JobControlRecord *jcr, RunContex is_virtual ? "NextPool: " : "", is_virtual ? (jcr->res.next_pool ? jcr->res.next_pool->name() : _("*None*")) : "", is_virtual ? "\n" : "", - jcr->res.wstore ? jcr->res.wstore->name() : _("*None*"), + jcr->res.write_storage ? jcr->res.write_storage->name() : _("*None*"), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority, jcr->plugin_options ? "Plugin Options: " : "", @@ -1403,7 +1403,7 @@ static bool DisplayJobParameters(UaContext *ua, JobControlRecord *jcr, RunContex is_virtual ? " (From " : "", is_virtual ? jcr->res.npool_source : "", is_virtual ? ")\n" : "", - jcr->res.wstore ? jcr->res.wstore->name() : _("*None*"), + jcr->res.write_storage ? jcr->res.write_storage->name() : _("*None*"), jcr->res.wstore_source, bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority, @@ -1452,7 +1452,7 @@ static bool DisplayJobParameters(UaContext *ua, JobControlRecord *jcr, RunContex jcr->res.client->name(), jcr->res.fileset->name(), NPRT(jcr->res.pool->name()), jcr->res.pool_source, - jcr->res.rstore->name(), jcr->res.rstore_source, + jcr->res.read_storage->name(), jcr->res.rstore_source, Name, verify_list, bstrutime(dt, sizeof(dt), jcr->sched_time), @@ -1474,7 +1474,7 @@ static bool DisplayJobParameters(UaContext *ua, JobControlRecord *jcr, RunContex jcr->res.client->name(), jcr->res.fileset->name(), NPRT(jcr->res.pool->name()), jcr->res.pool_source, - jcr->res.rstore->name(), jcr->res.rstore_source, + jcr->res.read_storage->name(), jcr->res.rstore_source, Name, verify_list, bstrutime(dt, sizeof(dt), jcr->sched_time), @@ -1523,7 +1523,7 @@ static bool DisplayJobParameters(UaContext *ua, JobControlRecord *jcr, RunContex rc.client_name, jcr->res.client->name(), jcr->backup_format, - jcr->res.rstore->name(), + jcr->res.read_storage->name(), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->res.catalog->name(), jcr->JobPriority, @@ -1551,7 +1551,7 @@ static bool DisplayJobParameters(UaContext *ua, JobControlRecord *jcr, RunContex rc.client_name, jcr->res.client->name(), jcr->backup_format, - jcr->res.rstore->name(), + jcr->res.read_storage->name(), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->res.catalog->name(), jcr->JobPriority, @@ -1583,7 +1583,7 @@ static bool DisplayJobParameters(UaContext *ua, JobControlRecord *jcr, RunContex rc.client_name, jcr->res.client->name(), jcr->backup_format, - jcr->res.rstore->name(), + jcr->res.read_storage->name(), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->res.catalog->name(), jcr->JobPriority, @@ -1611,7 +1611,7 @@ static bool DisplayJobParameters(UaContext *ua, JobControlRecord *jcr, RunContex rc.client_name, jcr->res.client->name(), jcr->backup_format, - jcr->res.rstore->name(), + jcr->res.read_storage->name(), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->res.catalog->name(), jcr->JobPriority, @@ -1649,7 +1649,7 @@ static bool DisplayJobParameters(UaContext *ua, JobControlRecord *jcr, RunContex rc.replace, jcr->res.client->name(), jcr->backup_format, - jcr->res.rstore->name(), + jcr->res.read_storage->name(), (jcr->RestoreJobId == 0) ? _("*None*") : edit_uint64(jcr->RestoreJobId, ec1), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->res.catalog->name(), @@ -1683,10 +1683,10 @@ static bool DisplayJobParameters(UaContext *ua, JobControlRecord *jcr, RunContex prt_type, job->name(), NPRT(jcr->RestoreBootstrap), - jcr->res.rstore ? jcr->res.rstore->name() : _("*None*"), + jcr->res.read_storage ? jcr->res.read_storage->name() : _("*None*"), NPRT(jcr->res.pool->name()), jcr->res.next_pool ? jcr->res.next_pool->name() : _("*None*"), - jcr->res.wstore ? jcr->res.wstore->name() : _("*None*"), + jcr->res.write_storage ? jcr->res.write_storage->name() : _("*None*"), (jcr->MigrateJobId == 0) ? _("*None*") : edit_uint64(jcr->MigrateJobId, ec1), bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->res.catalog->name(), @@ -1711,10 +1711,10 @@ static bool DisplayJobParameters(UaContext *ua, JobControlRecord *jcr, RunContex prt_type, job->name(), NPRT(jcr->RestoreBootstrap), - jcr->res.rstore ? jcr->res.rstore->name() : _("*None*"), + jcr->res.read_storage ? jcr->res.read_storage->name() : _("*None*"), jcr->res.rstore_source, NPRT(jcr->res.pool->name()), jcr->res.pool_source, - jcr->res.wstore ? jcr->res.wstore->name() : _("*None*"), + jcr->res.write_storage ? jcr->res.write_storage->name() : _("*None*"), jcr->res.wstore_source, jcr->res.next_pool ? jcr->res.next_pool->name() : _("*None*"), NPRT(jcr->res.npool_source), diff --git a/core/src/dird/ua_select.cc b/core/src/dird/ua_select.cc index 5d3f37c1066..791851806d3 100644 --- a/core/src/dird/ua_select.cc +++ b/core/src/dird/ua_select.cc @@ -1218,7 +1218,7 @@ StorageResource *get_storage_resource(UaContext *ua, bool use_default, bool auto ua->ErrorMsg(_("JobId %s is not running.\n"), edit_int64(jobid, ed1)); return NULL; } - store = jcr->res.wstore; + store = jcr->res.write_storage; FreeJcr(jcr); break; } else if (Bstrcasecmp(ua->argk[i], NT_("job")) || @@ -1231,7 +1231,7 @@ StorageResource *get_storage_resource(UaContext *ua, bool use_default, bool auto ua->ErrorMsg(_("Job \"%s\" is not running.\n"), ua->argv[i]); return NULL; } - store = jcr->res.wstore; + store = jcr->res.write_storage; FreeJcr(jcr); break; } else if (Bstrcasecmp(ua->argk[i], NT_("ujobid"))) { @@ -1243,7 +1243,7 @@ StorageResource *get_storage_resource(UaContext *ua, bool use_default, bool auto ua->ErrorMsg(_("Job \"%s\" is not running.\n"), ua->argv[i]); return NULL; } - store = jcr->res.wstore; + store = jcr->res.write_storage; FreeJcr(jcr); break; } diff --git a/core/src/dird/ua_status.cc b/core/src/dird/ua_status.cc index 342d80ea6c5..0666625ac7a 100644 --- a/core/src/dird/ua_status.cc +++ b/core/src/dird/ua_status.cc @@ -835,8 +835,8 @@ static void PrtRuntime(UaContext *ua, sched_pkt *sp) } if (ok) { mr.PoolId = jcr->jr.PoolId; - jcr->res.wstore = sp->store; - SetStorageidInMr(jcr->res.wstore, &mr); + jcr->res.write_storage = sp->store; + SetStorageidInMr(jcr->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, fnv_no_prune); @@ -1056,10 +1056,10 @@ static void ListRunningJobs(UaContext *ua) break; case JS_WaitSD: emsg = (char *) GetPoolMemory(PM_FNAME); - if (jcr->res.wstore) { - Mmsg(emsg, _("is waiting on Storage \"%s\""), jcr->res.wstore->name()); - } else if (jcr->res.rstore) { - Mmsg(emsg, _("is waiting on Storage \"%s\""), jcr->res.rstore->name()); + if (jcr->res.write_storage) { + Mmsg(emsg, _("is waiting on Storage \"%s\""), jcr->res.write_storage->name()); + } else if (jcr->res.read_storage) { + Mmsg(emsg, _("is waiting on Storage \"%s\""), jcr->res.read_storage->name()); } else { Mmsg(emsg, _("is waiting on Storage")); } @@ -1141,11 +1141,11 @@ static void ListRunningJobs(UaContext *ua) * client initiated connection */ Mmsg(emsg, _("is waiting for Client to connect (Client Initiated Connection)")); - } else if (!jcr->res.client || !jcr->res.wstore) { + } else if (!jcr->res.client || !jcr->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->name(), jcr->res.wstore->name()); + jcr->res.client->name(), jcr->res.write_storage->name()); } msg = emsg; break; @@ -1641,7 +1641,7 @@ static void StatusSlots(UaContext *ua, StorageResource *store) slot_number_t max_slots; changer_vol_list_t *vol_list = NULL; - ua->jcr->res.wstore = store; + ua->jcr->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 46a14c80df0..cbf364a9266 100644 --- a/core/src/dird/ua_update.cc +++ b/core/src/dird/ua_update.cc @@ -1119,7 +1119,7 @@ static void UpdateSlots(UaContext *ua) have_enabled = false; } - max_slots = GetNumSlots(ua, ua->jcr->res.wstore); + max_slots = GetNumSlots(ua, ua->jcr->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 69c0e601e23..dd36c4acfc7 100644 --- a/core/src/dird/vbackup.cc +++ b/core/src/dird/vbackup.cc @@ -169,20 +169,20 @@ bool DoNativeVbackup(JobControlRecord *jcr) char ed1[100]; int JobLevel_of_first_job; - if (!jcr->res.rstorage) { + if (!jcr->res.read_storage_list) { Jmsg(jcr, M_FATAL, 0, _("No storage for reading given.\n")); return false; } - if (!jcr->res.wstorage) { + if (!jcr->res.write_storage_list) { Jmsg(jcr, M_FATAL, 0, _("No storage for writing given.\n")); return false; } - Dmsg2(100, "rstorage=%p wstorage=%p\n", jcr->res.rstorage, jcr->res.wstorage); + 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.rstorage->first())->name(), - ((StorageResource *)jcr->res.wstorage->first())->name()); + ((StorageResource *)jcr->res.read_storage_list->first())->name(), + ((StorageResource *)jcr->res.write_storage_list->first())->name()); /* * Print Job Start message @@ -289,7 +289,7 @@ bool DoNativeVbackup(JobControlRecord *jcr) /* * Now start a job with the Storage daemon */ - if (!StartStorageDaemonJob(jcr, jcr->res.rstorage, jcr->res.wstorage, /* send_bsr */ true)) { + if (!StartStorageDaemonJob(jcr, jcr->res.read_storage_list, jcr->res.write_storage_list, /* send_bsr */ true)) { goto bail_out; } Dmsg0(100, "Storage daemon connection OK\n"); diff --git a/core/src/dird/verify.cc b/core/src/dird/verify.cc index 46d3be567db..733ab878b3d 100644 --- a/core/src/dird/verify.cc +++ b/core/src/dird/verify.cc @@ -251,7 +251,7 @@ bool DoVerify(JobControlRecord *jcr) /* * Now start a job with the Storage daemon */ - if (!StartStorageDaemonJob(jcr, jcr->res.rstorage, NULL, /* send_bsr */ true)) { + if (!StartStorageDaemonJob(jcr, jcr->res.read_storage_list, NULL, /* send_bsr */ true)) { return false; } @@ -336,7 +336,7 @@ bool DoVerify(JobControlRecord *jcr) } if (!jcr->passive_client) { - StorageResource *store = jcr->res.rstore; + StorageResource *store = jcr->res.read_storage; /* * Send Storage daemon address to the File daemon diff --git a/core/src/filed/evaluate_job_command.cc b/core/src/filed/evaluate_job_command.cc new file mode 100644 index 00000000000..b794c9682f9 --- /dev/null +++ b/core/src/filed/evaluate_job_command.cc @@ -0,0 +1,86 @@ +/** + BAREOSĀ® - Backup Archiving REcovery Open Sourced + + Copyright (C) 2019-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. +*/ + +#include "filed/dir_cmd.h" +#include "include/bareos.h" + +const std::string EvaluateJobcommand::jobcmd { "JobId=%d Job=%127s SDid=%u SDtime=%u Authorization=%100s" }; +const std::string EvaluateJobcommand::jobcmdssl { "JobId=%d Job=%127s SDid=%u SDtime=%u Authorization=%100s ssl=%d\n" }; + +namespace filedaemon { + +class EvaluateJobcommand +{ + public: + EvaluateJobcommand(); + : uint32_t JobId(0) + , Job[24] + , VolSessionId(0) + , VolSessionTime(0) + PoolMem sd_auth_key; + , tls_policy(TlsPolicy::kBnetTlsUnknown) + + + uint32_t JobId; + char Job[24]; + uint32_t VolSessionId; + uint32_t VolSessionTime; + PoolMem sd_auth_key; + TlsPolicy tls_policy = TlsPolicy::kBnetTlsUnknown; + + private: + std::string jobcmd { "JobId=%d Job=%127s SDid=%u SDtime=%u Authorization=%100s" }; + std::string jobcmdssl { "JobId=%d Job=%127s SDid=%u SDtime=%u Authorization=%100s ssl=%d\n" }; +}; + +JobMessageProtocolVersion EvaluateJobcommand(const POOLMEM *msg, + uint32_t &JobId, + char *Job, + uint32_t &VolSessionId, + uint32_t &VolSessionTime, + PoolMem &sd_auth_key, + TlsPolicy &tls_policy) +{ + int tries = 2; + JobMessageProtocolVersion successful_protocol = JobMessageProtocolVersion::kVersionUndefinded; + + for (int protocol_try = 1; !successful_protocol && protocol_try <= tries; protocol_try++) { + switch (protocol_try) { + case JobMessageProtocolVersion::kVersionFrom_18_2: + if (sscanf(msg, jobcmdssl, &JobId, Job, &VolSessionId, &VolSessionTime, + sd_auth_key.c_str(), &tls_policy) == 6) { + successful_protocol = static_cast(protocol_try); + } + break; + case JobMessageProtocolVersion::KVersionBefore_18_2: + if (sscanf(msg, jobcmd, &JobId, Job, &VolSessionId, &VolSessionTime, + sd_auth_key.c_str()) == 5) { + successful_protocol = static_cast(protocol_try); + } + break; + default: + break; + } + } + return successful_protocol; +} + +} /* namespace filedamon */ diff --git a/core/src/include/jcr.h b/core/src/include/jcr.h index ba3af8ae234..e5f30f7b794 100644 --- a/core/src/include/jcr.h +++ b/core/src/include/jcr.h @@ -247,9 +247,9 @@ struct Resources { 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 *rstore; /**< Selected read storage */ - directordaemon::StorageResource *wstore; /**< Selected write storage */ - directordaemon::StorageResource *pstore; /**< Selected paired storage (saved wstore or rstore) */ + directordaemon::StorageResource *read_storage; /**< Selected read storage */ + directordaemon::StorageResource *write_storage; /**< Selected write storage */ + directordaemon::StorageResource *paired_read_write_storage; /**< Selected paired storage (saved write_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 */ @@ -267,9 +267,9 @@ struct Resources { POOLMEM *rstore_source; /**< Where read storage came from */ POOLMEM *wstore_source; /**< Where write storage came from */ POOLMEM *catalog_source; /**< Where catalog came from */ - alist *rstorage; /**< Read storage possibilities */ - alist *wstorage; /**< Write storage possibilities */ - alist *pstorage; /**< Paired storage possibilities (saved wstorage or rstorage) */ + 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 */