From: Eric Bollengier Date: Fri, 6 May 2022 08:08:25 +0000 (+0200) Subject: Apply the algorithm in all cases X-Git-Tag: Beta-15.0.0~589 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2cb7832fa9e4a0417b391b9d68bb907328d63669;p=thirdparty%2Fbacula.git Apply the algorithm in all cases --- diff --git a/bacula/src/dird/mac.c b/bacula/src/dird/mac.c index 72b14f783..932cb75d7 100644 --- a/bacula/src/dird/mac.c +++ b/bacula/src/dird/mac.c @@ -386,7 +386,7 @@ bool do_mac(JCR *jcr) STORE *rstore = NULL; STORE *wstore = NULL; /* Keep original write storage source to set back during the cleanup */ - POOL_MEM wsource_origin; + POOL_MEM wsource_origin, rsource_origin; /* * If wjcr is NULL, there is nothing to do for this job, @@ -458,68 +458,65 @@ bool do_mac(JCR *jcr) jcr->setJobStatus(JS_WaitSD); wjcr->setJobStatus(JS_WaitSD); - if (jcr->store_mngr->get_rstore_list()->size() > 1) { - POOL_MEM src; - /* To help the user, we can check if the selected storage is compatible - * with what we have in the BSR - */ - bootstrap_info info; - if (!open_bootstrap_file(jcr, info)) { // We get the first Storage= - goto bail_out; - } - close_bootstrap_file(info); + /* To help the user, we can check if the selected storage is compatible + * with what we have in the BSR + */ + bootstrap_info info; + if (!open_bootstrap_file(jcr, info)) { // We get the first Storage= + goto bail_out; + } + close_bootstrap_file(info); - /* Keep the source of the information */ - pm_strcpy(src, jcr->store_mngr->get_rsource()); + /* Keep the source of the information */ + pm_strcpy(rsource_origin, jcr->store_mngr->get_rsource()); - /* If we have a Storage Group defined, we can look into it - * TODO: Like for Backup, we can also check for the different algorithms - * (least used, round robbin) - */ - bsr_store = (STORE *)GetResWithName(R_STORAGE, info.storage); - if (bsr_store) { - bool found=false; + /* + * TODO: Like for Backup, we can also check for the different algorithms + * (least used, round robbin) + */ + bsr_store = (STORE *)GetResWithName(R_STORAGE, info.storage); + if (bsr_store) { + bool found=false; + foreach_alist(store, jcr->store_mngr->get_rstore_list()) { + /* At least the Address and the Port should match */ + if (strcmp(store->address, bsr_store->address) == 0 && store->SDport == bsr_store->SDport) { + /* The storage is ok, it will select it */ + jcr->store_mngr->set_rstore(store, rsource_origin.c_str()); + found=true; + break; + } + } + if (!found) { + /* Maybe we can find a storage with the right name. Should not happen */ foreach_alist(store, jcr->store_mngr->get_rstore_list()) { - /* At least the Address and the Port should match */ - if (strcmp(store->address, bsr_store->address) == 0 && store->SDport == bsr_store->SDport) { - /* The storage is ok, it will select it */ - jcr->store_mngr->set_rstore(store, src.c_str()); + if (strcmp(store->hdr.name, info.storage) == 0) { + jcr->store_mngr->set_rstore(store, rsource_origin.c_str()); found=true; break; } } - if (!found) { - /* Maybe we can find a storage with the right name. Should not happen */ - foreach_alist(store, jcr->store_mngr->get_rstore_list()) { - if (strcmp(store->hdr.name, info.storage) == 0) { - jcr->store_mngr->set_rstore(store, src.c_str()); - found=true; - break; - } - } - } - if (!found) { - /* Let's try with the MediaType */ - foreach_alist(store, jcr->store_mngr->get_rstore_list()) { - if (strcmp(store->media_type, bsr_store->media_type) == 0) { - /* The Media type is the same, it will select it */ - jcr->store_mngr->set_rstore(store, src.c_str()); - break; - } + } + if (!found) { + /* Let's try with the MediaType */ + foreach_alist(store, jcr->store_mngr->get_rstore_list()) { + if (strcmp(store->media_type, bsr_store->media_type) == 0) { + /* The Media type is the same, it will select it */ + jcr->store_mngr->set_rstore(store, rsource_origin.c_str()); + break; } } - /* TODO: It is possible to iterate on the global list of Storage - * resource and pick the original one, it would solve automatically - * any configuration issues. - */ - if (!found) { - Jmsg(jcr, M_WARNING, 0, _("Could not find a compatible Storage to read volumes in the %s Job definition (%s/%s)\n"), - jcr->job->name(), bsr_store->hdr.name, bsr_store->media_type); - } - - } else { - Dmsg1(50, "Unable to find the Storage resource \"%s\" in the configuration\n", info.storage); } + /* TODO: It is possible to iterate on the global list of Storage + * resource and pick the original one, it would solve automatically + * any configuration issues. + */ + if (!found) { + Jmsg(jcr, M_WARNING, 0, _("Could not find a compatible Storage to read volumes in the %s Job definition (%s/%s)\n"), + jcr->job->name(), bsr_store->hdr.name, bsr_store->media_type); + } + + } else { + Dmsg1(50, "Unable to find the Storage resource \"%s\" in the configuration\n", info.storage); } /*