]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Probably fix for bug #1188 where Volume is purged while writing
authorKern Sibbald <kern@sibbald.com>
Tue, 18 Nov 2008 19:50:45 +0000 (19:50 +0000)
committerKern Sibbald <kern@sibbald.com>
Tue, 18 Nov 2008 19:50:45 +0000 (19:50 +0000)
     on it.
kes  Get message enhancement to avoid job name lookup.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8056 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/patches/2.4.3-getmsg.patch [new file with mode: 0644]
bacula/patches/2.4.3-purge-bug.patch [new file with mode: 0644]
bacula/src/dird/ua_purge.c
bacula/technotes-2.5

diff --git a/bacula/patches/2.4.3-getmsg.patch b/bacula/patches/2.4.3-getmsg.patch
new file mode 100644 (file)
index 0000000..926cbcd
--- /dev/null
@@ -0,0 +1,135 @@
+ This patch used the jcr stored in the BSOCK packet during callbacks
+ to the Director rather than looking them up in the JCR list.
+
+ It can be applied to Bacula version 2.4.3 (or earlier) with:
+
+ cd <bacula-source>
+ patch -p0 <2.4.3-getmsg.patch
+ ./configure <your options>
+ make
+ ...
+ make install
+
+
+Index: src/dird/getmsg.c
+===================================================================
+--- src/dird/getmsg.c  (revision 7970)
++++ src/dird/getmsg.c  (working copy)
+@@ -1,7 +1,7 @@
+ /*
+    Bacula® - The Network Backup Solution
+-   Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
++   Copyright (C) 2000-2008 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.
+@@ -20,7 +20,7 @@
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+    02110-1301, USA.
+-   Bacula® is a registered trademark of John Walker.
++   Bacula® is a registered trademark of Kern Sibbald.
+    The licensor of Bacula is the Free Software Foundation Europe
+    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+    Switzerland, email:ftf@fsfeurope.org.
+@@ -102,12 +102,12 @@
+    char Job[MAX_NAME_LENGTH];
+    char MsgType[20];
+    int type, level;
+-   JCR *jcr;
++   JCR *jcr = bs->jcr();
+    char *msg;
+    for (;;) {
+       n = bs->recv();
+-      Dmsg2(100, "bget_dirmsg %d: %s", n, bs->msg);
++      Dmsg2(300, "bget_dirmsg %d: %s\n", n, bs->msg);
+       if (is_bnet_stop(bs)) {
+          return n;                    /* error or terminate */
+@@ -142,7 +142,7 @@
+             bs->fsend("btime %s\n", edit_uint64(get_current_btime(),ed1));
+             break;
+          default:
+-            Emsg1(M_WARNING, 0, _("bget_dirmsg: unknown bnet signal %d\n"), bs->msglen);
++            Jmsg1(jcr, M_WARNING, 0, _("bget_dirmsg: unknown bnet signal %d\n"), bs->msglen);
+             return n;
+          }
+          continue;
+@@ -160,21 +160,13 @@
+        *  Try to fulfill it.
+        */
+       if (sscanf(bs->msg, "%020s Job=%127s ", MsgType, Job) != 2) {
+-         Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
++         Jmsg1(jcr, M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
+          continue;
+       }
+-      if (strcmp(Job, "*System*") == 0) {
+-         jcr = NULL;                  /* No jcr */
+-      } else if (!(jcr=get_jcr_by_full_name(Job))) {
+-         Emsg1(M_ERROR, 0, _("Job not found: %s\n"), bs->msg);
+-         continue;
+-      }
+-      Dmsg1(900, "Getmsg got jcr 0x%x\n", jcr);
+       /* Skip past "Jmsg Job=nnn" */
+       if (!(msg=find_msg_start(bs->msg))) {
+-         Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
+-         free_jcr(jcr);
++         Jmsg1(jcr, M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
+          continue;
+       }
+@@ -185,8 +177,7 @@
+       if (bs->msg[0] == 'J') {           /* Job message */
+          if (sscanf(bs->msg, "Jmsg Job=%127s type=%d level=%d",
+                     Job, &type, &level) != 3) {
+-            Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
+-            free_jcr(jcr);
++            Jmsg1(jcr, M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
+             continue;
+          }
+          Dmsg1(900, "Got msg: %s\n", bs->msg);
+@@ -199,7 +190,6 @@
+          }
+          Dmsg1(900, "Dispatch msg: %s", msg);
+          dispatch_message(jcr, type, level, msg);
+-         free_jcr(jcr);
+          continue;
+       }
+       /*
+@@ -209,21 +199,16 @@
+       if (bs->msg[0] == 'C') {        /* Catalog request */
+          Dmsg2(900, "Catalog req jcr 0x%x: %s", jcr, bs->msg);
+          catalog_request(jcr, bs);
+-         Dmsg1(900, "Calling freejcr 0x%x\n", jcr);
+-         free_jcr(jcr);
+          continue;
+       }
+       if (bs->msg[0] == 'U') {        /* SD sending attributes */
+          Dmsg2(900, "Catalog upd jcr 0x%x: %s", jcr, bs->msg);
+          catalog_update(jcr, bs);
+-         Dmsg1(900, "Calling freejcr 0x%x\n", jcr);
+-         free_jcr(jcr);
+          continue;
+       }
+       if (bs->msg[0] == 'M') {        /* Mount request */
+          Dmsg1(900, "Mount req: %s", bs->msg);
+          mount_request(jcr, bs, msg);
+-         free_jcr(jcr);
+          continue;
+       }
+       if (bs->msg[0] == 'S') {       /* Status change */
+@@ -232,9 +217,8 @@
+          if (sscanf(bs->msg, Job_status, &Job, &JobStatus) == 2) {
+             jcr->SDJobStatus = JobStatus; /* current status */
+          } else {
+-            Emsg1(M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
++            Jmsg1(jcr, M_ERROR, 0, _("Malformed message: %s\n"), bs->msg);
+          }
+-         free_jcr(jcr);
+          continue;
+       }
+ #ifdef needed
diff --git a/bacula/patches/2.4.3-purge-bug.patch b/bacula/patches/2.4.3-purge-bug.patch
new file mode 100644 (file)
index 0000000..4682962
--- /dev/null
@@ -0,0 +1,29 @@
+
+ This patch corrects appears to fix bug #1188, where a Volume can
+ be purged while it is being written.
+
+ Apply it to Bacula 2.4.3 (possibly earlier versions)
+ with:
+
+ cd <bacula-source>
+ patch -p0 <2.4.3-purge-bug.patch
+ ./configure <your-options>
+ make
+ ...
+ make install
+
+
+Index: src/dird/ua_purge.c
+===================================================================
+--- src/dird/ua_purge.c        (revision 8054)
++++ src/dird/ua_purge.c        (working copy)
+@@ -463,6 +463,9 @@
+    bool purged = false;
+    char ed1[50];
++   if (mr->FirstWritten == 0 || mr->LastWritten == 0) {
++      goto bail_out;               /* not written cannot purge */
++   }
+    if (strcmp(mr->VolStatus, "Purged") == 0) {
+       purged = true;
+       goto bail_out;
index d4b66e0ce9ac5949a150f9dcc4d8db443ddef119..d34c07baaf0746aecd023e63d48bd3c5718c9852 100644 (file)
@@ -463,6 +463,9 @@ bool is_volume_purged(UAContext *ua, MEDIA_DBR *mr)
    bool purged = false;
    char ed1[50];
 
+   if (mr->FirstWritten == 0 || mr->LastWritten == 0) {
+      goto bail_out;               /* not written cannot purge */
+   }
    if (strcmp(mr->VolStatus, "Purged") == 0) {
       purged = true;
       goto bail_out;
index 34cccf50f612d58080f530665192c7cd6890fdec..c551f0148b73c8d56add4bc6ae6f24c35a8bfa7d 100644 (file)
@@ -11,6 +11,8 @@ mixed priorities
 
 General:
 18Nov08
+kes  kes  Probably fix for bug #1188 where Volume is purged while writing
+     on it.
 kes  Implement bsr block level checking for disk files. However,
      it does not work correctly in accurate tests, and all the
      migration and copy tests, so it is turned off.