if ((errstat=rwl_init(&reservation_lock)) != 0) {
berrno be;
Emsg1(M_ABORT, 0, _("Unable to initialize reservation lock. ERR=%s\n"),
- be.strerror(errstat));
+ be.bstrerror(errstat));
}
}
if ((errstat=rwl_writelock(&reservation_lock)) != 0) {
berrno be;
Emsg2(M_ABORT, 0, "rwl_writelock failure. stat=%d: ERR=%s\n",
- errstat, be.strerror(errstat));
+ errstat, be.bstrerror(errstat));
}
}
if ((errstat=rwl_writeunlock(&reservation_lock)) != 0) {
berrno be;
Emsg2(M_ABORT, 0, "rwl_writeunlock failure. stat=%d: ERR=%s\n",
- errstat, be.strerror(errstat));
+ errstat, be.bstrerror(errstat));
}
}
for (vol=(VOLRES *)vol_list->first(); vol; vol=(VOLRES *)vol_list->next(vol)) {
if (vol->dev == dev) {
Dmsg0(000, "Two Volumes on same device.\n");
- ASSERT(1);
+ ASSERT(0);
dev = vol->dev;
}
}
*
* Return: VOLRES entry on success
- * NULL error
+ * NULL volume busy on another drive
*/
VOLRES *reserve_volume(DCR *dcr, const char *VolumeName)
{
* when adding a new volume that no newly scheduled
* job can reserve it.
*/
- lock_reservations();
P(vol_list_lock);
debug_list_volumes("begin reserve_volume", debug_nolock);
/*
/* Caller wants to switch Volume to another device */
if (!vol->dev->is_busy()) {
/* OK to move it -- I'm not sure this will work */
- Dmsg3(100, "Swap vol=%s from dev=%s to %s\n", VolumeName,
- dev->print_name(), dev->print_name());
+ Dmsg3(100, "==== Swap vol=%s from dev=%s to %s\n", VolumeName,
+ vol->dev->print_name(), dev->print_name());
vol->dev->vol = NULL; /* take vol from old drive */
vol->dev->VolHdr.VolumeName[0] = 0;
vol->dev = dev; /* point vol at new drive */
dev->vol = vol; /* point dev at vol */
dev->VolHdr.VolumeName[0] = 0;
} else {
+ Dmsg3(100, "Volume busy could not swap vol=%s from dev=%s to %s\n", VolumeName,
+ vol->dev->print_name(), dev->print_name());
vol = NULL; /* device busy */
- Dmsg3(100, "Logic ERROR!!!! could not swap vol=%s from dev=%s to %s\n", VolumeName,
- dev->print_name(), dcr->dev->print_name());
- ASSERT(1); /* blow up!!! */
}
}
}
get_out:
debug_list_volumes("end new volume", debug_nolock);
V(vol_list_lock);
- unlock_reservations();
return vol;
}
* Wiffle through them and find one that can do the backup.
*/
if (ok) {
- bool first = true; /* print wait message once */
+ int retries = 0; /* wait for device retries */
bool fail = false;
rctx.notify_dir = true;
lock_reservations();
}
/* Keep reservations locked *except* during wait_for_device() */
unlock_reservations();
- if (!rctx.suitable_device || !wait_for_device(jcr, first)) {
+ if (!rctx.suitable_device || !wait_for_device(jcr, retries)) {
Dmsg0(100, "Fail. !suitable_device || !wait_for_device\n");
fail = true;
}
lock_reservations();
- first = false;
bnet_sig(dir, BNET_HEARTBEAT); /* Inform Dir that we are alive */
}
unlock_reservations();
ASSERT(dcr);
- /* Get locks in correct order */
- unlock_reservations();
dev->dlock();
- lock_reservations();
if (is_device_unmounted(dev)) {
Dmsg1(200, "Device %s is BLOCKED due to user unmount.\n", dev->print_name());
ASSERT(dcr);
- /* Get locks in correct order */
- unlock_reservations();
dev->dlock();
- lock_reservations();
/* If device is being read, we cannot write it */
if (dev->can_read()) {
}
/* Check for prefer mounted volumes */
- if (rctx.PreferMountedVols && !dev->VolHdr.VolumeName[0] && dev->is_tape()) {
+// if (rctx.PreferMountedVols && !dev->VolHdr.VolumeName[0] && dev->is_tape()) {
+ if (rctx.PreferMountedVols && !dev->vol && dev->is_tape()) {
Mmsg(jcr->errmsg, _("3606 JobId=%u prefers mounted drives, but drive %s has no Volume.\n"),
jcr->JobId, dev->print_name());
queue_reserve_message(jcr);
- Dmsg1(110, "failed: want mounted -- no vol JobId=%u\n", jcr->JobId);
+ Dmsg1(110, "failed: want mounted -- no vol JobId=%u\n", (uint32_t)jcr->JobId);
return 0; /* No volume mounted */
}
/* Check for exact Volume name match */
+ /* ***FIXME*** use dev->vol.VolumeName */
if (rctx.exact_match && rctx.have_volume &&
strcmp(dev->VolHdr.VolumeName, rctx.VolumeName) != 0) {
Mmsg(jcr->errmsg, _("3607 JobId=%u wants Vol=\"%s\" drive has Vol=\"%s\" on drive %s.\n"),
}
/* Check for unused autochanger drive */
+ /* ***FIXME*** use !dev->is_busy() */
if (rctx.autochanger_only && dev->num_writers == 0 &&
dev->VolHdr.VolumeName[0] == 0) {
/* Device is available but not yet reserved, reserve it for us */