From 8ce1f8952a1280030cb278485d0263eb1ced7bbb Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Fri, 30 May 2008 18:31:57 +0000 Subject: [PATCH] Fix multiple media restore. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@7063 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/stored/acquire.c | 27 +++++++++++++++------------ bacula/technotes-2.1 | 1 + 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 680db29594..37ff22cbee 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -97,18 +97,6 @@ bool acquire_device_for_read(DCR *dcr) bstrncpy(dcr->media_type, vol->MediaType, sizeof(dcr->media_type)); dcr->VolCatInfo.Slot = vol->Slot; dcr->VolCatInfo.InChanger = vol->Slot > 0; - if (reserve_volume(dcr, dcr->VolumeName) == NULL) { - Dmsg2(100, "Could not reserve volume %s on %s\n", dcr->VolumeName, - dcr->dev->print_name()); - Jmsg2(jcr, M_FATAL, 0, _("Could not reserve volume %s on %s\n"), dcr->VolumeName, - dcr->dev->print_name()); - goto get_out; - } - if (dev->vol && dev->vol->is_swapping()) { - dev->vol->set_slot(vol->Slot); - Dmsg3(100, "swapping: slot=%d Vol=%s dev=%s\n", dev->vol->get_slot(), - dev->vol->vol_name, dev->print_name()); - } /* * If the MediaType requested for this volume is not the @@ -169,8 +157,10 @@ bool acquire_device_for_read(DCR *dcr) Dmsg1(50, "Media Type change. New device %s chosen.\n", dev->print_name()); bstrncpy(dcr->VolumeName, vol->VolumeName, sizeof(dcr->VolumeName)); + bstrncpy(dcr->VolCatInfo.VolCatName, vol->VolumeName, sizeof(dcr->VolCatInfo.VolCatName)); bstrncpy(dcr->media_type, vol->MediaType, sizeof(dcr->media_type)); dcr->VolCatInfo.Slot = vol->Slot; + dcr->VolCatInfo.InChanger = vol->Slot > 0; bstrncpy(dcr->pool_name, store->pool_name, sizeof(dcr->pool_name)); bstrncpy(dcr->pool_type, store->pool_type, sizeof(dcr->pool_type)); } else { @@ -182,6 +172,19 @@ bool acquire_device_for_read(DCR *dcr) } } + if (reserve_volume(dcr, dcr->VolumeName) == NULL) { + Dmsg2(100, "Could not reserve volume %s on %s\n", dcr->VolumeName, + dcr->dev->print_name()); + Jmsg2(jcr, M_FATAL, 0, _("Could not reserve volume %s on %s\n"), dcr->VolumeName, + dcr->dev->print_name()); + goto get_out; + } + if (dev->vol && dev->vol->is_swapping()) { + dev->vol->set_slot(vol->Slot); + Dmsg3(100, "swapping: slot=%d Vol=%s dev=%s\n", dev->vol->get_slot(), + dev->vol->vol_name, dev->print_name()); + } + init_device_wait_timers(dcr); diff --git a/bacula/technotes-2.1 b/bacula/technotes-2.1 index f1b0aa960f..db86975295 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -2,6 +2,7 @@ General: 30May08 +kes Fix multiple media restore. kes Make DEVICE Slot private and access it via a method. Allows better control over when it is set and cleared. kes Fix possible seg fault if SQL error. -- 2.39.2