Skip to content

Commit

Permalink
Fix wrong sanity check.
Browse files Browse the repository at this point in the history
When comparing if we use the same read and write storage in migrations
and copies we should ignore any autochanger devices as its fine to use
those as both read and write device.
  • Loading branch information
Marco van Wieringen committed Oct 9, 2014
1 parent f49380e commit 9c35eab
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions src/dird/migrate.c
Expand Up @@ -365,6 +365,24 @@ static bool set_migration_next_pool(JCR *jcr, POOLRES **retpool)
return true;
}

/*
* Sanity check that we are not using the same storage for reading and writing.
*/
static inline bool same_storage(JCR *jcr)
{
STORERES *read_store, *write_store;

read_store = (STORERES *)jcr->rstorage->first();
write_store = (STORERES *)jcr->wstorage->first();

if (!read_store->autochanger && !write_store->autochanger &&
bstrcmp(read_store->name(), write_store->name())) {
return true;
}

return false;
}

/*
* Do a Migration of a previous job
*
Expand Down Expand Up @@ -403,9 +421,18 @@ bool do_migration(JCR *jcr)
if (jcr->previous_jr.JobType != JT_BACKUP &&
jcr->previous_jr.JobType != JT_JOB_COPY) {
Jmsg(jcr, M_INFO, 0, _("JobId %s already %s probably by another Job. %s stopped.\n"),
edit_int64(jcr->previous_jr.JobId, ed1),
jcr->get_ActionName(true),
jcr->get_OperationName());
edit_int64(jcr->previous_jr.JobId, ed1),
jcr->get_ActionName(true),
jcr->get_OperationName());
jcr->setJobStatus(JS_Terminated);
migration_cleanup(jcr, jcr->JobStatus);
return true;
}

if (same_storage(jcr)) {
Jmsg(jcr, M_FATAL, 0, _("JobId %s cannot %s using the same read and write storage.\n"),
edit_int64(jcr->previous_jr.JobId, ed1),
jcr->get_OperationName());
jcr->setJobStatus(JS_Terminated);
migration_cleanup(jcr, jcr->JobStatus);
return true;
Expand Down

0 comments on commit 9c35eab

Please sign in to comment.