/* Forward referenced functions */
static void attach_dcr_to_dev(DCR *dcr);
-static bool is_tape_position_ok(JCR *jcr, DEVICE *dev);
/*********************************************************************
if (!dir_get_volume_info(dcr, GET_VOL_INFO_FOR_READ)) {
Jmsg1(jcr, M_WARNING, 0, "%s", jcr->errmsg);
}
+ dev->set_load(); /* set to load volume */
for ( ;; ) {
/* If not polling limit retries */
DEVICE *dev = dcr->dev;
JCR *jcr = dcr->jcr;
bool ok = false;
+ bool have_vol = false;
init_device_wait_timers(dcr);
if (dev->num_writers == 0) {
memcpy(&dev->VolCatInfo, &dcr->VolCatInfo, sizeof(dev->VolCatInfo));
}
- if (!is_tape_position_ok(jcr, dev)) {
- goto get_out;
- }
- } else {
+ have_vol = dcr->is_tape_position_ok();
+ }
+
+ if (!have_vol) {
Dmsg1(190, "jid=%u Do mount_next_write_vol\n", (uint32_t)jcr->JobId);
if (!dcr->mount_next_write_volume()) {
if (!job_canceled(jcr)) {
return ok ? dcr : NULL;
}
-/*
- * 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.
- */
-static bool is_tape_position_ok(JCR *jcr, DEVICE *dev)
-{
- 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);
- return false;
- }
- }
- return true;
-}
-
-
/*
* This job is done, so release the device. From a Unix standpoint,
* the device remains open.
dev->VolCatInfo.VolCatName, dev->print_name());
}
if (dev->num_writers == 0) { /* if not being used */
-// if (!dev->is_busy()) { /* if not being used */
volume_unused(dcr); /* we obviously are not using the volume */
}
}
int check_volume_label(bool &ask, bool &autochanger);
void release_volume();
void do_swapping(bool is_writing);
+ bool is_tape_position_ok();
};
/*
goto bail_out;
}
Dmsg2(100, "=== dcr->dev=%p dev=%p\n", dcr->dev, dev);
-// dev = dcr->dev; /* may have changed in reserve volume */
/* Compare Volume Names */
Dmsg2(130, "Compare Vol names: VolName=%s hdr=%s\n", VolName?VolName:"*", dev->VolHdr.VolumeName);
Dmsg0(190, "release_volume\n");
}
+/*
+ * Insanity check
+ *
+ * Check to see if the tape position as defined by the OS is
+ * the same as our concept. If it is not,
+ * 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.
+ */
+bool DCR::is_tape_position_ok()
+{
+ 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_ERROR, 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);
+ /*
+ * If the current file is greater than zero, it means we probably
+ * have some bad count of EOF marks, so mark tape in error. Otherwise
+ * the operator might have moved the tape, so we just release it
+ * and try again.
+ */
+ if (file > 0) {
+ mark_volume_in_error();
+ }
+ release_volume();
+ return false;
+ }
+ }
+ return true;
+}
+
+
/*
* If we are reading, we come here at the end of the tape
* and see if there are more volumes to be mounted.
vol->dev->print_name());
vol->set_in_use();
dcr->reserved_volume = true;
+ bstrncpy(dcr->VolumeName, vol->vol_name, sizeof(dcr->VolumeName));
}
debug_list_volumes("end new volume");
unlock_volumes();
#undef VERSION
#define VERSION "2.3.22"
-#define BDATE "25 May 2008"
-#define LSMDATE "25May08"
+#define BDATE "26 May 2008"
+#define LSMDATE "26May08"
#define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n"
#define BYEAR "2008" /* year for copyright messages in progs */
General:
+26May08
+kes If operator has rewind tape, print warning, release tape and
+ try once more. If tape is positioned somewhere, something went
+ wrong, so mark the tape in error and try once more. Previously
+ this error was fatal, now it produces an error message.
+kes Ensure correct volume name displayed during restore
+kes Ensure that Volume is mounted for restore.
25May08
kes Fix a few more Coverity reported problems.
24May08