dcr->VolumeName, dev->print_name());
get_out:
- P(dev->mutex);
+ dev->lock();
if (dcr->reserved_device) {
dev->reserved_device--;
Dmsg2(100, "Dec reserve=%d dev=%s\n", dev->reserved_device, dev->print_name());
dcr->reserved_device = false;
}
- V(dev->mutex);
+ dev->unlock();
dev->unblock();
Dmsg1(50, "jcr->dcr=%p\n", jcr->dcr);
return ok;
if (dev->num_writers == 0) {
memcpy(&dev->VolCatInfo, &dcr->VolCatInfo, sizeof(dev->VolCatInfo));
}
+
+ /*
+ * Insanity check
+ *
+ * Check to see if the tape position as defined by the OS is
+ * the same as our concept. If it is not, we bail out, because
+ * it means the user has probably manually rewound the tape.
+ * Note, we check only if num_writers == 0, but this code will
+ * also work fine for any number of writers. If num_writers > 0,
+ * we probably should cancel all jobs using this device, or
+ * perhaps even abort the SD, or at a minimum, mark the tape
+ * in error. Another strategy with num_writers == 0, would be
+ * to rewind the tape and do a new eod() request.
+ */
+ if (dev->is_tape() && dev->num_writers == 0) {
+ int32_t file = dev->get_os_tape_file();
+ if (file >= 0 && file != (int32_t)dev->get_file()) {
+ Jmsg(jcr, M_FATAL, 0, _("Invalid tape position on volume \"%s\""
+ " on device %s. Expected %d, got %d\n"),
+ dev->VolHdr.VolumeName, dev->print_name(), dev->get_file(), file);
+ goto get_out;
+ }
+ }
}
} else {
/* Not already in append mode, so mount the device */
}
dev->VolCatInfo.VolCatJobs++; /* increment number of jobs on vol */
dir_update_volume_info(dcr, false); /* send Volume info to Director */
- P(dev->mutex);
+ dev->lock();
if (dcr->reserved_device) {
dev->reserved_device--;
Dmsg2(100, "Dec reserve=%d dev=%s\n", dev->reserved_device, dev->print_name());
dcr->reserved_device = false;
}
- V(dev->mutex);
+ dev->unlock();
dev->unblock();
return dcr;
* Error return
*/
get_out:
- P(dev->mutex);
+ dev->lock();
if (dcr->reserved_device) {
dev->reserved_device--;
Dmsg2(100, "Dec reserve=%d dev=%s\n", dev->reserved_device, dev->print_name());
dcr->reserved_device = false;
}
- V(dev->mutex);
+ dev->unlock();
dev->unblock();
return NULL;
}