From 89c2a43f0ca27864aeb438e2928cdc6b8d6df464 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sat, 19 Apr 2008 10:08:44 +0000 Subject: [PATCH] Force unload of volume when wrong volume mounted in SD. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.2@6842 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/stored/acquire.c | 11 ++++++++++- bacula/src/stored/mount.c | 4 +++- bacula/src/version.h | 4 ++-- bacula/technotes-2.1 | 2 ++ 4 files changed, 17 insertions(+), 4 deletions(-) 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 48d3ae8d98..444de95350 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.2.10-b1" -#define BDATE "15 April 2008" -#define LSMDATE "15Apr08" +#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.1 b/bacula/technotes-2.1 index fc0eba5e26..eabd080bff 100644 --- a/bacula/technotes-2.1 +++ b/bacula/technotes-2.1 @@ -1,6 +1,8 @@ Technical notes on version 2.2 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. -- 2.39.5