From 9adda15d15364a03b51984780eefbfb23110414b Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 21 Apr 2011 12:57:20 +0200 Subject: [PATCH] Change all sm_checks into Dsm_check for performance reasons --- bacula/src/dird/job.c | 10 +++++----- bacula/src/filed/backup.c | 4 ++-- bacula/src/filed/job.c | 2 +- bacula/src/lib/bpipe.c | 6 +++--- bacula/src/lib/bsock.c | 8 ++++++-- bacula/src/stored/btape.c | 23 +++++++++++------------ bacula/src/stored/dev.c | 8 ++++---- bacula/src/stored/dvd.c | 16 ++++++++-------- bacula/src/stored/job.c | 4 ++-- bacula/src/stored/scan.c | 5 ++--- 10 files changed, 44 insertions(+), 42 deletions(-) diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index 056c4cb522..d428bd064b 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -104,7 +104,7 @@ bool setup_job(JCR *jcr) int errstat; jcr->lock(); - sm_check(__FILE__, __LINE__, true); + Dsm_check(100); init_msg(jcr, jcr->messages); /* Initialize termination condition variable */ @@ -234,7 +234,7 @@ bool setup_job(JCR *jcr) generate_job_event(jcr, "JobInit"); generate_plugin_event(jcr, bEventJobInit); - Dsm_check(1); + Dsm_check(100); return true; bail_out: @@ -259,7 +259,7 @@ static void *job_thread(void *arg) JCR *jcr = (JCR *)arg; pthread_detach(pthread_self()); - Dsm_check(1); + Dsm_check(100); Dmsg0(200, "=====Start Job=========\n"); jcr->setJobStatus(JS_Running); /* this will be set only if no error */ @@ -360,7 +360,7 @@ static void *job_thread(void *arg) generate_daemon_event(jcr, "JobEnd"); generate_plugin_event(jcr, bEventJobEnd); Dmsg1(50, "======== End Job stat=%c ==========\n", jcr->JobStatus); - sm_check(__FILE__, __LINE__, true); + Dsm_check(100); return NULL; } @@ -531,7 +531,7 @@ static void job_monitor_watchdog(watchdog_t *self) control_jcr = (JCR *)self->data; - Dsm_check(1); + Dsm_check(100); Dmsg1(800, "job_monitor_watchdog %p called\n", self); foreach_jcr(jcr) { diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index ab842c3280..21b1906de1 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -1344,7 +1344,7 @@ void strip_path(FF_PKT *ff_pkt) pm_strcpy(ff_pkt->link_save, ff_pkt->link); Dmsg2(500, "strcpy link_save=%d link=%d\n", strlen(ff_pkt->link_save), strlen(ff_pkt->link)); - sm_check(__FILE__, __LINE__, true); + Dsm_check(200); } /** @@ -1383,7 +1383,7 @@ void unstrip_path(FF_PKT *ff_pkt) strcpy(ff_pkt->link, ff_pkt->link_save); Dmsg2(500, "strcpy link=%d link_save=%d\n", strlen(ff_pkt->link), strlen(ff_pkt->link_save)); - sm_check(__FILE__, __LINE__, true); + Dsm_check(200); } } diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index fdc767b479..1820fc9850 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -401,7 +401,7 @@ void *handle_client_request(void *dirp) Dmsg0(100, "Done with term_find_files\n"); free_jcr(jcr); /* destroy JCR record */ Dmsg0(100, "Done with free_jcr\n"); - Dsm_check(1); + Dsm_check(100); garbage_collect_memory_pool(); return NULL; } diff --git a/bacula/src/lib/bpipe.c b/bacula/src/lib/bpipe.c index 79a6c0cbce..ad2e7ad36d 100644 --- a/bacula/src/lib/bpipe.c +++ b/bacula/src/lib/bpipe.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2002-2010 Free Software Foundation Europe e.V. + Copyright (C) 2002-2011 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. @@ -394,7 +394,7 @@ int run_program_full_output(char *prog, int wait, POOLMEM *&results) const int bufsize = 32000; - sm_check(__FILE__, __LINE__, false); + Dsm_check(200); tmp = get_pool_memory(PM_MESSAGE); buf = (char *)malloc(bufsize+1); @@ -407,7 +407,7 @@ int run_program_full_output(char *prog, int wait, POOLMEM *&results) goto bail_out; } - sm_check(__FILE__, __LINE__, false); + Dsm_check(200); tmp[0] = 0; while (1) { buf[0] = 0; diff --git a/bacula/src/lib/bsock.c b/bacula/src/lib/bsock.c index ed0e47282c..e0bd085f8d 100644 --- a/bacula/src/lib/bsock.c +++ b/bacula/src/lib/bsock.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2007-2010 Free Software Foundation Europe e.V. + Copyright (C) 2007-2011 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. @@ -554,7 +554,11 @@ int32_t BSOCK::recv() * buffer is at least one byte longer than the message length. */ msg[nbytes] = 0; /* terminate in case it is a string */ - sm_check(__FILE__, __LINE__, false); + /* + * The following uses *lots* of resources so turn it on only for + * serious debugging. + */ + Dsm_check(300); get_out: if (m_use_locking) V(m_mutex); diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index dc7ecabb47..d70da195c2 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -317,7 +317,7 @@ int main(int margc, char *margv[]) static void terminate_btape(int stat) { - sm_check(__FILE__, __LINE__, false); + Dsm_check(200); if (configfile) { free(configfile); } @@ -748,7 +748,7 @@ static void rectestcmd() return; } - sm_check(__FILE__, __LINE__, false); + Dsm_check(200); block = new_block(dev); rec = new_record(); @@ -756,7 +756,7 @@ static void rectestcmd() rec->data = check_pool_memory_size(rec->data, i); memset(rec->data, i & 0xFF, i); rec->data_len = i; - sm_check(__FILE__, __LINE__, false); + Dsm_check(200); if (write_record_to_block(block, rec)) { empty_block(block); blkno++; @@ -764,11 +764,11 @@ static void rectestcmd() } else { break; } - sm_check(__FILE__, __LINE__, false); + Dsm_check(200); } free_record(rec); free_block(block); - sm_check(__FILE__, __LINE__, false); + Dsm_check(200); } /* @@ -1888,7 +1888,7 @@ static void wrcmd() if (!dev->is_open()) { open_the_device(); } - sm_check(__FILE__, __LINE__, false); + Dsm_check(200); empty_block(block); if (verbose > 1) { dump_block(block, "test"); @@ -1899,7 +1899,7 @@ static void wrcmd() rec->data = check_pool_memory_size(rec->data, i); memset(rec->data, i & 0xFF, i); rec->data_len = i; - sm_check(__FILE__, __LINE__, false); + Dsm_check(200); if (!write_record_to_block(block, rec)) { Pmsg0(0, _("Error writing record to block.\n")); goto bail_out; @@ -1913,8 +1913,7 @@ static void wrcmd() Pmsg0(0, _("Wrote block to device.\n")); bail_out: - sm_check(__FILE__, __LINE__, false); - sm_check(__FILE__, __LINE__, false); + Dsm_check(200); } /* @@ -2798,7 +2797,7 @@ static void qfillcmd() count = 1000; } - sm_check(__FILE__, __LINE__, false); + Dsm_check(200); i = block->buf_len - 100; ASSERT (i > 0); @@ -2833,7 +2832,7 @@ static void qfillcmd() scan_blocks(); bail_out: - sm_check(__FILE__, __LINE__, false); + Dsm_check(200); } /* @@ -2921,7 +2920,7 @@ do_tape_cmds() bool found; while (!quit && get_cmd("*")) { - sm_check(__FILE__, __LINE__, false); + Dsm_check(200); found = false; parse_args(cmd, &args, &argc, argk, argv, MAX_CMD_ARGS); for (i=0; imount_command; } else { @@ -1992,7 +1992,7 @@ bool DEVICE::do_tape_mount(int mount, int dotimeout) set_mounted(false); free_pool_memory(results); Dmsg0(200, "============ mount=0\n"); - Dsm_check(1); + Dsm_check(200); return false; } @@ -2015,7 +2015,7 @@ bool DEVICE::do_file_mount(int mount, int dotimeout) int status, tries, name_max, count; berrno be; - Dsm_check(1); + Dsm_check(200); if (mount) { icmd = device->mount_command; } else { @@ -2115,7 +2115,7 @@ get_out: set_mounted(false); free_pool_memory(results); Dmsg0(200, "============ mount=0\n"); - Dsm_check(1); + Dsm_check(200); return false; } diff --git a/bacula/src/stored/dvd.c b/bacula/src/stored/dvd.c index dcb6a8e2d2..b0c7656a67 100644 --- a/bacula/src/stored/dvd.c +++ b/bacula/src/stored/dvd.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2005-2010 Free Software Foundation Europe e.V. + Copyright (C) 2005-2011 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. @@ -98,7 +98,7 @@ bool DEVICE::update_freespace() /* The device must be mounted in order to dvd-freespace to work */ mount(1); - sm_check(__FILE__, __LINE__, false); + Dsm_check(400); icmd = device->free_space_command; if (!icmd) { @@ -165,7 +165,7 @@ bool DEVICE::update_freespace() free_pool_memory(results); Dmsg4(29, "leave update_freespace: free_space=%s freespace_ok=%d free_space_errno=%d have_media=%d\n", edit_uint64(free_space, ed1), !!is_freespace_ok(), free_space_errno, !!have_media()); - sm_check(__FILE__, __LINE__, false); + Dsm_check(400); return ok; } @@ -209,7 +209,7 @@ bool dvd_write_part(DCR *dcr) unlink(archive_name.c_str()); dev->set_part_spooled(false); Dmsg1(29, "========= unlink(%s)\n", archive_name.c_str()); - sm_check(__FILE__, __LINE__, false); + Dsm_check(400); return true; } @@ -222,7 +222,7 @@ bool dvd_write_part(DCR *dcr) dev->clear_freespace_ok(); /* need to update freespace */ - sm_check(__FILE__, __LINE__, false); + Dsm_check(400); Dmsg3(29, "dvd_write_part: device is %s, part is %d, is_mounted=%d\n", dev->print_name(), dev->part, dev->is_mounted()); icmd = dev->device->write_part_command; @@ -267,7 +267,7 @@ bool dvd_write_part(DCR *dcr) if (!dev->truncating) { dcr->mark_volume_in_error(); } - sm_check(__FILE__, __LINE__, false); + Dsm_check(400); return false; } Jmsg(dcr->jcr, M_INFO, 0, _("Part %d (%lld bytes) written to DVD.\n"), dev->part, dev->part_size); @@ -284,14 +284,14 @@ bool dvd_write_part(DCR *dcr) unlink(archive_name.c_str()); dev->set_part_spooled(false); Dmsg1(29, "========= unlink(%s)\n", archive_name.c_str()); - sm_check(__FILE__, __LINE__, false); + Dsm_check(400); /* growisofs umounted the device, so remount it (it will update the free space) */ dev->clear_mounted(); dev->mount(1); Jmsg(dcr->jcr, M_INFO, 0, _("Remaining free space %s on %s\n"), edit_uint64_with_commas(dev->free_space, ed1), dev->print_name()); - sm_check(__FILE__, __LINE__, false); + Dsm_check(400); return true; } diff --git a/bacula/src/stored/job.c b/bacula/src/stored/job.c index c2d925965f..959994a9bd 100644 --- a/bacula/src/stored/job.c +++ b/bacula/src/stored/job.c @@ -163,7 +163,7 @@ bool run_cmd(JCR *jcr) struct timespec timeout; int errstat = 0; - Dsm_check(1); + Dsm_check(200); Dmsg1(200, "Run_cmd: %s\n", jcr->dir_bsock->msg); /* If we do not need the FD, we are doing a migrate, copy, or virtual @@ -422,7 +422,7 @@ void stored_free_jcr(JCR *jcr) delete jcr->write_store; jcr->write_store = NULL; } - Dsm_check(1); + Dsm_check(200); if (jcr->JobId != 0) write_state_file(me->working_directory, "bacula-sd", get_first_port_host_order(me->sdaddrs)); diff --git a/bacula/src/stored/scan.c b/bacula/src/stored/scan.c index a0292d8072..514331c865 100644 --- a/bacula/src/stored/scan.c +++ b/bacula/src/stored/scan.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2006-2007 Free Software Foundation Europe e.V. + Copyright (C) 2006-2011 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. @@ -32,7 +32,6 @@ * * Kern Sibbald, MMVI * - * Version $Id$ */ #include "bacula.h" @@ -137,7 +136,7 @@ get_out: dcr->VolCatInfo = dcrVolCatInfo; /* structure assignment */ VolCatInfo = devVolCatInfo; /* structure assignment */ } - sm_check(__FILE__, __LINE__, false); + Dsm_check(100); return found; } -- 2.39.5