* Version $Id$
*/
/*
- Copyright (C) 2000-2003 Kern Sibbald and John Walker
+ Copyright (C) 2000-2004 Kern Sibbald and John Walker
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
#include "bacula.h" /* pull in global headers */
#include "stored.h" /* pull in Storage Deamon headers */
-/* Forward referenced routines */
-static void mark_volume_in_error(JCR *jcr, DEVICE *dev);
-
-
/*
* If release is set, we rewind the current volume,
* which we no longer want, and ask the user (console)
Dmsg0(100, "Enter mount_next_volume()\n");
+ init_dev_wait_timers(dev);
+
/*
* Attempt to mount the next volume. If something non-fatal goes
* wrong, we come back here to re-try (new op messages, re-read
* Volume, ...)
*/
mount_next_vol:
- if (retry++ > 5) {
+ /* Ignore retry if this is poll request */
+ if (!dev->poll && retry++ > 8) {
Jmsg(jcr, M_FATAL, 0, _("Too many errors trying to mount device %s.\n"),
dev_name(dev));
return 0;
* Get Director's idea of what tape we should have mounted.
* in jcr->VolCatInfo
*/
- Dmsg0(100, "Before dir_find_next\n");
- if (!dir_find_next_appendable_volume(jcr)) {
- Dmsg0(100, "not dir_find_next\n");
- if (!dir_ask_sysop_to_mount_next_volume(jcr, dev)) {
+ Dmsg0(200, "Before dir_find_next_appendable_volume.\n");
+ while (!dir_find_next_appendable_volume(jcr)) {
+ Dmsg0(200, "not dir_find_next\n");
+ if (!dir_ask_sysop_to_create_appendable_volume(jcr, dev)) {
return 0;
}
+ Dmsg0(200, "Again dir_find_next_append...\n");
}
if (job_canceled(jcr)) {
return 0;
Dmsg2(100, "Ask=%d autochanger=%d\n", ask, autochanger);
release = true; /* release next time if we "recurse" */
- if (ask && !dir_ask_sysop_to_mount_next_volume(jcr, dev)) {
+ if (ask && !dir_ask_sysop_to_mount_volume(jcr, dev)) {
Dmsg0(100, "Error return ask_sysop ...\n");
return 0; /* error return */
}
}
Dmsg1(100, "want vol=%s\n", jcr->VolumeName);
+ if (dev->poll && dev_cap(dev, CAP_CLOSEONPOLL)) {
+ force_close_dev(dev);
+ }
+
/* Open device */
if (!(dev_state(dev, ST_OPENED))) {
int mode;
VOLUME_CAT_INFO VolCatInfo;
Dmsg1(100, "Vol NAME Error Name=%s\n", jcr->VolumeName);
+ /* If polling and got a previous bad name, ignore it */
+ if (dev->poll && strcmp(dev->BadVolName, dev->VolHdr.VolName) == 0) {
+ ask = true;
+ Dmsg1(200, "Vol Name error supress due to poll. Name=%s\n",
+ jcr->VolumeName);
+ goto mount_next_vol;
+ }
/*
* OK, we got a different volume mounted. First save the
* requested Volume info (jcr) structure, then query if
/* Check if this is a valid Volume in the pool */
pm_strcpy(&jcr->VolumeName, dev->VolHdr.VolName);
if (!dir_get_volume_info(jcr, GET_VOL_INFO_FOR_WRITE)) {
+ bstrncpy(dev->BadVolName, dev->VolHdr.VolName, sizeof(dev->BadVolName));
Jmsg(jcr, M_WARNING, 0, _("Director wanted Volume \"%s\".\n"
" Current Volume \"%s\" not acceptable because:\n"
" %s"),
case VOL_NO_MEDIA:
default:
/* Send error message */
- Jmsg(jcr, M_WARNING, 0, "%s", jcr->errmsg);
+ if (!dev->poll) {
+ Jmsg(jcr, M_WARNING, 0, "%s", jcr->errmsg);
+ } else {
+ Dmsg1(200, "Msg suppressed by poll: %s\n", jcr->errmsg);
+ }
ask = true;
goto mount_next_vol;
}
*/
if (!dev_cap(dev, CAP_STREAM)) {
if (!rewind_dev(dev)) {
- Jmsg2(jcr, M_WARNING, 0, _("Rewind error on device %s. ERR=%s\n"),
+ Jmsg2(jcr, M_WARNING, 0, _("Rewind error on device \"%s\". ERR=%s\n"),
dev_name(dev), strerror_dev(dev));
}
if (recycle) {
if (!truncate_dev(dev)) {
- Jmsg2(jcr, M_WARNING, 0, _("Truncate error on device %s. ERR=%s\n"),
+ Jmsg2(jcr, M_WARNING, 0, _("Truncate error on device \"%s\". ERR=%s\n"),
dev_name(dev), strerror_dev(dev));
}
}
/* Attempt write to check write permission */
if (!write_block_to_dev(jcr, dev, block)) {
- Jmsg2(jcr, M_ERROR, 0, _("Unable to write device %s. ERR=%s\n"),
+ Jmsg2(jcr, M_ERROR, 0, _("Unable to write device \"%s\". ERR=%s\n"),
dev_name(dev), strerror_dev(dev));
goto mount_next_vol;
}
bstrncpy(dev->VolCatInfo.VolCatStatus, "Append", sizeof(dev->VolCatInfo.VolCatStatus));
dir_update_volume_info(jcr, dev, 1); /* indicate doing relabel */
if (recycle) {
- Jmsg(jcr, M_INFO, 0, _("Recycled volume \"%s\" on device %s, all previous data lost.\n"),
+ Jmsg(jcr, M_INFO, 0, _("Recycled volume \"%s\" on device \"%s\", all previous data lost.\n"),
jcr->VolumeName, dev_name(dev));
} else {
- Jmsg(jcr, M_INFO, 0, _("Wrote label to prelabeled Volume \"%s\" on device %s\n"),
+ Jmsg(jcr, M_INFO, 0, _("Wrote label to prelabeled Volume \"%s\" on device \"%s\"\n"),
jcr->VolumeName, dev_name(dev));
}
/*
Jmsg(jcr, M_INFO, 0, _("Volume \"%s\" previously written, moving to end of data.\n"),
jcr->VolumeName);
if (!eod_dev(dev)) {
- Jmsg(jcr, M_ERROR, 0, _("Unable to position to end of data %s. ERR=%s\n"),
+ Jmsg(jcr, M_ERROR, 0, _("Unable to position to end of data on device \"%s\". ERR=%s\n"),
dev_name(dev), strerror_dev(dev));
mark_volume_in_error(jcr, dev);
goto mount_next_vol;
* that the database says we should be.
*/
if (dev->VolCatInfo.VolCatFiles == dev_file(dev)) {
- Jmsg(jcr, M_INFO, 0, _("Ready to append to end of Volume at file=%d.\n"),
- dev_file(dev));
+ Jmsg(jcr, M_INFO, 0, _("Ready to append to end of Volume \"%s\" at file=%d.\n"),
+ jcr->VolumeName, dev_file(dev));
} else {
- Jmsg(jcr, M_ERROR, 0, _("I canot write on this volume because:\n\
+ Jmsg(jcr, M_ERROR, 0, _("I canot write on Volume \"%s\" because:\n\
The number of files mismatch! Volume=%u Catalog=%u\n"),
- dev_file(dev), dev->VolCatInfo.VolCatFiles);
+ jcr->VolumeName, dev_file(dev), dev->VolCatInfo.VolCatFiles);
mark_volume_in_error(jcr, dev);
goto mount_next_vol;
}
return 1;
}
-static void mark_volume_in_error(JCR *jcr, DEVICE *dev)
+/*
+ * Mark volume in error in catalog
+ */
+void mark_volume_in_error(JCR *jcr, DEVICE *dev)
{
Jmsg(jcr, M_INFO, 0, _("Marking Volume \"%s\" in Error in Catalog.\n"),
jcr->VolumeName);