if (dev->vol == NULL) {
Dmsg2(dbglvl, "JobId=%u vol_unused: no vol on %s\n", (int)dcr->jcr->JobId, dev->print_name());
- debug_list_volumes("null return unreserve_volume");
+ debug_list_volumes("null vol cannot unreserve_volume");
return false;
}
if (dev->is_busy()) {
Dmsg2(dbglvl, "JobId=%u vol_unused: no vol on %s\n", (int)dcr->jcr->JobId, dev->print_name());
- debug_list_volumes("dev busy return unreserve_volume");
+ debug_list_volumes("dev busy cannot unreserve_volume");
return false;
}
vol = dev->vol;
dev->vol = NULL;
vol_list->remove(vol);
- Dmsg2(dbglvl, "free_volume %s at %p dev=%s\n", vol->vol_name, dev->print_name());
+ Dmsg2(dbglvl, "free_volume %s dev=%s\n", vol->vol_name, dev->print_name());
free_vol_item(vol);
debug_list_volumes("free_volume");
unlock_volumes();
rctx.device_name = device_name;
stat = search_res_for_device(rctx);
if (stat == 1) { /* found available device */
- Dmsg2(dbglvl, "JobId=%u Suitable device found=%s\n", (int)rctx.jcr->JobId,
+ Dmsg2(dbglvl, "JobId=%u available device found=%s\n", (int)rctx.jcr->JobId,
device_name);
ok = true;
break;
Dmsg1(dbglvl, "JobId=%u No next volume found\n", (int)rctx.jcr->JobId);
rctx.have_volume = false;
rctx.VolumeName[0] = 0;
- }
+ /*
+ * If there is at least one volume that is valid and in use,
+ * but we get here, check if we are running with prefers
+ * non-mounted drives. In that case, we have selected a
+ * non-used drive and our one and only volume is mounted
+ * elsewhere, so we bail out and retry using that drive.
+ */
+ if (dcr->volume_in_use && !rctx.PreferMountedVols) {
+ rctx.PreferMountedVols = true;
+ goto bail_out;
+ }
+ }
}
ok = reserve_device_for_append(dcr, rctx);
if (ok) {
}
}
if (!ok) {
- rctx.have_volume = false;
- free_dcr(dcr);
- Dmsg1(dbglvl, "JobId=%u Not OK.\n", (int)rctx.jcr->JobId);
- return 0;
+ goto bail_out;
}
- POOL_MEM dev_name;
if (rctx.notify_dir) {
+ POOL_MEM dev_name;
BSOCK *dir = rctx.jcr->dir_bsock;
pm_strcpy(dev_name, rctx.device->hdr.name);
bash_spaces(dev_name);
ok = true;
}
return ok ? 1 : -1;
+
+bail_out:
+ rctx.have_volume = false;
+ free_dcr(dcr);
+ Dmsg1(dbglvl, "JobId=%u Not OK.\n", (int)rctx.jcr->JobId);
+ return 0;
}
/*