-/*
- * Routines to acquire and release a device for read/write
- *
- * Kern Sibbald, August MMII
- *
- * Version $Id$
- */
/*
Bacula® - The Network Backup Solution
- Copyright (C) 2002-2006 Free Software Foundation Europe e.V.
+ Copyright (C) 2002-2007 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
(FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
Switzerland, email:ftf@fsfeurope.org.
*/
+/*
+ * Routines to acquire and release a device for read/write
+ *
+ * Kern Sibbald, August MMII
+ *
+ * Version $Id$
+ */
#include "bacula.h" /* pull in global headers */
#include "stored.h" /* pull in Storage Deamon headers */
dev->block(BST_DOING_ACQUIRE);
if (dev->num_writers > 0) {
- Jmsg2(jcr, M_FATAL, 0, _("Num_writers=%d not zero. Job %d canceled.\n"),
+ Jmsg2(jcr, M_FATAL, 0, _("Acquire read: num_writers=%d not zero. Job %d canceled.\n"),
dev->num_writers, jcr->JobId);
goto get_out;
}
vol = jcr->VolList;
if (!vol) {
char ed1[50];
- Jmsg(jcr, M_FATAL, 0, _("No volumes specified. Job %s canceled.\n"),
+ Jmsg(jcr, M_FATAL, 0, _("No volumes specified for reading. Job %s canceled.\n"),
edit_int64(jcr->JobId, ed1));
goto get_out;
}
vol = vol->next;
}
if (!vol) {
- Jmsg(jcr, M_FATAL, 0, _("Logic error: no next volume. Numvol=%d Curvol=%d\n"),
+ Jmsg(jcr, M_FATAL, 0, _("Logic error: no next volume to read. Numvol=%d Curvol=%d\n"),
jcr->NumReadVolumes, jcr->CurReadVolume);
goto get_out; /* should not happen */
}
break;
} /* end for loop */
if (!ok) {
- Jmsg1(jcr, M_FATAL, 0, _("Too many errors trying to mount device %s.\n"),
+ Jmsg1(jcr, M_FATAL, 0, _("Too many errors trying to mount device %s for reading.\n"),
dev->print_name());
goto get_out;
}
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;
* With the reservation system, this should not happen
*/
if (dev->can_read()) {
- Jmsg1(jcr, M_FATAL, 0, _("Device %s is busy reading.\n"), dev->print_name());
- Dmsg1(200, "Device %s is busy reading.\n", dev->print_name());
+ Jmsg1(jcr, M_FATAL, 0, _("Want to append, but device %s is busy reading.\n"), dev->print_name());
+ Dmsg1(200, "Want to append but device %s is busy reading.\n", dev->print_name());
goto get_out;
}
free_unused_volume(dcr);
}
if (dev->num_writers != 0) {
- Jmsg3(jcr, M_FATAL, 0, _("Wanted Volume \"%s\", but device %s is busy writing on \"%s\" .\n"),
+ 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 Volume \"%s\", but device %s is busy writing on \"%s\" .\n",
+ 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);
goto get_out;
}
if (jcr->NumWriteVolumes == 0) {
jcr->NumWriteVolumes = 1;
}
- P(dev->mutex);
+ dev->VolCatInfo.VolCatJobs++; /* increment number of jobs on vol */
+ dir_update_volume_info(dcr, false); /* send Volume info to Director */
+ 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;
}
if (dev->can_read()) {
dev->clear_read(); /* clear read bit */
-
- /******FIXME**** send read volume usage statistics to director */
+ Dmsg0(100, "dir_update_vol_info. Release0\n");
+ dir_update_volume_info(dcr, false); /* send Volume info to Director */
} else if (dev->num_writers > 0) {
/*
}
if (!dev->at_weot()) {
dev->VolCatInfo.VolCatFiles = dev->file; /* set number of files */
- dev->VolCatInfo.VolCatJobs++; /* increment number of jobs */
/* Note! do volume update before close, which zaps VolCatInfo */
Dmsg0(100, "dir_update_vol_info. Release0\n");
dir_update_volume_info(dcr, false); /* send Volume info to Director */