From: Kern Sibbald Date: Fri, 15 Sep 2006 13:06:10 +0000 (+0000) Subject: kes Put attach_dcr_to_dev in a subroutine. X-Git-Tag: Release-2.0.0~447 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ee5b1e9ee0ad5e91e5085d1af5bb38c4697a0496;p=bacula%2Fbacula kes Put attach_dcr_to_dev in a subroutine. kes Make attaching/detaching to/from a device use a flag and only detach if actually attached. kes Add dvd-simulator.in to scripts directory and add to configure. kes Fix code in acquire.c that checks fd != 0 to use dev->is_open(). This could be a cause of a number of drive reservation problems. Note, this code is now in attach_dcr_to_dev(). kes Suppress doing Volume updates if it is a system job. This should prevent the DVD label blocking. kes Clear the freespace ok flag in a couple of strategic places. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3470 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index b61da9e8b9..aa3c4b4a32 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -1981,6 +1981,7 @@ AC_OUTPUT([autoconf/Make.common \ scripts/mtx-changer \ scripts/disk-changer \ scripts/dvd-handler \ + scripts/dvd-simulator \ scripts/bacula-tray-monitor.desktop \ scripts/logwatch/Makefile \ scripts/logwatch/logfile.bacula.conf \ @@ -2055,7 +2056,7 @@ AC_OUTPUT([autoconf/Make.common \ cd scripts chmod 755 startmysql stopmysql bacula startit stopit btraceback mtx-changer -chmod 755 dvd-handler +chmod 755 dvd-handler dvd-simulator chmod 755 bconsole gconsole mtx-changer devel_bacula logrotate cd .. diff --git a/bacula/configure b/bacula/configure index 107e8d1a67..05c807d839 100755 --- a/bacula/configure +++ b/bacula/configure @@ -14957,26 +14957,26 @@ if test "${with_python+set}" = set; then if test -f $python_root/include/python2.2/Python.h; then PYTHON_INCDIR=-I$python_root/include/python2.2 if test -d $python_root/lib64/python2.2/config; then - PYTHON_LIBS="-L$python_root/lib64/python2.2/config -lpython2.2" - else - PYTHON_LIBS="-L$python_root/lib/python2.2/config -lpython2.2" - fi + PYTHON_LIBS="-L$python_root/lib64/python2.2/config -lpython2.2" + else + PYTHON_LIBS="-L$python_root/lib/python2.2/config -lpython2.2" + fi break elif test -f $python_root/include/python2.3/Python.h; then PYTHON_INCDIR=-I$python_root/include/python2.3 if test -d $python_root/lib64/python2.3/config; then - PYTHON_LIBS="-L$python_root/lib64/python2.3/config -lpython2.3" - else - PYTHON_LIBS="-L$python_root/lib/python2.3/config -lpython2.3" - fi + PYTHON_LIBS="-L$python_root/lib64/python2.3/config -lpython2.3" + else + PYTHON_LIBS="-L$python_root/lib/python2.3/config -lpython2.3" + fi break elif test -f $python_root/include/python2.4/Python.h; then PYTHON_INCDIR=-I$python_root/include/python2.4 if test -d $python_root/lib64/python2.4/config; then - PYTHON_LIBS="-L$python_root/lib64/python2.4/config -lpython2.4" - else - PYTHON_LIBS="-L$python_root/lib/python2.4/config -lpython2.4" - fi + PYTHON_LIBS="-L$python_root/lib64/python2.4/config -lpython2.4" + else + PYTHON_LIBS="-L$python_root/lib/python2.4/config -lpython2.4" + fi break fi done @@ -14984,10 +14984,10 @@ if test "${with_python+set}" = set; then if test -f $prefix/include/Python.h; then PYTHON_INCDIR=-I$prefix/include if test -d $prefix/lib64/config; then - PYTHON_LIBS="-L$prefix/lib64/config -lpython" - else - PYTHON_LIBS="-L$prefix/lib/config -lpython" - fi + PYTHON_LIBS="-L$prefix/lib64/config -lpython" + else + PYTHON_LIBS="-L$prefix/lib/config -lpython" + fi else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 @@ -16631,9 +16631,9 @@ echo "$as_me: error: Unable to find libpq-fe.h in standard locations" >&2;} elif test -f $withval/include/postgresql/libpq-fe.h; then POSTGRESQL_INCDIR=$withval/include/postgresql if test -d $withval/lib64; then - POSTGRESQL_LIBDIR=$withval/lib64 + POSTGRESQL_LIBDIR=$withval/lib64 else - POSTGRESQL_LIBDIR=$withval/lib + POSTGRESQL_LIBDIR=$withval/lib fi POSTGRESQL_BINDIR=$withval/bin else @@ -16921,7 +16921,7 @@ echo "$as_me: error: Invalid MySQL directory $withval - unable to find mysql.h u fi fi SQL_INCLUDE=-I$MYSQL_INCDIR - if test -f $MYSQL_LIBDIR/libmysqlclient_r.a; then + if test -f "$MYSQL_LIBDIR/libmysqlclient_r.a"; then SQL_LFLAGS="-L$MYSQL_LIBDIR -lmysqlclient_r -lz" cat >>confdefs.h <<\_ACEOF #define HAVE_THREAD_SAFE_MYSQL 1 @@ -17670,7 +17670,7 @@ ac_x_header_dirs=' /usr/openwin/share/include' if test "$ac_x_includes" = no; then - # Guess where to find include files, by looking for Xlib.h. + # Guess where to find include files, by looking for Intrinsic.h. # First, try using that file with no special directory specified. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ @@ -17678,7 +17678,7 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 @@ -17705,7 +17705,7 @@ else sed 's/^/| /' conftest.$ac_ext >&5 for ac_dir in $ac_x_header_dirs; do - if test -r "$ac_dir/X11/Xlib.h"; then + if test -r "$ac_dir/X11/Intrinsic.h"; then ac_x_includes=$ac_dir break fi @@ -17726,11 +17726,11 @@ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include +#include int main () { -XrmInitialize () +XtMalloc (0) ; return 0; } @@ -29769,8 +29769,8 @@ freebsd) DISTVER=`uname -a |awk '{print $3}'` VER=`echo $DISTVER | cut -c 1` if test x$VER = x4 ; then - PTHREAD_LIB="${PTHREAD_LIBS}" - CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS}" + PTHREAD_LIB="${PTHREAD_LIBS:--pthread}" + CFLAGS="${CFLAGS} ${PTHREAD_CFLAGS:--pthread}" fi lld="qd" llu="qu" @@ -29971,7 +29971,7 @@ if test "x${subsysdir}" = "x${sbindir}" ; then exit 1 fi - ac_config_files="$ac_config_files autoconf/Make.common Makefile manpages/Makefile scripts/startmysql scripts/stopmysql scripts/btraceback scripts/startit scripts/stopit scripts/bconsole scripts/gconsole scripts/bacula scripts/bacula-ctl-dir scripts/bacula-ctl-fd scripts/bacula-ctl-sd scripts/devel_bacula scripts/Makefile scripts/logrotate scripts/bacula.desktop.gnome1 scripts/bacula.desktop.gnome2 scripts/bacula.desktop.gnome1.consolehelper scripts/bacula.desktop.gnome2.consolehelper scripts/bacula.desktop.gnome1.xsu scripts/bacula.desktop.gnome2.xsu scripts/gnome-console.console_apps scripts/mtx-changer scripts/disk-changer scripts/dvd-handler scripts/bacula-tray-monitor.desktop scripts/logwatch/Makefile scripts/logwatch/logfile.bacula.conf scripts/wxconsole.console_apps scripts/wxconsole.desktop.consolehelper scripts/wxconsole.desktop.xsu src/Makefile src/host.h src/console/Makefile src/console/bconsole.conf src/gnome2-console/Makefile src/gnome2-console/gnome-console.conf src/wx-console/Makefile src/wx-console/wx-console.conf src/tray-monitor/Makefile src/tray-monitor/tray-monitor.conf src/dird/Makefile src/dird/bacula-dir.conf src/lib/Makefile src/stored/Makefile src/stored/bacula-sd.conf src/filed/Makefile src/filed/bacula-fd.conf src/cats/Makefile src/cats/make_catalog_backup src/cats/delete_catalog_backup src/cats/create_postgresql_database src/cats/update_postgresql_tables src/cats/make_postgresql_tables src/cats/grant_postgresql_privileges src/cats/drop_postgresql_tables src/cats/drop_postgresql_database src/cats/create_mysql_database src/cats/update_mysql_tables src/cats/make_mysql_tables src/cats/grant_mysql_privileges src/cats/drop_mysql_tables src/cats/drop_mysql_database src/cats/create_sqlite_database src/cats/update_sqlite_tables src/cats/make_sqlite_tables src/cats/grant_sqlite_privileges src/cats/drop_sqlite_tables src/cats/drop_sqlite_database src/cats/create_sqlite3_database src/cats/update_sqlite3_tables src/cats/make_sqlite3_tables src/cats/grant_sqlite3_privileges src/cats/drop_sqlite3_tables src/cats/drop_sqlite3_database src/cats/sqlite src/cats/mysql src/cats/create_bdb_database src/cats/update_bdb_tables src/cats/make_bdb_tables src/cats/grant_bdb_privileges src/cats/drop_bdb_tables src/cats/drop_bdb_database src/cats/create_bacula_database src/cats/update_bacula_tables src/cats/grant_bacula_privileges src/cats/make_bacula_tables src/cats/drop_bacula_tables src/cats/drop_bacula_database src/findlib/Makefile src/pygtk-console/Makefile src/tools/Makefile po/Makefile.in $PFILES" + ac_config_files="$ac_config_files autoconf/Make.common Makefile manpages/Makefile scripts/startmysql scripts/stopmysql scripts/btraceback scripts/startit scripts/stopit scripts/bconsole scripts/gconsole scripts/bacula scripts/bacula-ctl-dir scripts/bacula-ctl-fd scripts/bacula-ctl-sd scripts/devel_bacula scripts/Makefile scripts/logrotate scripts/bacula.desktop.gnome1 scripts/bacula.desktop.gnome2 scripts/bacula.desktop.gnome1.consolehelper scripts/bacula.desktop.gnome2.consolehelper scripts/bacula.desktop.gnome1.xsu scripts/bacula.desktop.gnome2.xsu scripts/gnome-console.console_apps scripts/mtx-changer scripts/disk-changer scripts/dvd-handler scripts/dvd-simulator scripts/bacula-tray-monitor.desktop scripts/logwatch/Makefile scripts/logwatch/logfile.bacula.conf scripts/wxconsole.console_apps scripts/wxconsole.desktop.consolehelper scripts/wxconsole.desktop.xsu src/Makefile src/host.h src/console/Makefile src/console/bconsole.conf src/gnome2-console/Makefile src/gnome2-console/gnome-console.conf src/wx-console/Makefile src/wx-console/wx-console.conf src/tray-monitor/Makefile src/tray-monitor/tray-monitor.conf src/dird/Makefile src/dird/bacula-dir.conf src/lib/Makefile src/stored/Makefile src/stored/bacula-sd.conf src/filed/Makefile src/filed/bacula-fd.conf src/cats/Makefile src/cats/make_catalog_backup src/cats/delete_catalog_backup src/cats/create_postgresql_database src/cats/update_postgresql_tables src/cats/make_postgresql_tables src/cats/grant_postgresql_privileges src/cats/drop_postgresql_tables src/cats/drop_postgresql_database src/cats/create_mysql_database src/cats/update_mysql_tables src/cats/make_mysql_tables src/cats/grant_mysql_privileges src/cats/drop_mysql_tables src/cats/drop_mysql_database src/cats/create_sqlite_database src/cats/update_sqlite_tables src/cats/make_sqlite_tables src/cats/grant_sqlite_privileges src/cats/drop_sqlite_tables src/cats/drop_sqlite_database src/cats/create_sqlite3_database src/cats/update_sqlite3_tables src/cats/make_sqlite3_tables src/cats/grant_sqlite3_privileges src/cats/drop_sqlite3_tables src/cats/drop_sqlite3_database src/cats/sqlite src/cats/mysql src/cats/create_bdb_database src/cats/update_bdb_tables src/cats/make_bdb_tables src/cats/grant_bdb_privileges src/cats/drop_bdb_tables src/cats/drop_bdb_database src/cats/create_bacula_database src/cats/update_bacula_tables src/cats/grant_bacula_privileges src/cats/make_bacula_tables src/cats/drop_bacula_tables src/cats/drop_bacula_database src/findlib/Makefile src/pygtk-console/Makefile src/tools/Makefile po/Makefile.in $PFILES" ac_config_commands="$ac_config_commands default" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -30541,6 +30541,7 @@ do "scripts/mtx-changer" ) CONFIG_FILES="$CONFIG_FILES scripts/mtx-changer" ;; "scripts/disk-changer" ) CONFIG_FILES="$CONFIG_FILES scripts/disk-changer" ;; "scripts/dvd-handler" ) CONFIG_FILES="$CONFIG_FILES scripts/dvd-handler" ;; + "scripts/dvd-simulator" ) CONFIG_FILES="$CONFIG_FILES scripts/dvd-simulator" ;; "scripts/bacula-tray-monitor.desktop" ) CONFIG_FILES="$CONFIG_FILES scripts/bacula-tray-monitor.desktop" ;; "scripts/logwatch/Makefile" ) CONFIG_FILES="$CONFIG_FILES scripts/logwatch/Makefile" ;; "scripts/logwatch/logfile.bacula.conf" ) CONFIG_FILES="$CONFIG_FILES scripts/logwatch/logfile.bacula.conf" ;; @@ -31624,7 +31625,7 @@ fi cd scripts chmod 755 startmysql stopmysql bacula startit stopit btraceback mtx-changer -chmod 755 dvd-handler +chmod 755 dvd-handler dvd-simulator chmod 755 bconsole gconsole mtx-changer devel_bacula logrotate cd .. diff --git a/bacula/scripts/.cvsignore b/bacula/scripts/.cvsignore index 588d20d72f..2e134c6153 100644 --- a/bacula/scripts/.cvsignore +++ b/bacula/scripts/.cvsignore @@ -14,6 +14,7 @@ devel_bacula gconsole mtx-changer dvd-handler +dvd-simulator Makefile bacula btraceback diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 7b2be84304..57b30160fb 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -24,7 +24,7 @@ #include "stored.h" /* pull in Storage Deamon headers */ /* Forward referenced functions */ -static void detach_dcr_from_dev(DCR *dcr); +static void attach_dcr_to_dev(DCR *dcr); /********************************************************************* @@ -120,9 +120,7 @@ bool acquire_device_for_read(DCR *dcr) jcr->read_dcr = dcr; dcr->device = new_dcr->device; dcr->max_job_spool_size = dcr->device->max_job_spool_size; - if (dev->fd != 0 && jcr && jcr->JobType != JT_SYSTEM) { - dev->attached_dcrs->append(dcr); /* attach dcr to device */ - } + attach_dcr_to_dev(dcr); new_dcr->VolumeName[0] = 0; free_dcr(new_dcr); dev->block(BST_DOING_ACQUIRE); @@ -539,11 +537,7 @@ DCR *new_dcr(JCR *jcr, DEVICE *dev) dcr->block = new_block(dev); dcr->rec = new_record(); dcr->max_job_spool_size = dev->device->max_job_spool_size; - /* Attach this dcr only if dev is initialized */ - if (dev->fd != 0 && jcr && jcr->JobType != JT_SYSTEM) { - dev->attached_dcrs->append(dcr); /* attach dcr to device */ -// jcr->dcrs->append(dcr); /* put dcr in list for Job */ - } + attach_dcr_to_dev(dcr); } dcr->spool_fd = -1; return dcr; @@ -575,7 +569,18 @@ static void remove_dcr_from_dcrs(DCR *dcr) } #endif -static void detach_dcr_from_dev(DCR *dcr) +static void attach_dcr_to_dev(DCR *dcr) +{ + DEVICE *dev = dcr->dev; + JCR *jcr = dcr->jcr; + + if (!dcr->attached_to_dev && dev->is_open() && jcr && jcr->JobType != JT_SYSTEM) { + dev->attached_dcrs->append(dcr); /* attach dcr to device */ + dcr->attached_to_dev = true; + } +} + +void detach_dcr_from_dev(DCR *dcr) { DEVICE *dev = dcr->dev; @@ -596,9 +601,10 @@ static void detach_dcr_from_dev(DCR *dcr) unlock_device(dev); } - /* Detach this dcr only if the dev is initialized */ - if (dcr->dev->fd != 0 && dcr->jcr && dcr->jcr->JobType != JT_SYSTEM) { + /* Detach this dcr only if attached */ + if (dcr->attached_to_dev) { dcr->dev->attached_dcrs->remove(dcr); /* detach dcr from device */ + dcr->attached_to_dev = false; // remove_dcr_from_dcrs(dcr); /* remove dcr from jcr list */ } free_unused_volume(dcr); /* free unused vols attached to this dcr */ diff --git a/bacula/src/stored/askdir.c b/bacula/src/stored/askdir.c index 54e125d92c..0a549aafae 100644 --- a/bacula/src/stored/askdir.c +++ b/bacula/src/stored/askdir.c @@ -287,6 +287,11 @@ bool dir_update_volume_info(DCR *dcr, bool label) int InChanger; POOL_MEM VolumeName; + /* If system job, do not update catalog */ + if (jcr->JobType == JT_SYSTEM) { + return true; + } + if (vol->VolCatName[0] == 0) { Jmsg0(jcr, M_FATAL, 0, _("NULL Volume name. This shouldn't happen!!!\n")); Pmsg0(000, _("NULL Volume name. This shouldn't happen!!!\n")); @@ -339,6 +344,11 @@ bool dir_create_jobmedia_record(DCR *dcr) JCR *jcr = dcr->jcr; BSOCK *dir = jcr->dir_bsock; + /* If system job, do not update catalog */ + if (jcr->JobType == JT_SYSTEM) { + return true; + } + if (!dcr->WroteVol) { return true; /* nothing written to tape */ } diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index 1a71b1825e..5cc8781e44 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -567,7 +567,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) /* Create JobMedia record */ mjcr->read_dcr->VolLastIndex = dcr->VolLastIndex; create_jobmedia_record(db, mjcr); - dev->attached_dcrs->remove(mjcr->read_dcr); + detach_dcr_from_dev(mjcr->read_dcr); free_jcr(mjcr); break; diff --git a/bacula/src/stored/dev.h b/bacula/src/stored/dev.h index 94851eee41..0408fc5206 100644 --- a/bacula/src/stored/dev.h +++ b/bacula/src/stored/dev.h @@ -414,6 +414,7 @@ public: bool NewFile; /* set when EOF written */ bool reserved_device; /* set if reserve done */ bool any_volume; /* Any OK for dir_find_next... */ + bool attached_to_dev; /* set when attached to dev */ uint32_t VolFirstIndex; /* First file index this Volume */ uint32_t VolLastIndex; /* Last file index this Volume */ uint32_t FileIndex; /* Current File Index */ diff --git a/bacula/src/stored/dvd.c b/bacula/src/stored/dvd.c index 5ee722c81e..74642dff7e 100644 --- a/bacula/src/stored/dvd.c +++ b/bacula/src/stored/dvd.c @@ -357,8 +357,6 @@ bool dvd_write_part(DCR *dcr) DEVICE *dev = dcr->dev; POOL_MEM archive_name(PM_FNAME); - dev->clear_freespace_ok(); /* need to update freespace */ - /* Don't write empty part files. * This is only useful when growisofs does not support write beyond * the 4GB boundary. @@ -393,6 +391,8 @@ bool dvd_write_part(DCR *dcr) int timeout; char ed1[50]; + dev->clear_freespace_ok(); /* need to update freespace */ + sm_check(__FILE__, __LINE__, false); 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; @@ -793,6 +793,7 @@ bool truncate_dvd(DCR *dcr) { DEVICE* dev = dcr->dev; + dev->clear_freespace_ok(); /* need to update freespace */ dev->close_part(dcr); if (!unmount_dvd(dev, 1)) { diff --git a/bacula/src/stored/protos.h b/bacula/src/stored/protos.h index bf31bc8125..84ef598d07 100644 --- a/bacula/src/stored/protos.h +++ b/bacula/src/stored/protos.h @@ -27,6 +27,7 @@ bool acquire_device_for_read(DCR *dcr); bool release_device(DCR *dcr); DCR *new_dcr(JCR *jcr, DEVICE *dev); void free_dcr(DCR *dcr); +void detach_dcr_from_dev(DCR *dcr); /* From askdir.c */ enum get_vol_info_rw { diff --git a/bacula/src/version.h b/bacula/src/version.h index fadd83a787..39ea8444ba 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "1.39.23" -#define BDATE "13 September 2006" -#define LSMDATE "13Sep06" +#define BDATE "15 September 2006" +#define LSMDATE "15Sep06" #define BYEAR "2006" /* year for copyright messages in progs */ /* Debug flags */ diff --git a/bacula/technotes-1.39 b/bacula/technotes-1.39 index 4e52178829..b9fdacb904 100644 --- a/bacula/technotes-1.39 +++ b/bacula/technotes-1.39 @@ -1,6 +1,17 @@ Technical notes on version 1.39 General: +15Sep06 +kes Put attach_dcr_to_dev in a subroutine. +kes Make attaching/detaching to/from a device use a flag and + only detach if actually attached. +kes Add dvd-simulator.in to scripts directory and add to configure. +kes Fix code in acquire.c that checks fd != 0 to use dev->is_open(). + This could be a cause of a number of drive reservation problems. + Note, this code is now in attach_dcr_to_dev(). +kes Suppress doing Volume updates if it is a system job. This should + prevent the DVD label blocking. +kes Clear the freespace ok flag in a couple of strategic places. 14Sep06 kes Put removing zero sized spool part file in subroutine and call from release_device().