From: Kern Sibbald Date: Wed, 12 Mar 2008 15:01:42 +0000 (+0000) Subject: Second cut of drive switching during backup X-Git-Tag: Release-7.0.0~4850 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=324c3a75457f49afbdac75494e24f4297808cd2b;p=bacula%2Fbacula Second cut of drive switching during backup git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6592 91ce42f0-d328-0410-95d8-f526ca767f89 --- 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/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.