From ac08c5631222a7afbbe7b75856a3f55e2fae0fe8 Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Wed, 3 Sep 2014 17:26:53 +0200 Subject: [PATCH] Fix wrong sanity check. 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. --- src/dird/migrate.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/dird/migrate.c b/src/dird/migrate.c index 337167352e6..8377d1c5d42 100644 --- a/src/dird/migrate.c +++ b/src/dird/migrate.c @@ -399,6 +399,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 * @@ -445,11 +463,7 @@ bool do_migration(JCR *jcr) return true; } - /* - * Sanity check that we are not using the same storage for reading and writing. - */ - if (bstrcmp(((STORERES *)jcr->rstorage->first())->name(), - ((STORERES *)jcr->wstorage->first())->name())) { + 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());