From: Kern Sibbald Date: Sun, 19 Dec 2004 16:39:42 +0000 (+0000) Subject: Update rescue disk to include mkinitrd X-Git-Tag: Release-1.38.0~698 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a43ad1c17087c1fc16cac48e716f3a0af775e226;p=bacula%2Fbacula Update rescue disk to include mkinitrd - 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 --- diff --git a/bacula/patches/1.36.1-spool.patch b/bacula/patches/1.36.1-spool.patch new file mode 100644 index 0000000000..899d7552b9 --- /dev/null +++ b/bacula/patches/1.36.1-spool.patch @@ -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 + 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; diff --git a/bacula/patches/patches-1.36.1 b/bacula/patches/patches-1.36.1 index 3d04705f7a..cf12c35f1c 100644 --- a/bacula/patches/patches-1.36.1 +++ b/bacula/patches/patches-1.36.1 @@ -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. diff --git a/bacula/src/dird/msgchan.c b/bacula/src/dird/msgchan.c index 0cc64ea907..fc854195a8 100644 --- a/bacula/src/dird/msgchan.c +++ b/bacula/src/dird/msgchan.c @@ -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; } diff --git a/bacula/src/dird/ua_run.c b/bacula/src/dird/ua_run.c index 89c0e200f6..9a95b87cc8 100644 --- a/bacula/src/dird/ua_run.c +++ b/bacula/src/dird/ua_run.c @@ -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; iargc; 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; diff --git a/bacula/src/lib/mem_pool.c b/bacula/src/lib/mem_pool.c index 0a2624243c..15497c24a1 100644 --- a/bacula/src/lib/mem_pool.c +++ b/bacula/src/lib/mem_pool.c @@ -15,13 +15,13 @@ * 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 @@ -43,11 +43,11 @@ #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"); } diff --git a/bacula/src/lib/protos.h b/bacula/src/lib/protos.h index a04e1f08e1..ba5bad997b 100644 --- a/bacula/src/lib/protos.h +++ b/bacula/src/lib/protos.h @@ -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)); diff --git a/bacula/src/lib/python.c b/bacula/src/lib/python.c index cffef6f539..789ea749d6 100644 --- a/bacula/src/lib/python.c +++ b/bacula/src/lib/python.c @@ -33,9 +33,11 @@ #ifdef HAVE_PYTHON #include +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() { } diff --git a/bacula/src/stored/spool.c b/bacula/src/stored/spool.c index ffe17ae893..5e05173f5a 100644 --- a/bacula/src/stored/spool.c +++ b/bacula/src/stored/spool.c @@ -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;