2 In some cases, Bacula will get an error
3 on a tape and not be able to write and EOF mark. In this
4 case, the tape will no longer be readable. When this happens,
5 Bacula tries to plunge on but gets into lots of trouble.
6 This patch should fix that by immediately marking the Job
7 in error, and by avoiding running through code that doesn't
8 make any sense after a fatal error.
10 Apply the patch to Bacula 1.34.6 (possibly earlier versions)
14 patch -p0 <1.34.6-block.patch
19 Index: src/stored/block.c
20 ===================================================================
21 RCS file: /cvsroot/bacula/bacula/src/stored/block.c,v
22 retrieving revision 1.74.2.1
23 diff -u -r1.74.2.1 block.c
24 --- src/stored/block.c 20 Jun 2004 11:43:04 -0000 1.74.2.1
25 +++ src/stored/block.c 23 Aug 2004 19:02:10 -0000
27 /* Create a jobmedia record for this job */
28 if (!dir_create_jobmedia_record(jcr)) {
30 - Jmsg(jcr, M_ERROR, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"),
31 + Jmsg(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"),
32 jcr->VolCatInfo.VolCatName, jcr->Job);
33 set_new_volume_parameters(jcr, dev);
38 if (!write_block_to_dev(dcr, block)) {
39 - stat = fixup_device_block_write_error(jcr, dev, block);
40 + if (job_canceled(jcr)) {
43 + stat = fixup_device_block_write_error(jcr, dev, block);
50 uint32_t wlen; /* length to write */
51 int hit_max1, hit_max2;
54 DEVICE *dev = dcr->dev;
58 edit_uint64_with_commas(max_cap, ed1), dev->dev_name);
59 block->write_failed = true;
60 if (weof_dev(dev, 1) != 0) { /* end tape */
61 - Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
62 + Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg);
63 dev->VolCatInfo.VolCatErrors++;
66 /* Don't do update after second EOF or file count will be wrong */
67 Dmsg0(100, "dir_update_volume_info\n");
68 dev->VolCatInfo.VolCatFiles = dev->file;
71 if (dev_state(dev, ST_TAPE) && weof_dev(dev, 1) != 0) { /* write eof */
73 - Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
74 + Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg);
75 block->write_failed = true;
76 dev->VolCatInfo.VolCatErrors++;
77 dev->state |= (ST_EOF | ST_EOT | ST_WEOT);
79 block->write_failed = true;
80 if (weof_dev(dev, 1) != 0) { /* end the tape */
81 dev->VolCatInfo.VolCatErrors++;
82 - Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
83 + Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg);
86 Dmsg0(100, "dir_update_volume_info\n");
87 dev->VolCatInfo.VolCatFiles = dev->file;
88 dir_update_volume_info(jcr, dev, 0);
89 - if (dev_cap(dev, CAP_TWOEOF) && weof_dev(dev, 1) != 0) { /* end the tape */
90 + if (ok && dev_cap(dev, CAP_TWOEOF) && weof_dev(dev, 1) != 0) { /* end the tape */
91 dev->VolCatInfo.VolCatErrors++;
92 Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
94 dev->state |= (ST_EOF | ST_EOT | ST_WEOT);
97 #define CHECK_LAST_BLOCK
98 #ifdef CHECK_LAST_BLOCK
101 * then re-read it and verify that the block number is
104 - if (dev->state & ST_TAPE && dev_cap(dev, CAP_BSR)) {
105 + if (ok && dev->state & ST_TAPE && dev_cap(dev, CAP_BSR)) {
107 /* Now back up over what we wrote and read the last block */
108 if (!bsf_dev(dev, 1)) {