]> git.sur5r.net Git - bacula/bacula/commitdiff
Update rescue disk to include mkinitrd
authorKern Sibbald <kern@sibbald.com>
Sun, 19 Dec 2004 16:39:42 +0000 (16:39 +0000)
committerKern Sibbald <kern@sibbald.com>
Sun, 19 Dec 2004 16:39:42 +0000 (16:39 +0000)
- Fix umount_drives in rescue disk (only one arg to umount)
- Ensure that if SD is manually set in Console, it is used.
- Put generate_event on pointer and plug it in init. This
  permits using it in /lib
- Correct despooling size reported to be Job specific rather
  than for the whole drive.

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

bacula/patches/1.36.1-spool.patch [new file with mode: 0644]
bacula/patches/patches-1.36.1
bacula/src/dird/msgchan.c
bacula/src/dird/ua_run.c
bacula/src/lib/mem_pool.c
bacula/src/lib/protos.h
bacula/src/lib/python.c
bacula/src/stored/spool.c

diff --git a/bacula/patches/1.36.1-spool.patch b/bacula/patches/1.36.1-spool.patch
new file mode 100644 (file)
index 0000000..899d755
--- /dev/null
@@ -0,0 +1,28 @@
+
+ This patch fixes the despooling size printed in the Job 
+ report. Previously, it reported the total size for the
+ device. This patch makes it report the size for the job.
+ Apply the patch to 1.36.1 with:
+
+ cd <bacula-source>
+ patch -p0 <1.36.1-spool.patch
+ make
+ make install
+ ...
+
+Index: src/stored/spool.c
+===================================================================
+RCS file: /cvsroot/bacula/bacula/src/stored/spool.c,v
+retrieving revision 1.22
+diff -u -r1.22 spool.c
+--- src/stored/spool.c 16 Oct 2004 11:51:32 -0000      1.22
++++ src/stored/spool.c 18 Dec 2004 20:39:02 -0000
+@@ -201,7 +201,7 @@
+    Dmsg0(100, "Despooling data\n");
+    Jmsg(jcr, M_INFO, 0, _("%s spooled data to Volume. Despooling %s bytes ...\n"),
+         commit?"Committing":"Writing",
+-      edit_uint64_with_commas(jcr->dcr->dev->spool_size, ec1));
++      edit_uint64_with_commas(jcr->dcr->spool_size, ec1));
+    dcr->spooling = false;
+    lock_device(dcr->dev);
+    dcr->dev_locked = true; 
index 3d04705f7a0d01133dc0364ad801240f42c0e735..cf12c35f1c3199a332249988ffff84e64e3c908f 100644 (file)
@@ -7,3 +7,8 @@
 03Dec04  1.16.1-slots.patch
  This patch should fix "update slots" with two different magazines
  in different pools by checking the pool when zapping the InChanger.
