From bc9b9b481e86991abd879d30aa03b64b4c68d578 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Wed, 12 Mar 2008 15:01:42 +0000 Subject: [PATCH] Second cut of drive switching during backup git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6592 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/stored/acquire.c | 29 +-- bacula/src/stored/ansi_label.c | 3 +- bacula/src/stored/autochanger.c | 2 +- bacula/src/stored/label.c | 6 +- bacula/src/stored/reserve.c | 4 +- bacula/src/win32/External-mingw32 | 2 +- bacula/src/win32/build-depkgs-mingw32 | 257 +++++++++++++------------- bacula/technotes-2.3 | 2 + 8 files changed, 158 insertions(+), 147 deletions(-) diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index aa5d0b1c94..96835fb1c0 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -318,7 +318,7 @@ DCR *acquire_device_for_append(DCR *dcr) bool do_mount = false; bool release = false; bool have_vol; - DEVICE *dev = dcr->dev; + DEVICE * volatile dev = dcr->dev; JCR *jcr = dcr->jcr; init_device_wait_timers(dcr); @@ -355,18 +355,25 @@ DCR *acquire_device_for_append(DCR *dcr) * dcr->VolumeName is what we pass into the routines, or * get back from the subroutines. */ - if (!have_vol && - !(dir_find_next_appendable_volume(dcr) && - strcmp(dev->VolHdr.VolumeName, dcr->VolumeName) == 0)) { /* wrong tape mounted */ - /* Wrong tape mounted, release it, then fall through to get correct one */ - Dmsg3(50, "Wrong tape mounted. Wanted:%s, got:%s, dev=%s release and try mount.\n", - dcr->VolumeName, dev->VolHdr.VolumeName, dev->print_name()); - /* Release drive only if tape really in drive */ + do_mount = false; + release = false; + /* If we do not have a volume, see if we can find one */ + if (!have_vol) { + have_vol = dir_find_next_appendable_volume(dcr); + dev = dcr->dev; + } + if (have_vol) { + do_mount = true; + /* Make sure it is what we we have on the drive */ if (dev->VolHdr.VolumeName[0]) { - release = true; + /* If we already have the volume, mount/release are not needed */ + do_mount = strcmp(dev->VolHdr.VolumeName, dcr->VolumeName) != 0; + if (do_mount) { + release = true; + } } - do_mount = true; - } else { + } + if (have_vol && !do_mount) { /* * At this point, the correct tape is already mounted, so * we do not need to do mount_next_write_volume(), unless diff --git a/bacula/src/stored/ansi_label.c b/bacula/src/stored/ansi_label.c index e8978ec7bc..8796ad4823 100644 --- a/bacula/src/stored/ansi_label.c +++ b/bacula/src/stored/ansi_label.c @@ -65,7 +65,7 @@ static bool same_label_names(char *bacula_name, char *ansi_name); */ int read_ansi_ibm_label(DCR *dcr) { - DEVICE *dev = dcr->dev; + DEVICE * volatile dev = dcr->dev; JCR *jcr = dcr->jcr; char label[80]; /* tape label */ int stat, i; @@ -148,6 +148,7 @@ int read_ansi_ibm_label(DCR *dcr) } *q = 0; reserve_volume(dcr, dev->VolHdr.VolumeName); + dev = dcr->dev; /* may have changed in reserve_volume */ Dmsg2(100, "Wanted ANSI Vol %s got %6s\n", VolName, dev->VolHdr.VolumeName); Mmsg2(jcr->errmsg, _("Wanted ANSI Volume \"%s\" got \"%s\"\n"), VolName, dev->VolHdr.VolumeName); return VOL_NAME_ERROR; diff --git a/bacula/src/stored/autochanger.c b/bacula/src/stored/autochanger.c index d04171d28a..cd0b19a84c 100644 --- a/bacula/src/stored/autochanger.c +++ b/bacula/src/stored/autochanger.c @@ -111,7 +111,7 @@ bool init_autochangers() int autoload_device(DCR *dcr, int writing, BSOCK *dir) { JCR *jcr = dcr->jcr; - DEVICE *dev = dcr->dev; + DEVICE * volatile dev = dcr->dev; int slot; int drive = dev->drive_index; int rtn_stat = -1; /* error status */ diff --git a/bacula/src/stored/label.c b/bacula/src/stored/label.c index 18b1aaa7b5..19d5630990 100644 --- a/bacula/src/stored/label.c +++ b/bacula/src/stored/label.c @@ -67,7 +67,7 @@ static void create_volume_label_record(DCR *dcr, DEV_RECORD *rec); int read_dev_volume_label(DCR *dcr) { JCR *jcr = dcr->jcr; - DEVICE *dev = dcr->dev; + DEVICE * volatile dev = dcr->dev; char *VolName = dcr->VolumeName; DEV_RECORD *record; bool ok = false; @@ -218,6 +218,7 @@ int read_dev_volume_label(DCR *dcr) stat = VOL_NAME_ERROR; goto bail_out; } + dev = dcr->dev; /* may have changed in reserve volume */ /* Compare Volume Names */ Dmsg2(130, "Compare Vol names: VolName=%s hdr=%s\n", VolName?VolName:"*", dev->VolHdr.VolumeName); @@ -310,7 +311,7 @@ bool write_volume_label_to_block(DCR *dcr) bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName, const char *PoolName, bool relabel, bool dvdnow) { - DEVICE *dev = dcr->dev; + DEVICE * volatile dev = dcr->dev; Dmsg0(150, "write_volume_label()\n"); @@ -405,6 +406,7 @@ bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName, dev->VolHdr.VolumeName, dev->print_name()); goto bail_out; } + dev = dcr->dev; /* may have changed in reserve_volume */ dev->clear_append(); /* remove append since this is PRE_LABEL */ return true; diff --git a/bacula/src/stored/reserve.c b/bacula/src/stored/reserve.c index 06d55b348c..1aafd357f0 100644 --- a/bacula/src/stored/reserve.c +++ b/bacula/src/stored/reserve.c @@ -311,7 +311,7 @@ static void free_vol_item(VOLRES *vol) VOLRES *reserve_volume(DCR *dcr, const char *VolumeName) { VOLRES *vol, *nvol; - DEVICE *dev = dcr->dev; + DEVICE * volatile dev = dcr->dev; ASSERT(dev != NULL); @@ -435,7 +435,7 @@ void switch_device(DCR *dcr, DEVICE *dev) dcr->VolCatInfo.Slot = save_dcr.VolCatInfo.Slot; bstrncpy(dcr->pool_name, save_dcr.pool_name, sizeof(dcr->pool_name)); bstrncpy(dcr->pool_type, save_dcr.pool_type, sizeof(dcr->pool_type)); - bstrncpy(dcr->dev_name, save_dcr.dev_name, sizeof(dcr->dev_name)); + bstrncpy(dcr->dev_name, dev->dev_name, sizeof(dcr->dev_name)); dev->reserved_device++; dcr->reserved_device = true; diff --git a/bacula/src/win32/External-mingw32 b/bacula/src/win32/External-mingw32 index eb93acac01..7dbfeb849c 100644 --- a/bacula/src/win32/External-mingw32 +++ b/bacula/src/win32/External-mingw32 @@ -32,7 +32,7 @@ OPENSSL|http://www.bacula.org/depkgs-mingw32/openssl-0.9.8b.tar.gz PCRE|http://www.bacula.org/depkgs-mingw32/pcre-6.3.tar.bz2 POSTGRESQL|http://www.bacula.org/depkgs-mingw32/postgresql-base-8.1.4.tar.bz2|postgresql-8.1.4 PTHREADS|http://www.bacula.org/depkgs-mingw32/pthreads-snap-2004-06-22.tar.gz -Qt4|ftp://ftp.trolltech.com/qt/source/qt-win-opensource-src-4.3.0.zip +Qt4|ftp://www.bacula.org/depkgs-mingw32/qt-win-opensource-src-4.3.4.zip SCONS|http://www.bacula.org/depkgs-mingw32/scons-0.96.92.tar.gz SED|http://www.bacula.org/depkgs-mingw32/sed-4.1.5.tar.gz SQLITE|http://www.bacula.org/depkgs-mingw32/sqlite-3.3.17.tar.gz diff --git a/bacula/src/win32/build-depkgs-mingw32 b/bacula/src/win32/build-depkgs-mingw32 index a2f944865c..046813ac6c 100755 --- a/bacula/src/win32/build-depkgs-mingw32 +++ b/bacula/src/win32/build-depkgs-mingw32 @@ -6,26 +6,26 @@ usage() { - echo "usage: $0 [-h] [-C] [] [] ..." - echo " -h Displays this usage" - echo " -C Clobbers (overwrites) the source code by " - echo " reextracting the archive and reapplying the" - echo " patches." - echo "" - echo " Optional dependency, If none are given then all" - echo " of them will be built." - echo "" - echo "Valid dependencies are:" - grep -v '^#' < External-mingw32 | cut -d'|' -f1 | cut -d'_' -f1 | tr A-Z a-z | sort -u | awk '{ print " " $1 }' + echo "usage: $0 [-h] [-C] [] [] ..." + echo " -h Displays this usage" + echo " -C Clobbers (overwrites) the source code by " + echo " reextracting the archive and reapplying the" + echo " patches." + echo "" + echo " Optional dependency, If none are given then all" + echo " of them will be built." + echo "" + echo "Valid dependencies are:" + grep -v '^#' < External-mingw32 | cut -d'|' -f1 | cut -d'_' -f1 | tr A-Z a-z | sort -u | awk '{ print " " $1 }' } CLOBBER_SOURCE= while getopts "hHC" opt; do - case ${opt} in - H|h|\?) usage;exit 1;; - C) CLOBBER_SOURCE=true;; - esac + case ${opt} in + H|h|\?) usage;exit 1;; + C) CLOBBER_SOURCE=true;; + esac done [ ${OPTIND} -gt 1 ] && shift `expr ${OPTIND} - 1` @@ -39,15 +39,15 @@ TOP_DIR=`pwd` if [ -e ${TOP_DIR}/cross-tools/mingw32/bin/mingw32-gcc ] then - cd ${TOP_DIR}/cross-tools/mingw32/bin - BIN_DIR=`pwd` + cd ${TOP_DIR}/cross-tools/mingw32/bin + BIN_DIR=`pwd` elif [ -e /mingw/bin/mingw32-gcc ] then - BIN_DIR=/mingw/bin + BIN_DIR=/mingw/bin else - echo The GCC cross compiler isn\'t installed. - echo You must run build-win32-cross-tools first - exit 1 + echo "The GCC cross compiler isn\'t installed." + echo "You must run build-win32-cross-tools first" + exit 1 fi [ ! -e ${TOP_DIR}/depkgs-mingw32 ] && mkdir ${TOP_DIR}/depkgs-mingw32 @@ -63,64 +63,64 @@ export PATH=${BIN_DIR}:${PATH} OLD_IFS=${IFS};IFS="|"; while read package url dir mkd; do - echo "Got package ${package}" - case ${package} in - \#*) ;; - *) eval "URL_${package}=${url};DIR_${package}=${dir};MKD_${package}=${mkd}";; + echo "Got package ${package}" + case ${package} in + \#*) ;; + *) eval "URL_${package}=${url};DIR_${package}=${dir};MKD_${package}=${mkd}";; esac done < ${SCRIPT_DIR}/External-mingw32 IFS=${OLD_IFS};unset OLD_IFS get_source() { - URL=$1 - SRC_DIR=$2 - MAKE_DIR=$3 - echo "Processing ${URL}" - ARCHIVE=`basename ${URL}` - - case ${ARCHIVE} in - *.tar.gz) ARCHIVER="tar xzf"; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.tar\.gz'`;; - *.tar.bz2) ARCHIVER="tar xjf"; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.tar\.bz2'`;; - *.zip) ARCHIVER="unzip -q"; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.zip'`;; - *.exe) ARCHIVER=""; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.zip'`;; - *) echo Unsupported archive type - $ARCHIVE; exit 1;; - esac - - cd ${DEPPKG_DIR}/src - - if [ ! -e "${ARCHIVE}" ] - then - echo Downloading "${URL}" - if wget --passive-ftp "${URL}" - then - : - else - echo Unable to download ${ARCHIVE} - exit 1 - fi - fi + URL=$1 + SRC_DIR=$2 + MAKE_DIR=$3 + echo "Processing ${URL}" + ARCHIVE=`basename ${URL}` + + case ${ARCHIVE} in + *.tar.gz) ARCHIVER="tar xzf"; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.tar\.gz'`;; + *.tar.bz2) ARCHIVER="tar xjf"; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.tar\.bz2'`;; + *.zip) ARCHIVER="unzip -q"; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.zip'`;; + *.exe) ARCHIVER=""; [ -z "${SRC_DIR}" ] && SRC_DIR=`expr "${ARCHIVE}" : '\(.*\)\.zip'`;; + *) echo Unsupported archive type - $ARCHIVE; exit 1;; + esac + + cd ${DEPPKG_DIR}/src + + if [ ! -e "${ARCHIVE}" ] + then + echo Downloading "${URL}" + if wget --passive-ftp "${URL}" + then + : + else + echo Unable to download ${ARCHIVE} + exit 1 + fi + fi - [ -z "${ARCHIVER}" ] && return 0 + [ -z "${ARCHIVER}" ] && return 0 - if [ ! -e "${SRC_DIR}" -o "${CLOBBER_SOURCE}" = "true" ] - then - rm -rf ${SRC_DIR} - echo Extracting ${ARCHIVE} - if [ "${MAKE_DIR}" = "true" ] - then - mkdir ${SRC_DIR} - cd ${SRC_DIR} - ${ARCHIVER} ../${ARCHIVE} > ../${ARCHIVE}.log 2>&1 - else - ${ARCHIVER} ${ARCHIVE} > ${ARCHIVE}.log 2>&1 - cd ${SRC_DIR} - fi - return 0 - fi + if [ ! -e "${SRC_DIR}" -o "${CLOBBER_SOURCE}" = "true" ] + then + rm -rf ${SRC_DIR} + echo Extracting ${ARCHIVE} + if [ "${MAKE_DIR}" = "true" ] + then + mkdir ${SRC_DIR} + cd ${SRC_DIR} + ${ARCHIVER} ../${ARCHIVE} > ../${ARCHIVE}.log 2>&1 + else + ${ARCHIVER} ${ARCHIVE} > ${ARCHIVE}.log 2>&1 + cd ${SRC_DIR} + fi + return 0 + fi - cd ${SRC_DIR} - return 1 + cd ${SRC_DIR} + return 1 } parse_output() @@ -143,10 +143,10 @@ do_patch() if patch -f -p0 "$@" >>patch.log < ${PATCH_FILE} then - : + : else - echo Patch failed - Check `pwd`/patch.log > /dev/tty - exit 1 + echo "Patch failed - Check `pwd`/patch.log" > /dev/tty + exit 1 fi } @@ -154,10 +154,10 @@ do_make() { if make -f "$@" 2>&1 then - : + : else - echo Make failed - Check `pwd`/make.log > /dev/tty - exit 1 + echo "Make failed - Check `pwd`/make.log" > /dev/tty + exit 1 fi | tee -a make.log | parse_output } @@ -165,9 +165,9 @@ process_zlib() { if get_source "${URL_ZLIB}" "${DIR_ZLIB}" "${MKD_ZLIB}" then - echo Patching zlib - >patch.log - do_patch zlib.patch + echo "Patching zlib" + >patch.log + do_patch zlib.patch fi echo Building zlib > make.log @@ -457,41 +457,41 @@ process_stab2cv() process_cmd_utils() { - if get_source "${URL_CMD_UTILS}" "${DIR_CMD_UTILS}" "${MKD_CMD_UTILS}" - then - # echo Patching cmd-utils - # >patch.log - # do_patch cmd-utils.patch - echo Configuring cmd-utils - ./configure --host=mingw32 \ - --prefix=${DEPPKG_DIR} \ - >make.log 2>&1 - fi - echo Building cmd-utils - do_make Makefile - echo Installing cmd-utils - do_make Makefile install + if get_source "${URL_CMD_UTILS}" "${DIR_CMD_UTILS}" "${MKD_CMD_UTILS}" + then + # echo Patching cmd-utils + # >patch.log + # do_patch cmd-utils.patch + echo Configuring cmd-utils + ./configure --host=mingw32 \ + --prefix=${DEPPKG_DIR} \ + >make.log 2>&1 + fi + echo Building cmd-utils + do_make Makefile + echo Installing cmd-utils + do_make Makefile install } process_mkisofs() { - get_source "${URL_MKISOFS}" "${DIR_MKISOFS}" "${MKD_MKISOFS}" - echo Installing mkisofs - cp `basename ${URL_MKISOFS}` ${DEPPKG_DIR}/bin + get_source "${URL_MKISOFS}" "${DIR_MKISOFS}" "${MKD_MKISOFS}" + echo Installing mkisofs + cp `basename ${URL_MKISOFS}` ${DEPPKG_DIR}/bin } process_dvd_rw_tools() { - if get_source "${URL_DVD_RW_TOOLS}" "${DIR_DVD_RW_TOOLS}" "${MKD_DVD_RW_TOOLS}" - then - echo Patching dvd+rw-tools - >patch.log - do_patch dvd+rw-tools.patch - fi - echo "Building dvd+rw-tools" - m4 -DOS=XMINGW32 Makefile.m4 | make -f - dvd+rw-tools >make.log 2>&1 - echo "Installing dvd+rw-tools" - m4 -DOS=XMINGW32 Makefile.m4 | make -f - prefix=${DEPPKG_DIR} manprefix=${DEPPKG_DIR} install >>make.log 2>&1 + if get_source "${URL_DVD_RW_TOOLS}" "${DIR_DVD_RW_TOOLS}" "${MKD_DVD_RW_TOOLS}" + then + echo Patching dvd+rw-tools + >patch.log + do_patch dvd+rw-tools.patch + fi + echo "Building dvd+rw-tools" + m4 -DOS=XMINGW32 Makefile.m4 | make -f - dvd+rw-tools >make.log 2>&1 + echo "Installing dvd+rw-tools" + m4 -DOS=XMINGW32 Makefile.m4 | make -f - prefix=${DEPPKG_DIR} manprefix=${DEPPKG_DIR} install >>make.log 2>&1 } process_qt4() @@ -502,30 +502,29 @@ process_qt4() if [ "$#" -eq 0 ] then - process_zlib - process_pcre - process_pthreads - process_openssl - process_mysql - process_sqlite - process_postgresql - process_wx - process_scons - process_nsis - process_mtx - process_mt - process_sed - process_stab2cv - process_cmd_utils - process_mkisofs - process_dvd_rw_tools - process_qt4 + process_zlib + process_pcre + process_pthreads + process_openssl + process_mysql + process_sqlite + process_postgresql + process_wx + process_scons + process_nsis + process_mtx + process_mt + process_sed + process_stab2cv + process_cmd_utils + process_mkisofs + process_dvd_rw_tools + process_qt4 else - for dependency in "$@" - do - eval "process_${dependency}" - done - + for dependency in "$@" + do + eval "process_${dependency}" + done fi #vss #Need to download from Microsoft diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index fbe03d9e6b..4b186e36b5 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -1,6 +1,8 @@ Technical notes on version 2.3 General: +12Mar08 +kes Second cut of drive switching during backup. 11Mar08 kes Fix Win32 build. kes Update Win32 version of wxWidgets to most recent version. -- 2.39.5