/*
Bacula® - The Network Backup Solution
- Copyright (C) 2004-2008 Free Software Foundation Europe e.V.
+ Copyright (C) 2004-2010 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.
*
* Kern Sibbald, March 2004
*
- * Version $Id$
*/
#include "bacula.h"
char ec1[50];
Dmsg0(100, "Despooling data\n");
+ if (jcr->dcr->job_spool_size == 0) {
+ Jmsg(jcr, M_WARNING, 0, _("Despooling zero bytes. Your disk is probably FULL!\n"));
+ }
+
/*
* Commit means that the job is done, so we commit, otherwise, we
* are despooling because of user spool size max or some error
#endif
/* Add run time, to get current wait time */
- time_t despool_start = time(NULL) - jcr->run_time;
+ int32_t despool_start = time(NULL) - jcr->run_time;
set_new_file_parameters(dcr);
if (!ok) {
Jmsg2(jcr, M_FATAL, 0, _("Fatal append error on device %s: ERR=%s\n"),
dcr->dev->print_name(), dcr->dev->bstrerror());
+ Dmsg2(000, "Fatal append error on device %s: ERR=%s\n",
+ dcr->dev->print_name(), dcr->dev->bstrerror());
}
Dmsg3(800, "Write block ok=%d FI=%d LI=%d\n", ok, block->FirstIndex, block->LastIndex);
}
if (!dir_create_jobmedia_record(dcr)) {
- Jmsg(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"),
- dcr->VolCatInfo.VolCatName, jcr->Job);
+ Jmsg2(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"),
+ dcr->getVolCatName(), jcr->Job);
}
/* Set new file/block parameters for current dcr */
set_new_file_parameters(dcr);
- /* Subtracting run_time give us elapsed time - wait_time since we started despooling */
- time_t despool_elapsed = time(NULL) - despool_start - jcr->run_time;
+ /*
+ * Subtracting run_time give us elapsed time - wait_time since
+ * we started despooling. Note, don't use time_t as it is 32 or 64
+ * bits depending on the OS and doesn't edit with %d
+ */
+ int32_t despool_elapsed = time(NULL) - despool_start - jcr->run_time;
if (despool_elapsed <= 0) {
despool_elapsed = 1;
}
- Jmsg(dcr->jcr, M_INFO, 0, _("Despooling elapsed time = %02d:%02d:%02d, Transfer rate = %s bytes/second\n"),
+ Jmsg(dcr->jcr, M_INFO, 0, _("Despooling elapsed time = %02d:%02d:%02d, Transfer rate = %s Bytes/second\n"),
despool_elapsed / 3600, despool_elapsed % 3600 / 60, despool_elapsed % 60,
edit_uint64_with_suffix(jcr->dcr->job_spool_size / despool_elapsed, ec1));
free(rdev);
dcr->spooling = true; /* turn on spooling again */
dcr->despooling = false;
-
- /*
- * We are done, so unblock the device, but if we have done a
- * commit, leave it locked so that the job cleanup does not
- * need to wait to release the device (no re-acquire of the lock).
+ /*
+ * Note, if committing we leave the device blocked. It will be removed in
+ * release_device();
*/
- dcr->dlock();
- unblock_device(dcr->dev);
- /* If doing a commit, leave the device locked -- unlocked in release_device() */
if (!commit) {
- dcr->dunlock();
+ dcr->dev->dunblock();
}
set_jcr_job_status(jcr, JS_Running);
dir_send_job_status(jcr);
bool despool = false;
DEV_BLOCK *block = dcr->block;
+ if (job_canceled(dcr->jcr)) {
+ return false;
+ }
ASSERT(block->binbuf == ((uint32_t) (block->bufp - block->buf)));
if (block->binbuf <= WRITE_BLKHDR_LENGTH) { /* Does block have data in it? */
return true;
be.bstrerror());
}
if (stat != (ssize_t)sizeof(hdr)) {
+ Jmsg(dcr->jcr, M_ERROR, 0, _("Error writing header to spool file."
+ " Disk probably full. Attempting recovery. Wanted to write=%d got=%d\n"),
+ (int)stat, (int)sizeof(hdr));
/* If we wrote something, truncate it, then despool */
if (stat != -1) {
#if defined(HAVE_WIN32)
V(mutex);
}
+static void make_unique_spool_filename(JCR *jcr, POOLMEM **name, int fd)
+{
+ Mmsg(name, "%s/%s.attr.%s.%d.spool", working_directory, my_name,
+ jcr->Job, fd);
+}
+
+/*
+ * Tell Director where to find the attributes spool file
+ * Note, if we are not on the same machine, the Director will
+ * return an error, and the higher level routine will transmit
+ * the data record by record -- using bsock->despool().
+ */
+static bool blast_attr_spool_file(JCR *jcr, boffset_t size)
+{
+ /* send full spool file name */
+ POOLMEM *name = get_pool_memory(PM_MESSAGE);
+ make_unique_spool_filename(jcr, &name, jcr->dir_bsock->m_fd);
+ bash_spaces(name);
+ jcr->dir_bsock->fsend("BlastAttr Job=%s File=%s\n", jcr->Job, name);
+ free_pool_memory(name);
+
+ if (jcr->dir_bsock->recv() <= 0) {
+ Jmsg(jcr, M_FATAL, 0, _("Network error on BlastAttributes.\n"));
+ return false;
+ }
+
+ if (!bstrcmp(jcr->dir_bsock->msg, "1000 OK BlastAttr\n")) {
+ return false;
+ }
+ return true;
+}
+
bool commit_attribute_spool(JCR *jcr)
{
boffset_t size;
char tbuf[100];
Dmsg1(100, "Commit attributes at %s\n", bstrftimes(tbuf, sizeof(tbuf),
- ( utime_t)time(NULL)));
+ (utime_t)time(NULL)));
if (are_attributes_spooled(jcr)) {
if (fseeko(jcr->dir_bsock->m_spool_fd, 0, SEEK_END) != 0) {
berrno be;
dir_send_job_status(jcr);
Jmsg(jcr, M_INFO, 0, _("Sending spooled attrs to the Director. Despooling %s bytes ...\n"),
edit_uint64_with_commas(size, ec1));
- jcr->dir_bsock->despool(update_attr_spool_size, size);
+
+ if (!blast_attr_spool_file(jcr, size)) {
+ /* Can't read spool file from director side,
+ * send content over network.
+ */
+ jcr->dir_bsock->despool(update_attr_spool_size, size);
+ }
return close_attr_spool_file(jcr, jcr->dir_bsock);
}
return true;
return false;
}
-static void make_unique_spool_filename(JCR *jcr, POOLMEM **name, int fd)
-{
- Mmsg(name, "%s/%s.attr.%s.%d.spool", working_directory, my_name,
- jcr->Job, fd);
-}
-
-
-bool open_attr_spool_file(JCR *jcr, BSOCK *bs)
+static bool open_attr_spool_file(JCR *jcr, BSOCK *bs)
{
POOLMEM *name = get_pool_memory(PM_MESSAGE);
return true;
}
-bool close_attr_spool_file(JCR *jcr, BSOCK *bs)
+static bool close_attr_spool_file(JCR *jcr, BSOCK *bs)
{
POOLMEM *name;
char tbuf[100];
Dmsg1(100, "Close attr spool file at %s\n", bstrftimes(tbuf, sizeof(tbuf),
- ( utime_t)time(NULL)));
+ (utime_t)time(NULL)));
if (!bs->m_spool_fd) {
return true;
}