Navigation Menu

Skip to content

Commit

Permalink
jcr: renamed rstore, wstore and related resource variables
Browse files Browse the repository at this point in the history
  • Loading branch information
franku committed Jan 15, 2019
1 parent 76f0f1d commit af5e0fd
Show file tree
Hide file tree
Showing 35 changed files with 419 additions and 333 deletions.
18 changes: 9 additions & 9 deletions core/src/dird/backup.cc
Expand Up @@ -115,20 +115,20 @@ 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;
}
}

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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;

/*
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion core/src/dird/backup.h
Expand Up @@ -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_
8 changes: 4 additions & 4 deletions core/src/dird/bsr.cc
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
10 changes: 5 additions & 5 deletions core/src/dird/catreq.cc
Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
/*
Expand Down Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions core/src/dird/dir_plugins.cc
Expand Up @@ -642,28 +642,28 @@ 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;
}
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;
}
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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions core/src/dird/dird_conf.cc
Expand Up @@ -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':
Expand Down
12 changes: 6 additions & 6 deletions core/src/dird/expand.cc
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion core/src/dird/fd_cmds.cc
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion core/src/dird/job.cc
Expand Up @@ -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 {
Expand Down
60 changes: 30 additions & 30 deletions core/src/dird/jobq.cc
Expand Up @@ -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);
}
Expand Down Expand Up @@ -816,25 +816,25 @@ 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);

return false;
}
}

if (jcr->res.wstore) {
if (jcr->res.write_storage) {
if (!IncWriteStore(jcr)) {
DecReadStore(jcr);
jcr->setJobStatus(JS_WaitStoreRes);
Expand Down Expand Up @@ -944,40 +944,40 @@ 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;
}
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);
}
Expand All @@ -990,33 +990,33 @@ 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;
}
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);
}
Expand Down

0 comments on commit af5e0fd

Please sign in to comment.