+
+18Dec04
+ This patch fixes the despooling size printed in the Job 
+ report. Previously, it reported the total size for the
+ device. This patch makes it report the size for the job.
index 0cc64ea907529f848f5cfaf8ca092b4a7b8efbc2..fc854195a855a92e27d035cbce3a54bdf447c002 100644 (file)
@@ -16,7 +16,7 @@
  *   Version $Id$
  */
 /*
-   Copyright (C) 2000-2004 Kern Sibbald and John Walker
+   Copyright (C) 2000-2004 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -141,27 +141,37 @@ int start_storage_daemon_job(JCR *jcr)
     */
 
    for (i=0; i < MAX_STORE; i++) {
+      /* 
+       * if storage[0] == NULL, storage was manually overridden in
+       *   a Console run command.
+       */
       if (jcr->storage[i]) {
         storage = (STORE *)jcr->storage[i]->first();
-        pm_strcpy(device_name, storage->dev_name);
-        pm_strcpy(media_type, storage->media_type);
-        pm_strcpy(pool_type, jcr->pool->pool_type);
-        pm_strcpy(pool_name, jcr->pool->hdr.name);
-        bash_spaces(device_name);
-        bash_spaces(media_type);
-        bash_spaces(pool_type);
-        bash_spaces(pool_name);
-        bnet_fsend(sd, use_device, device_name.c_str(), 
-                   media_type.c_str(), pool_name.c_str(), pool_type.c_str());
-         Dmsg1(110, ">stored: %s", sd->msg);
-         status = response(jcr, sd, OK_device, "Use Device", NO_DISPLAY);
-        if (!status) {
-           pm_strcpy(pool_type, sd->msg); /* save message */
-            Jmsg(jcr, M_FATAL, 0, _("\n"
-               "     Storage daemon didn't accept Device \"%s\" because:\n     %s"),
-              device_name.c_str(), pool_type.c_str()/* sd->msg */);
+      } else {
+        if (i == 0) {
+           storage = jcr->store;
+        } else {
+           continue;
         }
       }
+      pm_strcpy(device_name, storage->dev_name);
+      pm_strcpy(media_type, storage->media_type);
+      pm_strcpy(pool_type, jcr->pool->pool_type);
+      pm_strcpy(pool_name, jcr->pool->hdr.name);
+      bash_spaces(device_name);
+      bash_spaces(media_type);
+      bash_spaces(pool_type);
+      bash_spaces(pool_name);
+      bnet_fsend(sd, use_device, device_name.c_str(), 
+                media_type.c_str(), pool_name.c_str(), pool_type.c_str());
+      Dmsg1(110, ">stored: %s", sd->msg);
+      status = response(jcr, sd, OK_device, "Use Device", NO_DISPLAY);
+      if (!status) {
+        pm_strcpy(pool_type, sd->msg); /* save message */
+         Jmsg(jcr, M_FATAL, 0, _("\n"
+            "     Storage daemon didn't accept Device \"%s\" because:\n     %s"),
+           device_name.c_str(), pool_type.c_str()/* sd->msg */);
+      }
    }
    return status;
 }
index 89c0e200f6d75d539cffc870da7e133339f8007f..9a95b87cc886d0b1993f608272d8ee7ad1b72ca5 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 /*
-   Copyright (C) 2001-2004 Kern Sibbald and John Walker
+   Copyright (C) 2001-2004 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -104,7 +104,7 @@ int run_cmd(UAContext *ua, const char *cmd)
    catalog_name = NULL;
 
    for (i=1; i<ua->argc; i++) {
-      Dmsg2(200, "Doing arg %d = %s\n", i, ua->argk[i]);
+      Dmsg2(800, "Doing arg %d = %s\n", i, ua->argk[i]);
       kw_ok = false;
       /* Keep looking until we find a good keyword */
       for (j=0; !kw_ok && kw[j]; j++) {
@@ -114,7 +114,7 @@ int run_cmd(UAContext *ua, const char *cmd)
                bsendmsg(ua, _("Value missing for keyword %s\n"), ua->argk[i]);
               return 1;
            }
-            Dmsg1(200, "Got keyword=%s\n", kw[j]);
+            Dmsg1(800, "Got keyword=%s\n", kw[j]);
            switch (j) {
            case 0: /* job */
               if (job_name) {
@@ -263,7 +263,7 @@ int run_cmd(UAContext *ua, const char *cmd)
       }
    } /* end argc loop */
             
-   Dmsg0(200, "Done scan.\n");
+   Dmsg0(800, "Done scan.\n");
 
    CAT *catalog = NULL;
    if (catalog_name != NULL) {
@@ -273,6 +273,7 @@ int run_cmd(UAContext *ua, const char *cmd)
           return 0;
        }
    }
+   Dmsg1(200, "Using catalog=%s\n", catalog_name);
 
    if (job_name) {
       /* Find Job */
@@ -315,6 +316,7 @@ int run_cmd(UAContext *ua, const char *cmd)
               store->hdr.name);
       return 0;
    }
+   Dmsg1(200, "Using storage=%s\n", store->hdr.name);
 
    if (pool_name) {
       pool = (POOL *)GetResWithName(R_POOL, pool_name);
@@ -334,6 +336,7 @@ int run_cmd(UAContext *ua, const char *cmd)
               pool->hdr.name);
       return 0;
    }
+   Dmsg1(200, "Using pool\n", pool->hdr.name);
 
    if (client_name) {
       client = (CLIENT *)GetResWithName(R_CLIENT, client_name);
@@ -353,6 +356,7 @@ int run_cmd(UAContext *ua, const char *cmd)
               client->hdr.name);
       return 0;
    }
