Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bareos/bareos.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/dird/storage.cc')
-rw-r--r--core/src/dird/storage.cc235
1 files changed, 119 insertions, 116 deletions
diff --git a/core/src/dird/storage.cc b/core/src/dird/storage.cc
index 47b464957..058473135 100644
--- a/core/src/dird/storage.cc
+++ b/core/src/dird/storage.cc
@@ -31,7 +31,7 @@
#include "include/bareos.h"
#include "dird/dird_globals.h"
-#include "dird/jcr_private.h"
+#include "dird/director_jcr_impl.h"
#include "dird/sd_cmds.h"
#include "include/auth_protocol_types.h"
#include "lib/parse_conf.h"
@@ -100,21 +100,21 @@ void CopyRstorage(JobControlRecord* jcr,
{
if (storage) {
StorageResource* store = nullptr;
- if (jcr->impl->res.read_storage_list) {
- delete jcr->impl->res.read_storage_list;
+ if (jcr->dir_impl->res.read_storage_list) {
+ delete jcr->dir_impl->res.read_storage_list;
}
- jcr->impl->res.read_storage_list
+ jcr->dir_impl->res.read_storage_list
= new alist<StorageResource*>(10, not_owned_by_alist);
foreach_alist (store, storage) {
- jcr->impl->res.read_storage_list->append(store);
+ jcr->dir_impl->res.read_storage_list->append(store);
}
- if (!jcr->impl->res.rstore_source) {
- jcr->impl->res.rstore_source = GetPoolMemory(PM_MESSAGE);
+ if (!jcr->dir_impl->res.rstore_source) {
+ jcr->dir_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->dir_impl->res.rstore_source, where);
+ if (jcr->dir_impl->res.read_storage_list) {
+ jcr->dir_impl->res.read_storage
+ = (StorageResource*)jcr->dir_impl->res.read_storage_list->first();
}
}
}
@@ -128,30 +128,30 @@ 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
+ if (jcr->dir_impl->res.read_storage_list) { FreeRstorage(jcr); }
+ if (!jcr->dir_impl->res.read_storage_list) {
+ jcr->dir_impl->res.read_storage_list
= new alist<StorageResource*>(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->dir_impl->res.read_storage = store->store;
+ if (!jcr->dir_impl->res.rstore_source) {
+ jcr->dir_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->dir_impl->res.rstore_source, store->store_source);
+ foreach_alist (storage, jcr->dir_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->dir_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->dir_impl->res.read_storage_list) {
+ delete jcr->dir_impl->res.read_storage_list;
+ jcr->dir_impl->res.read_storage_list = NULL;
}
- jcr->impl->res.read_storage = NULL;
+ jcr->dir_impl->res.read_storage = NULL;
}
// Copy the storage definitions from an alist to the JobControlRecord
@@ -161,25 +161,25 @@ void CopyWstorage(JobControlRecord* jcr,
{
if (storage) {
StorageResource* st = nullptr;
- if (jcr->impl->res.write_storage_list) {
- delete jcr->impl->res.write_storage_list;
+ if (jcr->dir_impl->res.write_storage_list) {
+ delete jcr->dir_impl->res.write_storage_list;
}
- jcr->impl->res.write_storage_list
+ jcr->dir_impl->res.write_storage_list
= new alist<StorageResource*>(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->dir_impl->res.write_storage_list->append(st);
}
- if (!jcr->impl->res.wstore_source) {
- jcr->impl->res.wstore_source = GetPoolMemory(PM_MESSAGE);
+ if (!jcr->dir_impl->res.wstore_source) {
+ jcr->dir_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->dir_impl->res.wstore_source, where);
+ if (jcr->dir_impl->res.write_storage_list) {
+ jcr->dir_impl->res.write_storage
+ = (StorageResource*)jcr->dir_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->dir_impl->res.write_storage->resource_name_,
+ jcr->dir_impl->res.wstore_source);
}
}
}
@@ -193,34 +193,34 @@ 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
+ if (jcr->dir_impl->res.write_storage_list) { FreeWstorage(jcr); }
+ if (!jcr->dir_impl->res.write_storage_list) {
+ jcr->dir_impl->res.write_storage_list
= new alist<StorageResource*>(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->dir_impl->res.write_storage = store->store;
+ if (!jcr->dir_impl->res.wstore_source) {
+ jcr->dir_impl->res.wstore_source = GetPoolMemory(PM_MESSAGE);
}
- PmStrcpy(jcr->impl->res.wstore_source, store->store_source);
+ PmStrcpy(jcr->dir_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->dir_impl->res.write_storage->resource_name_,
+ jcr->dir_impl->res.wstore_source);
+ foreach_alist (storage, jcr->dir_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->dir_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->dir_impl->res.write_storage_list) {
+ delete jcr->dir_impl->res.write_storage_list;
+ jcr->dir_impl->res.write_storage_list = NULL;
}
- jcr->impl->res.write_storage = NULL;
+ jcr->dir_impl->res.write_storage = NULL;
}
/**
@@ -236,35 +236,37 @@ void SetPairedStorage(JobControlRecord* jcr)
switch (jcr->getJobType()) {
case JT_BACKUP:
// For a backup we look at the write storage.
- if (jcr->impl->res.write_storage_list) {
+ if (jcr->dir_impl->res.write_storage_list) {
/*
- * Setup the jcr->impl_->res.write_storage_list to point to all
+ * Setup the jcr->dir_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->dir_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
+ jcr->dir_impl->res.paired_read_write_storage_list
+ = jcr->dir_impl->res.write_storage_list;
+ jcr->dir_impl->res.write_storage_list
= new alist<StorageResource*>(10, not_owned_by_alist);
- foreach_alist (store, jcr->impl->res.paired_read_write_storage_list) {
+ foreach_alist (store,
+ jcr->dir_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->dir_impl->res.write_storage_list->append(
+ store->paired_storage);
}
}
/*
- * Swap the actual jcr->impl_->res.write_storage to point to the paired
- * storage entry. We save the actual storage entry in
+ * Swap the actual jcr->dir_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->impl->res.write_storage;
+ store = jcr->dir_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->dir_impl->res.write_storage = store->paired_storage;
+ jcr->dir_impl->res.paired_read_write_storage = store;
}
} else {
Jmsg(jcr, M_FATAL, 0,
@@ -273,16 +275,16 @@ void SetPairedStorage(JobControlRecord* jcr)
break;
case JT_RESTORE:
// For a restores we look at the read storage.
- if (jcr->impl->res.read_storage_list) {
+ if (jcr->dir_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.
+ * Setup the jcr->dir_impl_->res.paired_read_write_storage_list to point
+ * to all paired_storage entries of all the storage currently in the
+ * jcr->dir_impl_->res.read_storage_list.
*/
- jcr->impl->res.paired_read_write_storage_list
+ jcr->dir_impl->res.paired_read_write_storage_list
= new alist<StorageResource*>(10, not_owned_by_alist);
foreach_alist (paired_read_write_storage,
- jcr->impl->res.read_storage_list) {
+ jcr->dir_impl->res.read_storage_list) {
store = (StorageResource*)my_config->GetNextRes(R_STORAGE, NULL);
while (store) {
if (store->paired_storage == paired_read_write_storage) { break; }
@@ -296,15 +298,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->dir_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
+ * current entry in jcr->dir_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->dir_impl->res.read_storage) {
+ jcr->dir_impl->res.paired_read_write_storage = store;
}
}
}
@@ -316,35 +318,36 @@ void SetPairedStorage(JobControlRecord* jcr)
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->dir_impl->res.read_storage_list) {
/*
- * Setup the jcr->impl_->res.read_storage_list to point to all
+ * Setup the jcr->dir_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->dir_impl_->res.read_storage_list. Save the original list under
+ * jcr->dir_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
+ jcr->dir_impl->res.paired_read_write_storage_list
+ = jcr->dir_impl->res.read_storage_list;
+ jcr->dir_impl->res.read_storage_list
= new alist<StorageResource*>(10, not_owned_by_alist);
- foreach_alist (store, jcr->impl->res.paired_read_write_storage_list) {
+ foreach_alist (store,
+ jcr->dir_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->dir_impl->res.read_storage_list->append(store->paired_storage);
}
}
/*
- * Swap the actual jcr->impl_->res.read_storage to point to the paired
- * storage entry. We save the actual storage entry in
+ * Swap the actual jcr->dir_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->impl->res.read_storage;
+ store = jcr->dir_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->dir_impl->res.read_storage = store->paired_storage;
+ jcr->dir_impl->res.paired_read_write_storage = store;
}
} else {
Jmsg(jcr, M_FATAL, 0,
@@ -366,51 +369,51 @@ void SetPairedStorage(JobControlRecord* jcr)
*/
void FreePairedStorage(JobControlRecord* jcr)
{
- if (jcr->impl->res.paired_read_write_storage_list) {
+ if (jcr->dir_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->dir_impl->res.write_storage_list) {
/*
- * The jcr->impl_->res.write_storage_list contain a set of paired
+ * The jcr->dir_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->dir_impl->res.write_storage_list;
+ jcr->dir_impl->res.write_storage_list
+ = jcr->dir_impl->res.paired_read_write_storage_list;
+ jcr->dir_impl->res.paired_read_write_storage_list = NULL;
+ jcr->dir_impl->res.write_storage
+ = jcr->dir_impl->res.paired_read_write_storage;
+ jcr->dir_impl->res.paired_read_write_storage = NULL;
}
break;
case JT_RESTORE:
/*
- * The jcr->impl_->res.read_storage_list contain a set of paired
+ * The jcr->dir_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->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->dir_impl->res.paired_read_write_storage_list;
+ jcr->dir_impl->res.paired_read_write_storage_list = NULL;
+ jcr->dir_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->dir_impl->res.read_storage_list) {
/*
- * The jcr->impl_->res.read_storage_list contains a set of paired
+ * The jcr->dir_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->dir_impl->res.read_storage_list;
+ jcr->dir_impl->res.read_storage_list
+ = jcr->dir_impl->res.paired_read_write_storage_list;
+ jcr->dir_impl->res.paired_read_write_storage_list = NULL;
+ jcr->dir_impl->res.read_storage
+ = jcr->dir_impl->res.paired_read_write_storage;
+ jcr->dir_impl->res.paired_read_write_storage = NULL;
}
break;
default:
@@ -430,8 +433,8 @@ bool HasPairedStorage(JobControlRecord* jcr)
switch (jcr->getJobType()) {
case JT_BACKUP:
// 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->dir_impl->res.write_storage_list) {
+ foreach_alist (store, jcr->dir_impl->res.write_storage_list) {
if (!store->paired_storage) { return false; }
}
} else {
@@ -444,8 +447,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->dir_impl->res.read_storage_list) {
+ foreach_alist (store, jcr->dir_impl->res.read_storage_list) {
if (!store->paired_storage) { return false; }
}
} else {
@@ -472,7 +475,7 @@ bool SelectNextRstore(JobControlRecord* jcr, bootstrap_info& info)
{
UnifiedStorageResource ustore;
- if (bstrcmp(jcr->impl->res.read_storage->resource_name_, info.storage)) {
+ if (bstrcmp(jcr->dir_impl->res.read_storage->resource_name_, info.storage)) {
return true; /* Same SD nothing to change */
}