int32_t n = 0;
BSOCK *fd = jcr->file_bsock;
int fd_ok = FALSE;
+ uint32_t JobFiles, Errors;
+ uint64_t ReadBytes, JobBytes;
set_jcr_job_status(jcr, JS_Running);
/* Wait for Client to terminate */
while ((n = bget_dirmsg(fd)) >= 0) {
- if (sscanf(fd->msg, EndJob, &jcr->FDJobStatus, &jcr->JobFiles,
- &jcr->ReadBytes, &jcr->JobBytes, &jcr->Errors) == 5) {
+ if (!fd_ok && sscanf(fd->msg, EndJob, &jcr->FDJobStatus, &JobFiles,
+ &ReadBytes, &JobBytes, &Errors) == 5) {
fd_ok = TRUE;
set_jcr_job_status(jcr, jcr->FDJobStatus);
Dmsg1(100, "FDStatus=%c\n", (char)jcr->JobStatus);
}
bnet_sig(fd, BNET_TERMINATE); /* tell Client we are terminating */
+ /* Note, the SD stores in jcr->JobFiles/ReadBytes/JobBytes/Errors */
wait_for_storage_daemon_termination(jcr);
/* Return the first error status we find FD or SD */
if (!fd_ok || is_bnet_error(fd)) {
return JS_ErrorTerminated;
}
+ /* Return values from FD */
+ jcr->JobFiles = JobFiles;
+ jcr->Errors = Errors;
+ jcr->ReadBytes = ReadBytes;
+ jcr->JobBytes = JobBytes;
return jcr->SDJobStatus;
}
* If it is a tape, it checks the volume name
*/
for ( ; !(dev->state & ST_OPENED); ) {
- Dmsg1(120, "bstored: open vol=%s\n", jcr->VolumeName);
- if (open_dev(dev, jcr->VolumeName, READ_ONLY) < 0) {
- Jmsg(jcr, M_FATAL, 0, _("Open device %s volume %s failed, ERR=%s\n"),
- dev_name(dev), jcr->VolumeName, strerror_dev(dev));
- goto get_out;
- }
- Dmsg1(129, "open_dev %s OK\n", dev_name(dev));
+ Dmsg1(120, "bstored: open vol=%s\n", jcr->VolumeName);
+ if (open_dev(dev, jcr->VolumeName, READ_ONLY) < 0) {
+ Jmsg(jcr, M_FATAL, 0, _("Open device %s volume %s failed, ERR=%s\n"),
+ dev_name(dev), jcr->VolumeName, strerror_dev(dev));
+ goto get_out;
+ }
+ Dmsg1(129, "open_dev %s OK\n", dev_name(dev));
}
dev->state &= ~ST_LABEL; /* force reread of label */
Dmsg0(200, "calling read-vol-label\n");
dev->EndFile = dev->EndBlock = 0;
memset(&dev->VolCatInfo, 0, sizeof(dev->VolCatInfo));
memset(&dev->VolHdr, 0, sizeof(dev->VolHdr));
- dev->use_count--;
if (dev->tid) {
stop_thread_timer(dev->tid);
dev->tid = 0;
}
if (dev->fd >= 0 && dev->use_count == 1) {
do_close(dev);
- } else {
- Dmsg0(29, "close_dev but in use so leave open.\n");
- dev->use_count--;
}
+ dev->use_count--;
}
/*
}
Dmsg0(29, "really close_dev\n");
do_close(dev);
+ dev->use_count--;
}
int truncate_dev(DEVICE *dev)
Dmsg3(100, "unblock %d from %s:%d\n", dev->dev_blocked, file, line);
ASSERT(dev->dev_blocked);
dev->dev_blocked = BST_NOT_BLOCKED;
+ dev->no_wait_id = 0;
if (dev->num_waiting > 0) {
pthread_cond_broadcast(&dev->wait); /* wake them up */
}
}
+/*
+ * Enter with device locked and blocked
+ * Exit with device unlocked and blocked by us.
+ */
void _steal_device_lock(char *file, int line, DEVICE *dev, bsteal_lock_t *hold, int state)
{
Dmsg4(100, "steal lock. old=%d new=%d from %s:%d\n", dev->dev_blocked, state,
V(dev->mutex);
}
+/*
+ * Enter with device blocked by us but not locked
+ * Exit with device locked, and blocked by previous owner
+ */
void _return_device_lock(char *file, int line, DEVICE *dev, bsteal_lock_t *hold)
{
Dmsg4(100, "return lock. old=%d new=%d from %s:%d\n",
dev->no_wait_id = hold->no_wait_id;
}
-
-
-/* ==================================================================
- * New device locking code. It is not currently used.
- * ==================================================================
- */
-
-/*
- * New device locking scheme
- */
-void _new_lock_device(char *file, int line, DEVICE *dev)
-{
-#ifdef NEW_LOCK
- int errstat;
- if ((errstat=rwl_writelock(&dev->lock)) != 0) {
- e_msg(file, line, M_ABORT, 0, "rwl_writelock failure. ERR=%s\n",
- strerror(errstat));
- }
-#endif
-}
-
-void _new_lock_device(char *file, int line, DEVICE *dev, int state)
-{
-#ifdef NEW_LOCK
- int errstat;
- if ((errstat=rwl_writelock(&dev->lock)) != 0) {
- e_msg(file, line, M_ABORT, 0, "rwl_writelock failure. ERR=%s\n",
- strerror(errstat));
- }
- dev->dev_blocked = state;
-#endif
-}
-
-void _new_unlock_device(char *file, int line, DEVICE *dev)
-{
-#ifdef NEW_LOCK
- int errstat;
- if (dev->lock.w_active == 1) {
- dev->dev_blocked = BST_NOT_BLOCKED;
- }
- if ((errstat=rwl_writeunlock(&dev->lock)) != 0) {
- e_msg(file, line, M_ABORT, 0, "rwl_writeunlock failure. ERR=%s\n",
- strerror(errstat));
- }
-#endif
-}
-
-void new_steal_device_lock(DEVICE *dev, brwsteal_t *hold, int state)
-{
-#ifdef NEW_LOCK
- hold->state = dev->dev_blocked;
- hold->writer_id = dev->lock.writer_id;
- dev->dev_blocked = state;
- dev->lock.writer_id = pthread_self();
- V(dev->lock.mutex);
-#endif
-}
-
-void new_return_device_lock(DEVICE *dev, brwsteal_t *hold)
-{
-#ifdef NEW_LOCK
- P(dev->lock.mutex);
- dev->dev_blocked = hold->state;
- dev->lock.writer_id = hold->writer_id;
-#endif
-}
autoload_device(jcr, dev, 0, dir); /* autoload if possible */
block = new_block(dev);
- /* Ensure that the device is open -- not autoload_device() closes it */
+ /* Ensure that the device is open -- autoload_device() closes it */
for ( ; !(dev->state & ST_OPENED); ) {
- if (open_dev(dev, jcr->VolumeName, READ_WRITE) < 0) {
- if (dev->dev_errno == EAGAIN || dev->dev_errno == EBUSY) {
- bmicrosleep(30, 0);
- }
- bnet_fsend(dir, _("3910 Unable to open device %s. ERR=%s\n"),
- dev_name(dev), strerror_dev(dev));
- goto bail_out;
- }
+ if (open_dev(dev, jcr->VolumeName, READ_WRITE) < 0) {
+ if (dev->dev_errno == EAGAIN || dev->dev_errno == EBUSY) {
+ bmicrosleep(30, 0);
+ }
+ bnet_fsend(dir, _("3910 Unable to open device %s. ERR=%s\n"),
+ dev_name(dev), strerror_dev(dev));
+ goto bail_out;
+ }
}
/* See what we have for a Volume */
} else if (dev->dev_blocked == BST_WAITING_FOR_SYSOP) {
Dmsg2(90, "%d waiter dev_block=%d. doing unmount\n", dev->num_waiting,
dev->dev_blocked);
+ open_dev(dev, NULL, 0); /* fake open for close */
offline_or_rewind_dev(dev);
force_close_dev(dev);
dev->dev_blocked = BST_UNMOUNTED_WAITING_FOR_SYSOP;
} else { /* device not being used */
Dmsg0(90, "Device not in use, unmounting\n");
block_device(dev, BST_UNMOUNTED);
+ open_dev(dev, NULL, 0); /* fake open for close */
offline_or_rewind_dev(dev);
force_close_dev(dev);
bnet_fsend(dir, _("3002 Device %s unmounted.\n"), dev_name(dev));
/* */
#define VERSION "1.31"
#define VSTRING "1"
-#define BDATE "30 May 2003"
-#define LSMDATE "30May03"
+#define BDATE "01 Jun 2003"
+#define LSMDATE "01Jun03"
/* Debug flags */
#define DEBUG 1