/* Forward referenced functions */
static void attach_dcr_to_dev(DCR *dcr);
+static bool is_suitable_volume_mounted(DCR *dcr);
/*********************************************************************
*/
DCR *acquire_device_for_append(DCR *dcr)
{
- bool release = false;
- bool recycle = false;
bool do_mount = false;
+ bool release = false;
+ bool find;
DEVICE *dev = dcr->dev;
JCR *jcr = dcr->jcr;
goto get_out;
}
+ /*
+ * find defines whether or not mount_next_write_volume should
+ * as the Director again about what Volume to use.
+ */
+ find = is_suitable_volume_mounted(dcr);
if (dev->can_append()) {
Dmsg0(190, "device already in append.\n");
/*
* dcr->VolumeName is what we pass into the routines, or
* get back from the subroutines.
*/
- bstrncpy(dcr->VolumeName, dev->VolHdr.VolumeName, sizeof(dcr->VolumeName));
- if (!dir_get_volume_info(dcr, GET_VOL_INFO_FOR_WRITE) &&
+ if (!find &&
!(dir_find_next_appendable_volume(dcr) &&
strcmp(dev->VolHdr.VolumeName, dcr->VolumeName) == 0)) { /* wrong tape mounted */
Dmsg2(190, "Wrong tape mounted: %s. wants:%s\n", dev->VolHdr.VolumeName,
dcr->VolumeName);
- /* Release volume reserved by dir_find_next_appendable_volume() */
- if (dcr->VolumeName[0]) {
- volume_unused(dcr);
- }
if (dev->num_writers != 0) {
Jmsg3(jcr, M_FATAL, 0, _("Wanted to append to Volume \"%s\", but device %s is busy writing on \"%s\" .\n"),
dcr->VolumeName, dev->print_name(), dev->VolHdr.VolumeName);
Dmsg3(200, "Wanted to append to Volume \"%s\", but device %s is busy writing on \"%s\" .\n",
dcr->VolumeName, dev->print_name(), dev->VolHdr.VolumeName);
+ /* Release volume reserved by dir_find_next_appendable_volume() */
+ if (dcr->VolumeName[0]) {
+ volume_unused(dcr);
+ }
goto get_out;
}
/* Wrong tape mounted, release it, then fall through to get correct one */
* we do not need to do mount_next_write_volume(), unless
* we need to recycle the tape.
*/
- recycle = strcmp(dcr->VolCatInfo.VolCatStatus, "Recycle") == 0;
- Dmsg1(190, "Correct tape mounted. recycle=%d\n", recycle);
- if (recycle && dev->num_writers != 0) {
+ do_mount = strcmp(dcr->VolCatInfo.VolCatStatus, "Recycle") == 0;
+ Dmsg1(190, "Correct tape mounted. recycle=%d\n", do_mount);
+ if (do_mount && dev->num_writers != 0) {
Jmsg(jcr, M_FATAL, 0, _("Cannot recycle volume \"%s\""
" on device %s because it is in use by another job.\n"),
dev->VolHdr.VolumeName, dev->print_name());
do_mount = true;
}
- if (do_mount || recycle) {
+ if (do_mount) {
Dmsg0(190, "Do mount_next_write_vol\n");
- bool mounted = mount_next_write_volume(dcr, release);
+ bool mounted = mount_next_write_volume(dcr, find, release);
if (!mounted) {
if (!job_canceled(jcr)) {
/* Reduce "noise" -- don't print if job canceled */
}
+static bool is_suitable_volume_mounted(DCR *dcr)
+{
+ DEVICE *dev = dcr->dev;
+
+ /* Volume mounted? */
+ if (dev->VolHdr.VolumeName[0] == 0) {
+ return false; /* no */
+ }
+ bstrncpy(dcr->VolumeName, dev->VolHdr.VolumeName, sizeof(dcr->VolumeName));
+ return dir_get_volume_info(dcr, GET_VOL_INFO_FOR_WRITE);
+}
+
/*
* This job is done, so release the device. From a Unix standpoint,
* the device remains open.
BSOCK *dir = jcr->dir_bsock;
bool found = false;
- Dmsg0(200, "dir_find_next_appendable_volume\n");
+ Dmsg2(200, "dir_find_next_appendable_volume: reserved=%d Vol=%s\n",
+ dcr->reserved_device, dcr->VolumeName);
+
/*
* Try the twenty oldest or most available volumes. Note,
* the most available could already be mounted on another
edit_uint64_with_commas(dev->VolCatInfo.VolCatBlocks, b2),
bstrftime(dt, sizeof(dt), time(NULL)));
- if (!mount_next_write_volume(dcr, 1)) {
+ /* Called with find=true, release=true */
+ if (!mount_next_write_volume(dcr, true, true)) {
free_block(label_blk);
dcr->block = block;
dev->dlock();
* impossible to get the requested Volume.
*
*/
-bool mount_next_write_volume(DCR *dcr, bool release)
+bool mount_next_write_volume(DCR *dcr, bool find, bool release)
{
int retry = 0;
bool ask = false, recycle, autochanger;
* in dcr->VolCatInfo
*/
Dmsg0(200, "Before dir_find_next_appendable_volume.\n");
- while (!dir_find_next_appendable_volume(dcr)) {
- Dmsg0(200, "not dir_find_next\n");
- if (!dir_ask_sysop_to_create_appendable_volume(dcr)) {
- return false;
+ if (find) {
+ while (!dir_find_next_appendable_volume(dcr)) {
+ Dmsg0(200, "not dir_find_next\n");
+ if (!dir_ask_sysop_to_create_appendable_volume(dcr)) {
+ return false;
+ }
+ Dmsg0(200, "Again dir_find_next_append...\n");
}
- Dmsg0(200, "Again dir_find_next_append...\n");
+ } else {
+ find = true; /* set true for next pass if any */
}
if (job_canceled(jcr)) {
return false;
* If we autochanged to correct Volume or (we have not just
* released the Volume AND we can automount) we go ahead
* and read the label. If there is no tape in the drive,
- * we will err, recurse and ask the operator the next time.
+ * we will fail, recurse and ask the operator the next time.
*/
if (!release && dev->is_tape() && dev->has_cap(CAP_AUTOMOUNT)) {
Dmsg0(150, "(1)Ask=0\n");
bool is_this_bsr_done(BSR *bsr, DEV_RECORD *rec);
/* From mount.c */
-bool mount_next_write_volume(DCR *dcr, bool release);
+bool mount_next_write_volume(DCR *dcr, bool find, bool release);
bool mount_next_read_volume(DCR *dcr);
void mark_volume_in_error(DCR *dcr);
* because it was probably inserted by another job.
*/
if (strcmp(vol->vol_name, VolumeName) == 0) {
+ Dmsg2(dbglvl, "jid=%u OK, vol=%s on device.\n", (int)dcr->jcr->JobId, VolumeName);
goto get_out; /* Volume already on this device */
} else {
- if (dev->is_busy() && dev->VolHdr.VolumeName[0]) {
- vol = NULL;
- goto get_out;
- }
Dmsg3(dbglvl, "jid=%u reserve_vol free vol=%s at %p\n",
(int)dcr->jcr->JobId, vol->vol_name, vol->vol_name);
debug_list_volumes("reserve_vol free");
#undef VERSION
#define VERSION "2.3.5"
-#define BDATE "23 September 2007"
-#define LSMDATE "23Sep07"
+#define BDATE "24 September 2007"
+#define LSMDATE "24Sep07"
#define PROG_COPYRIGHT "Copyright (C) %d-2007 Free Software Foundation Europe e.V.\n"
#define BYEAR "2007" /* year for copyright messages in progs */
Technical notes on version 2.3
General:
+24Sep07
+kes Back out one small change to the reservation system (reserving a volume).
+kes Rework how a Volume is mounted. It is now much more intelligent and
+ will always attempt to use any mounted volume if possible and reduces
+ calls to the Director asking about volumes.
23Sep07
kes Turn off some code when batch insert not enabled.
kes Edit FD name in connect error messages.