+   Dmsg1(200, "Using client=%s\n", client->hdr.name);
 
    if (fileset_name) {
       fileset = (FILESET *)GetResWithName(R_FILESET, fileset_name);
@@ -390,6 +394,12 @@ int run_cmd(UAContext *ua, const char *cmd)
 
    jcr->verify_job = verify_job;
    jcr->store = store;
+   /* If specific name given, zap all other stores */
+   if (store_name) {
+      for (i=0; i < MAX_STORE; i++) {
+        jcr->storage[i] = NULL;
+      }
+   }
    jcr->client = client;
    jcr->fileset = fileset;
    jcr->pool = pool;
index 0a2624243c2afc1c804cd7b87cf39426f1b1a80d..15497c24a1522db9a17392b30e37d8a9fd5298a3 100644 (file)
  *  there is enough memory, simply call the check_pool_memory_size()
  *  with the desired size and it will adjust only if necessary.
  *
- *           Kern E. Sibbald
+ *          Kern E. Sibbald
  *
  *   Version $Id$
  */
 
 /*
-   Copyright (C) 2000-2004 Kern Sibbald and John Walker
+   Copyright (C) 2000-2004 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
 #include "bacula.h"
 
 struct s_pool_ctl {
-   int32_t size;                      /* default size */
-   int32_t max_allocated;             /* max allocated */
-   int32_t max_used;                  /* max buffers used */
-   int32_t in_use;                    /* number in use */
-   struct abufhead *free_buf;         /* pointer to free buffers */
+   int32_t size;                     /* default size */
+   int32_t max_allocated;            /* max allocated */
+   int32_t max_used;                 /* max buffers used */
+   int32_t in_use;                   /* number in use */
+   struct abufhead *free_buf;        /* pointer to free buffers */
 };
 
 /* Bacula Name length plus extra */
@@ -59,30 +59,30 @@ struct s_pool_ctl {
  * Define default Pool buffer sizes
  */
 static struct s_pool_ctl pool_ctl[] = {
-   {  256,  256, 0, 0, NULL },        /* PM_NOPOOL no pooling */
-   {  NLEN, NLEN,0, 0, NULL },        /* PM_NAME Bacula name */
-   {  256,  256, 0, 0, NULL },        /* PM_FNAME filename buffers */
-   {  512,  512, 0, 0, NULL },        /* PM_MESSAGE message buffer */
-   { 1024, 1024, 0, 0, NULL }         /* PM_EMSG error message buffer */
+   {  256,  256, 0, 0, NULL },       /* PM_NOPOOL no pooling */
+   {  NLEN, NLEN,0, 0, NULL },       /* PM_NAME Bacula name */
+   {  256,  256, 0, 0, NULL },       /* PM_FNAME filename buffers */
+   {  512,  512, 0, 0, NULL },       /* PM_MESSAGE message buffer */
+   { 1024, 1024, 0, 0, NULL }        /* PM_EMSG error message buffer */
 };
 #else
 
 /* This is used ONLY when stress testing the code */
 static struct s_pool_ctl pool_ctl[] = {
-   {   20,   20, 0, 0, NULL },        /* PM_NOPOOL no pooling */
-   {  NLEN, NLEN,0, 0, NULL },        /* PM_NAME Bacula name */
-   {   20,   20, 0, 0, NULL },        /* PM_FNAME filename buffers */
-   {   20,   20, 0, 0, NULL },        /* PM_MESSAGE message buffer */
-   {   20,   20, 0, 0, NULL }         /* PM_EMSG error message buffer */
+   {   20,   20, 0, 0, NULL },       /* PM_NOPOOL no pooling */
+   {  NLEN, NLEN,0, 0, NULL },       /* PM_NAME Bacula name */
+   {   20,   20, 0, 0, NULL },       /* PM_FNAME filename buffers */
+   {   20,   20, 0, 0, NULL },       /* PM_MESSAGE message buffer */
+   {   20,   20, 0, 0, NULL }        /* PM_EMSG error message buffer */
 };
 #endif
 
 
 /*  Memory allocation control structures and storage.  */
 struct abufhead {
-   int32_t ablen;                     /* Buffer length in bytes */
-   int32_t pool;                      /* pool */
-   struct abufhead *next;             /* pointer to next free buffer */
+   int32_t ablen;                    /* Buffer length in bytes */
+   int32_t pool;                     /* pool */
+   struct abufhead *next;            /* pointer to next free buffer */
 };
 
 static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -105,10 +105,10 @@ POOLMEM *sm_get_pool_memory(const char *fname, int lineno, int pool)
       pool_ctl[pool].free_buf = buf->next;
       pool_ctl[pool].in_use++;
       if (pool_ctl[pool].in_use > pool_ctl[pool].max_used) {
-         pool_ctl[pool].max_used = pool_ctl[pool].in_use;
+        pool_ctl[pool].max_used = pool_ctl[pool].in_use;
       }
       V(mutex);
-      Dmsg3(300, "sm_get_pool_memory reuse %x to %s:%d\n", buf, fname, lineno);
+      Dmsg3(800, "sm_get_pool_memory reuse %x to %s:%d\n", buf, fname, lineno);
       sm_new_owner(fname, lineno, (char *)buf);
       return (POOLMEM *)((char *)buf+HEAD_SIZE);
    }
