]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/1.34.6/1.34.6-block.patch
ebl Add patch to allow a more easy selection for restore
[bacula/bacula] / bacula / patches / 1.34.6 / 1.34.6-block.patch
1
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.
9
10 Apply the patch to Bacula 1.34.6 (possibly earlier versions)
11 with:
12
13   cd <bacula-source>
14   patch -p0 <1.34.6-block.patch
15   make
16   make install
17   ...
18
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
26 @@ -356,7 +356,7 @@
27        /* Create a jobmedia record for this job */
28        if (!dir_create_jobmedia_record(jcr)) {
29          dev->dev_errno = EIO;
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);
34          stat = 0;
35 @@ -372,7 +372,11 @@
36     }
37  
38     if (!write_block_to_dev(dcr, block)) {
39 -       stat = fixup_device_block_write_error(jcr, dev, block);
40 +       if (job_canceled(jcr)) {
41 +         stat = 0;
42 +       } else {
43 +         stat = fixup_device_block_write_error(jcr, dev, block);
44 +       }
45     }
46  
47  bail_out:
48 @@ -393,7 +397,7 @@
49     ssize_t stat = 0;
50     uint32_t wlen;                    /* length to write */
51     int hit_max1, hit_max2;
52 -   bool ok;
53 +   bool ok = true;
54     DEVICE *dev = dcr->dev;
55     JCR *jcr = dcr->jcr;
56  
57 @@ -463,9 +467,9 @@
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++;
64 -      }
65 +      } 
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;
69 @@ -485,7 +489,7 @@
70  
71        if (dev_state(dev, ST_TAPE) && weof_dev(dev, 1) != 0) {           /* write eof */
72          /* 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);
78 @@ -559,18 +563,18 @@
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);
84 +        ok = false;
85        }
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);
93        }
94        dev->state |= (ST_EOF | ST_EOT | ST_WEOT);
95         
96 -      ok = true;
97  #define CHECK_LAST_BLOCK
98  #ifdef CHECK_LAST_BLOCK
99        /* 
100 @@ -580,7 +584,7 @@
101         *   then re-read it and verify that the block number is
102         *   correct.
103         */
104 -      if (dev->state & ST_TAPE && dev_cap(dev, CAP_BSR)) {
105 +      if (ok && dev->state & ST_TAPE && dev_cap(dev, CAP_BSR)) {
106  
107          /* Now back up over what we wrote and read the last block */
108          if (!bsf_dev(dev, 1)) {