From: Kern Sibbald Date: Sat, 19 Apr 2008 10:09:40 +0000 (+0000) Subject: Force unload of volume when wrong volume mounted in SD. X-Git-Tag: Release-7.0.0~4691 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=49a774fbfbf49c31689262ede5ce406185a8375a;p=bacula%2Fbacula Force unload of volume when wrong volume mounted in SD. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@6843 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 5733a4b803..207e3415dc 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -238,7 +238,10 @@ bool acquire_device_for_read(DCR *dcr) } else { bstrncpy(dev->BadVolName, dev->VolHdr.VolumeName, sizeof(dev->BadVolName)); } - unload_autochanger(dcr, -1); + if (!unload_autochanger(dcr, -1)) { + /* at least free the device so we can re-open with correct volume */ + dev->close(); + } /* Fall through */ default: Jmsg1(jcr, M_WARNING, 0, "%s", jcr->errmsg); @@ -262,6 +265,12 @@ default_path: try_autochanger = false; continue; /* try reading volume mounted */ } + /* Try closing and re-opening */ + dev->close(); + dev->clear_unload(); + if (dev->open(dcr, OPEN_READ_ONLY) >= 0) { + continue; + } } /* Mount a specific volume and no other */ diff --git a/bacula/src/stored/mount.c b/bacula/src/stored/mount.c index 5b22b3fa6c..f0d0baf8ee 100644 --- a/bacula/src/stored/mount.c +++ b/bacula/src/stored/mount.c @@ -633,11 +633,12 @@ void DCR::mark_volume_in_error() { Jmsg(jcr, M_INFO, 0, _("Marking Volume \"%s\" in Error in Catalog.\n"), VolumeName); - dev->VolCatInfo = VolCatInfo; /* structure assignment */ + dev->VolCatInfo = VolCatInfo; /* structure assignment */ bstrncpy(dev->VolCatInfo.VolCatStatus, "Error", sizeof(dev->VolCatInfo.VolCatStatus)); Dmsg0(150, "dir_update_vol_info. Set Error.\n"); dir_update_volume_info(this, false, false); volume_unused(this); + dev->set_unload(); /* must get a new volume */ } /* @@ -690,6 +691,7 @@ void DCR::release_volume() if (dev->is_open()) { dev->offline_or_rewind(); } + dev->set_unload(); Dmsg0(190, "release_volume\n"); } diff --git a/bacula/src/version.h b/bacula/src/version.h index 938d63051a..2aceda5db4 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.3.18" -#define BDATE "16 April 2008" -#define LSMDATE "16Apr08" +#define BDATE "19 April 2008" +#define LSMDATE "19Apr08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index 12dcd636e6..b5546ef249 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -24,6 +24,8 @@ Add long term statistics job table General: +19Apr08 +kes Force unload of volume when wrong volume mounted in SD. 17Apr08 kes Fix bat seg fault at termination. kes Add Bacula generated version to bat about box.