@@ -124,7 +124,7 @@ POOLMEM *sm_get_pool_memory(const char *fname, int lineno, int pool)
       pool_ctl[pool].max_used = pool_ctl[pool].in_use;
    }
    V(mutex);
-   Dmsg3(300, "sm_get_pool_memory give %x to %s:%d\n", buf, fname, lineno);
+   Dmsg3(800, "sm_get_pool_memory give %x to %s:%d\n", buf, fname, lineno);
    return (POOLMEM *)((char *)buf+HEAD_SIZE);
 }
 
@@ -202,30 +202,30 @@ void sm_free_pool_memory(const char *fname, int lineno, POOLMEM *obuf)
    pool = buf->pool;
    pool_ctl[pool].in_use--;
    if (pool == 0) {
-      free((char *)buf);              /* free nonpooled memory */
-   } else {                           /* otherwise link it to the free pool chain */
+      free((char *)buf);             /* free nonpooled memory */
+   } else {                          /* otherwise link it to the free pool chain */
 #ifdef DEBUG
       struct abufhead *next;
       /* Don't let him free the same buffer twice */
       for (next=pool_ctl[pool].free_buf; next; next=next->next) {
-         if (next == buf) {
-            Dmsg4(300, "bad free_pool_memory %x pool=%d from %s:%d\n", buf, pool, fname, lineno);
-            V(mutex);                 /* unblock the pool */
-            ASSERT(next != buf);      /* attempt to free twice */
-         }
+        if (next == buf) {
+            Dmsg4(800, "bad free_pool_memory %x pool=%d from %s:%d\n", buf, pool, fname, lineno);
+           V(mutex);                 /* unblock the pool */
+           ASSERT(next != buf);      /* attempt to free twice */
+        }
       }
 #endif
       buf->next = pool_ctl[pool].free_buf;
       pool_ctl[pool].free_buf = buf;
    }
-   Dmsg4(300, "free_pool_memory %x pool=%d from %s:%d\n", buf, pool, fname, lineno);
+   Dmsg4(800, "free_pool_memory %x pool=%d from %s:%d\n", buf, pool, fname, lineno);
    V(mutex);
 }
 
 
 #else
 
-/* =========  NO SMARTALLOC  =========================================  */
+/* =========  NO SMARTALLOC  ========================================= */
 
 POOLMEM *get_pool_memory(int pool)
 {
@@ -332,22 +332,22 @@ void free_pool_memory(POOLMEM *obuf)
    pool = buf->pool;
    pool_ctl[pool].in_use--;
    if (pool == 0) {
-      free((char *)buf);              /* free nonpooled memory */
-   } else {                           /* otherwise link it to the free pool chain */
+      free((char *)buf);             /* free nonpooled memory */
+   } else {                          /* otherwise link it to the free pool chain */
 #ifdef DEBUG
       struct abufhead *next;
       /* Don't let him free the same buffer twice */
       for (next=pool_ctl[pool].free_buf; next; next=next->next) {
-         if (next == buf) {
-            V(mutex);
-            ASSERT(next != buf);  /* attempt to free twice */
-         }
+        if (next == buf) {
+           V(mutex);
+           ASSERT(next != buf);  /* attempt to free twice */
+        }
       }
 #endif
       buf->next = pool_ctl[pool].free_buf;
       pool_ctl[pool].free_buf = buf;
    }
-   Dmsg2(300, "free_pool_memory %x pool=%d\n", buf, pool);
+   Dmsg2(800, "free_pool_memory %x pool=%d\n", buf, pool);
    V(mutex);
 }
 
