#include "bacula.h"
#include "stored.h"
+#ifdef DEBUG_BLOCK_CHECKSUM
+static const bool debug_block_checksum = true;
+#else
+static const bool debug_block_checksum = false;
+#endif
+
+#ifdef NO_TAPE_WRITE_TEST
+static const bool no_tape_write_test = true;
+#else
+static const bool no_tape_write_test = false;
+#endif
+
+
static bool terminate_writing_volume(DCR *dcr);
static bool do_new_file_bookkeeping(DCR *dcr);
static bool do_dvd_size_checks(DCR *dcr);
DCR *dcr = this;
if (dcr->spooling) {
+ Dmsg0(100, "Write to spool\n");
stat = write_block_to_spool_file(dcr);
return stat;
}
if (!dcr->is_dev_locked()) { /* device already locked? */
/* note, do not change this to dcr->r_dlock */
- dev->r_dlock(); /* no, lock it */
+ dev->rLock(); /* no, lock it */
}
/*
if (dcr->NewVol || dcr->NewFile) {
if (job_canceled(jcr)) {
stat = false;
+ Dmsg0(100, "Canceled\n");
goto bail_out;
}
/* Create a jobmedia record for this job */
dcr->getVolCatName(), jcr->Job);
set_new_volume_parameters(dcr);
stat = false;
+ Dmsg0(100, "cannot create media record\n");
goto bail_out;
}
if (dcr->NewVol) {
bail_out:
if (!dcr->is_dev_locked()) { /* did we lock dev above? */
/* note, do not change this to dcr->dunlock */
- dev->dunlock(); /* unlock it now */
+ dev->Unlock(); /* unlock it now */
}
return stat;
}
int hit_max1, hit_max2;
bool ok = true;
DCR *dcr = this;
+ uint32_t checksum;
-#ifdef NO_TAPE_WRITE_TEST
- empty_block(block);
- return true;
-#endif
+ if (no_tape_write_test) {
+ empty_block(block);
+ return true;
+ }
if (job_canceled(jcr)) {
return false;
}
Dmsg0(100, "return write_block_to_dev with ST_WEOT\n");
dev->dev_errno = ENOSPC;
Jmsg1(jcr, M_FATAL, 0, _("Cannot write block. Device at EOM. dev=%s\n"), dev->print_name());
+ Dmsg1(100, "Attempt to write on read-only Volume. dev=%s\n", dev->print_name());
return false;
}
if (!dev->can_append()) {
dev->dev_errno = EIO;
Jmsg1(jcr, M_FATAL, 0, _("Attempt to write on read-only Volume. dev=%s\n"), dev->print_name());
+ Dmsg1(100, "Attempt to write on read-only Volume. dev=%s\n", dev->print_name());
return false;
}
-
+
if (!dev->is_open()) {
Jmsg1(jcr, M_FATAL, 0, _("Attempt to write on closed device=%s\n"), dev->print_name());
+ Dmsg1(100, "Attempt to write on closed device=%s\n", dev->print_name());
return false;
}
+
/*
* Clear to the end of the buffer if it is not full,
* and on tape devices, apply min and fixed blocking.
}
}
-#ifdef DEBUG_BLOCK_CHECKSUM
- uint32_t checksum;
checksum = ser_block_header(block, dev->do_checksum());
-#else
- ser_block_header(block, dev->do_checksum());
-#endif
/* Limit maximum Volume size to value specified by user */
hit_max1 = (dev->max_volume_size > 0) &&
} while (stat == -1 && (errno == EBUSY || errno == EIO) && retry++ < 3);
-#ifdef DEBUG_BLOCK_CHECKSUM
- uint32_t achecksum = ser_block_header(block, dev->do_checksum());
- if (checksum != achecksum) {
- Jmsg2(jcr, M_ERROR, 0, _("Block checksum changed during write: before=%ud after=%ud\n"),
- checksum, achecksum);
- dump_block(block, "with checksum error");
+ if (debug_block_checksum) {
+ uint32_t achecksum = ser_block_header(block, dev->do_checksum());
+ if (checksum != achecksum) {
+ Jmsg2(jcr, M_ERROR, 0, _("Block checksum changed during write: before=%ud after=%ud\n"),
+ checksum, achecksum);
+ dump_block(block, "with checksum error");
+ }
}
-#endif
#ifdef DEBUG_BLOCK_ZEROING
if (bp[0] == 0 && bp[1] == 0 && bp[2] == 0 && block->buf[12] == 0) {
bool ok;
Dmsg0(250, "Enter read_block_from_device\n");
- dev->r_dlock();
+ dev->rLock();
ok = read_block_from_dev(check_block_numbers);
- dev->dunlock();
+ dev->Unlock();
Dmsg0(250, "Leave read_block_from_device\n");
return ok;
}
Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
dev->set_short_block();
block->read_len = block->binbuf = 0;
+ Dmsg2(200, "set block=%p binbuf=%d\n", block, block->binbuf);
return false; /* return error */
}