@@ -368,9 +368,9 @@ void close_memory_pool()
    for (int i=1; i<=PM_MAX; i++) {
       buf = pool_ctl[i].free_buf;
       while (buf) {
-         next = buf->next;
-         free((char *)buf);
-         buf = next;
+        next = buf->next;
+        free((char *)buf);
+        buf = next;
       }
       pool_ctl[i].free_buf = NULL;
    }
@@ -398,7 +398,7 @@ void print_memory_pool_stats()
    Dmsg0(-1, "Pool   Maxsize  Maxused  Inuse\n");
    for (int i=0; i<=PM_MAX; i++)
       Dmsg4(-1, "%5s  %7d  %7d  %5d\n", pool_name(i), pool_ctl[i].max_allocated,
-         pool_ctl[i].max_used, pool_ctl[i].in_use);
+        pool_ctl[i].max_used, pool_ctl[i].in_use);
 
    Dmsg0(-1, "\n");
 }
index a04e1f08e16e34f3fb861e22ae6ee22d03c52029..ba5bad997b825556a8b16bd92c7c9f58e339cef1 100644 (file)
@@ -174,9 +174,10 @@ char *getgroup (gid_t gid);
 void free_getgroup_cache();
 
 /* python.c */
+typedef int (EVENT_HANDLER)(JCR *jcr, const char *event);
 void init_python_interpreter(const char *progname, const char *scripts);
 void term_python_interpreter();
-int generate_event(JCR *jcr, const char *event);
+extern EVENT_HANDLER *generate_event;
 
 /* signal.c */
 void             init_signals             (void terminate(int sig));
index cffef6f539c0ecfef315469f8ceebf8dab01f5e8..789ea749d6f741de1d761a4c33dc3102af3fe6d2 100644 (file)
 #ifdef HAVE_PYTHON
 #include <Python.h>
 
+EVENT_HANDLER *generate_event;
 
 PyObject *bacula_get(PyObject *self, PyObject *args);
 PyObject *bacula_set(PyObject *self, PyObject *args, PyObject *keyw);
+int _generate_event(JCR *jcr, const char *event);
 
 /* Pull in Bacula entry points */
 extern PyMethodDef BaculaMethods[];
@@ -53,6 +55,7 @@ void init_python_interpreter(const char *progname, const char *scripts)
             "sys.path.append('%s')\n", scripts);
    PyRun_SimpleString(buf);
    PyEval_ReleaseLock();
+   generate_event = _generate_event;
 }
 
 void term_python_interpreter()
@@ -69,7 +72,7 @@ void term_python_interpreter()
  *         -1 on Python error
  *          1 OK
  */
-int generate_event(JCR *jcr, const char *event)
+int _generate_event(JCR *jcr, const char *event)
 {
    PyObject *pName, *pModule, *pDict, *pFunc;
    PyObject *pArgs, *pValue;
@@ -135,8 +138,11 @@ int generate_event(JCR *jcr, const char *event)
  *  No Python configured
  */
 
-int generate_event(JCR *jcr, const char *event) { return 0; }
-void init_python_interpreter(const char *progname, const char *scripts) { }
+int _generate_event(JCR *jcr, const char *event) { return 0; }
+void init_python_interpreter(const char *progname, const char *scripts)
+{
+   generate_event = _generate_event;   
+}
 void term_python_interpreter() { }
 
 
index ffe17ae8933cb8a3f4c25fa7c2246e27d1056a59..5e05173f5a646024043233030b603c7237cbbe61 100644 (file)
@@ -201,7 +201,7 @@ static bool despool_data(DCR *dcr, bool commit)
    Dmsg0(100, "Despooling data\n");
    Jmsg(jcr, M_INFO, 0, _("%s spooled data to Volume. Despooling %s bytes ...\n"),
         commit?"Committing":"Writing",
-       edit_uint64_with_commas(jcr->dcr->dev->spool_size, ec1));
+       edit_uint64_with_commas(jcr->dcr->spool_size, ec1));
    dcr->spooling = false;
    lock_device(dcr->dev);
    dcr->dev_locked = true;